|
|
@ -1,9 +1,6 @@
|
|
|
|
package ca.uhn.fhir.to;
|
|
|
|
package ca.uhn.fhir.to;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;
|
|
|
|
import static org.apache.commons.lang3.StringUtils.*;
|
|
|
|
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 java.io.ByteArrayInputStream;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
@ -94,8 +91,8 @@ public class Controller {
|
|
|
|
private TemplateEngine myTemplateEngine;
|
|
|
|
private TemplateEngine myTemplateEngine;
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = { "/about" })
|
|
|
|
@RequestMapping(value = { "/about" })
|
|
|
|
public String actionAbout(final HomeRequest theRequest, final ModelMap theModel) {
|
|
|
|
public String actionAbout(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
|
|
|
|
addCommonParams(theRequest, theModel);
|
|
|
|
addCommonParams(theServletRequest, theRequest, theModel);
|
|
|
|
|
|
|
|
|
|
|
|
theModel.put("notHome", true);
|
|
|
|
theModel.put("notHome", true);
|
|
|
|
theModel.put("extraBreadcrumb", "About");
|
|
|
|
theModel.put("extraBreadcrumb", "About");
|
|
|
@ -106,11 +103,11 @@ public class Controller {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = { "/conformance" })
|
|
|
|
@RequestMapping(value = { "/conformance" })
|
|
|
|
public String actionConformance(final HomeRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) {
|
|
|
|
public String actionConformance(HttpServletRequest theServletRequest, final HomeRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) {
|
|
|
|
addCommonParams(theRequest, theModel);
|
|
|
|
addCommonParams(theServletRequest, theRequest, theModel);
|
|
|
|
|
|
|
|
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
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;
|
|
|
|
ResultType returnsResource = ResultType.RESOURCE;
|
|
|
|
|
|
|
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
@ -137,10 +134,10 @@ public class Controller {
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@RequestMapping(value = { "/delete" })
|
|
|
|
@RequestMapping(value = { "/delete" })
|
|
|
|
public String actionDelete(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
|
|
|
public String actionDelete(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
|
|
|
addCommonParams(theRequest, theModel);
|
|
|
|
addCommonParams(theReq, theRequest, theModel);
|
|
|
|
|
|
|
|
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor);
|
|
|
|
GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor);
|
|
|
|
|
|
|
|
|
|
|
|
RuntimeResourceDefinition def;
|
|
|
|
RuntimeResourceDefinition def;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -175,10 +172,10 @@ public class Controller {
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = { "/get-tags" })
|
|
|
|
@RequestMapping(value = { "/get-tags" })
|
|
|
|
public String actionGetTags(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
|
|
|
public String actionGetTags(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
|
|
|
addCommonParams(theRequest, theModel);
|
|
|
|
addCommonParams(theReq, theRequest, theModel);
|
|
|
|
|
|
|
|
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor);
|
|
|
|
GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor);
|
|
|
|
|
|
|
|
|
|
|
|
Class<? extends IResource> resType = null;
|
|
|
|
Class<? extends IResource> resType = null;
|
|
|
|
ResultType returnsResource = ResultType.TAGLIST;
|
|
|
|
ResultType returnsResource = ResultType.TAGLIST;
|
|
|
@ -238,17 +235,17 @@ public class Controller {
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = { "/", "/home" })
|
|
|
|
@RequestMapping(value = { "/", "/home" })
|
|
|
|
public String actionHome(HttpServletRequest theServletRequest, final HomeRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) {
|
|
|
|
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());
|
|
|
|
ourLog.info(theServletRequest.toString());
|
|
|
|
return "home";
|
|
|
|
return "home";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = { "/page" })
|
|
|
|
@RequestMapping(value = { "/page" })
|
|
|
|
public String actionPage(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
|
|
|
public String actionPage(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
|
|
|
addCommonParams(theRequest, theModel);
|
|
|
|
addCommonParams(theReq, theRequest, theModel);
|
|
|
|
|
|
|
|
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
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"));
|
|
|
|
String url = defaultString(theReq.getParameter("page-url"));
|
|
|
|
if (!url.startsWith(theModel.get("base").toString())) {
|
|
|
|
if (!url.startsWith(theModel.get("base").toString())) {
|
|
|
@ -279,10 +276,10 @@ public class Controller {
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = { "/read" })
|
|
|
|
@RequestMapping(value = { "/read" })
|
|
|
|
public String actionRead(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
|
|
|
public String actionRead(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
|
|
|
addCommonParams(theRequest, theModel);
|
|
|
|
addCommonParams(theReq, theRequest, theModel);
|
|
|
|
|
|
|
|
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor);
|
|
|
|
GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor);
|
|
|
|
|
|
|
|
|
|
|
|
RuntimeResourceDefinition def;
|
|
|
|
RuntimeResourceDefinition def;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -323,11 +320,11 @@ public class Controller {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping({ "/resource" })
|
|
|
|
@RequestMapping({ "/resource" })
|
|
|
|
public String actionResource(final ResourceRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) {
|
|
|
|
public String actionResource(HttpServletRequest theServletRequest, final ResourceRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) {
|
|
|
|
IResource conformance = addCommonParams(theRequest, theModel);
|
|
|
|
IResource conformance = addCommonParams(theServletRequest, theRequest, theModel);
|
|
|
|
|
|
|
|
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
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();
|
|
|
|
String resourceName = theRequest.getResource();
|
|
|
|
RuntimeResourceDefinition def = getContext(theRequest).getResourceDefinition(theRequest.getResource());
|
|
|
|
RuntimeResourceDefinition def = getContext(theRequest).getResourceDefinition(theRequest.getResource());
|
|
|
@ -447,7 +444,7 @@ public class Controller {
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@RequestMapping(value = { "/search" })
|
|
|
|
@RequestMapping(value = { "/search" })
|
|
|
|
public String actionSearch(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
|
|
|
public String actionSearch(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) {
|
|
|
|
addCommonParams(theRequest, theModel);
|
|
|
|
addCommonParams(theReq, theRequest, theModel);
|
|
|
|
|
|
|
|
|
|
|
|
StringWriter clientCodeJsonStringWriter = new StringWriter();
|
|
|
|
StringWriter clientCodeJsonStringWriter = new StringWriter();
|
|
|
|
JsonGenerator clientCodeJsonWriter = Json.createGenerator(clientCodeJsonStringWriter);
|
|
|
|
JsonGenerator clientCodeJsonWriter = Json.createGenerator(clientCodeJsonStringWriter);
|
|
|
@ -456,7 +453,7 @@ public class Controller {
|
|
|
|
clientCodeJsonWriter.write("base", (String) theModel.get("base"));
|
|
|
|
clientCodeJsonWriter.write("base", (String) theModel.get("base"));
|
|
|
|
|
|
|
|
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
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();
|
|
|
|
IUntypedQuery search = client.search();
|
|
|
|
IQuery query;
|
|
|
|
IQuery query;
|
|
|
@ -548,11 +545,11 @@ public class Controller {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = { "/transaction" })
|
|
|
|
@RequestMapping(value = { "/transaction" })
|
|
|
|
public String actionTransaction(final TransactionRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) {
|
|
|
|
public String actionTransaction(HttpServletRequest theServletRequest, final TransactionRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) {
|
|
|
|
addCommonParams(theRequest, theModel);
|
|
|
|
addCommonParams(theServletRequest, theRequest, theModel);
|
|
|
|
|
|
|
|
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
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());
|
|
|
|
String body = preProcessMessageBody(theRequest.getTransactionBody());
|
|
|
|
|
|
|
|
|
|
|
@ -599,13 +596,13 @@ public class Controller {
|
|
|
|
return "result";
|
|
|
|
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()) {
|
|
|
|
if (myConfig.getDebugTemplatesMode()) {
|
|
|
|
myTemplateEngine.getCacheManager().clearAllCaches();
|
|
|
|
myTemplateEngine.getCacheManager().clearAllCaches();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final String serverId = theRequest.getServerIdWithDefault(myConfig);
|
|
|
|
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);
|
|
|
|
final String serverName = theRequest.getServerName(myConfig);
|
|
|
|
theModel.put("serverId", serverId);
|
|
|
|
theModel.put("serverId", serverId);
|
|
|
|
theModel.put("base", serverBase);
|
|
|
|
theModel.put("base", serverBase);
|
|
|
@ -615,7 +612,7 @@ public class Controller {
|
|
|
|
theModel.put("pretty", theRequest.getPretty());
|
|
|
|
theModel.put("pretty", theRequest.getPretty());
|
|
|
|
theModel.put("serverEntries", myConfig.getIdToServerName());
|
|
|
|
theModel.put("serverEntries", myConfig.getIdToServerName());
|
|
|
|
|
|
|
|
|
|
|
|
return loadAndAddConf(theRequest, theModel);
|
|
|
|
return loadAndAddConf(theServletRequest, theRequest, theModel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Header[] applyHeaderFilters(Header[] theAllHeaders) {
|
|
|
|
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) {
|
|
|
|
private void doActionCreateOrValidate(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel, String theMethod) {
|
|
|
|
boolean validate = "validate".equals(theMethod);
|
|
|
|
boolean validate = "validate".equals(theMethod);
|
|
|
|
|
|
|
|
|
|
|
|
addCommonParams(theRequest, theModel);
|
|
|
|
addCommonParams(theReq, theRequest, theModel);
|
|
|
|
|
|
|
|
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor);
|
|
|
|
GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor);
|
|
|
|
|
|
|
|
|
|
|
|
Class<? extends IResource> type = null; // def.getImplementingClass();
|
|
|
|
Class<? extends IResource> type = null; // def.getImplementingClass();
|
|
|
|
if ("history-type".equals(theMethod)) {
|
|
|
|
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) {
|
|
|
|
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();
|
|
|
|
CaptureInterceptor interceptor = new CaptureInterceptor();
|
|
|
|
GenericClient client = theRequest.newClient(getContext(theRequest), myConfig, interceptor);
|
|
|
|
GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor);
|
|
|
|
|
|
|
|
|
|
|
|
String id = null;
|
|
|
|
String id = null;
|
|
|
|
Class<? extends IResource> type = null; // def.getImplementingClass();
|
|
|
|
Class<? extends IResource> type = null; // def.getImplementingClass();
|
|
|
@ -1009,20 +1006,20 @@ public class Controller {
|
|
|
|
return true;
|
|
|
|
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)) {
|
|
|
|
switch (theRequest.getFhirVersion(myConfig)) {
|
|
|
|
case DEV:
|
|
|
|
case DEV:
|
|
|
|
return loadAndAddConfDev(theRequest, theModel);
|
|
|
|
return loadAndAddConfDev(theServletRequest, theRequest, theModel);
|
|
|
|
case DSTU1:
|
|
|
|
case DSTU1:
|
|
|
|
return loadAndAddConfDstu1(theRequest, theModel);
|
|
|
|
return loadAndAddConfDstu1(theServletRequest, theRequest, theModel);
|
|
|
|
case DSTU2:
|
|
|
|
case DSTU2:
|
|
|
|
return loadAndAddConfDev(theRequest, theModel);
|
|
|
|
return loadAndAddConfDev(theServletRequest, theRequest, theModel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("Unknown version: " + theRequest.getFhirVersion(myConfig));
|
|
|
|
throw new IllegalStateException("Unknown version: " + theRequest.getFhirVersion(myConfig));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Conformance loadAndAddConfDstu1(final HomeRequest theRequest, final ModelMap theModel) {
|
|
|
|
private Conformance loadAndAddConfDstu1(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
|
|
|
|
IGenericClient client = getContext(theRequest).newRestfulGenericClient(theRequest.getServerBase(myConfig));
|
|
|
|
IGenericClient client = getContext(theRequest).newRestfulGenericClient(theRequest.getServerBase(theServletRequest, myConfig));
|
|
|
|
|
|
|
|
|
|
|
|
Conformance conformance;
|
|
|
|
Conformance conformance;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -1080,8 +1077,8 @@ public class Controller {
|
|
|
|
return conformance;
|
|
|
|
return conformance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private IResource loadAndAddConfDev(final HomeRequest theRequest, final ModelMap theModel) {
|
|
|
|
private IResource loadAndAddConfDev(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
|
|
|
|
IGenericClient client = getContext(theRequest).newRestfulGenericClient(theRequest.getServerBase(myConfig));
|
|
|
|
IGenericClient client = getContext(theRequest).newRestfulGenericClient(theRequest.getServerBase(theServletRequest, myConfig));
|
|
|
|
|
|
|
|
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.Conformance conformance;
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.Conformance conformance;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|