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

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


      }
      return retVal;
    case Constants.STATUS_HTTP_400_BAD_REQUEST:
      throw new InvalidRequestException("Server responded with: " + IOUtils.toString(theResponseReader));
    case Constants.STATUS_HTTP_404_NOT_FOUND:
      throw new ResourceNotFoundException("Server responded with: " + IOUtils.toString(theResponseReader));
    case Constants.STATUS_HTTP_405_METHOD_NOT_ALLOWED:
      throw new MethodNotAllowedException("Server responded with: " + IOUtils.toString(theResponseReader));
    case Constants.STATUS_HTTP_409_CONFLICT:
      throw new ResourceVersionConflictException("Server responded with: " + IOUtils.toString(theResponseReader));
    case Constants.STATUS_HTTP_412_PRECONDITION_FAILED:
View Full Code Here


    case BUNDLE:
      streamResponseAsBundle(theServer, theResponse, result, responseEncoding, theRequest.getFhirServerBase(), theRequest.getCompleteUrl(), prettyPrint, requestIsBrowser, narrativeMode);
      break;
    case RESOURCE:
      if (result.size() == 0) {
        throw new ResourceNotFoundException(theRequest.getId());
      } else if (result.size() > 1) {
        throw new InternalErrorException("Method returned multiple resources");
      }
      streamResponseAsResource(theServer, theResponse, result.get(0), responseEncoding, prettyPrint, requestIsBrowser, narrativeMode);
      break;
