diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml new file mode 100644 index 00000000000..7139770d8b0 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml @@ -0,0 +1,294 @@ + + 4.0.0 + + + + ca.uhn.hapi.fhir + hapi-fhir-cli + 1.4-SNAPSHOT + ../pom.xml + + + hapi-fhir-cli-app + jar + + HAPI FHIR - Command Line Client - Application + + + + + + ca.uhn.hapi.fhir + hapi-fhir-base + 1.4-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-cli-jpaserver + 1.4-SNAPSHOT + war + + + ca.uhn.hapi.fhir + hapi-fhir-cli-jpaserver + 1.4-SNAPSHOT + jar + classes + + + ca.uhn.hapi.fhir + hapi-fhir-testpage-overlay + 1.4-SNAPSHOT + classes + + + + ca.uhn.hapi.fhir + hapi-fhir-structures-dstu + 1.4-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-structures-dstu2 + 1.4-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-structures-dstu2.1 + 1.4-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-structures-hl7org-dstu2 + 1.4-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-validation-resources-dstu2 + 1.4-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-validation-resources-dstu2.1 + 1.4-SNAPSHOT + + + + ch.qos.logback + logback-classic + + + javax.servlet + javax.servlet-api + + + + commons-cli + commons-cli + + + + org.springframework + spring-core + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + + + org.springframework + spring-context + + + xml-apis + xml-apis + + + + + org.springframework + spring-beans + + + org.springframework + spring-tx + + + org.springframework + spring-context-support + + + org.springframework + spring-web + + + + org.eclipse.jetty + jetty-servlets + + + org.eclipse.jetty + jetty-servlet + + + org.eclipse.jetty + jetty-server + + + org.eclipse.jetty + jetty-util + + + org.eclipse.jetty + jetty-webapp + + + org.eclipse.jetty.websocket + websocket-api + + + org.eclipse.jetty.websocket + websocket-client + + + org.slf4j + jcl-over-slf4j + + + + org.thymeleaf + thymeleaf + + + org.thymeleaf + thymeleaf-spring4 + + + + org.ebaysf.web + cors-filter + + + com.phloc + phloc-schematron + + + com.phloc + phloc-commons + + + + org.fusesource.jansi + jansi + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + process-resources + + copy + + + + + ca.uhn.hapi.fhir + hapi-fhir-cli-jpaserver + 1.4-SNAPSHOT + war + true + target/classes + hapi-fhir-cli-jpaserver.war + + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + org.apache.maven.plugins + maven-shade-plugin + 2.4.1 + + + package + + shade + + + hapi-fhir-cli + + + + + ca.uhn.fhir.cli.App + + + + + * + + **/*.SF + **/*.RSA + + + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [2.10,) + + copy + + + + + + + + + + + + + + + diff --git a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/App.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/App.java similarity index 91% rename from hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/App.java rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/App.java index 530ebf553dd..a9fb6b713a7 100644 --- a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/App.java +++ b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/App.java @@ -117,6 +117,7 @@ public class App { System.out.println("\ud83d\udd25 " + ansi().bold() + "HAPI FHIR" + ansi().boldOff() + " " + VersionUtil.getVersion() + " - Command Line Tool"); System.out.println("------------------------------------------------------------"); System.out.println("Max configured JVM memory (Xmx): " + FileUtils.getFileSizeDisplay(Runtime.getRuntime().maxMemory(), 1)); + System.out.println("Detected Java version: " + System.getProperty("java.version")); System.out.println("------------------------------------------------------------"); } @@ -172,6 +173,7 @@ public class App { CommandLine parsedOptions; logAppHeader(); + validateJavaVersion(); loggingConfigOn(); try { @@ -197,4 +199,16 @@ public class App { } + private static void validateJavaVersion() { + String specVersion = System.getProperty("java.specification.version"); + double version = Double.parseDouble(specVersion); + if (version < 1.8) { + System.err.flush(); + System.err.println("HAPI-CLI requires Java 1.8+ to run (detected " + specVersion + ")"); + System.err.println("Note that the HAPI library requires only Java 1.6, but you must install"); + System.err.println("a newer JVM in order to use the HAPI CLI tool."); + System.exit(1); + } + } + } diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/BaseCommand.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/BaseCommand.java new file mode 100644 index 00000000000..d5d1f7fe207 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/BaseCommand.java @@ -0,0 +1,71 @@ +package ca.uhn.fhir.cli; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.ParseException; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.rest.client.IGenericClient; + +public abstract class BaseCommand implements Comparable { + + private static final String SPEC_DEFAULT_VERSION = "dstu2"; + + private FhirContext myFhirCtx; + + public BaseCommand() { + super(); + } + + @Override + public int compareTo(BaseCommand theO) { + return getCommandName().compareTo(theO.getCommandName()); + } + + public abstract String getCommandDescription(); + + public abstract String getCommandName(); + + public abstract Options getOptions(); + + protected IGenericClient newClient(FhirContext ctx, String theBaseUrl) { + ctx.getRestfulClientFactory().setSocketTimeout(10 * 60 * 1000); + IGenericClient fhirClient = ctx.newRestfulGenericClient(theBaseUrl); + return fhirClient; + } + + public abstract void run(CommandLine theCommandLine) throws ParseException, Exception; + +// public FhirContext getFhirCtx() { +// if (myFhirCtx == null) { +// myFhirCtx = FhirContext.forDstu2(); +// } +// return myFhirCtx; +// } + + protected void addFhirVersionOption(Options theOptions) { + Option opt = new Option("f", "fhirversion", true, "Spec version to upload (default is '" + SPEC_DEFAULT_VERSION + "')"); + opt.setRequired(false); + theOptions.addOption(opt); + } + + protected FhirContext getSpecVersionContext(CommandLine theCommandLine) throws ParseException { + if (myFhirCtx == null) { + String specVersion = theCommandLine.getOptionValue("f", SPEC_DEFAULT_VERSION); + FhirVersionEnum version; + if ("dstu2".equals(specVersion)) { + version = FhirVersionEnum.DSTU2; + } else if ("dstu2.1".equals(specVersion)) { + version = FhirVersionEnum.DSTU2_1; + } else { + throw new ParseException("Unknown spec version: " + specVersion); + } + + myFhirCtx = new FhirContext(version); + } + return myFhirCtx; + } + +} \ No newline at end of file diff --git a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/CommandFailureException.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/CommandFailureException.java similarity index 100% rename from hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/CommandFailureException.java rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/CommandFailureException.java diff --git a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/ExampleDataUploader.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ExampleDataUploader.java similarity index 95% rename from hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/ExampleDataUploader.java rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ExampleDataUploader.java index 03ff3aa6ace..51d77022311 100644 --- a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/ExampleDataUploader.java +++ b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ExampleDataUploader.java @@ -47,7 +47,6 @@ import ca.uhn.fhir.util.ResourceReferenceInfo; public class ExampleDataUploader extends BaseCommand { - private static final String SPEC_DEFAULT_VERSION = "dstu2"; private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleDataUploader.class); @@ -66,10 +65,8 @@ public class ExampleDataUploader extends BaseCommand { Options options = new Options(); Option opt; - opt = new Option("f", "fhirversion", true, "Spec version to upload (default is '" + SPEC_DEFAULT_VERSION + "')"); - opt.setRequired(false); - options.addOption(opt); - + addFhirVersionOption(options); + opt = new Option("t", "target", true, "Base URL for the target server (e.g. \"http://example.com/fhir\")"); opt.setRequired(true); options.addOption(opt); @@ -87,7 +84,8 @@ public class ExampleDataUploader extends BaseCommand { @Override public void run(CommandLine theCommandLine) throws Exception { - String specVersion = theCommandLine.getOptionValue("f", SPEC_DEFAULT_VERSION); + FhirContext ctx = getSpecVersionContext(theCommandLine); + String targetServer = theCommandLine.getOptionValue("t"); if (isBlank(targetServer)) { throw new ParseException("No target server (-t) specified"); @@ -104,17 +102,17 @@ public class ExampleDataUploader extends BaseCommand { } } - FhirContext ctx; String specUrl; - if (SPEC_DEFAULT_VERSION.equals(specVersion)) { - ctx = FhirContext.forDstu2(); - specUrl = "http://hl7.org/fhir/" + specVersion + "/examples-json.zip"; - } else if ("dstu2.1".equals(specVersion)) { - ctx = FhirContext.forDstu2_1(); + switch (ctx.getVersion().getVersion()) { + case DSTU2: + specUrl = "http://hl7.org/fhir/dstu2/examples-json.zip"; + break; + case DSTU2_1: specUrl = "http://hl7-fhir.github.io/examples-json.zip"; - } else { - throw new ParseException("Unknown spec version: " + specVersion); + break; + default: + throw new ParseException("Invalid spec version for this command: " + ctx.getVersion().getVersion()); } ourLog.info("HTTP fetching: {}", specUrl); diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu2.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu2.java new file mode 100644 index 00000000000..e48a1806e48 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu2.java @@ -0,0 +1,58 @@ +package ca.uhn.fhir.cli; + +import org.hl7.fhir.instance.hapi.validation.IValidationSupport; +import org.hl7.fhir.instance.model.ValueSet; +import org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent; +import org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent; +import org.hl7.fhir.instance.model.api.IBaseResource; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.rest.client.IGenericClient; +import ca.uhn.fhir.rest.client.ServerValidationModeEnum; +import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; + +public class LoadingValidationSupportDstu2 implements IValidationSupport { + + private static FhirContext myCtx = FhirContext.forDstu2Hl7Org(); + + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(LoadingValidationSupportDstu2.class); + + @Override + public ValueSetExpansionComponent expandValueSet(FhirContext theContext, ConceptSetComponent theInclude) { + return null; + } + + @Override + public ValueSet fetchCodeSystem(FhirContext theContext, String theSystem) { + return null; + } + + @Override + public T fetchResource(FhirContext theContext, Class theClass, String theUri) { + String resName = myCtx.getResourceDefinition(theClass).getName(); + ourLog.info("Attempting to fetch {} at URL: {}", resName, theUri); + + myCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); + IGenericClient client = myCtx.newRestfulGenericClient("http://example.com"); + + T result; + try { + result = client.read(theClass, theUri); + } catch (BaseServerResponseException e) { + throw new CommandFailureException("FAILURE: Received HTTP " + e.getStatusCode() + ": " + e.getMessage()); + } + ourLog.info("Successfully loaded resource"); + return result; + } + + @Override + public boolean isCodeSystemSupported(FhirContext theContext, String theSystem) { + return false; + } + + @Override + public CodeValidationResult validateCode(FhirContext theContext, String theCodeSystem, String theCode, String theDisplay) { + return null; + } + +} diff --git a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupport.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu21.java similarity index 90% rename from hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupport.java rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu21.java index 6cffd283c1d..07109930b51 100644 --- a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupport.java +++ b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu21.java @@ -11,11 +11,11 @@ import ca.uhn.fhir.rest.client.IGenericClient; import ca.uhn.fhir.rest.client.ServerValidationModeEnum; import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; -public class LoadingValidationSupport implements IValidationSupport { +public class LoadingValidationSupportDstu21 implements IValidationSupport { - private static FhirContext myCtx = FhirContext.forDstu2Hl7Org(); + private static FhirContext myCtx = FhirContext.forDstu2_1(); - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(LoadingValidationSupport.class); + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(LoadingValidationSupportDstu21.class); @Override public ValueSetExpansionComponent expandValueSet(FhirContext theContext, ConceptSetComponent theInclude) { diff --git a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java similarity index 63% rename from hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java index d3f7e42bfa1..9bed6f5f878 100644 --- a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java @@ -6,13 +6,25 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.EventListener; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.io.IOUtils; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.webapp.WebAppContext; +import org.springframework.web.context.ContextLoader; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; + +import ca.uhn.fhir.jpa.demo.ContextHolder; +import ca.uhn.fhir.jpa.demo.FhirServerConfig; +import ca.uhn.fhir.jpa.demo.FhirServerConfigDstu21; public class RunServerCommand extends BaseCommand { @@ -32,6 +44,7 @@ public class RunServerCommand extends BaseCommand { @Override public Options getOptions() { Options options = new Options(); + addFhirVersionOption(options); options.addOption(OPTION_P, "port", true, "The port to listen on (default is " + DEFAULT_PORT + ")"); return options; } @@ -47,6 +60,8 @@ public class RunServerCommand extends BaseCommand { @Override public void run(CommandLine theCommandLine) throws ParseException { myPort = parseOptionInteger(theCommandLine, OPTION_P, DEFAULT_PORT); + + ContextHolder.setCtx(getSpecVersionContext(theCommandLine)); // ((ch.qos.logback.classic.Logger)LoggerFactory.getLogger("/")).setLevel(Level.ERROR); @@ -56,7 +71,7 @@ public class RunServerCommand extends BaseCommand { tempWarFile = File.createTempFile("hapi-fhir", ".war"); tempWarFile.deleteOnExit(); - InputStream inStream = RunServerCommand.class.getResourceAsStream("/hapi-fhir-jpaserver-example.war"); + InputStream inStream = RunServerCommand.class.getResourceAsStream("/hapi-fhir-cli-jpaserver.war"); OutputStream outStream = new BufferedOutputStream(new FileOutputStream(tempWarFile, false)); IOUtils.copy(inStream, outStream); } catch (IOException e) { @@ -64,12 +79,37 @@ public class RunServerCommand extends BaseCommand { return; } - ourLog.info("Starting HAPI FHIR JPA server"); + final ContextLoaderListener cll = new ContextLoaderListener(); + + ourLog.info("Starting HAPI FHIR JPA server in {} mode", ContextHolder.getCtx().getVersion().getVersion()); WebAppContext root = new WebAppContext(); root.setAllowDuplicateFragmentNames(true); root.setWar(tempWarFile.getAbsolutePath()); root.setParentLoaderPriority(true); root.setContextPath("/"); + root.addEventListener(new ServletContextListener() { + @Override + public void contextInitialized(ServletContextEvent theSce) { + theSce.getServletContext().setInitParameter(ContextLoader.CONTEXT_CLASS_PARAM, AnnotationConfigWebApplicationContext.class.getName()); + switch (ContextHolder.getCtx().getVersion().getVersion()) { + case DSTU2: + theSce.getServletContext().setInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, FhirServerConfig.class.getName()); + break; + case DSTU2_1: + theSce.getServletContext().setInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, FhirServerConfigDstu21.class.getName()); + break; + } + cll.contextInitialized(theSce); + } + + @Override + public void contextDestroyed(ServletContextEvent theSce) { + cll.contextDestroyed(theSce); + } + }); + + String path = ContextHolder.getPath(); + root.addServlet("ca.uhn.fhir.jpa.demo.JpaServerDemo", path + "*"); myServer = new Server(myPort); myServer.setHandler(root); @@ -82,7 +122,7 @@ public class RunServerCommand extends BaseCommand { ourLog.info("Server started on port {}", myPort); ourLog.info("Web Testing UI : http://localhost:{}/", myPort); - ourLog.info("Server Base URL: http://localhost:{}/baseDstu2/", myPort); + ourLog.info("Server Base URL: http://localhost:{}{}", myPort, path); } diff --git a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java similarity index 64% rename from hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java index cda71350802..5a5cbe99557 100644 --- a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java @@ -24,6 +24,7 @@ import org.hl7.fhir.dstu21.hapi.validation.DefaultProfileValidationSupport; import org.hl7.fhir.dstu21.hapi.validation.FhirInstanceValidator; import org.hl7.fhir.dstu21.hapi.validation.ValidationSupportChain; import org.hl7.fhir.dstu21.model.StructureDefinition; +import org.hl7.fhir.instance.model.api.IBaseResource; import com.phloc.commons.io.file.FileUtils; @@ -51,6 +52,7 @@ public class ValidateCommand extends BaseCommand { @Override public Options getOptions() { Options retVal = new Options(); + addFhirVersionOption(retVal); OptionGroup source = new OptionGroup(); source.addOption(new Option("f", "file", true, "The name of the file to validate")); @@ -60,7 +62,8 @@ public class ValidateCommand extends BaseCommand { retVal.addOption("x", "xsd", false, "Validate using Schemas"); retVal.addOption("s", "sch", false, "Validate using Schematrons"); retVal.addOption("p", "profile", false, "Validate using Profiles (StructureDefinition / ValueSet)"); - retVal.addOption("r", "fetch-remote", false, "Allow fetching remote resources (in other words, if a resource being validated refers to an external StructureDefinition, Questionnaire, etc. this flag allows the validator to access the internet to try and fetch this resource)"); + retVal.addOption("r", "fetch-remote", false, + "Allow fetching remote resources (in other words, if a resource being validated refers to an external StructureDefinition, Questionnaire, etc. this flag allows the validator to access the internet to try and fetch this resource)"); retVal.addOption(new Option("l", "fetch-local", true, "Fetch a profile locally and use it if referenced")); retVal.addOption("e", "encoding", false, "File encoding (default is UTF-8)"); @@ -91,28 +94,55 @@ public class ValidateCommand extends BaseCommand { throw new ParseException("Could not detect encoding (json/xml) of contents"); } - FhirValidator val = getFhirCtx().newValidator(); + FhirContext ctx = getSpecVersionContext(theCommandLine); + FhirValidator val = ctx.newValidator(); + + IBaseResource localProfileResource = null; + if (theCommandLine.hasOption("l")) { + String localProfile = theCommandLine.getOptionValue("l"); + ourLog.info("Loading profile: {}", localProfile); + String input; + try { + input = IOUtils.toString(new FileReader(new File(localProfile))); + } catch (IOException e) { + throw new ParseException("Failed to load file '" + localProfile + "' - Error: " + e.toString()); + } + + localProfileResource = MethodUtil.detectEncodingNoDefault(input).newParser(ctx).parseResource(input); + } + if (theCommandLine.hasOption("p")) { - FhirInstanceValidator instanceValidator = new FhirInstanceValidator(); - val.registerValidatorModule(instanceValidator); - ValidationSupportChain validationSupport = new ValidationSupportChain(new DefaultProfileValidationSupport()); - if (theCommandLine.hasOption("l")) { - String localProfile = theCommandLine.getOptionValue("l"); - ourLog.info("Loading profile: {}", localProfile); - String input; - try { - input = IOUtils.toString(new FileReader(new File(localProfile))); - } catch (IOException e) { - throw new ParseException("Failed to load file '" + localProfile + "' - Error: " + e.toString()); + switch (ctx.getVersion().getVersion()) { + case DSTU2: { + org.hl7.fhir.instance.hapi.validation.FhirInstanceValidator instanceValidator = new org.hl7.fhir.instance.hapi.validation.FhirInstanceValidator(); + val.registerValidatorModule(instanceValidator); + org.hl7.fhir.instance.hapi.validation.ValidationSupportChain validationSupport = new org.hl7.fhir.instance.hapi.validation.ValidationSupportChain( + new org.hl7.fhir.instance.hapi.validation.DefaultProfileValidationSupport()); + if (localProfileResource != null) { + instanceValidator.setStructureDefintion((org.hl7.fhir.instance.model.StructureDefinition) localProfileResource); } - - StructureDefinition sd = (StructureDefinition) MethodUtil.detectEncodingNoDefault(input).newParser(getFhirCtx()).parseResource(input); - instanceValidator.setStructureDefintion(sd); + if (theCommandLine.hasOption("r")) { + validationSupport.addValidationSupport(new LoadingValidationSupportDstu2()); + } + instanceValidator.setValidationSupport(validationSupport); + break; } - if (theCommandLine.hasOption("r")) { - validationSupport.addValidationSupport(new LoadingValidationSupport()); + case DSTU2_1: { + FhirInstanceValidator instanceValidator = new FhirInstanceValidator(); + val.registerValidatorModule(instanceValidator); + ValidationSupportChain validationSupport = new ValidationSupportChain(new DefaultProfileValidationSupport()); + if (localProfileResource != null) { + instanceValidator.setStructureDefintion((StructureDefinition) localProfileResource); + } + if (theCommandLine.hasOption("r")) { + validationSupport.addValidationSupport(new LoadingValidationSupportDstu21()); + } + instanceValidator.setValidationSupport(validationSupport); + break; + } + default: + throw new ParseException("Profile validation (-p) is not supported for this FHIR version"); } - instanceValidator.setValidationSupport(validationSupport); } val.setValidateAgainstStandardSchema(theCommandLine.hasOption("x")); @@ -125,7 +155,7 @@ public class ValidateCommand extends BaseCommand { for (SingleValidationMessage next : results.getMessages()) { count++; b.append(App.LINESEP); - String leftString = "Issue "+count+": "; + String leftString = "Issue " + count + ": "; int leftWidth = leftString.length(); b.append(ansi().fg(Color.GREEN)).append(leftString); if (next.getSeverity() != null) { diff --git a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java similarity index 100% rename from hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java diff --git a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/WebsocketSubscribeCommand.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/WebsocketSubscribeCommand.java similarity index 100% rename from hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/WebsocketSubscribeCommand.java rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/WebsocketSubscribeCommand.java diff --git a/hapi-fhir-cli/src/main/resources/logback-cli-off.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/resources/logback-cli-off.xml similarity index 100% rename from hapi-fhir-cli/src/main/resources/logback-cli-off.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/resources/logback-cli-off.xml diff --git a/hapi-fhir-cli/src/main/resources/logback-cli-on.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/resources/logback-cli-on.xml similarity index 100% rename from hapi-fhir-cli/src/main/resources/logback-cli-on.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/resources/logback-cli-on.xml diff --git a/hapi-fhir-cli/src/main/script/hapi-fhir-cli b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/script/hapi-fhir-cli similarity index 100% rename from hapi-fhir-cli/src/main/script/hapi-fhir-cli rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/script/hapi-fhir-cli diff --git a/hapi-fhir-cli/src/main/script/hapi-fhir-cli.cmd b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/script/hapi-fhir-cli.cmd similarity index 100% rename from hapi-fhir-cli/src/main/script/hapi-fhir-cli.cmd rename to hapi-fhir-cli/hapi-fhir-cli-app/src/main/script/hapi-fhir-cli.cmd diff --git a/hapi-fhir-cli/src/test/java/ValidateTest.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/java/ValidateTest.java similarity index 100% rename from hapi-fhir-cli/src/test/java/ValidateTest.java rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/java/ValidateTest.java diff --git a/hapi-fhir-cli/src/test/resources/nl/nl-core-address-official.dstu2.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-address-official.dstu2.xml similarity index 100% rename from hapi-fhir-cli/src/test/resources/nl/nl-core-address-official.dstu2.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-address-official.dstu2.xml diff --git a/hapi-fhir-cli/src/test/resources/nl/nl-core-address.dstu2.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-address.dstu2.xml similarity index 100% rename from hapi-fhir-cli/src/test/resources/nl/nl-core-address.dstu2.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-address.dstu2.xml diff --git a/hapi-fhir-cli/src/test/resources/nl/nl-core-humanname-familyname-prefix.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-humanname-familyname-prefix.xml similarity index 100% rename from hapi-fhir-cli/src/test/resources/nl/nl-core-humanname-familyname-prefix.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-humanname-familyname-prefix.xml diff --git a/hapi-fhir-cli/src/test/resources/nl/nl-core-humanname-familyname.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-humanname-familyname.xml similarity index 100% rename from hapi-fhir-cli/src/test/resources/nl/nl-core-humanname-familyname.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-humanname-familyname.xml diff --git a/hapi-fhir-cli/src/test/resources/nl/nl-core-humanname.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-humanname.xml similarity index 100% rename from hapi-fhir-cli/src/test/resources/nl/nl-core-humanname.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-humanname.xml diff --git a/hapi-fhir-cli/src/test/resources/nl/nl-core-patient.dstu2.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-patient.dstu2.xml similarity index 100% rename from hapi-fhir-cli/src/test/resources/nl/nl-core-patient.dstu2.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/nl-core-patient.dstu2.xml diff --git a/hapi-fhir-cli/src/test/resources/nl/patient-example-a.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/patient-example-a.xml similarity index 100% rename from hapi-fhir-cli/src/test/resources/nl/patient-example-a.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/patient-example-a.xml diff --git a/hapi-fhir-cli/src/test/resources/nl/validate.sh b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/validate.sh similarity index 100% rename from hapi-fhir-cli/src/test/resources/nl/validate.sh rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/nl/validate.sh diff --git a/hapi-fhir-cli/src/test/resources/patient-uslab-example1.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/patient-uslab-example1.xml similarity index 100% rename from hapi-fhir-cli/src/test/resources/patient-uslab-example1.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/patient-uslab-example1.xml diff --git a/hapi-fhir-cli/src/test/resources/uslab-patient.profile.xml b/hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/uslab-patient.profile.xml similarity index 100% rename from hapi-fhir-cli/src/test/resources/uslab-patient.profile.xml rename to hapi-fhir-cli/hapi-fhir-cli-app/src/test/resources/uslab-patient.profile.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/.gitignore b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/.gitignore new file mode 100644 index 00000000000..f59bdf9b9af --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/.gitignore @@ -0,0 +1,130 @@ +/target +/jpaserver_derby_files +*.log +ca.uhn.fhir.jpa.entity.ResourceTable/ + +# Created by https://www.gitignore.io + +### Java ### +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties + + +### Vim ### +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +*.un~ +Session.vim +.netrwhist +*~ + + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties + + + +### Eclipse ### +*.pydevproject +.metadata +.gradle +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath + +# Eclipse Core +.project + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# PDT-specific +.buildpath + +# sbteclipse plugin +.target + +# TeXlipse plugin +.texlipse + diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml new file mode 100644 index 00000000000..0ba43dafca8 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml @@ -0,0 +1,245 @@ + + 4.0.0 + + + + ca.uhn.hapi.fhir + hapi-fhir-cli + 1.4-SNAPSHOT + ../pom.xml + + + hapi-fhir-cli-jpaserver + war + + HAPI FHIR - Command Line Client - Server WAR + + + + + + ca.uhn.hapi.fhir + hapi-fhir-base + 1.4-SNAPSHOT + provided + + + + + ca.uhn.hapi.fhir + hapi-fhir-structures-dstu + 1.4-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-structures-dstu2 + 1.4-SNAPSHOT + + + + + ca.uhn.hapi.fhir + hapi-fhir-jpaserver-base + 1.4-SNAPSHOT + + + + + ca.uhn.hapi.fhir + hapi-fhir-testpage-overlay + 1.4-SNAPSHOT + war + provided + + + ca.uhn.hapi.fhir + hapi-fhir-testpage-overlay + 1.4-SNAPSHOT + classes + provided + + + + + ch.qos.logback + logback-classic + provided + + + + + javax.servlet + javax.servlet-api + provided + + + + + org.thymeleaf + thymeleaf + provided + + + + + org.ebaysf.web + cors-filter + + + servlet-api + javax.servlet + + + + + + + org.springframework + spring-web + provided + + + + + org.apache.commons + commons-dbcp2 + + + + commons-cli + commons-cli + + + + + org.apache.derby + derby + + + org.apache.derby + derbynet + + + org.apache.derby + derbyclient + + + + + org.eclipse.jetty + jetty-servlets + test + + + org.eclipse.jetty + jetty-servlet + test + + + org.eclipse.jetty + jetty-server + test + + + org.eclipse.jetty + jetty-util + test + + + org.eclipse.jetty + jetty-webapp + test + + + com.phloc + phloc-schematron + + + + + + + + hapi-fhir-cli-jpaserver + + + + + + org.eclipse.jetty + jetty-maven-plugin + + + /hapi-fhir-jpaserver-example + true + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.6 + 1.6 + + + + + + org.apache.maven.plugins + maven-war-plugin + + + + ${maven.build.timestamp} + + + + + ca.uhn.hapi.fhir + hapi-fhir-testpage-overlay + + + src/main/webapp/WEB-INF/web.xml + true + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + true + + + + + integration-test + verify + + + + + + + + + diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/readme.intellij.txt b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/readme.intellij.txt new file mode 100644 index 00000000000..049d5d341a5 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/readme.intellij.txt @@ -0,0 +1,31 @@ +Running hapi-fhir-jpaserver-example in Tomcat from IntelliJ + +Install Tomcat. + +Make sure you have Tomcat set up in IntelliJ. +File->Settings->Build, Execution, Deployment->Application Servers +Click + +Select "Tomcat Server" +Enter the path to your tomcat deployment for both Tomcat Home (IntelliJ will fill in base directory for you) + +Add a Run Configuration for running hapi-fhir-jpaserver-example under Tomcat +Run->Edit Configurations +Click the green + +Select Tomcat Server, Local +Change the name to whatever you wish +Uncheck the "After launch" checkbox +On the "Deployment" tab, click the green + +Select "Artifact" +Select "hapi-fhir-jpaserver-example:war" +In "Application context" type /hapi + +Run the configuration +You should now have an "Application Servers" in the list of windows at the bottom. +Click it. +Select your server, and click the green triangle (or the bug if you want to debug) +Wait for the console output to stop + +Point your browser (or fiddler, or what have you) to +http://localhost:8080/hapi/base/Patient + +You should get an empty bundle back. \ No newline at end of file diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/ContextHolder.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/ContextHolder.java new file mode 100644 index 00000000000..d9613f68f1a --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/ContextHolder.java @@ -0,0 +1,38 @@ +package ca.uhn.fhir.jpa.demo; + +import org.apache.commons.cli.ParseException; +import org.apache.commons.lang3.Validate; + +import ca.uhn.fhir.context.FhirContext; + +public class ContextHolder { + + private static FhirContext ourCtx; + private static String ourPath; + + public static FhirContext getCtx() { + Validate.notNull(ourPath, "Context not set"); + return ourCtx; + } + + public static void setCtx(FhirContext theCtx) throws ParseException { + switch (theCtx.getVersion().getVersion()) { + case DSTU2: + ourPath = "/baseDstu2/"; + break; + case DSTU2_1: + ourPath = "/baseDstu2.1/"; + break; + default: + throw new ParseException("FHIR version not supported by this command: " + ContextHolder.getCtx().getVersion().getVersion()); + } + + ourCtx = theCtx; + } + + public static String getPath() { + Validate.notNull(ourPath, "Context not set"); + return ourPath; + } + +} diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java new file mode 100644 index 00000000000..a2e06509102 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java @@ -0,0 +1,121 @@ +package ca.uhn.fhir.jpa.demo; + +import java.util.Properties; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +import org.apache.commons.dbcp2.BasicDataSource; +import org.apache.commons.lang3.time.DateUtils; +import org.hibernate.jpa.HibernatePersistenceProvider; +import org.springframework.beans.factory.annotation.Autowire; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu2; +import ca.uhn.fhir.jpa.dao.DaoConfig; +import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorDstu2; +import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; +import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; +import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; + +@Configuration +@EnableTransactionManagement() +public class FhirServerConfig extends BaseJavaConfigDstu2 { + + /** + * Configure FHIR properties around the the JPA server via this bean + */ + @Bean() + public DaoConfig daoConfig() { + DaoConfig retVal = new DaoConfig(); + retVal.setSubscriptionEnabled(true); + retVal.setSubscriptionPollDelay(5000); + retVal.setSubscriptionPurgeInactiveAfterMillis(DateUtils.MILLIS_PER_HOUR); + retVal.setAllowMultipleDelete(true); + return retVal; + } + + /** + * The following bean configures the database connection. The 'url' property value of "jdbc:derby:directory:jpaserver_derby_files;create=true" indicates that the server should save resources in a + * directory called "jpaserver_derby_files". + * + * A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource. + */ + @Bean(destroyMethod = "close") + public DataSource dataSource() { + BasicDataSource retVal = new BasicDataSource(); + retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver()); + retVal.setUrl("jdbc:derby:directory:target/jpaserver_derby_files;create=true"); + retVal.setUsername(""); + retVal.setPassword(""); + return retVal; + } + + @Bean() + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean(); + retVal.setPersistenceUnitName("HAPI_PU"); + retVal.setDataSource(dataSource()); + retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity"); + retVal.setPersistenceProvider(new HibernatePersistenceProvider()); + retVal.setJpaProperties(jpaProperties()); + return retVal; + } + + private Properties jpaProperties() { + Properties extraProperties = new Properties(); + extraProperties.put("hibernate.dialect", org.hibernate.dialect.DerbyTenSevenDialect.class.getName()); + extraProperties.put("hibernate.format_sql", "true"); + extraProperties.put("hibernate.show_sql", "false"); + extraProperties.put("hibernate.hbm2ddl.auto", "update"); + extraProperties.put("hibernate.jdbc.batch_size", "20"); + extraProperties.put("hibernate.cache.use_query_cache", "false"); + extraProperties.put("hibernate.cache.use_second_level_cache", "false"); + extraProperties.put("hibernate.cache.use_structured_entries", "false"); + extraProperties.put("hibernate.cache.use_minimal_puts", "false"); + extraProperties.put("hibernate.search.default.directory_provider", "filesystem"); + extraProperties.put("hibernate.search.default.indexBase", "target/lucenefiles"); + extraProperties.put("hibernate.search.lucene_version", "LUCENE_CURRENT"); + return extraProperties; + } + + /** + * Do some fancy logging to create a nice access log that has details about each incoming request. + */ + public IServerInterceptor loggingInterceptor() { + LoggingInterceptor retVal = new LoggingInterceptor(); + retVal.setLoggerName("fhirtest.access"); + retVal.setMessageFormat( + "Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]"); + retVal.setLogExceptions(true); + retVal.setErrorMessageFormat("ERROR - ${requestVerb} ${requestUrl}"); + return retVal; + } + + /** + * This interceptor adds some pretty syntax highlighting in responses when a browser is detected + */ + @Bean(autowire = Autowire.BY_TYPE) + public IServerInterceptor responseHighlighterInterceptor() { + ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor(); + return retVal; + } + + @Bean(autowire = Autowire.BY_TYPE) + public IServerInterceptor subscriptionSecurityInterceptor() { + SubscriptionsRequireManualActivationInterceptorDstu2 retVal = new SubscriptionsRequireManualActivationInterceptorDstu2(); + return retVal; + } + + @Bean() + public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { + JpaTransactionManager retVal = new JpaTransactionManager(); + retVal.setEntityManagerFactory(entityManagerFactory); + return retVal; + } + +} diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu21.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu21.java new file mode 100644 index 00000000000..0ba42d8f4cf --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu21.java @@ -0,0 +1,129 @@ +package ca.uhn.fhir.jpa.demo; + +import java.util.Properties; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +import org.apache.commons.dbcp2.BasicDataSource; +import org.apache.commons.lang3.time.DateUtils; +import org.hibernate.jpa.HibernatePersistenceProvider; +import org.springframework.beans.factory.annotation.Autowire; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu21; +import ca.uhn.fhir.jpa.dao.DaoConfig; +import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorDstu21; +import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; +import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; +import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; + +/** + * This class isn't used by default by the example, but + * you can use it as a config if you want to support DSTU2.1 + * instead of DSTU2 in your server. + * + * See https://github.com/jamesagnew/hapi-fhir/issues/278 + */ +@Configuration +@EnableTransactionManagement() +public class FhirServerConfigDstu21 extends BaseJavaConfigDstu21 { + + /** + * Configure FHIR properties around the the JPA server via this bean + */ + @Bean() + public DaoConfig daoConfig() { + DaoConfig retVal = new DaoConfig(); + retVal.setSubscriptionEnabled(true); + retVal.setSubscriptionPollDelay(5000); + retVal.setSubscriptionPurgeInactiveAfterMillis(DateUtils.MILLIS_PER_HOUR); + retVal.setAllowMultipleDelete(true); + return retVal; + } + + /** + * The following bean configures the database connection. The 'url' property value of "jdbc:derby:directory:jpaserver_derby_files;create=true" indicates that the server should save resources in a + * directory called "jpaserver_derby_files". + * + * A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource. + */ + @Bean(destroyMethod = "close") + public DataSource dataSource() { + BasicDataSource retVal = new BasicDataSource(); + retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver()); + retVal.setUrl("jdbc:derby:directory:target/jpaserver_derby_files;create=true"); + retVal.setUsername(""); + retVal.setPassword(""); + return retVal; + } + + @Bean() + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean(); + retVal.setPersistenceUnitName("HAPI_PU"); + retVal.setDataSource(dataSource()); + retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity"); + retVal.setPersistenceProvider(new HibernatePersistenceProvider()); + retVal.setJpaProperties(jpaProperties()); + return retVal; + } + + private Properties jpaProperties() { + Properties extraProperties = new Properties(); + extraProperties.put("hibernate.dialect", org.hibernate.dialect.DerbyTenSevenDialect.class.getName()); + extraProperties.put("hibernate.format_sql", "true"); + extraProperties.put("hibernate.show_sql", "false"); + extraProperties.put("hibernate.hbm2ddl.auto", "update"); + extraProperties.put("hibernate.jdbc.batch_size", "20"); + extraProperties.put("hibernate.cache.use_query_cache", "false"); + extraProperties.put("hibernate.cache.use_second_level_cache", "false"); + extraProperties.put("hibernate.cache.use_structured_entries", "false"); + extraProperties.put("hibernate.cache.use_minimal_puts", "false"); + extraProperties.put("hibernate.search.default.directory_provider", "filesystem"); + extraProperties.put("hibernate.search.default.indexBase", "target/lucenefiles"); + extraProperties.put("hibernate.search.lucene_version", "LUCENE_CURRENT"); +// extraProperties.put("hibernate.search.default.worker.execution", "async"); + return extraProperties; + } + + /** + * Do some fancy logging to create a nice access log that has details about each incoming request. + */ + public IServerInterceptor loggingInterceptor() { + LoggingInterceptor retVal = new LoggingInterceptor(); + retVal.setLoggerName("fhirtest.access"); + retVal.setMessageFormat( + "Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]"); + retVal.setLogExceptions(true); + retVal.setErrorMessageFormat("ERROR - ${requestVerb} ${requestUrl}"); + return retVal; + } + + /** + * This interceptor adds some pretty syntax highlighting in responses when a browser is detected + */ + @Bean(autowire = Autowire.BY_TYPE) + public IServerInterceptor responseHighlighterInterceptor() { + ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor(); + return retVal; + } + + @Bean(autowire = Autowire.BY_TYPE) + public IServerInterceptor subscriptionSecurityInterceptor() { + SubscriptionsRequireManualActivationInterceptorDstu21 retVal = new SubscriptionsRequireManualActivationInterceptorDstu21(); + return retVal; + } + + @Bean() + public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { + JpaTransactionManager retVal = new JpaTransactionManager(); + retVal.setEntityManagerFactory(entityManagerFactory); + return retVal; + } + +} diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirTesterConfig.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirTesterConfig.java new file mode 100644 index 00000000000..87b599cdb2e --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirTesterConfig.java @@ -0,0 +1,58 @@ +package ca.uhn.fhir.jpa.demo; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.to.FhirTesterMvcConfig; +import ca.uhn.fhir.to.TesterConfig; + +//@formatter:off +/** + * This spring config file configures the web testing module. It serves two + * purposes: + * 1. It imports FhirTesterMvcConfig, which is the spring config for the + * tester itself + * 2. It tells the tester which server(s) to talk to, via the testerConfig() + * method below + */ +@Configuration +@Import(FhirTesterMvcConfig.class) +public class FhirTesterConfig { + + /** + * This bean tells the testing webpage which servers it should configure itself + * to communicate with. In this example we configure it to talk to the local + * server, as well as one public server. If you are creating a project to + * deploy somewhere else, you might choose to only put your own server's + * address here. + * + * Note the use of the ${serverBase} variable below. This will be replaced with + * the base URL as reported by the server itself. Often for a simple Tomcat + * (or other container) installation, this will end up being something + * like "http://localhost:8080/hapi-fhir-jpaserver-example". If you are + * deploying your server to a place with a fully qualified domain name, + * you might want to use that instead of using the variable. + */ + @Bean + public TesterConfig testerConfig() { + TesterConfig retVal = new TesterConfig(); + retVal + .addServer() + .withId("home") + .withFhirVersion(ContextHolder.getCtx().getVersion().getVersion()) + .withBaseUrl("${serverBase}" + ContextHolder.getPath()) + .withName("Local Tester"); + + retVal + .addServer() + .withId("hapi") + .withFhirVersion(FhirVersionEnum.DSTU2) + .withBaseUrl("http://fhirtest.uhn.ca/baseDstu2") + .withName("Public HAPI Test Server"); + return retVal; + } + +} +//@formatter:on diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java new file mode 100644 index 00000000000..149fdb88bf9 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java @@ -0,0 +1,149 @@ +package ca.uhn.fhir.jpa.demo; + +import java.util.Collection; +import java.util.List; + +import javax.servlet.ServletException; + +import org.hl7.fhir.dstu21.model.Meta; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.WebApplicationContext; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.jpa.dao.DaoConfig; +import ca.uhn.fhir.jpa.dao.IFhirSystemDao; +import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu1; +import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2; +import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu21; +import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1; +import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2; +import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu21; +import ca.uhn.fhir.model.api.IResource; +import ca.uhn.fhir.model.dstu2.composite.MetaDt; +import ca.uhn.fhir.model.dstu2.resource.Bundle; +import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; +import ca.uhn.fhir.rest.server.ETagSupportEnum; +import ca.uhn.fhir.rest.server.EncodingEnum; +import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider; +import ca.uhn.fhir.rest.server.IResourceProvider; +import ca.uhn.fhir.rest.server.RestfulServer; +import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; + +public class JpaServerDemo extends RestfulServer { + + private static final long serialVersionUID = 1L; + + private WebApplicationContext myAppCtx; + + @SuppressWarnings("unchecked") + @Override + protected void initialize() throws ServletException { + super.initialize(); + + setFhirContext(ContextHolder.getCtx()); + + // Get the spring context from the web container (it's declared in web.xml) + myAppCtx = ContextLoaderListener.getCurrentWebApplicationContext(); + + /* + * The hapi-fhir-server-resourceproviders-dev.xml file is a spring configuration + * file which is automatically generated as a part of hapi-fhir-jpaserver-base and + * contains bean definitions for a resource provider for each resource type + */ + String resourceProviderBeanName; + FhirVersionEnum fhirVersion = ContextHolder.getCtx().getVersion().getVersion(); + switch (fhirVersion) { + case DSTU1: + resourceProviderBeanName = "myResourceProvidersDstu1"; + break; + case DSTU2: + resourceProviderBeanName = "myResourceProvidersDstu2"; + break; + case DSTU2_1: + resourceProviderBeanName = "myResourceProvidersDstu21"; + break; + default: + throw new IllegalStateException(); + } + + List beans = myAppCtx.getBean(resourceProviderBeanName, List.class); + setResourceProviders(beans); + + /* + * The system provider implements non-resource-type methods, such as + * transaction, and global history. + */ + Object systemProvider; + if (fhirVersion == FhirVersionEnum.DSTU1) { + systemProvider = myAppCtx.getBean("mySystemProviderDstu1", JpaSystemProviderDstu1.class); + } else if (fhirVersion == FhirVersionEnum.DSTU2) { + systemProvider = myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class); + } else if (fhirVersion == FhirVersionEnum.DSTU2_1) { + systemProvider = myAppCtx.getBean("mySystemProviderDstu21", JpaSystemProviderDstu21.class); + } else { + throw new IllegalStateException(); + } + setPlainProviders(systemProvider); + + /* + * The conformance provider exports the supported resources, search parameters, etc for + * this server. The JPA version adds resource counts to the exported statement, so it + * is a nice addition. + */ + if (fhirVersion == FhirVersionEnum.DSTU1) { + IFhirSystemDao, MetaDt> systemDao = myAppCtx.getBean("mySystemDaoDstu1", + IFhirSystemDao.class); + JpaConformanceProviderDstu1 confProvider = new JpaConformanceProviderDstu1(this, systemDao); + confProvider.setImplementationDescription("Example Server"); + setServerConformanceProvider(confProvider); + } else if (fhirVersion == FhirVersionEnum.DSTU2) { + IFhirSystemDao systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class); + JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, + myAppCtx.getBean(DaoConfig.class)); + confProvider.setImplementationDescription("Example Server"); + setServerConformanceProvider(confProvider); + } else if (fhirVersion == FhirVersionEnum.DSTU2_1) { + IFhirSystemDao systemDao = myAppCtx + .getBean("mySystemDaoDstu21", IFhirSystemDao.class); + JpaConformanceProviderDstu21 confProvider = new JpaConformanceProviderDstu21(this, systemDao, + myAppCtx.getBean(DaoConfig.class)); + confProvider.setImplementationDescription("Example Server"); + setServerConformanceProvider(confProvider); + } else { + throw new IllegalStateException(); + } + + /* + * Enable ETag Support (this is already the default) + */ + setETagSupport(ETagSupportEnum.ENABLED); + + /* + * This server tries to dynamically generate narratives + */ + FhirContext ctx = getFhirContext(); + ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); + + /* + * Default to XML and pretty printing + */ + setDefaultPrettyPrint(true); + setDefaultResponseEncoding(EncodingEnum.JSON); + + /* + * This is a simple paging strategy that keeps the last 10 searches in memory + */ + setPagingProvider(new FifoMemoryPagingProvider(10)); + + /* + * Load interceptors for the server from Spring (these are defined in FhirServerConfig.java) + */ + Collection interceptorBeans = myAppCtx.getBeansOfType(IServerInterceptor.class).values(); + for (IServerInterceptor interceptor : interceptorBeans) { + this.registerInterceptor(interceptor); + } + + } + +} diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/resources/logback.xml b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/resources/logback.xml new file mode 100644 index 00000000000..ffec8d30c06 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + INFO + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} [%file:%line] %msg%n + + + + + + + + \ No newline at end of file diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/templates/about.html b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/templates/about.html new file mode 100644 index 00000000000..d552027e956 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/templates/about.html @@ -0,0 +1,67 @@ + + + + About This Server + + + +
+
+ +
+
+
+ +
+ +
+ +
+
+

About This Server

+
+
+
+ +
+

+ This server provides a nearly complete implementation of the FHIR Specification + using a 100% open source software stack. It is hosted by University Health Network. +

+

+ The architecture in use here is shown in the image on the right. This server is built + from a number of modules of the + HAPI FHIR + project, which is a 100% open-source (Apache 2.0 Licensed) Java based + implementation of the FHIR specification. +

+

+ +

+
+
+
+
+

Data On This Server

+
+
+

+ This server is regularly loaded with a standard set of test data sourced + from UHN's own testing environment. Do not use this server to store any data + that you will need later, as we will be regularly resetting it. +

+

+ This is not a production server and it provides no privacy. Do not store any + confidential data here. +

+
+
+ +
+
+
+ +
+
+ + diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/templates/tmpl-footer.html b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/templates/tmpl-footer.html new file mode 100644 index 00000000000..bf18c498a78 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/templates/tmpl-footer.html @@ -0,0 +1,16 @@ + + +
+ +
+ diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html new file mode 100644 index 00000000000..7a831600a0f --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html @@ -0,0 +1,8 @@ + + +
+

+ This server is deployed using HAPI-FHIR CLI (Command Line Interface). +

+
+ diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/web.xml b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..a77904866c6 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,112 @@ + + + + + + + + spring + org.springframework.web.servlet.DispatcherServlet + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + contextConfigLocation + ca.uhn.fhir.jpa.demo.FhirTesterConfig + + 2 + + + + + + spring + / + + + + + + + CORS Filter + org.ebaysf.web.cors.CORSFilter + + A comma separated list of allowed origins. Note: An '*' cannot be used for an allowed origin when using credentials. + cors.allowed.origins + * + + + A comma separated list of HTTP verbs, using which a CORS request can be made. + cors.allowed.methods + GET,POST,PUT,DELETE,OPTIONS + + + A comma separated list of allowed headers when making a non simple CORS request. + cors.allowed.headers + X-FHIR-Starter,Origin,Accept,X-Requested-With,Content-Type,Access-Control-Request-Method,Access-Control-Request-Headers + + + A comma separated list non-standard response headers that will be exposed to XHR2 object. + cors.exposed.headers + Location,Content-Location + + + A flag that suggests if CORS is supported with cookies + cors.support.credentials + true + + + A flag to control logging + cors.logging.enabled + true + + + Indicates how long (in seconds) the results of a preflight request can be cached in a preflight result cache. + cors.preflight.maxage + 300 + + + + CORS Filter + /* + + + + diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/javaee_6.xsd b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/javaee_6.xsd new file mode 100644 index 00000000000..9fb587749ce --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/javaee_6.xsd @@ -0,0 +1,2419 @@ + + + + + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + + Copyright 2003-2009 Sun Microsystems, Inc. All rights reserved. + + The contents of this file are subject to the terms of either the + GNU General Public License Version 2 only ("GPL") or the Common + Development and Distribution License("CDDL") (collectively, the + "License"). You may not use this file except in compliance with + the License. You can obtain a copy of the License at + https://glassfish.dev.java.net/public/CDDL+GPL.html or + glassfish/bootstrap/legal/LICENSE.txt. See the License for the + specific language governing permissions and limitations under the + License. + + When distributing the software, include this License Header + Notice in each file and include the License file at + glassfish/bootstrap/legal/LICENSE.txt. Sun designates this + particular file as subject to the "Classpath" exception as + provided by Sun in the GPL Version 2 section of the License file + that accompanied this code. If applicable, add the following + below the License Header, with the fields enclosed by brackets [] + replaced by your own identifying information: + "Portions Copyrighted [year] [name of copyright owner]" + + Contributor(s): + + If you wish your version of this file to be governed by only the + CDDL or only the GPL Version 2, indicate your decision by adding + "[Contributor] elects to include this software in this + distribution under the [CDDL or GPL Version 2] license." If you + don't indicate a single choice of license, a recipient has the + option to distribute your version of this file under either the + CDDL, the GPL Version 2 or to extend the choice of license to its + licensees as provided above. However, if you add GPL Version 2 + code and therefore, elected the GPL Version 2 license, then the + option applies only if the new code is made subject to such + option by the copyright holder. + + + + + + + + The following definitions that appear in the common + shareable schema(s) of Java EE deployment descriptors should be + interpreted with respect to the context they are included: + + Deployment Component may indicate one of the following: + java ee application; + application client; + web application; + enterprise bean; + resource adapter; + + Deployment File may indicate one of the following: + ear file; + war file; + jar file; + rar file; + + + + + + + + + + + This group keeps the usage of the contained description related + elements consistent across Java EE deployment descriptors. + + All elements may occur multiple times with different languages, + to support localization of the content. + + + + + + + + + + + + + + + This group keeps the usage of the contained JNDI environment + reference elements consistent across Java EE deployment descriptors. + + + + + + + + + + + + + + + + + + + + + + + This group collects elements that are common to most + JNDI resource elements. + + + + + + + + + + The JNDI name to be looked up to resolve a resource reference. + + + + + + + + + + + + This group collects elements that are common to all the + JNDI resource elements. It does not include the lookup-name + element, that is only applicable to some resource elements. + + + + + + + + + A product specific name that this resource should be + mapped to. The name of this resource, as defined by the + resource's name element or defaulted, is a name that is + local to the application component using the resource. + (It's a name in the JNDI java:comp/env namespace.) Many + application servers provide a way to map these local + names to names of resources known to the application + server. This mapped name is often a global JNDI name, + but may be a name of any form. + + Application servers are not required to support any + particular form or type of mapped name, nor the ability + to use mapped names. The mapped name is + product-dependent and often installation-dependent. No + use of a mapped name is portable. + + + + + + + + + + + + + + + + Configuration of a DataSource. + + + + + + + + + Description of this DataSource. + + + + + + + + + The name element specifies the JNDI name of the + data source being defined. + + + + + + + + + DataSource, XADataSource or ConnectionPoolDataSource + implementation class. + + + + + + + + + Database server name. + + + + + + + + + Port number where a server is listening for requests. + + + + + + + + + Name of a database on a server. + + + + + + + + url property is specified + along with other standard DataSource properties + such as serverName, databaseName + and portNumber, the more specific properties will + take precedence and url will be ignored. + + ]]> + + + + + + + + User name to use for connection authentication. + + + + + + + + + Password to use for connection authentication. + + + + + + + + + JDBC DataSource property. This may be a vendor-specific + property or a less commonly used DataSource property. + + + + + + + + + Sets the maximum time in seconds that this data source + will wait while attempting to connect to a database. + + + + + + + + + Set to false if connections should not participate in + transactions. + + + + + + + + + Isolation level for connections. + + + + + + + + + Number of connections that should be created when a + connection pool is initialized. + + + + + + + + + Maximum number of connections that should be concurrently + allocated for a connection pool. + + + + + + + + + Minimum number of connections that should be concurrently + allocated for a connection pool. + + + + + + + + + The number of seconds that a physical connection should + remain unused in the pool before the connection is + closed for a connection pool. + + + + + + + + + The total number of statements that a connection pool + should keep open. + + + + + + + + + + + + + + + + The description type is used by a description element to + provide text describing the parent element. The elements + that use this type should include any information that the + Deployment Component's Deployment File file producer wants + to provide to the consumer of the Deployment Component's + Deployment File (i.e., to the Deployer). Typically, the + tools used by such a Deployment File consumer will display + the description when processing the parent element that + contains the description. + + The lang attribute defines the language that the + description is provided in. The default value is "en" (English). + + + + + + + + + + + + + + + This type defines a dewey decimal that is used + to describe versions of documents. + + + + + + + + + + + + + + + + Employee Self Service + + + The value of the xml:lang attribute is "en" (English) by default. + + ]]> + + + + + + + + + + + + + + + + EmployeeRecord + + ../products/product.jar#ProductEJB + + ]]> + + + + + + + + + + + + + + + The ejb-local-refType is used by ejb-local-ref elements for + the declaration of a reference to an enterprise bean's local + home or to the local business interface of a 3.0 bean. + The declaration consists of: + + - an optional description + - the EJB reference name used in the code of the Deployment + Component that's referencing the enterprise bean. + - the optional expected type of the referenced enterprise bean + - the optional expected local interface of the referenced + enterprise bean or the local business interface of the + referenced enterprise bean. + - the optional expected local home interface of the referenced + enterprise bean. Not applicable if this ejb-local-ref refers + to the local business interface of a 3.0 bean. + - optional ejb-link information, used to specify the + referenced enterprise bean + - optional elements to define injection of the named enterprise + bean into a component field or property. + + + + + + + + + + + + + + + + + + + + + + ejb/Payroll + + ]]> + + + + + + + + + + + + + + + The ejb-refType is used by ejb-ref elements for the + declaration of a reference to an enterprise bean's home or + to the remote business interface of a 3.0 bean. + The declaration consists of: + + - an optional description + - the EJB reference name used in the code of + the Deployment Component that's referencing the enterprise + bean. + - the optional expected type of the referenced enterprise bean + - the optional remote interface of the referenced enterprise bean + or the remote business interface of the referenced enterprise + bean + - the optional expected home interface of the referenced + enterprise bean. Not applicable if this ejb-ref + refers to the remote business interface of a 3.0 bean. + - optional ejb-link information, used to specify the + referenced enterprise bean + - optional elements to define injection of the named enterprise + bean into a component field or property + + + + + + + + + + + + + + + + + + + + + + + The ejb-ref-typeType contains the expected type of the + referenced enterprise bean. + + The ejb-ref-type designates a value + that must be one of the following: + + Entity + Session + + + + + + + + + + + + + + + + + + + This type is used to designate an empty + element when used. + + + + + + + + + + + + + + The env-entryType is used to declare an application's + environment entry. The declaration consists of an optional + description, the name of the environment entry, a type + (optional if the value is injected, otherwise required), and + an optional value. + + It also includes optional elements to define injection of + the named resource into fields or JavaBeans properties. + + If a value is not specified and injection is requested, + no injection will occur and no entry of the specified name + will be created. This allows an initial value to be + specified in the source code without being incorrectly + changed when no override has been specified. + + If a value is not specified and no injection is requested, + a value must be supplied during deployment. + + This type is used by env-entry elements. + + + + + + + + + minAmount + + ]]> + + + + + + + java.lang.Integer + + ]]> + + + + + + + 100.00 + + ]]> + + + + + + + + + + + + + + + java.lang.Boolean + java.lang.Class + com.example.Color + + ]]> + + + + + + + + + + + + + + + The elements that use this type designate the name of a + Java class or interface. The name is in the form of a + "binary name", as defined in the JLS. This is the form + of name used in Class.forName(). Tools that need the + canonical name (the name used in source code) will need + to convert this binary name to the canonical name. + + + + + + + + + + + + + + + + This type defines four different values which can designate + boolean values. This includes values yes and no which are + not designated by xsd:boolean + + + + + + + + + + + + + + + + + + + + + The icon type contains small-icon and large-icon elements + that specify the file names for small and large GIF, JPEG, + or PNG icon images used to represent the parent element in a + GUI tool. + + The xml:lang attribute defines the language that the + icon file names are provided in. Its value is "en" (English) + by default. + + + + + + + + employee-service-icon16x16.jpg + + ]]> + + + + + + + employee-service-icon32x32.jpg + + ]]> + + + + + + + + + + + + + + + + An injection target specifies a class and a name within + that class into which a resource should be injected. + + The injection target class specifies the fully qualified + class name that is the target of the injection. The + Java EE specifications describe which classes can be an + injection target. + + The injection target name specifies the target within + the specified class. The target is first looked for as a + JavaBeans property name. If not found, the target is + looked for as a field name. + + The specified resource will be injected into the target + during initialization of the class by either calling the + set method for the target property or by setting a value + into the named field. + + + + + + + + + + + + + + The following transaction isolation levels are allowed + (see documentation for the java.sql.Connection interface): + TRANSACTION_READ_UNCOMMITTED + TRANSACTION_READ_COMMITTED + TRANSACTION_REPEATABLE_READ + TRANSACTION_SERIALIZABLE + + + + + + + + + + + + + + + + + + + The java-identifierType defines a Java identifier. + The users of this type should further verify that + the content does not contain Java reserved keywords. + + + + + + + + + + + + + + + + + + This is a generic type that designates a Java primitive + type or a fully qualified name of a Java interface/type, + or an array of such types. + + + + + + + + + + + + + + + + + : + + Example: + + jdbc:mysql://localhost:3307/testdb + + ]]> + + + + + + + + + + + + + + + + + The jndi-nameType type designates a JNDI name in the + Deployment Component's environment and is relative to the + java:comp/env context. A JNDI name must be unique within the + Deployment Component. + + + + + + + + + + + + + + + com.aardvark.payroll.PayrollHome + + ]]> + + + + + + + + + + + + + + + The lifecycle-callback type specifies a method on a + class to be called when a lifecycle event occurs. + Note that each class may have only one lifecycle callback + method for any given event and that the method may not + be overloaded. + + If the lifefycle-callback-class element is missing then + the class defining the callback is assumed to be the + component class in scope at the place in the descriptor + in which the callback definition appears. + + + + + + + + + + + + + + + + + The listenerType indicates the deployment properties for a web + application listener bean. + + + + + + + + + + The listener-class element declares a class in the + application must be registered as a web + application listener bean. The value is the fully + qualified classname of the listener class. + + + + + + + + + + + + + + + + The localType defines the fully-qualified name of an + enterprise bean's local interface. + + + + + + + + + + + + + + + + The local-homeType defines the fully-qualified + name of an enterprise bean's local home interface. + + + + + + + + + + + + + + + + This type is a general type that can be used to declare + parameter/value lists. + + + + + + + + + + The param-name element contains the name of a + parameter. + + + + + + + + + The param-value element contains the value of a + parameter. + + + + + + + + + + + + + + + + The elements that use this type designate either a relative + path or an absolute path starting with a "/". + + In elements that specify a pathname to a file within the + same Deployment File, relative filenames (i.e., those not + starting with "/") are considered relative to the root of + the Deployment File's namespace. Absolute filenames (i.e., + those starting with "/") also specify names in the root of + the Deployment File's namespace. In general, relative names + are preferred. The exception is .war files where absolute + names are preferred for consistency with the Servlet API. + + + + + + + + + + + + + + + + myPersistenceContext + + + + + myPersistenceContext + + PersistenceUnit1 + + Extended + + + ]]> + + + + + + + + + The persistence-context-ref-name element specifies + the name of a persistence context reference; its + value is the environment entry name used in + Deployment Component code. The name is a JNDI name + relative to the java:comp/env context. + + + + + + + + + The Application Assembler(or BeanProvider) may use the + following syntax to avoid the need to rename persistence + units to have unique names within a Java EE application. + + The Application Assembler specifies the pathname of the + root of the persistence.xml file for the referenced + persistence unit and appends the name of the persistence + unit separated from the pathname by #. The pathname is + relative to the referencing application component jar file. + In this manner, multiple persistence units with the same + persistence unit name may be uniquely identified when the + Application Assembler cannot change persistence unit names. + + + + + + + + + + Used to specify properties for the container or persistence + provider. Vendor-specific properties may be included in + the set of properties. Properties that are not recognized + by a vendor must be ignored. Entries that make use of the + namespace javax.persistence and its subnamespaces must not + be used for vendor-specific properties. The namespace + javax.persistence is reserved for use by the specification. + + + + + + + + + + + + + + + + + The persistence-context-typeType specifies the transactional + nature of a persistence context reference. + + The value of the persistence-context-type element must be + one of the following: + Transaction + Extended + + + + + + + + + + + + + + + + + + + Specifies a name/value pair. + + + + + + + + + + + + + + + + + + + + myPersistenceUnit + + + + + myPersistenceUnit + + PersistenceUnit1 + + + + ]]> + + + + + + + + + The persistence-unit-ref-name element specifies + the name of a persistence unit reference; its + value is the environment entry name used in + Deployment Component code. The name is a JNDI name + relative to the java:comp/env context. + + + + + + + + + The Application Assembler(or BeanProvider) may use the + following syntax to avoid the need to rename persistence + units to have unique names within a Java EE application. + + The Application Assembler specifies the pathname of the + root of the persistence.xml file for the referenced + persistence unit and appends the name of the persistence + unit separated from the pathname by #. The pathname is + relative to the referencing application component jar file. + In this manner, multiple persistence units with the same + persistence unit name may be uniquely identified when the + Application Assembler cannot change persistence unit names. + + + + + + + + + + + + + + + + com.wombat.empl.EmployeeService + + ]]> + + + + + + + + + + + + + + + jms/StockQueue + + javax.jms.Queue + + + + ]]> + + + + + + + + + The resource-env-ref-name element specifies the name + of a resource environment reference; its value is + the environment entry name used in + the Deployment Component code. The name is a JNDI + name relative to the java:comp/env context and must + be unique within a Deployment Component. + + + + + + + + + The resource-env-ref-type element specifies the type + of a resource environment reference. It is the + fully qualified name of a Java language class or + interface. + + + + + + + + + + + + + + + + + jdbc/EmployeeAppDB + javax.sql.DataSource + Container + Shareable + + + ]]> + + + + + + + + + The res-ref-name element specifies the name of a + resource manager connection factory reference. + The name is a JNDI name relative to the + java:comp/env context. + The name must be unique within a Deployment File. + + + + + + + + + The res-type element specifies the type of the data + source. The type is specified by the fully qualified + Java language class or interface + expected to be implemented by the data source. + + + + + + + + + + + + + + + + + + + The res-authType specifies whether the Deployment Component + code signs on programmatically to the resource manager, or + whether the Container will sign on to the resource manager + on behalf of the Deployment Component. In the latter case, + the Container uses information that is supplied by the + Deployer. + + The value must be one of the two following: + + Application + Container + + + + + + + + + + + + + + + + + + + The res-sharing-scope type specifies whether connections + obtained through the given resource manager connection + factory reference can be shared. The value, if specified, + must be one of the two following: + + Shareable + Unshareable + + The default value is Shareable. + + + + + + + + + + + + + + + + + + + The run-asType specifies the run-as identity to be + used for the execution of a component. It contains an + optional description, and the name of a security role. + + + + + + + + + + + + + + + + + + The role-nameType designates the name of a security role. + + The name must conform to the lexical rules for a token. + + + + + + + + + + + + + + + + + This role includes all employees who are authorized + to access the employee service application. + + employee + + + ]]> + + + + + + + + + + + + + + + + + The security-role-refType contains the declaration of a + security role reference in a component's or a + Deployment Component's code. The declaration consists of an + optional description, the security role name used in the + code, and an optional link to a security role. If the + security role is not specified, the Deployer must choose an + appropriate security role. + + + + + + + + + + The value of the role-name element must be the String used + as the parameter to the + EJBContext.isCallerInRole(String roleName) method or the + HttpServletRequest.isUserInRole(String role) method. + + + + + + + + + The role-link element is a reference to a defined + security role. The role-link element must contain + the name of one of the security roles defined in the + security-role elements. + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:QName. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:boolean. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:NMTOKEN. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:anyURI. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:integer. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:positiveInteger. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:nonNegativeInteger. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:string. + + + + + + + + + + + + + + + + + + This is a special string datatype that is defined by Java EE as + a base type for defining collapsed strings. When schemas + require trailing/leading space elimination as well as + collapsing the existing whitespace, this base type may be + used. + + + + + + + + + + + + + + + + + + This simple type designates a boolean with only two + permissible values + + - true + - false + + + + + + + + + + + + + + + + + + The url-patternType contains the url pattern of the mapping. + It must follow the rules specified in Section 11.2 of the + Servlet API Specification. This pattern is assumed to be in + URL-decoded form and must not contain CR(#xD) or LF(#xA). + If it contains those characters, the container must inform + the developer with a descriptive error message. + The container must preserve all characters including whitespaces. + + + + + + + + + + + + + + + + CorporateStocks + + + + ]]> + + + + + + + + + The message-destination-name element specifies a + name for a message destination. This name must be + unique among the names of message destinations + within the Deployment File. + + + + + + + + + A product specific name that this message destination + should be mapped to. Each message-destination-ref + element that references this message destination will + define a name in the namespace of the referencing + component or in one of the other predefined namespaces. + Many application servers provide a way to map these + local names to names of resources known to the + application server. This mapped name is often a global + JNDI name, but may be a name of any form. Each of the + local names should be mapped to this same global name. + + Application servers are not required to support any + particular form or type of mapped name, nor the ability + to use mapped names. The mapped name is + product-dependent and often installation-dependent. No + use of a mapped name is portable. + + + + + + + + + The JNDI name to be looked up to resolve the message destination. + + + + + + + + + + + + + + + + jms/StockQueue + + javax.jms.Queue + + Consumes + + CorporateStocks + + + + ]]> + + + + + + + + + The message-destination-ref-name element specifies + the name of a message destination reference; its + value is the environment entry name used in + Deployment Component code. + + + + + + + + + + + + + + + + + + + + The message-destination-usageType specifies the use of the + message destination indicated by the reference. The value + indicates whether messages are consumed from the message + destination, produced for the destination, or both. The + Assembler makes use of this information in linking producers + of a destination with its consumers. + + The value of the message-destination-usage element must be + one of the following: + Consumes + Produces + ConsumesProduces + + + + + + + + + + + + + + + + + + + javax.jms.Queue + + + ]]> + + + + + + + + + + + + + + + The message-destination-linkType is used to link a message + destination reference or message-driven bean to a message + destination. + + The Assembler sets the value to reflect the flow of messages + between producers and consumers in the application. + + The value must be the message-destination-name of a message + destination in the same Deployment File or in another + Deployment File in the same Java EE application unit. + + Alternatively, the value may be composed of a path name + specifying a Deployment File containing the referenced + message destination with the message-destination-name of the + destination appended and separated from the path name by + "#". The path name is relative to the Deployment File + containing Deployment Component that is referencing the + message destination. This allows multiple message + destinations with the same name to be uniquely identified. + + + + + + + + + diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/jsp_2_2.xsd b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/jsp_2_2.xsd new file mode 100644 index 00000000000..fa41e4266f1 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/jsp_2_2.xsd @@ -0,0 +1,389 @@ + + + + + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + + Copyright 2003-2009 Sun Microsystems, Inc. All rights reserved. + + The contents of this file are subject to the terms of either the + GNU General Public License Version 2 only ("GPL") or the Common + Development and Distribution License("CDDL") (collectively, the + "License"). You may not use this file except in compliance with + the License. You can obtain a copy of the License at + https://glassfish.dev.java.net/public/CDDL+GPL.html or + glassfish/bootstrap/legal/LICENSE.txt. See the License for the + specific language governing permissions and limitations under the + License. + + When distributing the software, include this License Header + Notice in each file and include the License file at + glassfish/bootstrap/legal/LICENSE.txt. Sun designates this + particular file as subject to the "Classpath" exception as + provided by Sun in the GPL Version 2 section of the License file + that accompanied this code. If applicable, add the following + below the License Header, with the fields enclosed by brackets [] + replaced by your own identifying information: + "Portions Copyrighted [year] [name of copyright owner]" + + Contributor(s): + + If you wish your version of this file to be governed by only the + CDDL or only the GPL Version 2, indicate your decision by adding + "[Contributor] elects to include this software in this + distribution under the [CDDL or GPL Version 2] license." If you + don't indicate a single choice of license, a recipient has the + option to distribute your version of this file under either the + CDDL, the GPL Version 2 or to extend the choice of license to its + licensees as provided above. However, if you add GPL Version 2 + code and therefore, elected the GPL Version 2 license, then the + option applies only if the new code is made subject to such + option by the copyright holder. + + + + + + + + This is the XML Schema for the JSP 2.2 deployment descriptor + types. The JSP 2.2 schema contains all the special + structures and datatypes that are necessary to use JSP files + from a web application. + + The contents of this schema is used by the web-common_3_0.xsd + file to define JSP specific content. + + + + + + + + The following conventions apply to all Java EE + deployment descriptor elements unless indicated otherwise. + + - In elements that specify a pathname to a file within the + same JAR file, relative filenames (i.e., those not + starting with "/") are considered relative to the root of + the JAR file's namespace. Absolute filenames (i.e., those + starting with "/") also specify names in the root of the + JAR file's namespace. In general, relative names are + preferred. The exception is .war files where absolute + names are preferred for consistency with the Servlet API. + + + + + + + + + + + + + + The jsp-configType is used to provide global configuration + information for the JSP files in a web application. It has + two subelements, taglib and jsp-property-group. + + + + + + + + + + + + + + + + + + The jsp-file element contains the full path to a JSP file + within the web application beginning with a `/'. + + + + + + + + + + + + + + + + The jsp-property-groupType is used to group a number of + files so they can be given global property information. + All files so described are deemed to be JSP files. The + following additional properties can be described: + + - Control whether EL is ignored. + - Control whether scripting elements are invalid. + - Indicate pageEncoding information. + - Indicate that a resource is a JSP document (XML). + - Prelude and Coda automatic includes. + - Control whether the character sequence #{ is allowed + when used as a String literal. + - Control whether template text containing only + whitespaces must be removed from the response output. + - Indicate the default contentType information. + - Indicate the default buffering model for JspWriter + - Control whether error should be raised for the use of + undeclared namespaces in a JSP page. + + + + + + + + + + + Can be used to easily set the isELIgnored + property of a group of JSP pages. By default, the + EL evaluation is enabled for Web Applications using + a Servlet 2.4 or greater web.xml, and disabled + otherwise. + + + + + + + + + The valid values of page-encoding are those of the + pageEncoding page directive. It is a + translation-time error to name different encodings + in the pageEncoding attribute of the page directive + of a JSP page and in a JSP configuration element + matching the page. It is also a translation-time + error to name different encodings in the prolog + or text declaration of a document in XML syntax and + in a JSP configuration element matching the document. + It is legal to name the same encoding through + mulitple mechanisms. + + + + + + + + + Can be used to easily disable scripting in a + group of JSP pages. By default, scripting is + enabled. + + + + + + + + + If true, denotes that the group of resources + that match the URL pattern are JSP documents, + and thus must be interpreted as XML documents. + If false, the resources are assumed to not + be JSP documents, unless there is another + property group that indicates otherwise. + + + + + + + + + The include-prelude element is a context-relative + path that must correspond to an element in the + Web Application. When the element is present, + the given path will be automatically included (as + in an include directive) at the beginning of each + JSP page in this jsp-property-group. + + + + + + + + + The include-coda element is a context-relative + path that must correspond to an element in the + Web Application. When the element is present, + the given path will be automatically included (as + in an include directive) at the end of each + JSP page in this jsp-property-group. + + + + + + + + + The character sequence #{ is reserved for EL expressions. + Consequently, a translation error occurs if the #{ + character sequence is used as a String literal, unless + this element is enabled (true). Disabled (false) by + default. + + + + + + + + + Indicates that template text containing only whitespaces + must be removed from the response output. It has no + effect on JSP documents (XML syntax). Disabled (false) + by default. + + + + + + + + + The valid values of default-content-type are those of the + contentType page directive. It specifies the default + response contentType if the page directive does not include + a contentType attribute. + + + + + + + + + The valid values of buffer are those of the + buffer page directive. It specifies if buffering should be + used for the output to response, and if so, the size of the + buffer to use. + + + + + + + + + The default behavior when a tag with unknown namespace is used + in a JSP page (regular syntax) is to silently ignore it. If + set to true, then an error must be raised during the translation + time when an undeclared tag is used in a JSP page. Disabled + (false) by default. + + + + + + + + + + + + + + + + The taglibType defines the syntax for declaring in + the deployment descriptor that a tag library is + available to the application. This can be done + to override implicit map entries from TLD files and + from the container. + + + + + + + + + A taglib-uri element describes a URI identifying a + tag library used in the web application. The body + of the taglib-uri element may be either an + absolute URI specification, or a relative URI. + There should be no entries in web.xml with the + same taglib-uri value. + + + + + + + + + the taglib-location element contains the location + (as a resource relative to the root of the web + application) where to find the Tag Library + Description file for the tag library. + + + + + + + + + diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/web-app_3_0.xsd b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/web-app_3_0.xsd new file mode 100644 index 00000000000..bbcdf43cd3a --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/web-app_3_0.xsd @@ -0,0 +1,272 @@ + + + + + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + + Copyright 2003-2009 Sun Microsystems, Inc. All rights reserved. + + The contents of this file are subject to the terms of either the + GNU General Public License Version 2 only ("GPL") or the Common + Development and Distribution License("CDDL") (collectively, the + "License"). You may not use this file except in compliance with + the License. You can obtain a copy of the License at + https://glassfish.dev.java.net/public/CDDL+GPL.html or + glassfish/bootstrap/legal/LICENSE.txt. See the License for the + specific language governing permissions and limitations under the + License. + + When distributing the software, include this License Header + Notice in each file and include the License file at + glassfish/bootstrap/legal/LICENSE.txt. Sun designates this + particular file as subject to the "Classpath" exception as + provided by Sun in the GPL Version 2 section of the License file + that accompanied this code. If applicable, add the following + below the License Header, with the fields enclosed by brackets [] + replaced by your own identifying information: + "Portions Copyrighted [year] [name of copyright owner]" + + Contributor(s): + + If you wish your version of this file to be governed by only the + CDDL or only the GPL Version 2, indicate your decision by adding + "[Contributor] elects to include this software in this + distribution under the [CDDL or GPL Version 2] license." If you + don't indicate a single choice of license, a recipient has the + option to distribute your version of this file under either the + CDDL, the GPL Version 2 or to extend the choice of license to its + licensees as provided above. However, if you add GPL Version 2 + code and therefore, elected the GPL Version 2 license, then the + option applies only if the new code is made subject to such + option by the copyright holder. + + + + + + + + ... + + + The instance documents may indicate the published version of + the schema using the xsi:schemaLocation attribute for Java EE + namespace with the following location: + + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd + + ]]> + + + + + + + The following conventions apply to all Java EE + deployment descriptor elements unless indicated otherwise. + + - In elements that specify a pathname to a file within the + same JAR file, relative filenames (i.e., those not + starting with "/") are considered relative to the root of + the JAR file's namespace. Absolute filenames (i.e., those + starting with "/") also specify names in the root of the + JAR file's namespace. In general, relative names are + preferred. The exception is .war files where absolute + names are preferred for consistency with the Servlet API. + + + + + + + + + + + + + + The web-app element is the root of the deployment + descriptor for a web application. Note that the sub-elements + of this element can be in the arbitrary order. Because of + that, the multiplicity of the elements of distributable, + session-config, welcome-file-list, jsp-config, login-config, + and locale-encoding-mapping-list was changed from "?" to "*" + in this schema. However, the deployment descriptor instance + file must not contain multiple elements of session-config, + jsp-config, and login-config. When there are multiple elements of + welcome-file-list or locale-encoding-mapping-list, the container + must concatenate the element contents. The multiple occurence + of the element distributable is redundant and the container + treats that case exactly in the same way when there is only + one distributable. + + + + + + + + The servlet element contains the name of a servlet. + The name must be unique within the web application. + + + + + + + + + + + The filter element contains the name of a filter. + The name must be unique within the web application. + + + + + + + + + + + The ejb-local-ref-name element contains the name of an EJB + reference. The EJB reference is an entry in the web + application's environment and is relative to the + java:comp/env context. The name must be unique within + the web application. + + It is recommended that name is prefixed with "ejb/". + + + + + + + + + + + The ejb-ref-name element contains the name of an EJB + reference. The EJB reference is an entry in the web + application's environment and is relative to the + java:comp/env context. The name must be unique within + the web application. + + It is recommended that name is prefixed with "ejb/". + + + + + + + + + + + The resource-env-ref-name element specifies the name of + a resource environment reference; its value is the + environment entry name used in the web application code. + The name is a JNDI name relative to the java:comp/env + context and must be unique within a web application. + + + + + + + + + + + The message-destination-ref-name element specifies the name of + a message destination reference; its value is the + environment entry name used in the web application code. + The name is a JNDI name relative to the java:comp/env + context and must be unique within a web application. + + + + + + + + + + + The res-ref-name element specifies the name of a + resource manager connection factory reference. The name + is a JNDI name relative to the java:comp/env context. + The name must be unique within a web application. + + + + + + + + + + + The env-entry-name element contains the name of a web + application's environment entry. The name is a JNDI + name relative to the java:comp/env context. The name + must be unique within a web application. + + + + + + + + + + + A role-name-key is specified to allow the references + from the security-role-refs. + + + + + + + + + + + The keyref indicates the references from + security-role-ref to a specified role-name. + + + + + + + + + diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/web-common_3_0.xsd b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/web-common_3_0.xsd new file mode 100644 index 00000000000..f994bc2c651 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/web-common_3_0.xsd @@ -0,0 +1,1575 @@ + + + + + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + + Copyright 2003-2009 Sun Microsystems, Inc. All rights reserved. + + The contents of this file are subject to the terms of either the + GNU General Public License Version 2 only ("GPL") or the Common + Development and Distribution License("CDDL") (collectively, the + "License"). You may not use this file except in compliance with + the License. You can obtain a copy of the License at + https://glassfish.dev.java.net/public/CDDL+GPL.html or + glassfish/bootstrap/legal/LICENSE.txt. See the License for the + specific language governing permissions and limitations under the + License. + + When distributing the software, include this License Header + Notice in each file and include the License file at + glassfish/bootstrap/legal/LICENSE.txt. Sun designates this + particular file as subject to the "Classpath" exception as + provided by Sun in the GPL Version 2 section of the License file + that accompanied this code. If applicable, add the following + below the License Header, with the fields enclosed by brackets [] + replaced by your own identifying information: + "Portions Copyrighted [year] [name of copyright owner]" + + Contributor(s): + + If you wish your version of this file to be governed by only the + CDDL or only the GPL Version 2, indicate your decision by adding + "[Contributor] elects to include this software in this + distribution under the [CDDL or GPL Version 2] license." If you + don't indicate a single choice of license, a recipient has the + option to distribute your version of this file under either the + CDDL, the GPL Version 2 or to extend the choice of license to its + licensees as provided above. However, if you add GPL Version 2 + code and therefore, elected the GPL Version 2 license, then the + option applies only if the new code is made subject to such + option by the copyright holder. + + + + + + + + ... + + + The instance documents may indicate the published version of + the schema using the xsi:schemaLocation attribute for Java EE + namespace with the following location: + + http://java.sun.com/xml/ns/javaee/web-common_3_0.xsd + + ]]> + + + + + + + The following conventions apply to all Java EE + deployment descriptor elements unless indicated otherwise. + + - In elements that specify a pathname to a file within the + same JAR file, relative filenames (i.e., those not + starting with "/") are considered relative to the root of + the JAR file's namespace. Absolute filenames (i.e., those + starting with "/") also specify names in the root of the + JAR file's namespace. In general, relative names are + preferred. The exception is .war files where absolute + names are preferred for consistency with the Servlet API. + + + + + + + + + + + + + + + + + The context-param element contains the declaration + of a web application's servlet context + initialization parameters. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The metadata-complete attribute defines whether this + deployment descriptor and other related deployment + descriptors for this module (e.g., web service + descriptors) are complete, or whether the class + files available to this module and packaged with + this application should be examined for annotations + that specify deployment information. + + If metadata-complete is set to "true", the deployment + tool must ignore any annotations that specify deployment + information, which might be present in the class files + of the application. + + If metadata-complete is not specified or is set to + "false", the deployment tool must examine the class + files of the application for annotations, as + specified by the specifications. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The auth-constraintType indicates the user roles that + should be permitted access to this resource + collection. The role-name used here must either correspond + to the role-name of one of the security-role elements + defined for this web application, or be the specially + reserved role-name "*" that is a compact syntax for + indicating all roles in the web application. If both "*" + and rolenames appear, the container interprets this as all + roles. If no roles are defined, no user is allowed access + to the portion of the web application described by the + containing security-constraint. The container matches + role names case sensitively when determining access. + + + + + + + + + + + + + + + + + + The auth-methodType is used to configure the authentication + mechanism for the web application. As a prerequisite to + gaining access to any web resources which are protected by + an authorization constraint, a user must have authenticated + using the configured mechanism. Legal values are "BASIC", + "DIGEST", "FORM", "CLIENT-CERT", or a vendor-specific + authentication scheme. + + Used in: login-config + + + + + + + + + + + + + + + + The dispatcher has five legal values: FORWARD, REQUEST, + INCLUDE, ASYNC, and ERROR. + + A value of FORWARD means the Filter will be applied under + RequestDispatcher.forward() calls. + A value of REQUEST means the Filter will be applied under + ordinary client calls to the path or servlet. + A value of INCLUDE means the Filter will be applied under + RequestDispatcher.include() calls. + A value of ASYNC means the Filter will be applied under + calls dispatched from an AsyncContext. + A value of ERROR means the Filter will be applied under the + error page mechanism. + + The absence of any dispatcher elements in a filter-mapping + indicates a default of applying filters only under ordinary + client calls to the path or servlet. + + + + + + + + + + + + + + + + + + + + + + The error-code contains an HTTP error code, ex: 404 + + Used in: error-page + + + + + + + + + + + + + + + + + + + The error-pageType contains a mapping between an error code + or exception type to the path of a resource in the web + application. + + Error-page declarations using the exception-type element in + the deployment descriptor must be unique up to the class name of + the exception-type. Similarly, error-page declarations using the + status-code element must be unique in the deployment descriptor + up to the status code. + + Used in: web-app + + + + + + + + + + + The exception-type contains a fully qualified class + name of a Java exception type. + + + + + + + + + + The location element contains the location of the + resource in the web application relative to the root of + the web application. The value of the location must have + a leading `/'. + + + + + + + + + + + + + + + + The filterType is used to declare a filter in the web + application. The filter is mapped to either a servlet or a + URL pattern in the filter-mapping element, using the + filter-name value to reference. Filters can access the + initialization parameters declared in the deployment + descriptor at runtime via the FilterConfig interface. + + Used in: web-app + + + + + + + + + + + The fully qualified classname of the filter. + + + + + + + + + + The init-param element contains a name/value pair as + an initialization param of a servlet filter + + + + + + + + + + + + + + + + Declaration of the filter mappings in this web + application is done by using filter-mappingType. + The container uses the filter-mapping + declarations to decide which filters to apply to a request, + and in what order. The container matches the request URI to + a Servlet in the normal way. To determine which filters to + apply it matches filter-mapping declarations either on + servlet-name, or on url-pattern for each filter-mapping + element, depending on which style is used. The order in + which filters are invoked is the order in which + filter-mapping declarations that match a request URI for a + servlet appear in the list of filter-mapping elements.The + filter-name value must be the value of the filter-name + sub-elements of one of the filter declarations in the + deployment descriptor. + + + + + + + + + + + + + + + + + + + + + + This type defines a string which contains at least one + character. + + + + + + + + + + + + + + + + + + The logical name of the filter is declare + by using filter-nameType. This name is used to map the + filter. Each filter name is unique within the web + application. + + Used in: filter, filter-mapping + + + + + + + + + + + + + + + + The form-login-configType specifies the login and error + pages that should be used in form based login. If form based + authentication is not used, these elements are ignored. + + Used in: login-config + + + + + + + + + The form-login-page element defines the location in the web + app where the page that can be used for login can be + found. The path begins with a leading / and is interpreted + relative to the root of the WAR. + + + + + + + + + The form-error-page element defines the location in + the web app where the error page that is displayed + when login is not successful can be found. + The path begins with a leading / and is interpreted + relative to the root of the WAR. + + + + + + + + + + + + + A HTTP method type as defined in HTTP 1.1 section 2.2. + + + + + + + + + + + + + + + + + + + + + + + + + + The login-configType is used to configure the authentication + method that should be used, the realm name that should be + used for this application, and the attributes that are + needed by the form login mechanism. + + Used in: web-app + + + + + + + + + + The realm name element specifies the realm name to + use in HTTP Basic authorization. + + + + + + + + + + + + + + + + + The mime-mappingType defines a mapping between an extension + and a mime type. + + Used in: web-app + + + + + + + + The extension element contains a string describing an + extension. example: "txt" + + + + + + + + + + + + + + + + + The mime-typeType is used to indicate a defined mime type. + + Example: + "text/plain" + + Used in: mime-mapping + + + + + + + + + + + + + + + + + + The security-constraintType is used to associate + security constraints with one or more web resource + collections + + Used in: web-app + + + + + + + + + + + + + + + + + + + + The servletType is used to declare a servlet. + It contains the declarative data of a + servlet. If a jsp-file is specified and the load-on-startup + element is present, then the JSP should be precompiled and + loaded. + + Used in: web-app + + + + + + + + + + + + The servlet-class element contains the fully + qualified class name of the servlet. + + + + + + + + + + + + The load-on-startup element indicates that this + servlet should be loaded (instantiated and have + its init() called) on the startup of the web + application. The optional contents of these + element must be an integer indicating the order in + which the servlet should be loaded. If the value + is a negative integer, or the element is not + present, the container is free to load the servlet + whenever it chooses. If the value is a positive + integer or 0, the container must load and + initialize the servlet as the application is + deployed. The container must guarantee that + servlets marked with lower integers are loaded + before servlets marked with higher integers. The + container may choose the order of loading of + servlets with the same load-on-start-up value. + + + + + + + + + + + + + + + + + + + + + The servlet-mappingType defines a mapping between a + servlet and a url pattern. + + Used in: web-app + + + + + + + + + + + + + + + + + + The servlet-name element contains the canonical name of the + servlet. Each servlet name is unique within the web + application. + + + + + + + + + + + + + + + + The session-configType defines the session parameters + for this web application. + + Used in: web-app + + + + + + + + + The session-timeout element defines the default + session timeout interval for all sessions created + in this web application. The specified timeout + must be expressed in a whole number of minutes. + If the timeout is 0 or less, the container ensures + the default behaviour of sessions is never to time + out. If this element is not specified, the container + must set its default timeout period. + + + + + + + + + The cookie-config element defines the configuration of the + session tracking cookies created by this web application. + + + + + + + + + The tracking-mode element defines the tracking modes + for sessions created by this web application + + + + + + + + + + + + + + + + The cookie-configType defines the configuration for the + session tracking cookies of this web application. + + Used in: session-config + + + + + + + + + The name that will be assigned to any session tracking + cookies created by this web application. + The default is JSESSIONID + + + + + + + + + The domain name that will be assigned to any session tracking + cookies created by this web application. + + + + + + + + + The path that will be assigned to any session tracking + cookies created by this web application. + + + + + + + + + The comment that will be assigned to any session tracking + cookies created by this web application. + + + + + + + + + Specifies whether any session tracking cookies created + by this web application will be marked as HttpOnly + + + + + + + + + Specifies whether any session tracking cookies created + by this web application will be marked as secure + even if the request that initiated the corresponding session + is using plain HTTP instead of HTTPS + + + + + + + + + The lifetime (in seconds) that will be assigned to any + session tracking cookies created by this web application. + Default is -1 + + + + + + + + + + + + + + + + The name that will be assigned to any session tracking + cookies created by this web application. + The default is JSESSIONID + + Used in: cookie-config + + + + + + + + + + + + + + + + The domain name that will be assigned to any session tracking + cookies created by this web application. + + Used in: cookie-config + + + + + + + + + + + + + + + + The path that will be assigned to any session tracking + cookies created by this web application. + + Used in: cookie-config + + + + + + + + + + + + + + + + The comment that will be assigned to any session tracking + cookies created by this web application. + + Used in: cookie-config + + + + + + + + + + + + + + + + The tracking modes for sessions created by this web + application + + Used in: session-config + + + + + + + + + + + + + + + + + + + + The transport-guaranteeType specifies that the communication + between client and server should be NONE, INTEGRAL, or + CONFIDENTIAL. NONE means that the application does not + require any transport guarantees. A value of INTEGRAL means + that the application requires that the data sent between the + client and server be sent in such a way that it can't be + changed in transit. CONFIDENTIAL means that the application + requires that the data be transmitted in a fashion that + prevents other entities from observing the contents of the + transmission. In most cases, the presence of the INTEGRAL or + CONFIDENTIAL flag will indicate that the use of SSL is + required. + + Used in: user-data-constraint + + + + + + + + + + + + + + + + + + + + The user-data-constraintType is used to indicate how + data communicated between the client and container should be + protected. + + Used in: security-constraint + + + + + + + + + + + + + + + + + + The elements that use this type designate a path starting + with a "/" and interpreted relative to the root of a WAR + file. + + + + + + + + + + + + + + + This type contains the recognized versions of + web-application supported. It is used to designate the + version of the web application. + + + + + + + + + + + + + + + + The web-resource-collectionType is used to identify the + resources and HTTP methods on those resources to which a + security constraint applies. If no HTTP methods are specified, + then the security constraint applies to all HTTP methods. + If HTTP methods are specified by http-method-omission + elements, the security constraint applies to all methods + except those identified in the collection. + http-method-omission and http-method elements are never + mixed in the same collection. + + Used in: security-constraint + + + + + + + + + The web-resource-name contains the name of this web + resource collection. + + + + + + + + + + + + Each http-method names an HTTP method to which the + constraint applies. + + + + + + + + + Each http-method-omission names an HTTP method to + which the constraint does not apply. + + + + + + + + + + + + + + + + + The welcome-file-list contains an ordered list of welcome + files elements. + + Used in: web-app + + + + + + + + + The welcome-file element contains file name to use + as a default welcome file, such as index.html + + + + + + + + + + + + + The localeType defines valid locale defined by ISO-639-1 + and ISO-3166. + + + + + + + + + + + + + The encodingType defines IANA character sets. + + + + + + + + + + + + + + + + The locale-encoding-mapping-list contains one or more + locale-encoding-mapping(s). + + + + + + + + + + + + + + + + + The locale-encoding-mapping contains locale name and + encoding name. The locale name must be either "Language-code", + such as "ja", defined by ISO-639 or "Language-code_Country-code", + such as "ja_JP". "Country code" is defined by ISO-3166. + + + + + + + + + + + + + + + + + + This element indicates that the ordering sub-element in which + it was placed should take special action regarding the ordering + of this application resource relative to other application + configuration resources. + See section 8.2.2 of the specification for details. + + + + + + + + + + + + + + Please see section 8.2.2 of the specification for details. + + + + + + + + + + + + + + + + + Please see section 8.2.2 of the specification for details. + + + + + + + + + + + + + + + + + This element contains a sequence of "name" elements, each of + which + refers to an application configuration resource by the "name" + declared on its web.xml fragment. This element can also contain + a single "others" element which specifies that this document + comes + before or after other documents within the application. + See section 8.2.2 of the specification for details. + + + + + + + + + + + + + + + + + This element specifies configuration information related to the + handling of multipart/form-data requests. + + + + + + + + + The directory location where uploaded files will be stored + + + + + + + + + The maximum size limit of uploaded files + + + + + + + + + The maximum size limit of multipart/form-data requests + + + + + + + + + The size threshold after which an uploaded file will be + written to disk + + + + + + + + diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/xml.xsd b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/xml.xsd new file mode 100644 index 00000000000..aea7d0db0a4 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/webapp/WEB-INF/xsd/xml.xsd @@ -0,0 +1,287 @@ + + + + + + +
+

About the XML namespace

+ +
+

+ This schema document describes the XML namespace, in a form + suitable for import by other schema documents. +

+

+ See + http://www.w3.org/XML/1998/namespace.html and + + http://www.w3.org/TR/REC-xml for information + about this namespace. +

+

+ Note that local names in this namespace are intended to be + defined only by the World Wide Web Consortium or its subgroups. + The names currently defined in this namespace are listed below. + They should not be used with conflicting semantics by any Working + Group, specification, or document instance. +

+

+ See further below in this document for more information about how to refer to this schema document from your own + XSD schema documents and about the + namespace-versioning policy governing this schema document. +

+
+
+
+
+ + + + +
+ +

lang (as an attribute name)

+

+ denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification.

+ +
+
+

Notes

+

+ Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. +

+

+ See BCP 47 at + http://www.rfc-editor.org/rfc/bcp/bcp47.txt + and the IANA language subtag registry at + + http://www.iana.org/assignments/language-subtag-registry + for further information. +

+

+ The union allows for the 'un-declaration' of xml:lang with + the empty string. +

+
+
+
+ + + + + + + + + +
+ + + + +
+ +

space (as an attribute name)

+

+ denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification.

+ +
+
+
+ + + + + + +
+ + + +
+ +

base (as an attribute name)

+

+ denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification.

+ +

+ See http://www.w3.org/TR/xmlbase/ + for information about this attribute. +

+
+
+
+
+ + + + +
+ +

id (as an attribute name)

+

+ denotes an attribute whose value + should be interpreted as if declared to be of type ID. + This name is reserved by virtue of its definition in the + xml:id specification.

+ +

+ See http://www.w3.org/TR/xml-id/ + for information about this attribute. +

+
+
+
+
+ + + + + + + + + + +
+ +

Father (in any context at all)

+ +
+

+ denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: +

+
+

+ In appreciation for his vision, leadership and + dedication the W3C XML Plenary on this 10th day of + February, 2000, reserves for Jon Bosak in perpetuity + the XML name "xml:Father". +

+
+
+
+
+
+ + + +
+

About this schema document

+ +
+

+ This schema defines attributes and an attribute group suitable + for use by schemas wishing to allow xml:base, + xml:lang, xml:space or + xml:id attributes on elements they define. +

+

+ To enable this, such a schema must import this schema for + the XML namespace, e.g. as follows: +

+
+          <schema . . .>
+           . . .
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+     
+

+ or +

+
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
+     
+

+ Subsequently, qualified reference to any of the attributes or the + group defined below will have the desired effect, e.g. +

+
+          <type . . .>
+           . . .
+           <attributeGroup ref="xml:specialAttrs"/>
+     
+

+ will define a type which will schema-validate an instance element + with any of those attributes. +

+
+
+
+
+ + + +
+

Versioning policy for this schema document

+
+

+ In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + + http://www.w3.org/2009/01/xml.xsd. +

+

+ At the date of issue it can also be found at + + http://www.w3.org/2001/xml.xsd. +

+

+ The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML + Schema itself, or with the XML namespace itself. In other words, + if the XML Schema or XML namespaces change, the version of this + document at + http://www.w3.org/2001/xml.xsd + + will change accordingly; the version at + + http://www.w3.org/2009/01/xml.xsd + + will not change. +

+

+ Previous dated (and unchanging) versions of this schema + document are at: +

+ +
+
+
+
+ +
+ diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/test/java/ca/uhn/fhir/jpa/demo/ExampleServerIT.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/test/java/ca/uhn/fhir/jpa/demo/ExampleServerIT.java new file mode 100644 index 00000000000..f4efde6ddd9 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/test/java/ca/uhn/fhir/jpa/demo/ExampleServerIT.java @@ -0,0 +1,81 @@ +package ca.uhn.fhir.jpa.demo; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.webapp.WebAppContext; +import org.hl7.fhir.instance.model.api.IIdType; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.model.dstu2.resource.Patient; +import ca.uhn.fhir.rest.client.IGenericClient; +import ca.uhn.fhir.rest.client.ServerValidationModeEnum; +import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; + +public class ExampleServerIT { + + private static IGenericClient ourClient; + private static final FhirContext ourCtx = FhirContext.forDstu2(); + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerIT.class); + + private static int ourPort; + + private static Server ourServer; + private static String ourServerBase; + + @Test + public void testCreateAndRead() throws IOException { + String methodName = "testCreateResourceConditional"; + + Patient pt = new Patient(); + pt.addName().addFamily(methodName); + IIdType id = ourClient.create().resource(pt).execute().getId(); + + Patient pt2 = ourClient.read().resource(Patient.class).withId(id).execute(); + assertEquals(methodName, pt2.getName().get(0).getFamily().get(0).getValue()); + } + + @AfterClass + public static void afterClass() throws Exception { + ourServer.stop(); + } + + @BeforeClass + public static void beforeClass() throws Exception { + /* + * This runs under maven, and I'm not sure how else to figure out the target directory from code.. + */ + String path = ExampleServerIT.class.getClassLoader().getResource(".keep_hapi-fhir-jpaserver-example").getPath(); + path = new File(path).getParent(); + path = new File(path).getParent(); + path = new File(path).getParent(); + + ourLog.info("Project base path is: {}", path); + + ourPort = RandomServerPortProvider.findFreePort(); + ourServer = new Server(ourPort); + + WebAppContext webAppContext = new WebAppContext(); + webAppContext.setContextPath("/"); + webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml"); + webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-example"); + webAppContext.setParentLoaderPriority(true); + + ourServer.setHandler(webAppContext); + ourServer.start(); + + ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); + ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000); + ourServerBase = "http://localhost:" + ourPort + "/baseDstu2"; + ourClient = ourCtx.newRestfulGenericClient(ourServerBase); + ourClient.registerInterceptor(new LoggingInterceptor(true)); + + } + +} diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/test/java/ca/uhn/fhir/jpa/demo/RandomServerPortProvider.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/test/java/ca/uhn/fhir/jpa/demo/RandomServerPortProvider.java new file mode 100644 index 00000000000..c8f4e49757d --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/test/java/ca/uhn/fhir/jpa/demo/RandomServerPortProvider.java @@ -0,0 +1,36 @@ +package ca.uhn.fhir.jpa.demo; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.ArrayList; +import java.util.List; + +/** + * Provides server ports + */ +public class RandomServerPortProvider { + + private static List ourPorts = new ArrayList(); + + public static int findFreePort() { + ServerSocket server; + try { + server = new ServerSocket(0); + int port = server.getLocalPort(); + ourPorts.add(port); + server.close(); + Thread.sleep(500); + return port; + } catch (IOException e) { + throw new Error(e); + } catch (InterruptedException e) { + throw new Error(e); + } + } + + public static List list() { + return ourPorts; + } + +} + \ No newline at end of file diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/test/resources/.keep_hapi-fhir-jpaserver-example b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/test/resources/.keep_hapi-fhir-jpaserver-example new file mode 100644 index 00000000000..e69de29bb2d diff --git a/hapi-fhir-cli/pom.xml b/hapi-fhir-cli/pom.xml index bd114964636..f8b9004cf97 100644 --- a/hapi-fhir-cli/pom.xml +++ b/hapi-fhir-cli/pom.xml @@ -1,8 +1,7 @@ - + 4.0.0 - ca.uhn.hapi.fhir hapi-fhir @@ -11,236 +10,13 @@ hapi-fhir-cli - jar - - HAPI FHIR - Command Line Client - - - - - - ca.uhn.hapi.fhir - hapi-fhir-base - 1.4-SNAPSHOT - - - ca.uhn.hapi.fhir - hapi-fhir-jpaserver-example - 1.4-SNAPSHOT - war - - - ca.uhn.hapi.fhir - hapi-fhir-structures-dstu - 1.4-SNAPSHOT - - - ca.uhn.hapi.fhir - hapi-fhir-structures-dstu2 - 1.4-SNAPSHOT - - - ca.uhn.hapi.fhir - hapi-fhir-structures-dstu2.1 - 1.4-SNAPSHOT - - - ca.uhn.hapi.fhir - hapi-fhir-structures-hl7org-dstu2 - 1.4-SNAPSHOT - - - ca.uhn.hapi.fhir - hapi-fhir-validation-resources-dstu2 - 1.4-SNAPSHOT - - - ca.uhn.hapi.fhir - hapi-fhir-validation-resources-dstu2.1 - 1.4-SNAPSHOT - - - - ch.qos.logback - logback-classic - - - javax.servlet - javax.servlet-api - - - - commons-cli - commons-cli - - - - org.springframework - spring-core - - - commons-logging - commons-logging - - - - - - org.eclipse.jetty - jetty-servlets - - - org.eclipse.jetty - jetty-servlet - - - org.eclipse.jetty - jetty-server - - - org.eclipse.jetty - jetty-util - - - org.eclipse.jetty - jetty-webapp - - - org.eclipse.jetty.websocket - websocket-api - - - org.eclipse.jetty.websocket - websocket-client - - - org.slf4j - jcl-over-slf4j - - - - org.thymeleaf - thymeleaf - - - - org.ebaysf.web - cors-filter - - - com.phloc - phloc-schematron - - - com.phloc - phloc-commons - - - - org.fusesource.jansi - jansi - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy - process-resources - - copy - - - - - ca.uhn.hapi.fhir - hapi-fhir-jpaserver-example - 1.4-SNAPSHOT - war - true - target/classes - hapi-fhir-jpaserver-example.war - - - - - - - - - org.apache.maven.plugins - maven-deploy-plugin - - true - - - - org.apache.maven.plugins - maven-shade-plugin - 2.4.1 - - - package - - shade - - - hapi-fhir-cli - - - - - ca.uhn.fhir.cli.App - - - - - * - - **/*.SF - **/*.RSA - - - - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-dependency-plugin - [2.10,) - - copy - - - - - - - - - - - - - + pom + HAPI FHIR - Command Line Client - Base Project + + + hapi-fhir-cli-jpaserver + hapi-fhir-cli-app + + diff --git a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/BaseCommand.java b/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/BaseCommand.java deleted file mode 100644 index 0ed9f849a9b..00000000000 --- a/hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/BaseCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -package ca.uhn.fhir.cli; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.rest.client.IGenericClient; - -public abstract class BaseCommand implements Comparable { - - private FhirContext myFhirCtx; - - public BaseCommand() { - super(); - } - - @Override - public int compareTo(BaseCommand theO) { - return getCommandName().compareTo(theO.getCommandName()); - } - - public abstract String getCommandDescription(); - - public abstract String getCommandName(); - - public abstract Options getOptions(); - - protected IGenericClient newClient(FhirContext ctx, String theBaseUrl) { - ctx.getRestfulClientFactory().setSocketTimeout(10 * 60 * 1000); - IGenericClient fhirClient = ctx.newRestfulGenericClient(theBaseUrl); - return fhirClient; - } - - public abstract void run(CommandLine theCommandLine) throws ParseException, Exception; - - public FhirContext getFhirCtx() { - if (myFhirCtx == null) { - myFhirCtx = FhirContext.forDstu2(); - } - return myFhirCtx; - } - -} \ No newline at end of file diff --git a/hapi-fhir-jpaserver-example/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu21.java b/hapi-fhir-jpaserver-example/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu21.java index 5d68f49df9e..0ba42d8f4cf 100644 --- a/hapi-fhir-jpaserver-example/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu21.java +++ b/hapi-fhir-jpaserver-example/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu21.java @@ -70,7 +70,6 @@ public class FhirServerConfigDstu21 extends BaseJavaConfigDstu21 { retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity"); retVal.setPersistenceProvider(new HibernatePersistenceProvider()); retVal.setJpaProperties(jpaProperties()); - retVal.afterPropertiesSet(); return retVal; } diff --git a/pom.xml b/pom.xml index 9daae5a0adf..751c6f8fbc4 100644 --- a/pom.xml +++ b/pom.xml @@ -45,20 +45,8 @@ - + junit junit @@ -245,7 +233,7 @@ 10.12.1.1 2.22.1 - 9.3.7.v20160115 + 9.3.7.v20160115 5.0.7.Final @@ -703,6 +691,11 @@ plexus-compiler-javac-errorprone 2.7 + + org.codehaus.plexus + plexus-utils + 3.0.22 + @@ -749,7 +742,7 @@ random -Dfile.encoding=UTF-8 -Xmx712m 1 - +