Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ".well-known/smart-configuration", change liberty config layout, and update user's guide #939

Merged
merged 7 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ jobs:
- name: Build parent without tests
run: |
mvn -B install --file fhir-parent -DskipTests -P integration --no-transfer-progress
mvn -B dockerfile:build -f fhir-install --no-transfer-progress
- name: Server Integration Tests
run: |
export WORKSPACE=${GITHUB_WORKSPACE}
Expand Down Expand Up @@ -290,6 +291,7 @@ jobs:
- name: Build parent without tests
run: |
mvn -B install --file fhir-parent -DskipTests -P integration --no-transfer-progress
mvn -B dockerfile:build -f fhir-install --no-transfer-progress
- name: Server Integration Tests
run: |
export WORKSPACE=${GITHUB_WORKSPACE}
Expand Down
2 changes: 1 addition & 1 deletion build/README-DB2.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Running fhir server integration tests using docker db2.
## Prerequisites

- [Docker](https://www.docker.com)
- `ibmcom/ibm-fhir-server:latest` (built with the fhir-install module)
- `ibmcom/ibm-fhir-server:latest` (built from the fhir-install module)


## Run
Expand Down
267 changes: 207 additions & 60 deletions docs/src/pages/guides/FHIRServerUsersGuide.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2016,2019
* (C) Copyright IBM Corp. 2016, 2020
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -58,7 +58,7 @@
*/
public class FHIRClientImpl implements FHIRClient {

private static final String KEYSTORE_TYPE_JKS = "JKS";
private static final String KEYSTORE_TYPE = "pkcs12";

private Client client = null;
private Properties clientProperties = null;
Expand Down Expand Up @@ -866,7 +866,7 @@ private void initProperties(Properties props) throws Exception {
if (trustStoreLoc != null && trustStoreEncodedPwd != null) {
setTrustStoreLocation(trustStoreLoc);
setTrustStorePassword(FHIRUtilities.decode(trustStoreEncodedPwd));
setTrustStore(loadKeyStoreFile(getTrustStoreLocation(), getTrustStorePassword(), KEYSTORE_TYPE_JKS));
setTrustStore(loadKeyStoreFile(getTrustStoreLocation(), getTrustStorePassword(), KEYSTORE_TYPE));
}
}

Expand All @@ -875,7 +875,7 @@ private void initProperties(Properties props) throws Exception {
setKeyStoreLocation(getRequiredProperty(PROPNAME_KEYSTORE_LOCATION));
setKeyStorePassword(FHIRUtilities.decode(getRequiredProperty(PROPNAME_KEYSTORE_PASSWORD)));
setKeyStoreKeyPassword(FHIRUtilities.decode(getRequiredProperty(PROPNAME_KEYSTORE_KEY_PASSWORD)));
setKeyStore(loadKeyStoreFile(getKeyStoreLocation(), getKeyStorePassword(), KEYSTORE_TYPE_JKS));
setKeyStore(loadKeyStoreFile(getKeyStoreLocation(), getKeyStorePassword(), KEYSTORE_TYPE));
}

setLoggingEnabled(Boolean.parseBoolean(getProperty(PROPNAME_LOGGING_ENABLED, "false")));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2016,2019
* (C) Copyright IBM Corp. 2016, 2020
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -27,28 +27,28 @@
public class FHIRClientSample {
public final static int OK = 200;
public final static int CREATED = 201;

public static void main(String[] args) throws Exception {

// Create properties to be used to configure the client.
Properties clientProperties = new Properties();
clientProperties.setProperty(FHIRClient.PROPNAME_BASE_URL, "http://localhost:9080/fhir-server/api/v4");
clientProperties.setProperty(FHIRClient.PROPNAME_BASE_URL, "https://localhost:9443/fhir-server/api/v4");

// Retrieve an instance of the FHIRClient interface.
FHIRClient client = FHIRClientFactory.getClient(clientProperties);

// Create and initialize patient.
Patient patient = Patient.builder().build();
Patient patient = Patient.builder().id("test").build();
// patient.set...

// 1) Persist the patient and then display its location URI (e.g. "Patient/123/_history/1").
FHIRResponse response = client.create(patient);
if (response.getStatus() == CREATED) {
System.out.println("Patient resource was persisted, location = " + response.getLocation());
} else {
System.out.println("Error persisting patient, status code = " + response.getStatus());
}

// 2) Retrieve an Observation.
response = client.read("Observation", "123");
if (response.getStatus() == OK) {
Expand All @@ -60,28 +60,28 @@ public static void main(String[] args) throws Exception {
OperationOutcome operationOutcome = response.getResource(OperationOutcome.class);
// display operationOutcome message, etc.
}

// 3) Retrieve a specific version of a MedicationAdministration.
response = client.vread("MedicationAdministration", "12345", "2");
// Check status code, retrieve resource, etc.

// 4) Retrieve the most recent 5 versions of a Patient.
FHIRParameters parameters = new FHIRParameters().count(5);
response = client.history("Patient", "123", parameters);
// Check status code, retrieve response bundle, etc.

// 5) Search for patients born on 1/1/1970.
parameters = new FHIRParameters().searchParam("birthdate", ValuePrefix.EQ, "1970-01-01");
response = client.search("Patient", parameters);

// 6) Validate a Patient resource.
response = client.validate(patient);
// Check status code, retrieve OperationOutcome response resource, etc.

// 7) Invoke a batch request.
Bundle bundle = Bundle.builder().type(BundleType.BATCH).build();
// Initialize bundle by adding individual operations (read, vread, create, update, etc.)

response = client.batch(bundle);
// Check status code, retrieve Bundle response resource, etc.
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2016,2019
* (C) Copyright IBM Corp. 2016, 2020
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -124,7 +124,7 @@ public void run() throws Exception {
*/
private Properties readProperties() throws Exception {
Properties props = new Properties();
try (InputStream is = resolveFileLocation("fhir-client.properties")) {
try (InputStream is = resolveFileLocation("test.properties")) {
props.load(is);
return props;
}
Expand Down Expand Up @@ -173,7 +173,7 @@ private void displayOperationOutcome(FHIRResponse response) {

/**
* Create a new Patient resource with the specified name and mobile
*
*
* @param firstName
* @param lastName
* @param mobilePhoneNum
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed fhir-client/src/test/resources/fhirClientTruststore.jks
Binary file not shown.
4 changes: 2 additions & 2 deletions fhir-client/src/test/resources/test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ fhirclient.basicauth.username = fhiruser
fhirclient.basicauth.password = change-password

fhirclient.clientauth.enabled = true
fhirclient.keystore.location = fhirClientKeystore.jks
fhirclient.keystore.location = fhirClientKeyStore.p12
fhirclient.keystore.password = change-password
fhirclient.keystore.key.password = change-password
fhirclient.truststore.location = fhirClientTruststore.jks
fhirclient.truststore.location = fhirClientTrustStore.p12
fhirclient.truststore.password = change-password

fhirclient.oAuth2.enabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,9 @@ public void grantSequencePrivileges(String schemaName, String objectName, Collec


/**
* Create FHIR data and admin schemas
* Create a database schema
*
* @param schemaName
* @param adminSchemaName
*/
public void createFhirSchemas(String schemaName, String adminSchemaName);


public void createSchema(String schemaName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;

import com.ibm.fhir.database.utils.api.DuplicateNameException;
import com.ibm.fhir.database.utils.api.IConnectionProvider;
import com.ibm.fhir.database.utils.api.IDatabaseAdapter;
import com.ibm.fhir.database.utils.api.IDatabaseStatement;
Expand Down Expand Up @@ -508,4 +509,14 @@ public void grantSequencePrivileges(String schemaName, String variableName, Coll
logger.info("Applying: " + grant); // Grants are very useful to see logged
runStatement(grant);
}

@Override
public void createSchema(String schemaName) {
try {
String ddl = "CREATE SCHEMA " + schemaName;
runStatement(ddl);
} catch (DuplicateNameException e) {
logger.log(Level.WARNING, "The schema '" + schemaName + "' already exists; proceed with caution.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.logging.Logger;

import com.ibm.fhir.database.utils.api.DataAccessException;
import com.ibm.fhir.database.utils.api.DuplicateNameException;
import com.ibm.fhir.database.utils.api.IConnectionProvider;
import com.ibm.fhir.database.utils.api.IDatabaseStatement;
import com.ibm.fhir.database.utils.api.IDatabaseTarget;
Expand Down Expand Up @@ -435,22 +434,6 @@ public boolean checkCompatibility(String adminSchema) {
return true;
}

@Override
public void createFhirSchemas(String schemaName, String adminSchemaName) {
try {
String ddl = "CREATE SCHEMA " + schemaName;
runStatement(ddl);
} catch (DuplicateNameException e) {
logger.log(Level.WARNING, "The schema '" + schemaName + "' already exists; proceed with caution.");
}
try {
String ddl = "CREATE SCHEMA " + adminSchemaName;
runStatement(ddl);
} catch (DuplicateNameException e) {
logger.log(Level.WARNING, "The schema '" + adminSchemaName + "' already exists; proceed with caution.");
}
}

@Override
public void runStatement(IDatabaseStatement stmt) {
super.runStatement(stmt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,6 @@ protected List<String> prefixTenantColumn(String tenantColumnName, List<String>
return columns;
}

@Override
public void createFhirSchemas(String schemaName, String adminSchemaName) {
String ddl = "CREATE SCHEMA " + schemaName;
runStatement(ddl);
ddl = "CREATE SCHEMA " + adminSchemaName;
runStatement(ddl);
}

@Override
public void runStatement(IDatabaseStatement stmt) {
if (stmt instanceof AddForeignKeyConstraint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.ibm.fhir.database.utils.api.ConnectionDetails;
import com.ibm.fhir.database.utils.api.ConnectionException;
import com.ibm.fhir.database.utils.api.DataAccessException;
import com.ibm.fhir.database.utils.api.DuplicateNameException;
import com.ibm.fhir.database.utils.api.IDatabaseTranslator;
import com.ibm.fhir.database.utils.api.LockException;
import com.ibm.fhir.database.utils.api.UndefinedNameException;
Expand Down Expand Up @@ -52,7 +53,8 @@ public boolean isDuplicate(SQLException x) {

@Override
public boolean isAlreadyExists(SQLException x) {
return "42710".equals(x.getSQLState());
// X0Y68 is for a schema, X0Y32 is for an object (e.g. a table)
return "X0Y68".equals(x.getSQLState()) || "X0Y32".equals(x.getSQLState());
}

@Override
Expand Down Expand Up @@ -86,6 +88,9 @@ else if (isConnectionError(x)) {
else if (isDuplicate(x)) {
return new UniqueConstraintViolationException(x);
}
else if (isAlreadyExists(x)) {
return new DuplicateNameException(x);
}
else if (isUndefinedName(x)) {
return new UndefinedNameException(x);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import com.ibm.fhir.database.utils.api.IDatabaseTypeAdapter;

/**
* Blob Column
* Binary Large OBject (BLOB) Column
*/
public class BlobColumn extends ColumnBase {

private final long size;

private final int inlineSize;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* (C) Copyright IBM Corp. 2020
*
* SPDX-License-Identifier: Apache-2.0
*/

package com.ibm.fhir.database.utils.model;

import com.ibm.fhir.database.utils.api.IDatabaseTypeAdapter;

/**
* Character Large OBject (CLOB) Column
*/
public class ClobColumn extends ColumnBase {
public ClobColumn(String name, boolean nullable) {
super(name, nullable);
}

public ClobColumn(String name, boolean nullable, String defaultVal) {
super(name, nullable, defaultVal);
}

@Override
public String getTypeInfo(IDatabaseTypeAdapter adapter) {
return "CLOB";
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019
* (C) Copyright IBM Corp. 2019, 2020
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -12,13 +12,16 @@
* An immutable definition of a column in a table
*/
public abstract class ColumnBase {

// Name of the column
private final String name;

// Does the column allow null values
private final boolean nullable;

// The default value for the column (usually null)
private final String defaultVal;

/**
* Protected constructor - for use by subclasses
* @param name
Expand All @@ -27,6 +30,19 @@ public abstract class ColumnBase {
protected ColumnBase(String name, boolean nullable) {
this.name = name;
this.nullable = nullable;
this.defaultVal = null;
}

/**
* Protected constructor - for use by subclasses
* @param name
* @param nullable
* @param defaultVal
*/
protected ColumnBase(String name, boolean nullable, String defaultVal) {
this.name = name;
this.nullable = nullable;
this.defaultVal = defaultVal;
}

/**
Expand All @@ -45,6 +61,14 @@ public boolean isNullable() {
return nullable;
}

/**
* Getter for the default value of this column
* @return possibly null
*/
public String getDefaultVal() {
return defaultVal;
}

/**
* Get the type info string
* @param adapter
Expand Down
Loading