Package ca.uhn.fhir.model.dstu.resource

Examples of ca.uhn.fhir.model.dstu.resource.Binary


    if (theIsSubElementWithinResource && theResource.getId() != null && isNotBlank(theResource.getId().getValue())) {
      theEventWriter.write("id", theResource.getId().getValue());
    }

    if (theResource instanceof Binary) {
      Binary bin = (Binary) theResource;
      theEventWriter.write("contentType", bin.getContentType());
      theEventWriter.write("content",bin.getContentAsBase64());
    } else {
      extractAndWriteExtensionsAsDirectChild(theResource, theEventWriter, resDef, theResDef, theResource);
      encodeCompositeElementToStreamWriter(theResDef, theResource, theResource, theEventWriter, resDef);
    }
    theEventWriter.writeEnd();
View Full Code Here


  }

  @Override
  public Object invokeClient(String theResponseMimeType, InputStream theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException, BaseServerResponseException {
    byte[] contents = IOUtils.toByteArray(theResponseReader);
    Binary resource = new Binary(theResponseMimeType, contents);

    switch (getMethodReturnType()) {
    case BUNDLE:
      return Bundle.withSingleResource(resource);
    case LIST_OF_RESOURCES:
View Full Code Here

  private static void streamResponseAsResource(RestfulServer theServer, HttpServletResponse theHttpResponse, IResource theResource, EncodingEnum theResponseEncoding, boolean thePrettyPrint,
      boolean theRequestIsBrowser, NarrativeModeEnum theNarrativeMode, int stausCode, boolean theRespondGzip) throws IOException {
    theHttpResponse.setStatus(stausCode);

    if (theResource instanceof Binary) {
      Binary bin = (Binary) theResource;
      if (isNotBlank(bin.getContentType())) {
        theHttpResponse.setContentType(bin.getContentType());
      } else {
        theHttpResponse.setContentType(Constants.CT_OCTET_STREAM);
      }
      if (bin.getContent() == null || bin.getContent().length == 0) {
        return;
      }
      theHttpResponse.setContentLength(bin.getContent().length);
      ServletOutputStream oos = theHttpResponse.getOutputStream();
      oos.write(bin.getContent());
      oos.close();
      return;
    }

    if (theRequestIsBrowser && theServer.isUseBrowserFriendlyContentTypes()) {
View Full Code Here

    appendExtraParamsWithQuestionMark(theExtraParams, b, b.indexOf("?") == -1);
    String url = b.toString();

    if (myResource != null && Binary.class.isAssignableFrom(myResource.getClass())) {
      Binary binary = (Binary) myResource;
      ByteArrayEntity entity = new ByteArrayEntity(binary.getContent(), ContentType.parse(binary.getContentType()));
      HttpRequestBase retVal = createRequest(url, entity);
      return retVal;
    }

    IParser parser;
View Full Code Here

  @Override
  protected IResource parseIncomingServerResource(Request theRequest) throws IOException {
    if (myBinary) {
      String ct = theRequest.getServletRequest().getHeader(Constants.HEADER_CONTENT_TYPE);
      byte[] contents = IOUtils.toByteArray(theRequest.getServletRequest().getInputStream());
      return new Binary(ct, contents);
    }else {
      return super.parseIncomingServerResource(theRequest);
    }
  }
View Full Code Here

    if (theIncludedResource && StringUtils.isNotBlank(theResource.getId().getValue())) {
      theEventWriter.writeAttribute("id", theResource.getId().getValue());
    }

    if (theResource instanceof Binary) {
      Binary bin = (Binary) theResource;
      theEventWriter.writeAttribute("contentType", bin.getContentType());
      theEventWriter.writeCharacters(bin.getContentAsBase64());
    } else {
      encodeCompositeElementToStreamWriter(resDef, theResource, theResource, theEventWriter, resDef, theIncludedResource);
    }

    theEventWriter.writeEndElement();
View Full Code Here

    if (theIncludedResource && StringUtils.isNotBlank(theResource.getId().getValue())) {
      theEventWriter.writeAttribute("id", theResource.getId().getValue());
    }

    if (theResource instanceof Binary) {
      Binary bin = (Binary) theResource;
      theEventWriter.writeAttribute("contentType", bin.getContentType());
      theEventWriter.writeCharacters(bin.getContentAsBase64());
    } else {
      encodeCompositeElementToStreamWriter(resDef, theResource, theResource, theEventWriter, resDef, theIncludedResource);
    }

    theEventWriter.writeEndElement();
View Full Code Here

    if (theIsSubElementWithinResource && theResource.getId() != null && isNotBlank(theResource.getId().getValue())) {
      theEventWriter.write("id", theResource.getId().getValue());
    }

    if (theResource instanceof Binary) {
      Binary bin = (Binary) theResource;
      theEventWriter.write("contentType", bin.getContentType());
      theEventWriter.write("content", bin.getContentAsBase64());
    } else {
      encodeCompositeElementToStreamWriter(theResDef, theResource, theResource, theEventWriter, resDef);
    }
    theEventWriter.writeEnd();
  }
View Full Code Here

  @Override
  public Object invokeClient(String theResponseMimeType, InputStream theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException,
      BaseServerResponseException {
    byte[] contents = IOUtils.toByteArray(theResponseReader);
    Binary resource = new Binary(theResponseMimeType, contents);

    switch (getMethodReturnType()) {
    case BUNDLE:
      return Bundle.withSingleResource(resource);
    case LIST_OF_RESOURCES:
View Full Code Here

        addProfileToBundleEntry(theServer.getFhirContext(), theResource);
      }
    }

    if (theResource instanceof Binary) {
      Binary bin = (Binary) theResource;
      if (isNotBlank(bin.getContentType())) {
        theHttpResponse.setContentType(bin.getContentType());
      } else {
        theHttpResponse.setContentType(Constants.CT_OCTET_STREAM);
      }
      if (bin.getContent() == null || bin.getContent().length == 0) {
        return;
      }

      theHttpResponse.addHeader(Constants.HEADER_CONTENT_DISPOSITION, "Attachment;");

      theHttpResponse.setContentLength(bin.getContent().length);
      ServletOutputStream oos = theHttpResponse.getOutputStream();
      oos.write(bin.getContent());
      oos.close();
      return;
    }

    if (theRequestIsBrowser && theServer.isUseBrowserFriendlyContentTypes()) {
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.model.dstu.resource.Binary

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.