ourLog.info("Request Url: {}", requestUrl);
ourLog.info("Context Path: {}", servletContextPath);
servletPath = servletContextPath;
IdDt id = null;
IdDt versionId = null;
String operation = null;
String requestPath = requestFullPath.substring(servletPath.length());
if (requestPath.length() > 0 && requestPath.charAt(0) == '/') {
requestPath = requestPath.substring(1);
}
int contextIndex;
if (servletPath.length() == 0) {
contextIndex = requestUrl.indexOf(requestPath);
} else {
contextIndex = requestUrl.indexOf(servletPath);
}
String fhirServerBase = requestUrl.substring(0, contextIndex + servletPath.length());
if (fhirServerBase.endsWith("/")) {
fhirServerBase = fhirServerBase.substring(0, fhirServerBase.length() - 1);
}
String completeUrl = StringUtils.isNotBlank(request.getQueryString()) ? requestUrl + "?" + request.getQueryString() : requestUrl.toString();
Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());
StringTokenizer tok = new StringTokenizer(requestPath, "/");
if (!tok.hasMoreTokens()) {
throw new MethodNotFoundException("No resource name specified");
}
resourceName = tok.nextToken();
ResourceBinding resourceBinding = null;
BaseMethodBinding resourceMethod = null;
if ("metadata".equals(resourceName)) {
resourceMethod = myServerConformanceMethod;
} else {
resourceBinding = myResourceNameToProvider.get(resourceName);
if (resourceBinding == null) {
throw new MethodNotFoundException("Unknown resource type '" + resourceName + "' - Server knows how to handle: " + myResourceNameToProvider.keySet());
}
}
if (tok.hasMoreTokens()) {
String nextString = tok.nextToken();
if (nextString.startsWith("_")) {
operation = nextString;
} else {
id = new IdDt(nextString);
}
}
if (tok.hasMoreTokens()) {
String nextString = tok.nextToken();
if (nextString.startsWith("_")) {
if (operation != null) {
throw new InvalidRequestException("URL Path contains two operations (part beginning with _): " + requestPath);
}
operation = nextString;
}
}
if (tok.hasMoreTokens()) {
String nextString = tok.nextToken();
versionId = new IdDt(nextString);
}
// TODO: look for more tokens for version, compartments, etc...
Request r = new Request();