Fix build

This commit is contained in:
James Agnew 2016-05-09 13:10:12 -04:00
parent 061243b5c7
commit 975dfe4fa4
24 changed files with 1694 additions and 220 deletions

View File

@ -13,6 +13,7 @@ import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -59,16 +60,19 @@ import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
import ca.uhn.fhir.model.dstu2.resource.Bundle.EntryRequest; import ca.uhn.fhir.model.dstu2.resource.Bundle.EntryRequest;
import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum; import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum;
import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.client.IGenericClient; import ca.uhn.fhir.rest.client.IGenericClient;
import ca.uhn.fhir.rest.client.apache.GZipContentInterceptor; import ca.uhn.fhir.rest.client.apache.GZipContentInterceptor;
import ca.uhn.fhir.rest.server.IVersionSpecificBundleFactory;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
import ca.uhn.fhir.util.BundleUtil;
import ca.uhn.fhir.util.ResourceReferenceInfo; import ca.uhn.fhir.util.ResourceReferenceInfo;
import ca.uhn.fhir.validation.FhirValidator; import ca.uhn.fhir.validation.FhirValidator;
import ca.uhn.fhir.validation.ValidationResult; import ca.uhn.fhir.validation.ValidationResult;
public class ExampleDataUploader extends BaseCommand { public class ExampleDataUploader extends BaseCommand {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleDataUploader.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleDataUploader.class);
@Override @Override
@ -100,11 +104,13 @@ public class ExampleDataUploader extends BaseCommand {
opt.setRequired(false); opt.setRequired(false);
options.addOption(opt); options.addOption(opt);
opt = new Option("c", "cache", false, "Cache the downloaded examples-json.zip file in the ~/.hapi-fhir-cli/cache directory. Use this file for 12 hours if it exists, instead of fetching it from the internet."); opt = new Option("c", "cache", false,
"Cache the downloaded examples-json.zip file in the ~/.hapi-fhir-cli/cache directory. Use this file for 12 hours if it exists, instead of fetching it from the internet.");
opt.setRequired(false); opt.setRequired(false);
options.addOption(opt); options.addOption(opt);
// opt = new Option("c", "cache", true, "Store a copy of the downloaded example pack on the local disk using a file of the given name. Use this file instead of fetching it from the internet if the file already exists."); // opt = new Option("c", "cache", true, "Store a copy of the downloaded example pack on the local disk using a file of the given name. Use this file instead of fetching it from the internet if
// the file already exists.");
// opt.setRequired(false); // opt.setRequired(false);
// options.addOption(opt); // options.addOption(opt);
@ -234,8 +240,72 @@ public class ExampleDataUploader extends BaseCommand {
} }
private void sendBundleToTarget(String targetServer, FhirContext ctx, IBaseBundle bundle) throws Exception, IOException { private void sendBundleToTarget(String targetServer, FhirContext ctx, IBaseBundle bundle) throws Exception, IOException {
List<IBaseResource> resources = BundleUtil.toListOfResources(ctx, bundle);
String encoded = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(bundle); for (Iterator<IBaseResource> iter = resources.iterator(); iter.hasNext(); ) {
IBaseResource next = iter.next();
String nextType = ctx.getResourceDefinition(next).getName();
if (nextType.endsWith("Definition")) {
iter.remove();
} else if (nextType.contains("ValueSet")) {
iter.remove();
} else if (nextType.equals("CodeSystem")) {
iter.remove();
}
}
List<IBaseResource> subResourceList = new ArrayList<IBaseResource>();
while (resources.size() > 0) {
subResourceList.add(resources.remove(0));
boolean found = false;
do {
for (IBaseResource nextTarget : subResourceList) {
for (int i = 0; i < resources.size(); i++) {
IBaseResource nextCandidateSource = resources.get(i);
for (ResourceReferenceInfo nextRef : ctx.newTerser().getAllResourceReferences(nextCandidateSource)) {
/*
* If we have a reference URL but not a resource, it's a reference
* to another server and we can't upload it
*/
if (isNotBlank(nextRef.getResourceReference().getReferenceElement().getValue())) {
if (nextRef.getResourceReference().getReferenceElement().getValue().contains("gsk.com")) {
nextRef.getResourceReference().setReference("");
}
}
String nextRes = nextRef.getResourceReference().getReferenceElement().toUnqualifiedVersionless().getValue();
if (isNotBlank(nextRes) && nextRes.equals(nextTarget.getIdElement().toUnqualifiedVersionless().getValue())) {
subResourceList.add(resources.remove(i));
i--;
found = true;
}
}
}
}
} while (found == true);
if (subResourceList.size() < 10 && resources.size() > 0) {
subResourceList.add(resources.remove(0));
continue;
}
ourLog.info("About to upload {} examples in a transaction, {} remaining", subResourceList.size(), resources.size());
if (true) {
subResourceList.clear();
continue;
}
IVersionSpecificBundleFactory bundleFactory = ctx.newBundleFactory();
bundleFactory.initializeBundleFromResourceList(null, subResourceList, null, null, 0, BundleTypeEnum.TRANSACTION);
IBaseResource subBundle = bundleFactory.getResourceBundle();
String encoded = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(subBundle);
ourLog.info("Final bundle: {}", FileUtils.byteCountToDisplaySize(encoded.length())); ourLog.info("Final bundle: {}", FileUtils.byteCountToDisplaySize(encoded.length()));
if (targetServer.startsWith("file://")) { if (targetServer.startsWith("file://")) {
@ -255,12 +325,22 @@ public class ExampleDataUploader extends BaseCommand {
fhirClient.registerInterceptor(new GZipContentInterceptor()); fhirClient.registerInterceptor(new GZipContentInterceptor());
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
fhirClient.transaction().withBundle(bundle).execute(); try {
fhirClient.transaction().withBundle(encoded).execute();
} catch (BaseServerResponseException e) {
ourLog.error("Failed to upload", e);
ourLog.error("Failing bundle: {}", encoded);
}
long delay = System.currentTimeMillis() - start; long delay = System.currentTimeMillis() - start;
ourLog.info("Finished uploading bundle to server (took {} ms)", delay); ourLog.info("Finished uploading bundle to server (took {} ms)", delay);
} }
subResourceList.clear();
} }
}
private void processBundle(FhirContext ctx, IBaseBundle bundle) { private void processBundle(FhirContext ctx, IBaseBundle bundle) {
switch (ctx.getVersion().getVersion()) { switch (ctx.getVersion().getVersion()) {
case DSTU2: case DSTU2:
@ -283,7 +363,8 @@ public class ExampleDataUploader extends BaseCommand {
Entry next = iterator.next(); Entry next = iterator.next();
// DataElement have giant IDs that seem invalid, need to investigate this.. // DataElement have giant IDs that seem invalid, need to investigate this..
if ("DataElement".equals(next.getResource().getResourceName()) || "OperationOutcome".equals(next.getResource().getResourceName()) || "OperationDefinition".equals(next.getResource().getResourceName())) { if ("DataElement".equals(next.getResource().getResourceName()) || "OperationOutcome".equals(next.getResource().getResourceName())
|| "OperationDefinition".equals(next.getResource().getResourceName())) {
ourLog.info("Skipping " + next.getResource().getResourceName() + " example"); ourLog.info("Skipping " + next.getResource().getResourceName() + " example");
iterator.remove(); iterator.remove();
} else { } else {
@ -375,12 +456,12 @@ public class ExampleDataUploader extends BaseCommand {
Map<String, Integer> ids = new HashMap<String, Integer>(); Map<String, Integer> ids = new HashMap<String, Integer>();
Set<String> fullIds = new HashSet<String>(); Set<String> fullIds = new HashSet<String>();
for (Iterator<BundleEntryComponent> iterator = bundle.getEntry().iterator(); iterator.hasNext();) { for (Iterator<BundleEntryComponent> iterator = bundle.getEntry().iterator(); iterator.hasNext();) {
BundleEntryComponent next = iterator.next(); BundleEntryComponent next = iterator.next();
// DataElement have giant IDs that seem invalid, need to investigate this.. // DataElement have giant IDs that seem invalid, need to investigate this..
if ("DataElement".equals(next.getResource().getResourceType().name()) || "OperationOutcome".equals(next.getResource().getResourceType().name()) || "OperationDefinition".equals(next.getResource().getResourceType().name())) { if ("DataElement".equals(next.getResource().getResourceType().name()) || "OperationOutcome".equals(next.getResource().getResourceType().name())
|| "OperationDefinition".equals(next.getResource().getResourceType().name())) {
ourLog.info("Skipping " + next.getResource().getResourceType().name() + " example"); ourLog.info("Skipping " + next.getResource().getResourceType().name() + " example");
iterator.remove(); iterator.remove();
} else { } else {
@ -467,8 +548,7 @@ public class ExampleDataUploader extends BaseCommand {
} }
private Bundle getBundleFromFileDstu2(Integer limit, File inputFile, FhirContext ctx) private Bundle getBundleFromFileDstu2(Integer limit, File inputFile, FhirContext ctx) throws IOException, UnsupportedEncodingException {
throws IOException, UnsupportedEncodingException {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -533,8 +613,7 @@ public class ExampleDataUploader extends BaseCommand {
return bundle; return bundle;
} }
private org.hl7.fhir.dstu3.model.Bundle getBundleFromFileDstu3(Integer limit, File inputFile, FhirContext ctx) private org.hl7.fhir.dstu3.model.Bundle getBundleFromFileDstu3(Integer limit, File inputFile, FhirContext ctx) throws IOException, UnsupportedEncodingException {
throws IOException, UnsupportedEncodingException {
org.hl7.fhir.dstu3.model.Bundle bundle = new org.hl7.fhir.dstu3.model.Bundle(); org.hl7.fhir.dstu3.model.Bundle bundle = new org.hl7.fhir.dstu3.model.Bundle();
bundle.setType(BundleType.TRANSACTION); bundle.setType(BundleType.TRANSACTION);
@ -597,7 +676,8 @@ public class ExampleDataUploader extends BaseCommand {
if (nextResource == null) { if (nextResource == null) {
continue; continue;
} }
if (!ctx.getResourceDefinition((Class<? extends IBaseResource>) nextResource.getClass()).getName().equals("Bundle") && ctx.getResourceDefinition((Class<? extends IBaseResource>) nextResource.getClass()).getName().equals("SearchParameter")) { if (!ctx.getResourceDefinition((Class<? extends IBaseResource>) nextResource.getClass()).getName().equals("Bundle")
&& ctx.getResourceDefinition((Class<? extends IBaseResource>) nextResource.getClass()).getName().equals("SearchParameter")) {
BundleEntryComponent entry = bundle.addEntry(); BundleEntryComponent entry = bundle.addEntry();
entry.getRequest().setMethod(HTTPVerb.POST); entry.getRequest().setMethod(HTTPVerb.POST);
entry.setResource((Resource) nextResource); entry.setResource((Resource) nextResource);

View File

@ -182,71 +182,71 @@ public class ValidationDataUploader extends BaseCommand {
int total = 0; int total = 0;
int count = 0; int count = 0;
org.hl7.fhir.dstu3.model.Bundle bundle; org.hl7.fhir.dstu3.model.Bundle bundle;
String vsContents;
// String vsContents; try {
// try { ctx.getVersion().getPathToSchemaDefinitions();
// ctx.getVersion().getPathToSchemaDefinitions(); vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/dstu3/valueset/"+"valuesets.xml"), "UTF-8");
// vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/dstu3/valueset/"+"valuesets.xml"), "UTF-8"); } catch (IOException e) {
// } catch (IOException e) { throw new CommandFailureException(e.toString());
// throw new CommandFailureException(e.toString()); }
// } bundle = ctx.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents);
// org.hl7.fhir.dstu3.model.Bundle bundle = ctx.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents);
// total = bundle.getEntry().size();
// total = bundle.getEntry().size(); count = 1;
// count = 1; for (BundleEntryComponent i : bundle.getEntry()) {
// for (BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.dstu3.model.Resource next = i.getResource();
// org.hl7.fhir.dstu3.model.Resource next = i.getResource(); next.setId(next.getIdElement().toUnqualifiedVersionless());
// next.setId(next.getIdElement().toUnqualifiedVersionless());
// ourLog.info("Uploading ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() });
// ourLog.info("Uploading ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() }); try {
// try { client.update().resource(next).execute();
// client.update().resource(next).execute(); } catch (UnprocessableEntityException e) {
// } catch (UnprocessableEntityException e) { ourLog.warn("UnprocessableEntityException: " + e.toString());
// ourLog.warn("UnprocessableEntityException: " + e.toString()); }
// } count++;
// count++; }
// }
// try {
// try { vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/dstu3/valueset/"+"v3-codesystems.xml"), "UTF-8");
// vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/dstu3/valueset/"+"v3-codesystems.xml"), "UTF-8"); } catch (IOException e) {
// } catch (IOException e) { throw new CommandFailureException(e.toString());
// throw new CommandFailureException(e.toString()); }
// }
// bundle = ctx.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents);
// bundle = ctx.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents); total = bundle.getEntry().size();
// total = bundle.getEntry().size(); count = 1;
// count = 1; for (BundleEntryComponent i : bundle.getEntry()) {
// for (BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.dstu3.model.Resource next = i.getResource();
// org.hl7.fhir.dstu3.model.Resource next = i.getResource(); next.setId(next.getIdElement().toUnqualifiedVersionless());
// next.setId(next.getIdElement().toUnqualifiedVersionless());
// ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() });
// ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() }); client.update().resource(next).execute();
// client.update().resource(next).execute();
// count++;
// count++; }
// }
// try {
// try { vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/dstu3/valueset/"+"v2-tables.xml"), "UTF-8");
// vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/dstu3/valueset/"+"v2-tables.xml"), "UTF-8"); } catch (IOException e) {
// } catch (IOException e) { throw new CommandFailureException(e.toString());
// throw new CommandFailureException(e.toString()); }
// } bundle = ctx.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents);
// bundle = ctx.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents); total = bundle.getEntry().size();
// total = bundle.getEntry().size(); count = 1;
// count = 1; for (BundleEntryComponent i : bundle.getEntry()) {
// for (BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.dstu3.model.Resource next = i.getResource();
// org.hl7.fhir.dstu3.model.Resource next = i.getResource(); if (next.getIdElement().isIdPartValidLong()) {
// if (next.getIdElement().isIdPartValidLong()) { next.setIdElement(new IdType("v2-"+ next.getIdElement().getIdPart()));
// next.setIdElement(new IdType("v2-"+ next.getIdElement().getIdPart())); }
// } next.setId(next.getIdElement().toUnqualifiedVersionless());
// next.setId(next.getIdElement().toUnqualifiedVersionless());
// ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() });
// ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() }); client.update().resource(next).execute();
// client.update().resource(next).execute(); count++;
// count++; }
// }
// ourLog.info("Finished uploading ValueSets");
// ourLog.info("Finished uploading ValueSets");
uploadDstu3Profiles(ctx, client, "profiles-resources"); uploadDstu3Profiles(ctx, client, "profiles-resources");

View File

@ -454,7 +454,7 @@ public class FhirSystemDaoDstu3 extends BaseHapiFhirSystemDao<Bundle, Meta> {
for (Iterator<DeleteConflict> iter = deleteConflicts.iterator(); iter.hasNext(); ) { for (Iterator<DeleteConflict> iter = deleteConflicts.iterator(); iter.hasNext(); ) {
DeleteConflict next = iter.next(); DeleteConflict next = iter.next();
if (deletedResources.contains(next.getTargetId().toVersionless())) { if (deletedResources.contains(next.getTargetId().toUnqualifiedVersionless().getValue())) {
iter.remove(); iter.remove();
} }
} }

View File

@ -25,9 +25,11 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import javax.measure.unit.NonSI; import javax.measure.unit.NonSI;
import javax.measure.unit.Unit; import javax.measure.unit.Unit;
@ -44,6 +46,7 @@ import org.hl7.fhir.dstu3.model.CodeableConcept;
import org.hl7.fhir.dstu3.model.Coding; import org.hl7.fhir.dstu3.model.Coding;
import org.hl7.fhir.dstu3.model.Conformance.ConformanceRestSecurityComponent; import org.hl7.fhir.dstu3.model.Conformance.ConformanceRestSecurityComponent;
import org.hl7.fhir.dstu3.model.ContactPoint; import org.hl7.fhir.dstu3.model.ContactPoint;
import org.hl7.fhir.dstu3.model.DateTimeType;
import org.hl7.fhir.dstu3.model.Duration; import org.hl7.fhir.dstu3.model.Duration;
import org.hl7.fhir.dstu3.model.Enumeration; import org.hl7.fhir.dstu3.model.Enumeration;
import org.hl7.fhir.dstu3.model.HumanName; import org.hl7.fhir.dstu3.model.HumanName;
@ -55,13 +58,13 @@ import org.hl7.fhir.dstu3.model.Period;
import org.hl7.fhir.dstu3.model.Quantity; import org.hl7.fhir.dstu3.model.Quantity;
import org.hl7.fhir.dstu3.model.Questionnaire; import org.hl7.fhir.dstu3.model.Questionnaire;
import org.hl7.fhir.dstu3.model.StringType; import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.dstu3.model.Timing;
import org.hl7.fhir.dstu3.model.UriType; import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.dstu3.utils.FHIRPathEngine; import org.hl7.fhir.dstu3.utils.FHIRPathEngine;
import org.hl7.fhir.dstu3.utils.IWorkerContext; import org.hl7.fhir.dstu3.utils.IWorkerContext;
import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.omg.PortableServer.ThreadPolicyValue;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@ -176,6 +179,22 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
continue; continue;
} }
nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), nextValue.getStart(), nextValue.getEnd()); nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), nextValue.getStart(), nextValue.getEnd());
} else if (nextObject instanceof Timing) {
Timing nextValue = (Timing) nextObject;
if (nextValue.isEmpty()) {
continue;
}
TreeSet<Date> dates = new TreeSet<Date>();
for (DateTimeType nextEvent : nextValue.getEvent()) {
if (nextEvent.getValue() != null) {
dates.add(nextEvent.getValue());
}
}
if (dates.isEmpty()) {
continue;
}
nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), dates.first(), dates.last());
} else { } else {
if (!multiType) { if (!multiType) {
throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass()); throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());

View File

@ -14,6 +14,7 @@ import org.hibernate.search.jpa.Search;
import org.hl7.fhir.dstu3.hapi.validation.IValidationSupport; import org.hl7.fhir.dstu3.hapi.validation.IValidationSupport;
import org.hl7.fhir.dstu3.model.Appointment; import org.hl7.fhir.dstu3.model.Appointment;
import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.CarePlan;
import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.CodeableConcept; import org.hl7.fhir.dstu3.model.CodeableConcept;
import org.hl7.fhir.dstu3.model.Coding; import org.hl7.fhir.dstu3.model.Coding;
@ -157,6 +158,9 @@ protected IFhirResourceDao<Observation> myObservationDao;
@Qualifier("myPatientDaoDstu3") @Qualifier("myPatientDaoDstu3")
protected IFhirResourceDaoPatient<Patient> myPatientDao; protected IFhirResourceDaoPatient<Patient> myPatientDao;
@Autowired @Autowired
@Qualifier("myCarePlanDaoDstu3")
protected IFhirResourceDao<CarePlan> myCarePlanDao;
@Autowired
@Qualifier("myPractitionerDaoDstu3") @Qualifier("myPractitionerDaoDstu3")
protected IFhirResourceDao<Practitioner> myPractitionerDao; protected IFhirResourceDao<Practitioner> myPractitionerDao;
@Autowired @Autowired

View File

@ -40,6 +40,7 @@ import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu3.model.Bundle.BundleType; import org.hl7.fhir.dstu3.model.Bundle.BundleType;
import org.hl7.fhir.dstu3.model.Bundle.HTTPVerb; import org.hl7.fhir.dstu3.model.Bundle.HTTPVerb;
import org.hl7.fhir.dstu3.model.CarePlan;
import org.hl7.fhir.dstu3.model.CodeType; import org.hl7.fhir.dstu3.model.CodeType;
import org.hl7.fhir.dstu3.model.CodeableConcept; import org.hl7.fhir.dstu3.model.CodeableConcept;
import org.hl7.fhir.dstu3.model.Coding; import org.hl7.fhir.dstu3.model.Coding;
@ -68,6 +69,7 @@ import org.hl7.fhir.dstu3.model.Questionnaire;
import org.hl7.fhir.dstu3.model.Reference; import org.hl7.fhir.dstu3.model.Reference;
import org.hl7.fhir.dstu3.model.StringType; import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.dstu3.model.StructureDefinition; import org.hl7.fhir.dstu3.model.StructureDefinition;
import org.hl7.fhir.dstu3.model.Timing;
import org.hl7.fhir.dstu3.model.UriType; import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
@ -132,6 +134,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
} }
} }
@Test @Test
@Ignore @Ignore
public void testCreateBuiltInProfiles() throws Exception { public void testCreateBuiltInProfiles() throws Exception {
@ -569,6 +572,38 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
} }
} }
@Test
@Ignore
public void testTimingSearchParams() throws Exception {
Date before = new DateTimeType("2011-01-01T10:00:00Z").getValue();
Date middle = new DateTimeType("2011-01-02T10:00:00Z").getValue();
Date after = new DateTimeType("2011-01-03T10:00:00Z").getValue();
CarePlan cp = new CarePlan();
cp.addActivity().getDetail().setScheduled(new Timing().addEvent(before).addEvent(middle).addEvent(after));
cp.addActivity().getDetail();
IIdType id = myCarePlanDao.create(cp, mySrd).getId().toUnqualifiedVersionless();
CarePlan cp2 = new CarePlan();
cp2.addActivity().getDetail().setScheduled(new StringType("FOO"));
cp2.addActivity().getDetail();
IIdType id2 = myCarePlanDao.create(cp2, mySrd).getId().toUnqualifiedVersionless();
SearchParameterMap params;
params = new SearchParameterMap();
params.add(CarePlan.SP_ACTIVITYDATE, new DateRangeParam("2010-01-01T10:00:00Z", null));
assertThat(toUnqualifiedVersionlessIdValues(myCarePlanDao.search(params)), contains(id.getValue()));
params = new SearchParameterMap();
params.add(CarePlan.SP_ACTIVITYDATE, new DateRangeParam("2011-01-01T10:00:00Z", null));
assertThat(toUnqualifiedVersionlessIdValues(myCarePlanDao.search(params)), contains(id.getValue()));
params = new SearchParameterMap();
params.add(CarePlan.SP_ACTIVITYDATE, new DateRangeParam("2012-01-01T10:00:00Z", null));
assertThat(toUnqualifiedVersionlessIdValues(myCarePlanDao.search(params)), empty());
}
@Test @Test
public void testCreateWithIdFails() { public void testCreateWithIdFails() {
Patient p = new Patient(); Patient p = new Patient();
@ -677,6 +712,26 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
} }
@Test
public void testCreateWithIfNoneExistId() {
String methodName = "testCreateWithIfNoneExistId";
MethodOutcome results;
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
IIdType id = myPatientDao.create(p, mySrd).getId().toUnqualified();
ourLog.info("Created patient, got it: {}", id);
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
results = myPatientDao.create(p, "Patient?_id=" + id.toVersionless().getValue(), mySrd);
assertEquals(id.getIdPart(), results.getId().getIdPart());
assertEquals(id.getVersionIdPart(), results.getId().getVersionIdPart());
assertFalse(results.getCreated().booleanValue());
}
@Test @Test
public void testCreateWithIllegalReference() { public void testCreateWithIllegalReference() {
Observation o1 = new Observation(); Observation o1 = new Observation();

View File

@ -33,6 +33,7 @@ import java.util.List;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.http.client.ClientProtocolException; import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpDelete;
@ -123,6 +124,16 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
TestUtil.clearAllStaticFieldsForUnitTest(); TestUtil.clearAllStaticFieldsForUnitTest();
} }
/**
* Issue submitted by Bryn
*/
@Test
public void testCreateBundle() throws IOException {
String input = IOUtils.toString(getClass().getResourceAsStream("/bryn-bundle.json"));
Validate.notNull(input);
ourClient.create().resource(input).execute().getResource();
}
@Test @Test
public void testSearchByExtendedChars() throws Exception { public void testSearchByExtendedChars() throws Exception {

View File

@ -232,6 +232,8 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
ourClient.setLogRequestAndResponse(true); ourClient.setLogRequestAndResponse(true);
myRestServer = restServer; myRestServer = restServer;
} }
myRestServer.setDefaultResponseEncoding(EncodingEnum.XML);
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")

View File

@ -0,0 +1,646 @@
{
"resourceType":"Bundle",
"type":"collection",
"entry":[
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0016/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0016",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:52.296-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8480-6",
"display":"Systolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat004",
"display":"Fred"
},
"effectiveDateTime":"2015-06-11",
"valueQuantity":{
"value":133,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0018/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0018",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:52.922-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8480-6",
"display":"Systolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat004",
"display":"Fred"
},
"effectiveDateTime":"2015-11-11",
"valueQuantity":{
"value":141,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0001/_history/2",
"resource":{
"resourceType":"Observation",
"id":"res0001",
"meta":{
"versionId":"2",
"lastUpdated":"2016-05-05T03:16:47.800-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8480-6",
"display":"Systolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat001",
"display":"Jim"
},
"effectiveDateTime":"2015-09-10",
"valueQuantity":{
"value":155,
"unit":"mmHg",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0021/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0021",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:53.928-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8480-6",
"display":"Systolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat005",
"display":"Ada"
},
"effectiveDateTime":"2016-02-11",
"valueQuantity":{
"value":148,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0003/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0003",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:48.457-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8480-6",
"display":"Systolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat001",
"display":"Jim"
},
"effectiveDateTime":"2016-01-10",
"valueQuantity":{
"value":138,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0023/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0023",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:55.084-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8480-6",
"display":"Systolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat005",
"display":"Ada"
},
"effectiveDateTime":"2015-12-11",
"valueQuantity":{
"value":140,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0006/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0006",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:49.312-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8480-6",
"display":"Systolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat002",
"display":"Chewie"
},
"effectiveDateTime":"2016-04-10",
"valueQuantity":{
"value":141,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0008/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0008",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:49.886-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8480-6",
"display":"Systolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat002",
"display":"Chewie"
},
"effectiveDateTime":"2015-08-10",
"valueQuantity":{
"value":140,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0011/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0011",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:50.746-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8480-6",
"display":"Systolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat003",
"display":"Esther"
},
"effectiveDateTime":"2015-12-10",
"valueQuantity":{
"value":144,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0013/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0013",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:51.339-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8480-6",
"display":"Systolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat003",
"display":"Esther"
},
"effectiveDateTime":"2016-02-10",
"valueQuantity":{
"value":170,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0017/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0017",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:52.652-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8462-4",
"display":"Diastolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat004",
"display":"Fred"
},
"effectiveDateTime":"2015-06-11",
"valueQuantity":{
"value":77,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0019/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0019",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:53.256-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8462-4",
"display":"Diastolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat004",
"display":"Fred"
},
"effectiveDateTime":"2015-11-11",
"valueQuantity":{
"value":92,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0002/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0002",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:48.168-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8462-4",
"display":"Diastolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat001",
"display":"Jim"
},
"effectiveDateTime":"2015-09-10",
"valueQuantity":{
"value":95,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0022/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0022",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:54.560-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8462-4",
"display":"Diastolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat005",
"display":"Ada"
},
"effectiveDateTime":"2016-02-11",
"valueQuantity":{
"value":80,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0004/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0004",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:48.760-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8462-4",
"display":"Diastolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat001",
"display":"Jim"
},
"effectiveDateTime":"2016-01-10",
"valueQuantity":{
"value":80,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0024/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0024",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:55.462-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8462-4",
"display":"Diastolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat005",
"display":"Ada"
},
"effectiveDateTime":"2015-12-11",
"valueQuantity":{
"value":92,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0007/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0007",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:49.575-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8462-4",
"display":"Diastolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat002",
"display":"Chewie"
},
"effectiveDateTime":"2016-04-10",
"valueQuantity":{
"value":88,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0009/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0009",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:50.190-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8462-4",
"display":"Diastolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat002",
"display":"Chewie"
},
"effectiveDateTime":"2015-08-10",
"valueQuantity":{
"value":90,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0012/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0012",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:51.060-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8462-4",
"display":"Diastolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat003",
"display":"Esther"
},
"effectiveDateTime":"2015-12-10",
"valueQuantity":{
"value":85,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
},
{
"fullUrl":"http://fhirtest.uhn.ca/baseDstu3/Observation/res0014/_history/1",
"resource":{
"resourceType":"Observation",
"id":"res0014",
"meta":{
"versionId":"1",
"lastUpdated":"2016-05-05T03:16:51.737-04:00"
},
"status":"final",
"code":{
"coding":[
{
"system":"http://loinc.org",
"code":"8462-4",
"display":"Diastolic blood pressure"
}
]
},
"subject":{
"reference":"Patient/pat003",
"display":"Esther"
},
"effectiveDateTime":"2016-02-10",
"valueQuantity":{
"value":92,
"unit":"3092008",
"system":"http://unitsofmeasure.org",
"code":"mm[Hg]"
}
}
}
]
}

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View File

@ -0,0 +1,108 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- <parent> <groupId>ca.uhn.hapi.fhir</groupId> <artifactId>hapi-fhir</artifactId> <version>1.6-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> -->
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-uhnfhirtest-auth</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>HAPI FHIR - fhirtest.uhn.ca Auth Server</name>
<dependencies>
<dependency>
<groupId>org.mitre</groupId>
<artifactId>openid-connect-common</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>org.mitre</groupId>
<artifactId>openid-connect-server-webapp</artifactId>
<type>war</type>
<version>1.2.6</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webApp>
<contextPath>/</contextPath>
<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
<jettyEnvXml>src/main/webapp/WEB-INF/jetty-configure.xml</jettyEnvXml>
</webApp>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId></groupId>
<artifactId></artifactId>
<versionRange>[0.4,)</versionRange>
<goals>
<goal></goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Build-Time>${maven.build.timestamp}</Build-Time>
</manifestEntries>
</archive>
<overlays>
<overlay>
<groupId>org.mitre</groupId>
<artifactId>openid-connect-server-webapp</artifactId>
<!-- <excludes> <exclude>WEB-INF/classes/keystore.jwks</exclude> </excludes> -->
</overlay>
</overlays>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
<finalName>hapi-fhir-jpaserver-auth</finalName>
</build>
</project>

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 The MITRE Corporation
and the MIT Internet Trust Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<bean id="defaultKeyStore" class="org.mitre.jose.keystore.JWKSetKeyStore">
<property name="location" value="classpath:keystore.jwks" />
</bean>
<bean id="defaultsignerService" class="org.mitre.jwt.signer.service.impl.DefaultJWTSigningAndValidationService">
<constructor-arg name="keyStore" ref="defaultKeyStore" />
<property name="defaultSignerKeyId" value="rsa1" />
<property name="defaultSigningAlgorithmName" value="RS256" />
</bean>
<bean id="defaultEncryptionService" class="org.mitre.jwt.encryption.service.impl.DefaultJWTEncryptionAndDecryptionService">
<constructor-arg name="keyStore" ref="defaultKeyStore" />
<property name="defaultAlgorithm" value="RSA1_5" />
<property name="defaultDecryptionKeyId" value="rsa1" />
<property name="defaultEncryptionKeyId" value="rsa1" />
</bean>
</beans>

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 The MITRE Corporation
and the MIT Internet Trust Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd">
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="jdbcUrl" value="jdbc:hsqldb:mem:oic;sql.syntax_mys=true" />
<!-- <property name="jdbcUrl" value="jdbc:hsqldb:file:/tmp/oic;sql.syntax_mys=true" /> -->
<property name="username" value="oic" />
<property name="password" value="oic" />
</bean>
<!-- Use the following to set up the OIC tables in the in-memory DB
If you are using a file based HSQLDB you should not run this every time. -->
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="classpath:/db/tables/hsql_database_tables.sql"/>
<!-- The following file is for the jdbc-user-service spring security implementation -->
<jdbc:script location="classpath:/db/tables/security-schema.sql"/>
<!-- The following files are for safely bootstrapping users and clients into the database -->
<jdbc:script location="classpath:/db/tables/loading_temp_tables.sql"/>
<jdbc:script location="classpath:/db/users.sql"/>
<jdbc:script location="classpath:/db/clients.sql"/>
<jdbc:script location="classpath:/db/scopes.sql"/>
</jdbc:initialize-database>
<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.HSQLPlatform" />
<property name="showSql" value="true" />
</bean>
<!-- The following is for connecting to a MySQL database that has been initialized with
src/main/resources/db/tables/mysql_database_tables.sql -->
<!--
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost/oic" />
<property name="username" value="oic" />
<property name="password" value="oic" />
</bean>
<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.MySQLPlatform" />
<property name="showSql" value="true" />
</bean>
-->
<!-- The following is for connecting to a PostgreSQL database that has been initialized with
src/main/resources/db/tables/psql_database_tables.sql -->
<!--
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="jdbcUrl" value="jdbc:postgresql://localhost/oic" />
<property name="username" value="oic" />
<property name="password" value="oic" />
</bean>
<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.PostgreSQLPlatform" />
<property name="showSql" value="true" />
</bean>
-->
</beans>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>.*/foo-[^/]*\.jar$</Arg>
</Call>
</Configure>

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 The MITRE Corporation
and the MIT Internet Trust Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<qualifier value="defaultTransactionManager" />
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan" value="org.mitre" />
<property name="persistenceProviderClass" value="org.eclipse.persistence.jpa.PersistenceProvider" />
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaAdapter" />
<property name="jpaPropertyMap">
<map>
<entry key="eclipselink.weaving" value="false" />
<entry key="eclipselink.logging.level" value="INFO" />
<entry key="eclipselink.logging.level.sql" value="INFO" />
<entry key="eclipselink.cache.shared.default" value="false" />
</map>
</property>
<property name="persistenceUnitName" value="defaultPersistenceUnit" />
</bean>
</beans>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 The MITRE Corporation
and the MIT Internet Trust Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<!-- Empty: Override this file in your local project to change configuration options. -->
</beans>

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 The MITRE Corporation
and the MIT Internet Trust Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<bean id="configBean" class="org.mitre.openid.connect.config.ConfigurationPropertiesBean">
<!-- This property sets the root URL of the server, known as the issuer -->
<property name="issuer" value="http://localhost:8080/openid-connect-server-webapp/" />
<!-- This property is a URL pointing to a logo image 24px high to be used in the top bar -->
<property name="logoImageUrl" value="resources/images/openid_connect_small.png" />
<!-- This property sets the display name of the server, displayed in the topbar and page title -->
<property name="topbarTitle" value="OpenID Connect Server" />
<!-- This property sets the lifetime of registration access tokens, in seconds. Leave it unset (null) for no rotation. -->
<!-- <property name="regTokenLifeTime" value="172800" /> -->
<!-- This property forces the issuer value to start with "https", recommended on production servers -->
<!-- <property name="forceHttps" value="true" /> -->
<!-- This property sets the locale for server text -->
<!-- <property name="locale" value="sv" /> -->
<!-- This property sets the set of namespaces for language translation files. The default is "messages". These are checked in the order presented here. -->
<!--
<property name="languageNamespaces">
<list>
<value>foo</value>
<value>bar</value>
<value>messages</value>
</list>
</property>
-->
<!-- This property indicates if a dynamically registered client supports dual flows, such as client_credentials
at the same time with authorization_code or implicit -->
<!-- <property name="dualClient" value="true" /> -->
<!-- This property turns on HEART compliance mode -->
<!-- <property name="heartMode" value="true" /> -->
</bean>
</beans>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 The MITRE Corporation
and the MIT Internet Trust Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<!-- This file has been left blank -->
<!-- Feel free to override this by using a maven overlay. -->
<!-- see: https://github.com/mitreid-connect/OpenID-Connect-Java-Spring-Server/wiki/Maven-Overlay-Project-How-To/ -->
</beans>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 The MITRE Corporation
and the MIT Internet Trust Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
<!-- Configuration for scheduled tasks -->
<task:scheduler id="taskScheduler" pool-size="10" />
<task:executor id="taskExecutor" pool-size="5" />
<task:annotation-driven scheduler="taskScheduler" executor="taskExecutor" />
<!-- Schedule the token service and approved site service to clear out expired tokens and sites every 5 minutes -->
<task:scheduled-tasks scheduler="taskScheduler">
<task:scheduled ref="defaultOAuth2ProviderTokenService" method="clearExpiredTokens" fixed-delay="300000" initial-delay="600000"/>
<task:scheduled ref="defaultApprovedSiteService" method="clearExpiredSites" fixed-delay="300000" initial-delay="600000"/>
<task:scheduled ref="defaultOAuth2AuthorizationCodeService" method="clearExpiredAuthorizationCodes" fixed-delay="300000" initial-delay="600000"/>
</task:scheduled-tasks>
</beans>

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 The MITRE Corporation
and the MIT Internet Trust Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider>
<security:jdbc-user-service data-source-ref="dataSource"/>
</security:authentication-provider>
</security:authentication-manager>
<mvc:view-controller path="/login" view-name="login" />
<security:http disable-url-rewriting="true" use-expressions="true">
<security:form-login login-page="/login" authentication-failure-url="/login?error=failure" authentication-success-handler-ref="authenticationTimeStamper" />
<security:intercept-url pattern="/authorize" access="hasRole('ROLE_USER')" />
<security:intercept-url pattern="/**" access="permitAll" />
<security:custom-filter ref="authRequestFilter" after="SECURITY_CONTEXT_FILTER" />
<security:logout logout-url="/logout" />
<security:anonymous />
<security:expression-handler ref="oauthWebExpressionHandler" />
<security:headers>
<security:frame-options policy="DENY" />
</security:headers>
<security:csrf />
</security:http>
</beans>

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 The MITRE Corporation
and the MIT Internet Trust Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
metadata-complete="true">
<absolute-ordering />
<!-- The definition of the Root Spring Container shared by all Servlets
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/application-context.xml
</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- filter through Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Processes application requests -->
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
<error-page>
<location>/error</location>
</error-page>
</web-app>

View File

@ -3,7 +3,9 @@ package ca.uhn.fhir.validation;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -16,6 +18,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@ -89,17 +92,21 @@ public class FhirInstanceValidatorDstu3Test {
String vsContents; String vsContents;
vsContents = IOUtils.toString(FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/org/hl7/fhir/instance/model/dstu3/profile/" + name + ".xml"), "UTF-8"); vsContents = IOUtils.toString(FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/org/hl7/fhir/instance/model/dstu3/profile/" + name + ".xml"), "UTF-8");
TreeSet<String> ids = new TreeSet<String>();
bundle = ourCtx.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents); bundle = ourCtx.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents);
for (BundleEntryComponent i : bundle.getEntry()) { for (BundleEntryComponent i : bundle.getEntry()) {
org.hl7.fhir.dstu3.model.Resource next = i.getResource(); org.hl7.fhir.dstu3.model.Resource next = i.getResource();
ids.add(next.getId());
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(next)); ourLog.info("Validating {}", next.getId());
ValidationResult output = myVal.validateWithResult(next); ValidationResult output = myVal.validateWithResult(next);
List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output); List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output);
assertThat("Failed to validate " + i.getFullUrl(), errors, empty()); assertThat("Failed to validate " + i.getFullUrl(), errors, empty());
} }
ourLog.info("Validated the following:\n{}", ids);
} }
@Test @Test