View Full Code Here

    switch (theStatusCode) {
    case Constants.STATUS_HTTP_400_BAD_REQUEST:
      ex = new InvalidRequestException("Server responded with HTTP 400");
      break;
    case Constants.STATUS_HTTP_404_NOT_FOUND:
      ex = new ResourceNotFoundException("Server responded with HTTP 404");
      break;
    case Constants.STATUS_HTTP_405_METHOD_NOT_ALLOWED:
      ex = new MethodNotAllowedException("Server responded with HTTP 405");
      break;
    case Constants.STATUS_HTTP_409_CONFLICT:
View Full Code Here

    case BUNDLE:
      RestfulServer.streamResponseAsBundle(theServer, theResponse, result, responseEncoding, theRequest.getFhirServerBase(), theRequest.getCompleteUrl(), prettyPrint, requestIsBrowser, narrativeMode, 0, count, null, respondGzip);
      break;
    case RESOURCE:
      if (result.size() == 0) {
        throw new ResourceNotFoundException(theRequest.getId());
      } else if (result.size() > 1) {
        throw new InternalErrorException("Method returned multiple resources");
      }
      RestfulServer.streamResponseAsResource(theServer, theResponse, result.getResources(0, 1).get(0), responseEncoding, prettyPrint, requestIsBrowser, narrativeMode, respondGzip);
      break;
View Full Code Here

    switch (theStatusCode) {
    case Constants.STATUS_HTTP_400_BAD_REQUEST:
      ex = new InvalidRequestException("Server responded with HTTP 400");
      break;
    case Constants.STATUS_HTTP_404_NOT_FOUND:
      ex = new ResourceNotFoundException("Server responded with HTTP 404");
      break;
    case Constants.STATUS_HTTP_405_METHOD_NOT_ALLOWED:
      ex = new MethodNotAllowedException("Server responded with HTTP 405");
      break;
    case Constants.STATUS_HTTP_409_CONFLICT:
View Full Code Here

      RestfulServer.streamResponseAsBundle(theServer, response, bundle, responseEncoding, theRequest.getFhirServerBase(), prettyPrint, narrativeMode, respondGzip);
      break;
    case RESOURCE:
      if (result.size() == 0) {
        throw new ResourceNotFoundException(theRequest.getId());
      } else if (result.size() > 1) {
        throw new InternalErrorException("Method returned multiple resources");
      }

      IResource resource = result.getResources(0, 1).get(0);
View Full Code Here

      Map<String, String[]> params = new HashMap<String, String[]>(theRequest.getParameterMap());

      StringTokenizer tok = new StringTokenizer(requestPath, "/");
      if (!tok.hasMoreTokens()) {
        throw new ResourceNotFoundException("No resource name specified");
      }
      resourceName = tok.nextToken();
      if (resourceName.startsWith("_")) {
        operation = resourceName;
        resourceName = null;
      }

      ResourceBinding resourceBinding = null;
      BaseMethodBinding resourceMethod = null;
      if ("metadata".equals(resourceName)) {
        resourceMethod = myServerConformanceMethod;
      } else if (resourceName == null) {
        resourceBinding = myNullResourceBinding;
      } else {
        resourceBinding = myResourceNameToProvider.get(resourceName);
        if (resourceBinding == null) {
          throw new ResourceNotFoundException("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.equals(Constants.PARAM_HISTORY)) {
          if (tok.hasMoreTokens()) {
            String versionString = tok.nextToken();
            versionId = new IdDt(versionString);
          } else {
            operation = Constants.PARAM_HISTORY;
          }
        } else if (nextString.startsWith("_")) {
          if (operation != null) {
            throw new InvalidRequestException("URL Path contains two operations (part beginning with _): " + requestPath);
          }
          operation = nextString;
        }
      }

      // Secondary is for things like ..../_tags/_delete
      String secondaryOperation=null;
     
      while (tok.hasMoreTokens()) {
        String nextString = tok.nextToken();
        if (operation == null) {
          operation = nextString;
        }else if (secondaryOperation==null) {
          secondaryOperation=nextString;
        }else {
          throw new InvalidRequestException("URL path has unexpected token '"+nextString + "' at the end: " + requestPath);
        }
      }

      if (theRequestType == RequestType.PUT && versionId == null) {
        String contentLocation = theRequest.getHeader("Content-Location");
        if (contentLocation != null) {
          int idx = contentLocation.indexOf("/_history/");
          if (idx != -1) {
            String versionIdString = contentLocation.substring(idx + "/_history/".length());
            versionId = new IdDt(versionIdString);
          }
        }
      }

      // 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.setSecondaryOperation(secondaryOperation);
      r.setParameters(params);
      r.setRequestType(theRequestType);
      if ("application/x-www-form-urlencoded".equals(theRequest.getContentType())) {
        r.setInputReader(new StringReader(""));
      } else {
        r.setInputReader(theRequest.getReader());
      }
      r.setFhirServerBase(fhirServerBase);
      r.setCompleteUrl(completeUrl);
      r.setServletRequest(theRequest);
      r.setServletResponse(theResponse);

      if (resourceMethod == null && resourceBinding != null) {
        resourceMethod = resourceBinding.getMethod(r);
      }
      if (null == resourceMethod) {
        throw new ResourceNotFoundException("No resource method available for the supplied parameters " + params);
      }

      resourceMethod.invokeServer(this, r, theResponse);

    } catch (AuthenticationException e) {
View Full Code Here

    switch (theStatusCode) {
    case Constants.STATUS_HTTP_400_BAD_REQUEST:
      ex = new InvalidRequestException("Server responded with HTTP 400");
      break;
    case Constants.STATUS_HTTP_404_NOT_FOUND:
      ex = new ResourceNotFoundException("Server responded with HTTP 404");
      break;
    case Constants.STATUS_HTTP_405_METHOD_NOT_ALLOWED:
      ex = new MethodNotAllowedException("Server responded with HTTP 405");
      break;
    case Constants.STATUS_HTTP_409_CONFLICT:
View Full Code Here

    case BUNDLE:
      streamResponseAsBundle(theServer, theResponse, result, responseEncoding, theRequest.getFhirServerBase(), theRequest.getCompleteUrl(), prettyPrint, requestIsBrowser, narrativeMode);
      break;
    case RESOURCE:
      if (result.size() == 0) {
        throw new ResourceNotFoundException(theRequest.getId());
      } else if (result.size() > 1) {
        throw new InternalErrorException("Method returned multiple resources");
      }
      streamResponseAsResource(theServer, theResponse, result.get(0), responseEncoding, prettyPrint, requestIsBrowser, narrativeMode);
      break;
View Full Code Here

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

TOP

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

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.