Tabnine Logo
RestfulServerUtils$ResponseEncoding
Code IndexAdd Tabnine to your IDE (free)

How to use
RestfulServerUtils$ResponseEncoding
in
ca.uhn.fhir.rest.server

Best Java code snippets using ca.uhn.fhir.rest.server.RestfulServerUtils$ResponseEncoding (Showing top 20 results out of 315)

origin: jamesagnew/hapi-fhir

EncodingEnum linkEncoding = theRequest.getParameters().containsKey(Constants.PARAM_FORMAT) && responseEncoding != null ? responseEncoding.getEncoding() : null;
origin: jamesagnew/hapi-fhir

EncodingEnum retVal = EncodingEnum.forContentType(nextFormat);
if (retVal != null) {
  return new ResponseEncoding(theReq.getServer().getFhirContext(), retVal, nextFormat);
    if (q > bestQ || (q == bestQ && encoding.getEncoding() == thePrefer)) {
origin: jamesagnew/hapi-fhir

if (contentType.equals(responseEncoding.getContentType())) {
  returnRawResponse(theRequestDetails, theServletResponse, contentType, data);
  return false;
origin: ca.uhn.hapi.fhir/hapi-fhir-server

  responseEncoding = new ResponseEncoding(theServer.getFhirContext(), theServer.getDefaultResponseEncoding(), null);
  contentType = Constants.CT_HTML;
} else {
  contentType = responseEncoding.getResourceContentType();
origin: ca.uhn.hapi.fhir/hapi-fhir-server

EncodingEnum linkEncoding = theRequest.getParameters().containsKey(Constants.PARAM_FORMAT) && responseEncoding != null ? responseEncoding.getEncoding() : null;
origin: ca.uhn.hapi.fhir/hapi-fhir-server

ResponseEncoding encoding = RestfulServerUtils.determineResponseEncodingNoDefault(myRequestDetails, myRequestDetails.getServer().getDefaultResponseEncoding());
if (encoding != null) {
  return encoding.getEncoding().name();
origin: ca.uhn.hapi.fhir/hapi-fhir-server

EncodingEnum retVal = EncodingEnum.forContentType(nextFormat);
if (retVal != null) {
  return new ResponseEncoding(theReq.getServer().getFhirContext(), retVal, nextFormat);
    if (q > bestQ || (q == bestQ && encoding.getEncoding() == thePrefer)) {
origin: ca.uhn.hapi.fhir/hapi-fhir-server

encodingEnum = responseEncoding.getEncoding();
origin: ca.uhn.hapi.fhir/hapi-fhir-server

if (contentType.equals(responseEncoding.getContentType())) {
  returnRawResponse(theRequestDetails, theServletResponse, contentType, data);
  return false;
origin: ca.uhn.hapi.fhir/hapi-fhir-server

private static ResponseEncoding determineRequestEncodingNoDefaultReturnRE(RequestDetails theReq) {
  ResponseEncoding retVal = null;
  List<String> headers = theReq.getHeaders(Constants.HEADER_CONTENT_TYPE);
  if (headers != null) {
    Iterator<String> acceptValues = headers.iterator();
    if (acceptValues != null) {
      while (acceptValues.hasNext() && retVal == null) {
        String nextAcceptHeaderValue = acceptValues.next();
        if (nextAcceptHeaderValue != null && isNotBlank(nextAcceptHeaderValue)) {
          for (String nextPart : nextAcceptHeaderValue.split(",")) {
            int scIdx = nextPart.indexOf(';');
            if (scIdx == 0) {
              continue;
            }
            if (scIdx != -1) {
              nextPart = nextPart.substring(0, scIdx);
            }
            nextPart = nextPart.trim();
            EncodingEnum encoding = EncodingEnum.forContentType(nextPart);
            if (encoding != null) {
              retVal = new ResponseEncoding(theReq.getServer().getFhirContext(), encoding, nextPart);
              break;
            }
          }
        }
      }
    }
  }
  return retVal;
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

private void streamResponseHeaders(RequestDetails theRequestDetails, HttpServletResponse theServletResponse, StringBuilder b) {
  if (theServletResponse.getHeaderNames().isEmpty() == false) {
    b.append("<h1>Response Headers</h1>");
    b.append("<div class=\"headersDiv\">");
    for (String nextHeaderName : theServletResponse.getHeaderNames()) {
      for (String nextHeaderValue : theServletResponse.getHeaders(nextHeaderName)) {
        /*
         * Let's pretend we're returning a FHIR content type even though we're
         * actually returning an HTML one
         */
        if (nextHeaderName.equalsIgnoreCase(Constants.HEADER_CONTENT_TYPE)) {
          ResponseEncoding responseEncoding = RestfulServerUtils.determineResponseEncodingNoDefault(theRequestDetails, theRequestDetails.getServer().getDefaultResponseEncoding());
          if (responseEncoding != null && isNotBlank(responseEncoding.getResourceContentType())) {
            nextHeaderValue = responseEncoding.getResourceContentType() + ";charset=utf-8";
          }
        }
        b.append("<div class=\"headersRow\">");
        b.append("<span class=\"headerName\">").append(nextHeaderName).append(": ").append("</span>");
        b.append("<span class=\"headerValue\">").append(nextHeaderValue).append("</span>");
        b.append("</div>");
      }
    }
    b.append("</div>");
  }
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

public Object returnResponse(ServletRequestDetails theRequest, ParseAction<?> outcome, int operationStatus, boolean allowPrefer, MethodOutcome response, String resourceName) throws IOException {
  HttpServletResponse servletResponse = theRequest.getServletResponse();
  servletResponse.setStatus(operationStatus);
  servletResponse.setCharacterEncoding(Constants.CHARSET_NAME_UTF8);
  addHeadersToResponse(servletResponse);
  if (allowPrefer) {
    addContentLocationHeaders(theRequest, servletResponse, response, resourceName);
  }
  Writer writer;
  if (outcome != null) {
    ResponseEncoding encoding = RestfulServerUtils.determineResponseEncodingWithDefault(theRequest);
    servletResponse.setContentType(encoding.getResourceContentType());
    writer = servletResponse.getWriter();
    IParser parser = encoding.getEncoding().newParser(getFhirContext());
    parser.setPrettyPrint(RestfulServerUtils.prettyPrintResponse(this, theRequest));
    outcome.execute(parser, writer);
  } else {
    servletResponse.setContentType(Constants.CT_TEXT_WITH_UTF8);
    writer = servletResponse.getWriter();
  }
  return writer;
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

public static IParser getNewParser(FhirContext theContext, FhirVersionEnum theForVersion, RequestDetails theRequestDetails) {
  FhirContext context = getContextForVersion(theContext, theForVersion);
  // Determine response encoding
  EncodingEnum responseEncoding = RestfulServerUtils.determineResponseEncodingWithDefault(theRequestDetails).getEncoding();
  IParser parser;
  switch (responseEncoding) {
    case JSON:
      parser = context.newJsonParser();
      break;
    case XML:
    default:
      parser = context.newXmlParser();
      break;
  }
  configureResponseParser(theRequestDetails, parser);
  return parser;
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

private static ResponseEncoding getEncodingForContentType(FhirContext theFhirContext, boolean theStrict, String theContentType, String thePreferContentType) {
  EncodingEnum encoding;
  if (theStrict) {
    encoding = EncodingEnum.forContentTypeStrict(theContentType);
  } else {
    encoding = EncodingEnum.forContentType(theContentType);
  }
  if (isNotBlank(thePreferContentType)) {
    if (thePreferContentType.equals(theContentType)) {
      return new ResponseEncoding(theFhirContext, encoding, theContentType);
    }
  }
  if (encoding == null) {
    return null;
  }
  return new ResponseEncoding(theFhirContext, encoding, theContentType);
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

public static EncodingEnum determineRequestEncodingNoDefault(RequestDetails theReq) {
  ResponseEncoding retVal = determineRequestEncodingNoDefaultReturnRE(theReq);
  if (retVal == null) {
    return null;
  }
  return retVal.getEncoding();
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

public String getResourceContentType() {
  if (Boolean.TRUE.equals(isNonLegacy())) {
    return getEncoding().getResourceContentTypeNonLegacy();
  }
  return getEncoding().getResourceContentType();
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

/**
 * Determine whether a response should be given in JSON or XML format based on the incoming HttpServletRequest's
 * <code>"_format"</code> parameter and <code>"Accept:"</code> HTTP header.
 */
public static ResponseEncoding determineResponseEncodingWithDefault(RequestDetails theReq) {
  ResponseEncoding retVal = determineResponseEncodingNoDefault(theReq, theReq.getServer().getDefaultResponseEncoding());
  if (retVal == null) {
    retVal = new ResponseEncoding(theReq.getServer().getFhirContext(), theReq.getServer().getDefaultResponseEncoding(), null);
  }
  return retVal;
}
origin: jamesagnew/hapi-fhir

  responseEncoding = new ResponseEncoding(theServer.getFhirContext(), theServer.getDefaultResponseEncoding(), null);
  contentType = Constants.CT_HTML;
} else {
  contentType = responseEncoding.getResourceContentType();
origin: jamesagnew/hapi-fhir

ResponseEncoding encoding = RestfulServerUtils.determineResponseEncodingNoDefault(myRequestDetails, myRequestDetails.getServer().getDefaultResponseEncoding());
if (encoding != null) {
  return encoding.getEncoding().name();
origin: jamesagnew/hapi-fhir

encodingEnum = responseEncoding.getEncoding();
ca.uhn.fhir.rest.serverRestfulServerUtils$ResponseEncoding

Javadoc

Return type for RestfulServerUtils#determineRequestEncodingNoDefault(RequestDetails)

Most used methods

  • getEncoding
  • <init>
  • getContentType
  • getResourceContentType
  • isNonLegacy

Popular in Java

  • Start an intent from android
  • getSupportFragmentManager (FragmentActivity)
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (Timer)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now