Package ca.uhn.fhir.rest.server
Class RestfulServerUtils
- java.lang.Object
-
- ca.uhn.fhir.rest.server.RestfulServerUtils
-
public class RestfulServerUtils extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRestfulServerUtils.ResponseEncodingReturn type fordetermineRequestEncodingNoDefault(RequestDetails)
-
Constructor Summary
Constructors Constructor Description RestfulServerUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidconfigureResponseParser(RequestDetails theRequestDetails, ca.uhn.fhir.parser.IParser parser)static StringcreateEtag(String theVersionId)static StringcreatePagingLink(Set<ca.uhn.fhir.model.api.Include> theIncludes, RequestDetails theRequestDetails, String theSearchId, int theOffset, int theCount, Map<String,String[]> theRequestParameters, boolean thePrettyPrint, ca.uhn.fhir.model.valueset.BundleTypeEnum theBundleType)static StringcreatePagingLink(Set<ca.uhn.fhir.model.api.Include> theIncludes, RequestDetails theRequestDetails, String theSearchId, String thePageId, Map<String,String[]> theRequestParameters, boolean thePrettyPrint, ca.uhn.fhir.model.valueset.BundleTypeEnum theBundleType)static ca.uhn.fhir.rest.api.EncodingEnumdetermineRequestEncoding(RequestDetails theReq)static ca.uhn.fhir.rest.api.EncodingEnumdetermineRequestEncodingNoDefault(RequestDetails theReq)static RestfulServerUtils.ResponseEncodingdetermineResponseEncodingNoDefault(RequestDetails theReq, ca.uhn.fhir.rest.api.EncodingEnum thePrefer)Returns null if the request doesn't express that it wants FHIR.static RestfulServerUtils.ResponseEncodingdetermineResponseEncodingNoDefault(RequestDetails theReq, ca.uhn.fhir.rest.api.EncodingEnum thePrefer, String thePreferContentType)Try to determing the response content type, given the request Accept header and _format parameter.static RestfulServerUtils.ResponseEncodingdetermineResponseEncodingWithDefault(RequestDetails theReq)Determine whether a response should be given in JSON or XML format based on the incoming HttpServletRequest's"_format"parameter and"Accept:"HTTP header.static Set<ca.uhn.fhir.rest.api.SummaryEnum>determineSummaryMode(RequestDetails theRequest)static IntegerextractCountParameter(RequestDetails theRequest)static org.hl7.fhir.instance.model.api.IPrimitiveType<Date>extractLastUpdatedFromResource(org.hl7.fhir.instance.model.api.IBaseResource theResource)static org.hl7.fhir.instance.model.api.IIdTypefullyQualifyResourceIdOrReturnNull(IRestfulServerDefaults theServer, org.hl7.fhir.instance.model.api.IBaseResource theResource, String theServerBase, org.hl7.fhir.instance.model.api.IIdType theResourceId)static ca.uhn.fhir.parser.IParsergetNewParser(ca.uhn.fhir.context.FhirContext theContext, ca.uhn.fhir.context.FhirVersionEnum theForVersion, RequestDetails theRequestDetails)static Set<String>parseAcceptHeaderAndReturnHighestRankedOptions(javax.servlet.http.HttpServletRequest theRequest)static ca.uhn.fhir.rest.api.PreferHeaderparsePreferHeader(IRestfulServer<?> theServer, String theValue)static booleanprettyPrintResponse(IRestfulServerDefaults theServer, RequestDetails theRequest)static booleanrespectPreferHeader(ca.uhn.fhir.rest.api.RestOperationTypeEnum theRestOperationType)static ObjectstreamResponseAsResource(IRestfulServerDefaults theServer, org.hl7.fhir.instance.model.api.IBaseResource theResource, Set<ca.uhn.fhir.rest.api.SummaryEnum> theSummaryMode, int stausCode, boolean theAddContentLocationHeader, boolean respondGzip, RequestDetails theRequestDetails)static ObjectstreamResponseAsResource(IRestfulServerDefaults theServer, org.hl7.fhir.instance.model.api.IBaseResource theResource, Set<ca.uhn.fhir.rest.api.SummaryEnum> theSummaryMode, int theStatusCode, String theStatusMessage, boolean theAddContentLocationHeader, boolean respondGzip, RequestDetails theRequestDetails, org.hl7.fhir.instance.model.api.IIdType theOperationResourceId, org.hl7.fhir.instance.model.api.IPrimitiveType<Date> theOperationResourceLastUpdated)static IntegertryToExtractNamedParameter(RequestDetails theRequest, String theParamName)static voidvalidateResourceListNotNull(List<? extends org.hl7.fhir.instance.model.api.IBaseResource> theResourceList)
-
-
-
Constructor Detail
-
RestfulServerUtils
public RestfulServerUtils()
-
-
Method Detail
-
configureResponseParser
public static void configureResponseParser(RequestDetails theRequestDetails, ca.uhn.fhir.parser.IParser parser)
-
createPagingLink
public static String createPagingLink(Set<ca.uhn.fhir.model.api.Include> theIncludes, RequestDetails theRequestDetails, String theSearchId, int theOffset, int theCount, Map<String,String[]> theRequestParameters, boolean thePrettyPrint, ca.uhn.fhir.model.valueset.BundleTypeEnum theBundleType)
-
createPagingLink
public static String createPagingLink(Set<ca.uhn.fhir.model.api.Include> theIncludes, RequestDetails theRequestDetails, String theSearchId, String thePageId, Map<String,String[]> theRequestParameters, boolean thePrettyPrint, ca.uhn.fhir.model.valueset.BundleTypeEnum theBundleType)
-
determineRequestEncoding
public static ca.uhn.fhir.rest.api.EncodingEnum determineRequestEncoding(RequestDetails theReq)
-
determineRequestEncodingNoDefault
public static ca.uhn.fhir.rest.api.EncodingEnum determineRequestEncodingNoDefault(RequestDetails theReq)
-
determineResponseEncodingNoDefault
public static RestfulServerUtils.ResponseEncoding determineResponseEncodingNoDefault(RequestDetails theReq, ca.uhn.fhir.rest.api.EncodingEnum thePrefer)
Returns null if the request doesn't express that it wants FHIR. If it expresses that it wants XML and JSON equally, returns thePrefer.
-
determineResponseEncodingNoDefault
public static RestfulServerUtils.ResponseEncoding determineResponseEncodingNoDefault(RequestDetails theReq, ca.uhn.fhir.rest.api.EncodingEnum thePrefer, String thePreferContentType)
Try to determing the response content type, given the request Accept header and _format parameter. If a value is provided to thePreferContents, we'll prefer to return that value over the native FHIR value.
-
determineResponseEncodingWithDefault
public static RestfulServerUtils.ResponseEncoding determineResponseEncodingWithDefault(RequestDetails theReq)
Determine whether a response should be given in JSON or XML format based on the incoming HttpServletRequest's"_format"parameter and"Accept:"HTTP header.
-
determineSummaryMode
public static Set<ca.uhn.fhir.rest.api.SummaryEnum> determineSummaryMode(RequestDetails theRequest)
-
extractCountParameter
public static Integer extractCountParameter(RequestDetails theRequest)
-
extractLastUpdatedFromResource
public static org.hl7.fhir.instance.model.api.IPrimitiveType<Date> extractLastUpdatedFromResource(org.hl7.fhir.instance.model.api.IBaseResource theResource)
-
fullyQualifyResourceIdOrReturnNull
public static org.hl7.fhir.instance.model.api.IIdType fullyQualifyResourceIdOrReturnNull(IRestfulServerDefaults theServer, org.hl7.fhir.instance.model.api.IBaseResource theResource, String theServerBase, org.hl7.fhir.instance.model.api.IIdType theResourceId)
-
getNewParser
public static ca.uhn.fhir.parser.IParser getNewParser(ca.uhn.fhir.context.FhirContext theContext, ca.uhn.fhir.context.FhirVersionEnum theForVersion, RequestDetails theRequestDetails)
-
parseAcceptHeaderAndReturnHighestRankedOptions
public static Set<String> parseAcceptHeaderAndReturnHighestRankedOptions(javax.servlet.http.HttpServletRequest theRequest)
-
respectPreferHeader
public static boolean respectPreferHeader(ca.uhn.fhir.rest.api.RestOperationTypeEnum theRestOperationType)
-
parsePreferHeader
@Nonnull public static ca.uhn.fhir.rest.api.PreferHeader parsePreferHeader(IRestfulServer<?> theServer, String theValue)
-
prettyPrintResponse
public static boolean prettyPrintResponse(IRestfulServerDefaults theServer, RequestDetails theRequest)
-
streamResponseAsResource
public static Object streamResponseAsResource(IRestfulServerDefaults theServer, org.hl7.fhir.instance.model.api.IBaseResource theResource, Set<ca.uhn.fhir.rest.api.SummaryEnum> theSummaryMode, int stausCode, boolean theAddContentLocationHeader, boolean respondGzip, RequestDetails theRequestDetails) throws IOException
- Throws:
IOException
-
streamResponseAsResource
public static Object streamResponseAsResource(IRestfulServerDefaults theServer, org.hl7.fhir.instance.model.api.IBaseResource theResource, Set<ca.uhn.fhir.rest.api.SummaryEnum> theSummaryMode, int theStatusCode, String theStatusMessage, boolean theAddContentLocationHeader, boolean respondGzip, RequestDetails theRequestDetails, org.hl7.fhir.instance.model.api.IIdType theOperationResourceId, org.hl7.fhir.instance.model.api.IPrimitiveType<Date> theOperationResourceLastUpdated) throws IOException
- Throws:
IOException
-
createEtag
public static String createEtag(String theVersionId)
-
tryToExtractNamedParameter
public static Integer tryToExtractNamedParameter(RequestDetails theRequest, String theParamName)
-
validateResourceListNotNull
public static void validateResourceListNotNull(List<? extends org.hl7.fhir.instance.model.api.IBaseResource> theResourceList)
-
-