Package ca.uhn.fhir.parser

Examples of ca.uhn.fhir.parser.IParser


  }

  @Override
  protected Object parseRequestObject(Request theRequest) throws IOException {
    EncodingEnum encoding = RestfulServer.determineResponseEncoding(theRequest.getServletRequest());
    IParser parser = encoding.newParser(getContext());
    Bundle bundle = parser.parseBundle(theRequest.getServletRequest().getReader());
    return bundle;
  }
View Full Code Here


    public T invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException, BaseServerResponseException {
      EncodingEnum respType = EncodingEnum.forContentType(theResponseMimeType);
      if (respType == null) {
        throw NonFhirResponseException.newInstance(theResponseStatusCode, theResponseMimeType, theResponseReader);
      }
      IParser parser = respType.newParser(myContext);
      T retVal = parser.parseResource(myType, theResponseReader);
     
      if (myId != null) {
        retVal.setId(myId);
      }
     
View Full Code Here

    public TagList invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException, BaseServerResponseException {
      EncodingEnum respType = EncodingEnum.forContentType(theResponseMimeType);
      if (respType == null) {
        throw NonFhirResponseException.newInstance(theResponseStatusCode, theResponseMimeType, theResponseReader);
      }
      IParser parser = respType.newParser(myContext);
      return parser.parseTagList(theResponseReader);
    }
View Full Code Here

      ByteArrayEntity entity = new ByteArrayEntity(binary.getContent(), ContentType.parse(binary.getContentType()));
      HttpRequestBase retVal = createRequest(url, entity);
      return retVal;
    }

    IParser parser;
    String contentType;
    if (theEncoding == EncodingEnum.JSON) {
      parser = myContext.newJsonParser();
      contentType = Constants.CT_FHIR_JSON;
    } else {
      parser = myContext.newXmlParser();
      contentType = Constants.CT_FHIR_XML;
    }

    String contents;
    if (myTagList != null) {
      contents = parser.encodeTagListToString(myTagList);
    } else if (myBundle != null) {
      contents = parser.encodeBundleToString(myBundle);
    } else if (myResources != null) {
      Bundle bundle = RestfulServer.createBundleFromResourceList(myContext, "", myResources, "", "", myResources.size());
      contents = parser.encodeBundleToString(bundle);
    } else {
      contents = parser.encodeResourceToString(myResource);
    }

    StringEntity entity = new StringEntity(contents, ContentType.create(contentType, "UTF-8"));

    HttpRequestBase retVal = createRequest(url, entity);
View Full Code Here

      NonFhirResponseException ex = NonFhirResponseException.newInstance(theResponseStatusCode, theResponseMimeType, theResponseReader);
      populateException(ex, theResponseReader);
      throw ex;
    }

    IParser parser = encoding.newParser(getContext());
    return parser;
  }
View Full Code Here

    if (encoding == null) {
      throw new InvalidRequestException("Request contins non-FHIR conent-type header value: " + contentTypeHeader);
    }

    IParser parser = encoding.newParser(getContext());
    return parser;
  }
View Full Code Here

      break;
    case Constants.STATUS_HTTP_412_PRECONDITION_FAILED:
      ex = new ResourceVersionNotSpecifiedException("Server responded with HTTP 412");
      break;
    case Constants.STATUS_HTTP_422_UNPROCESSABLE_ENTITY:
      IParser parser = createAppropriateParserForParsingResponse(theResponseMimeType, theResponseReader, theStatusCode);
      OperationOutcome operationOutcome = parser.parseResource(OperationOutcome.class, theResponseReader);
      ex = new UnprocessableEntityException(operationOutcome);
      break;
    default:
      ex = new UnclassifiedServerFailureException(theStatusCode, "Server responded with HTTP " + theStatusCode);
      break;
View Full Code Here

    if (response != null && response.getOperationOutcome() != null) {
      EncodingEnum encoding = RestfulServer.determineResponseEncoding(theRequest.getServletRequest());
      theResponse.setContentType(encoding.getResourceContentType());
      Writer writer = theResponse.getWriter();
      IParser parser = encoding.newParser(getContext());
      parser.setPrettyPrint(RestfulServer.prettyPrintResponse(theRequest));
      try {
        parser.encodeResourceToWriter(response.getOperationOutcome(), writer);
      } finally {
        writer.close();
      }
    } else {
      theResponse.setContentType(Constants.CT_TEXT);
View Full Code Here

  /**
   * @throws IOException 
   */
  protected IResource parseIncomingServerResource(Request theRequest) throws IOException {
    EncodingEnum encoding = RestfulServer.determineRequestEncoding(theRequest);
    IParser parser = encoding.newParser(getContext());
    IResource resource = parser.parseResource(theRequest.getServletRequest().getReader());
    return resource;
  }
View Full Code Here

    theServer.addHeadersToResponse(theResponse);

    if (theE.getOperationOutcome() != null) {
      theResponse.setContentType(theEncoding.getResourceContentType());
      IParser parser = theEncoding.newParser(theServer.getFhirContext());
      parser.setPrettyPrint(RestfulServer.prettyPrintResponse(theRequest));
      Writer writer = theResponse.getWriter();
      try {
        parser.encodeResourceToWriter(theE.getOperationOutcome(), writer);
      } finally {
        writer.close();
      }
    } else {
      theResponse.setContentType(Constants.CT_TEXT);
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.parser.IParser

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.