Package ca.uhn.fhir.rest.server.exceptions

Examples of ca.uhn.fhir.rest.server.exceptions.MethodNotFoundException


      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();
      r.setResourceName(resourceName);
      r.setId(id);
      r.setVersion(versionId);
      r.setOperation(operation);
      r.setParameters(params);
      r.setRequestType(requestType);
      if ("application/x-www-form-urlencoded".equals(request.getContentType())) {
        r.setInputReader(new StringReader(""));
      } else {
        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) {
View Full Code Here


      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) {
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.rest.server.exceptions.MethodNotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.