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();
Object provider=null;
ResourceBinding resourceBinding=null;
BaseMethodBinding resourceMethod=null;
if ("metadata".equals(resourceName)) {
provider = myServerConformanceProvider;
if (provider==null) {
throw new ResourceNotFoundException("This server does not support 'metadata' query");
}
resourceMethod = myServerConformanceMethod;
} else {
resourceBinding = myResourceNameToProvider.get(resourceName);
if (resourceBinding == null) {
throw new MethodNotFoundException("Unknown resource type '" + resourceName+"' - Server knows how to handle: "+myResourceNameToProvider.keySet());
}
provider = resourceBinding.getResourceProvider();
}
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();
r.setResourceName(resourceName);
r.setId(id);
r.setVersion(versionId);
r.setOperation(operation);
r.setParameters(params);
r.setRequestType(requestType);
r.setResourceProvider(provider);
r.setInputReader(request.getReader());
r.setFhirServerBase(fhirServerBase);
r.setCompleteUrl(completeUrl);
r.setServletRequest(request);
if (resourceMethod == null && resourceBinding != null) {
resourceMethod = resourceBinding.getMethod(r);
}
if (null == resourceMethod) {
throw new MethodNotFoundException("No resource method available for the supplied parameters " + params);
}
resourceMethod.invokeServer(this, r, response);
} catch (AuthenticationException e) {