diff --git a/hapi-fhir-jpaserver-example/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml b/hapi-fhir-jpaserver-example/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml index fff367b7587..9f240eb7e40 100644 --- a/hapi-fhir-jpaserver-example/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml +++ b/hapi-fhir-jpaserver-example/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml @@ -12,7 +12,7 @@ - home , DSTU2 , Local Server , http://localhost:8080/hapi-fhir-jpaserver-example/base + home , DSTU2 , Local Server , ${serverBase}/base diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/web.xml b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/web.xml index 4d31ed984ca..501f23b7404 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/web.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/web.xml @@ -12,7 +12,7 @@ /WEB-INF/hapi-fhir-server-database-config.xml /WEB-INF/hapi-fhir-server-config.xml classpath:hapi-fhir-server-resourceproviders-dstu1.xml - classpath:hapi-fhir-server-resourceproviders-dev.xml + classpath:hapi-fhir-server-resourceproviders-dstu2.xml /WEB-INF/hapi-fhir-tester-application-context.xml /WEB-INF/hapi-fhir-tester-config.xml diff --git a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java index e5e4d29c046..fabc1701bc6 100644 --- a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java +++ b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java @@ -1,9 +1,6 @@ package ca.uhn.fhir.to; -import static org.apache.commons.lang3.StringUtils.defaultIfEmpty; -import static org.apache.commons.lang3.StringUtils.defaultString; -import static org.apache.commons.lang3.StringUtils.isBlank; -import static org.apache.commons.lang3.StringUtils.isNotBlank; +import static org.apache.commons.lang3.StringUtils.*; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -94,8 +91,8 @@ public class Controller { private TemplateEngine myTemplateEngine; @RequestMapping(value = { "/about" }) - public String actionAbout(final HomeRequest theRequest, final ModelMap theModel) { - addCommonParams(theRequest, theModel); + public String actionAbout(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) { + addCommonParams(theServletRequest, theRequest, theModel); theModel.put("notHome", true); theModel.put("extraBreadcrumb", "About"); @@ -106,11 +103,11 @@ public class Controller { } @RequestMapping(value = { "/conformance" }) - public String actionConformance(final HomeRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) { - addCommonParams(theRequest, theModel); + public String actionConformance(HttpServletRequest theServletRequest, final HomeRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) { + addCommonParams(theServletRequest, theRequest, theModel); CaptureInterceptor interceptor = new CaptureInterceptor(); - GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor); + GenericClient client = theRequest.newClient(theServletRequest, getContext(theRequest), myConfig, interceptor); ResultType returnsResource = ResultType.RESOURCE; long start = System.currentTimeMillis(); @@ -137,10 +134,10 @@ public class Controller { @SuppressWarnings("unchecked") @RequestMapping(value = { "/delete" }) public String actionDelete(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) { - addCommonParams(theRequest, theModel); + addCommonParams(theReq, theRequest, theModel); CaptureInterceptor interceptor = new CaptureInterceptor(); - GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor); + GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor); RuntimeResourceDefinition def; try { @@ -175,10 +172,10 @@ public class Controller { @RequestMapping(value = { "/get-tags" }) public String actionGetTags(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) { - addCommonParams(theRequest, theModel); + addCommonParams(theReq, theRequest, theModel); CaptureInterceptor interceptor = new CaptureInterceptor(); - GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor); + GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor); Class resType = null; ResultType returnsResource = ResultType.TAGLIST; @@ -238,17 +235,17 @@ public class Controller { @RequestMapping(value = { "/", "/home" }) public String actionHome(HttpServletRequest theServletRequest, final HomeRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) { - addCommonParams(theRequest, theModel); + addCommonParams(theServletRequest, theRequest, theModel); ourLog.info(theServletRequest.toString()); return "home"; } @RequestMapping(value = { "/page" }) public String actionPage(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) { - addCommonParams(theRequest, theModel); + addCommonParams(theReq, theRequest, theModel); CaptureInterceptor interceptor = new CaptureInterceptor(); - GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor); + GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor); String url = defaultString(theReq.getParameter("page-url")); if (!url.startsWith(theModel.get("base").toString())) { @@ -279,10 +276,10 @@ public class Controller { @RequestMapping(value = { "/read" }) public String actionRead(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) { - addCommonParams(theRequest, theModel); + addCommonParams(theReq, theRequest, theModel); CaptureInterceptor interceptor = new CaptureInterceptor(); - GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor); + GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor); RuntimeResourceDefinition def; try { @@ -323,11 +320,11 @@ public class Controller { } @RequestMapping({ "/resource" }) - public String actionResource(final ResourceRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) { - IResource conformance = addCommonParams(theRequest, theModel); + public String actionResource(HttpServletRequest theServletRequest, final ResourceRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) { + IResource conformance = addCommonParams(theServletRequest, theRequest, theModel); CaptureInterceptor interceptor = new CaptureInterceptor(); - GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor); + GenericClient client = theRequest.newClient(null, getContext(theRequest), myConfig, interceptor); String resourceName = theRequest.getResource(); RuntimeResourceDefinition def = getContext(theRequest).getResourceDefinition(theRequest.getResource()); @@ -447,7 +444,7 @@ public class Controller { @SuppressWarnings("unchecked") @RequestMapping(value = { "/search" }) public String actionSearch(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) { - addCommonParams(theRequest, theModel); + addCommonParams(theReq, theRequest, theModel); StringWriter clientCodeJsonStringWriter = new StringWriter(); JsonGenerator clientCodeJsonWriter = Json.createGenerator(clientCodeJsonStringWriter); @@ -456,7 +453,7 @@ public class Controller { clientCodeJsonWriter.write("base", (String) theModel.get("base")); CaptureInterceptor interceptor = new CaptureInterceptor(); - GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor); + GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor); IUntypedQuery search = client.search(); IQuery query; @@ -548,11 +545,11 @@ public class Controller { } @RequestMapping(value = { "/transaction" }) - public String actionTransaction(final TransactionRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) { - addCommonParams(theRequest, theModel); + public String actionTransaction(HttpServletRequest theServletRequest, final TransactionRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) { + addCommonParams(theServletRequest, theRequest, theModel); CaptureInterceptor interceptor = new CaptureInterceptor(); - GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor); + GenericClient client = theRequest.newClient(theServletRequest, getContext(theRequest), myConfig, interceptor); String body = preProcessMessageBody(theRequest.getTransactionBody()); @@ -599,13 +596,13 @@ public class Controller { return "result"; } - private IResource addCommonParams(final HomeRequest theRequest, final ModelMap theModel) { + private IResource addCommonParams(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) { if (myConfig.getDebugTemplatesMode()) { myTemplateEngine.getCacheManager().clearAllCaches(); } final String serverId = theRequest.getServerIdWithDefault(myConfig); - final String serverBase = theRequest.getServerBase(myConfig); + final String serverBase = theRequest.getServerBase(theServletRequest, myConfig); final String serverName = theRequest.getServerName(myConfig); theModel.put("serverId", serverId); theModel.put("base", serverBase); @@ -615,7 +612,7 @@ public class Controller { theModel.put("pretty", theRequest.getPretty()); theModel.put("serverEntries", myConfig.getIdToServerName()); - return loadAndAddConf(theRequest, theModel); + return loadAndAddConf(theServletRequest, theRequest, theModel); } private Header[] applyHeaderFilters(Header[] theAllHeaders) { @@ -634,10 +631,10 @@ public class Controller { private void doActionCreateOrValidate(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel, String theMethod) { boolean validate = "validate".equals(theMethod); - addCommonParams(theRequest, theModel); + addCommonParams(theReq, theRequest, theModel); CaptureInterceptor interceptor = new CaptureInterceptor(); - GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor); + GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor); Class type = null; // def.getImplementingClass(); if ("history-type".equals(theMethod)) { @@ -716,10 +713,10 @@ public class Controller { } private void doActionHistory(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel, String theMethod, String theMethodDescription) { - addCommonParams(theRequest, theModel); + addCommonParams(theReq, theRequest, theModel); CaptureInterceptor interceptor = new CaptureInterceptor(); - GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor); + GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor); String id = null; Class type = null; // def.getImplementingClass(); @@ -1009,20 +1006,20 @@ public class Controller { return true; } - private IResource loadAndAddConf(final HomeRequest theRequest, final ModelMap theModel) { + private IResource loadAndAddConf(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) { switch (theRequest.getFhirVersion(myConfig)) { case DEV: - return loadAndAddConfDev(theRequest, theModel); + return loadAndAddConfDev(theServletRequest, theRequest, theModel); case DSTU1: - return loadAndAddConfDstu1(theRequest, theModel); + return loadAndAddConfDstu1(theServletRequest, theRequest, theModel); case DSTU2: - return loadAndAddConfDev(theRequest, theModel); + return loadAndAddConfDev(theServletRequest, theRequest, theModel); } throw new IllegalStateException("Unknown version: " + theRequest.getFhirVersion(myConfig)); } - private Conformance loadAndAddConfDstu1(final HomeRequest theRequest, final ModelMap theModel) { - IGenericClient client = getContext(theRequest).newRestfulGenericClient(theRequest.getServerBase(myConfig)); + private Conformance loadAndAddConfDstu1(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) { + IGenericClient client = getContext(theRequest).newRestfulGenericClient(theRequest.getServerBase(theServletRequest, myConfig)); Conformance conformance; try { @@ -1080,8 +1077,8 @@ public class Controller { return conformance; } - private IResource loadAndAddConfDev(final HomeRequest theRequest, final ModelMap theModel) { - IGenericClient client = getContext(theRequest).newRestfulGenericClient(theRequest.getServerBase(myConfig)); + private IResource loadAndAddConfDev(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) { + IGenericClient client = getContext(theRequest).newRestfulGenericClient(theRequest.getServerBase(theServletRequest, myConfig)); ca.uhn.fhir.model.dstu2.resource.Conformance conformance; try { diff --git a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/model/HomeRequest.java b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/model/HomeRequest.java index e1d2115b37c..7eb47c70d2c 100644 --- a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/model/HomeRequest.java +++ b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/model/HomeRequest.java @@ -1,7 +1,8 @@ package ca.uhn.fhir.to.model; -import static org.apache.commons.lang3.StringUtils.isBlank; -import static org.apache.commons.lang3.StringUtils.isNotBlank; +import static org.apache.commons.lang3.StringUtils.*; + +import javax.servlet.http.HttpServletRequest; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpRequestBase; @@ -38,12 +39,23 @@ public class HomeRequest { return myResource; } - public String getServerBase(TesterConfig theConfig) { + public String getServerBase(HttpServletRequest theRequest, TesterConfig theConfig) { + String retVal; if (isBlank(myServerId) && !theConfig.getIdToServerBase().containsKey(myServerId)) { - return theConfig.getIdToServerBase().entrySet().iterator().next().getValue(); + retVal = theConfig.getIdToServerBase().entrySet().iterator().next().getValue(); } else { - return theConfig.getIdToServerBase().get(myServerId); + retVal = theConfig.getIdToServerBase().get(myServerId); } + + if (retVal.contains("${serverBase}")) { + String base = theRequest.getRequestURL().toString(); + if (base.endsWith("/")) { + base = base.substring(0, base.length() - 1); + } + retVal = retVal.replace("${serverBase}", base); + } + + return retVal; } @ModelAttribute("serverId") @@ -91,32 +103,32 @@ public class HomeRequest { myServerId = theServerId; } - public GenericClient newClient(FhirContext theContext, TesterConfig theConfig, Controller.CaptureInterceptor theInterceptor) { - GenericClient retVal = (GenericClient) theContext.newRestfulGenericClient(getServerBase(theConfig)); + public GenericClient newClient(HttpServletRequest theRequest, FhirContext theContext, TesterConfig theConfig, Controller.CaptureInterceptor theInterceptor) { + GenericClient retVal = (GenericClient) theContext.newRestfulGenericClient(getServerBase(theRequest, theConfig)); retVal.setKeepResponses(true); - + if ("true".equals(getPretty())) { retVal.setPrettyPrint(true); } else if ("false".equals(getPretty())) { retVal.setPrettyPrint(false); } - + if ("xml".equals(getEncoding())) { - retVal.setEncoding( EncodingEnum.XML); + retVal.setEncoding(EncodingEnum.XML); } else if ("json".equals(getEncoding())) { - retVal.setEncoding( EncodingEnum.JSON); - } + retVal.setEncoding(EncodingEnum.JSON); + } retVal.registerInterceptor(theInterceptor); - + final String remoteAddr = org.slf4j.MDC.get("req.remoteAddr"); retVal.registerInterceptor(new IClientInterceptor() { - + @Override public void interceptResponse(HttpResponse theRequest) { // nothing } - + @Override public void interceptRequest(HttpRequestBase theRequest) { if (isNotBlank(remoteAddr)) { @@ -124,17 +136,15 @@ public class HomeRequest { } } }); - - + return retVal; } - + public IParser newParser(FhirContext theCtx) { if ("json".equals(getEncoding())) { return theCtx.newJsonParser(); - } + } return theCtx.newXmlParser(); } - } diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile index d5a0500040c..76780e7b999 100644 --- a/vagrant/Vagrantfile +++ b/vagrant/Vagrantfile @@ -84,7 +84,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| base_version: 7, proxy_port: 80, # ssl_port: 443, - authbind: 'yes' + authbind: 'yes', + java_options: '-Dfhir.logdir=/var/log/fhir -Dfhir.db.location=/var/fhirdb' }, mysql: { version: '5.6', @@ -107,6 +108,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| FileUtils.cp(f, 'build') end + config.vm.provision 'shell', inline: 'mkdir /var/log/fhir' + config.vm.provision 'shell', inline: 'chmod 777 /var/log/fhir' + config.vm.provision 'shell', inline: 'mkdir /var/fhirdb' + config.vm.provision 'shell', inline: 'chmod 777 /var/fhirdb' + # puts "Deploying any/all built .war files."" config.vm.provision 'shell', inline: 'cp /build/*.war /var/lib/tomcat7/webapps' diff --git a/vagrant/chef/cookbooks/tomcat/CHANGELOG.md b/vagrant/chef/cookbooks/tomcat/CHANGELOG.md index 3f3a872c52f..ee2c98739ca 100644 --- a/vagrant/chef/cookbooks/tomcat/CHANGELOG.md +++ b/vagrant/chef/cookbooks/tomcat/CHANGELOG.md @@ -43,7 +43,6 @@ v0.15.4 (2014-02-18) ### Bug - **[COOK-4257](https://tickets.opscode.com/browse/COOK-4257)** - tomcat: broken on SmartOS SmartMachine images 13.3.0+ -- **[COOK-4097](https://tickets.opscode.com/browse/COOK-4097)** - default["tomcat"]["keytool"] is set to non-existent file on Debian/Ubuntu v0.15.2