Package org.hl7.fhir.dstu2.utils.client
Class ClientUtils
java.lang.Object
org.hl7.fhir.dstu2.utils.client.ClientUtils
Helper class handling lower level HTTP transport concerns. TODO Document
methods.
- Author:
- Claude Nanjo
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuildConnection
(URI baseServiceUri, String tail) Client connection methodsbuildConnection
(URI baseServiceUri, ResourceType resourceType, String id) protected void
configureFhirRequest
(org.apache.http.HttpRequest request, String format) Method adds required request headers.protected void
configureFhirRequest
(org.apache.http.HttpRequest request, String format, List<org.apache.http.Header> headers) Method adds required request headers.byte[]
getFeedAsByteArray
(Bundle feed, boolean pretty, boolean isJson) getLastModifiedResponseHeaderAsCalendarObject
(URLConnection serverConnection) protected String
getLocationHeader
(org.apache.http.HttpResponse response) org.hl7.fhir.utilities.ToolingClientLogger
protected IParser
org.apache.http.HttpHost
getProxy()
<T extends Resource>
byte[]getResourceAsByteArray
(T resource, boolean pretty, boolean isJson) Other general helper methodsint
int
boolean
issueDeleteRequest
(URI resourceUri) issueGetFeedRequest
(URI resourceUri, String resourceFormat) <T extends Resource>
ResourceRequest<T> issueGetResourceRequest
(URI resourceUri, String resourceFormat, int timeoutLoading) <T extends Resource>
ResourceRequest<T> issueOptionsRequest
(URI optionsUri, String resourceFormat, int timeoutLoading) issuePostFeedRequest
(URI resourceUri, Map<String, String> parameters, String resourceName, Resource resource, String resourceFormat) <T extends Resource>
ResourceRequest<T> issuePostRequest
(URI resourceUri, byte[] payload, String resourceFormat, int timeoutLoading) <T extends Resource>
ResourceRequest<T> issuePostRequest
(URI resourceUri, byte[] payload, String resourceFormat, List<org.apache.http.Header> headers, int timeoutLoading) <T extends Resource>
ResourceRequest<T> issuePutRequest
(URI resourceUri, byte[] payload, String resourceFormat, int timeoutLoading) <T extends Resource>
ResourceRequest<T> issuePutRequest
(URI resourceUri, byte[] payload, String resourceFormat, List<org.apache.http.Header> headers, int timeoutLoading) protected <T extends Resource>
ResourceRequest<T> issueResourceRequest
(String resourceFormat, org.apache.http.client.methods.HttpUriRequest request, byte[] payload, int timeoutLoading) protected <T extends Resource>
ResourceRequest<T> issueResourceRequest
(String resourceFormat, org.apache.http.client.methods.HttpUriRequest request, byte[] payload, List<org.apache.http.Header> headers, int timeoutLoading) protected <T extends Resource>
ResourceRequest<T> issueResourceRequest
(String resourceFormat, org.apache.http.client.methods.HttpUriRequest request, int timeoutLoading) Request/Response Helper methodspostBatchRequest
(URI resourceUri, byte[] payload, String resourceFormat, int timeoutLoading) protected org.apache.http.HttpResponse
sendPayload
(org.apache.http.client.methods.HttpEntityEnclosingRequestBase request, byte[] payload) Method posts request payloadprotected org.apache.http.HttpResponse
sendPayload
(org.apache.http.client.methods.HttpEntityEnclosingRequestBase request, byte[] payload, org.apache.http.HttpHost proxy, int timeoutLoading) Method posts request payloadprotected org.apache.http.HttpResponse
sendRequest
(org.apache.http.client.methods.HttpUriRequest request) void
setAcceptLanguage
(String language) void
setContentLanguage
(String language) void
setLogger
(org.hl7.fhir.utilities.ToolingClientLogger logger) void
setPassword
(String password) void
setProxy
(org.apache.http.HttpHost proxy) void
setRetryCount
(int retryCount) void
setTimeout
(int timeout) void
setUserAgent
(String userAgent) void
setUsername
(String username) protected Bundle
unmarshalFeed
(org.apache.http.HttpResponse response, String format) Unmarshals Bundle from response stream.protected <T extends Resource>
TunmarshalReference
(org.apache.http.HttpResponse response, String format) Unmarshals a resource from the response stream.protected String
writeInputStreamAsString
(InputStream instream) Used for debugging
-
Field Details
-
DEFAULT_CHARSET
- See Also:
-
HEADER_LOCATION
- See Also:
-
-
Constructor Details
-
ClientUtils
public ClientUtils()
-
-
Method Details
-
getProxy
-
setProxy
-
getTimeout
-
setTimeout
-
getUsername
-
setUsername
-
getPassword
-
setPassword
-
issueOptionsRequest
public <T extends Resource> ResourceRequest<T> issueOptionsRequest(URI optionsUri, String resourceFormat, int timeoutLoading) -
issueGetResourceRequest
public <T extends Resource> ResourceRequest<T> issueGetResourceRequest(URI resourceUri, String resourceFormat, int timeoutLoading) -
issuePutRequest
public <T extends Resource> ResourceRequest<T> issuePutRequest(URI resourceUri, byte[] payload, String resourceFormat, List<org.apache.http.Header> headers, int timeoutLoading) -
issuePutRequest
public <T extends Resource> ResourceRequest<T> issuePutRequest(URI resourceUri, byte[] payload, String resourceFormat, int timeoutLoading) -
issuePostRequest
public <T extends Resource> ResourceRequest<T> issuePostRequest(URI resourceUri, byte[] payload, String resourceFormat, List<org.apache.http.Header> headers, int timeoutLoading) -
issuePostRequest
public <T extends Resource> ResourceRequest<T> issuePostRequest(URI resourceUri, byte[] payload, String resourceFormat, int timeoutLoading) -
issueGetFeedRequest
-
postBatchRequest
public Bundle postBatchRequest(URI resourceUri, byte[] payload, String resourceFormat, int timeoutLoading) -
issueDeleteRequest
-
issueResourceRequest
protected <T extends Resource> ResourceRequest<T> issueResourceRequest(String resourceFormat, org.apache.http.client.methods.HttpUriRequest request, int timeoutLoading) Request/Response Helper methods -
issueResourceRequest
protected <T extends Resource> ResourceRequest<T> issueResourceRequest(String resourceFormat, org.apache.http.client.methods.HttpUriRequest request, byte[] payload, int timeoutLoading) - Parameters:
resourceFormat
-options
-- Returns:
-
issueResourceRequest
protected <T extends Resource> ResourceRequest<T> issueResourceRequest(String resourceFormat, org.apache.http.client.methods.HttpUriRequest request, byte[] payload, List<org.apache.http.Header> headers, int timeoutLoading) - Parameters:
resourceFormat
-options
-- Returns:
-
configureFhirRequest
Method adds required request headers. TODO handle JSON request as well.- Parameters:
request
-
-
configureFhirRequest
protected void configureFhirRequest(org.apache.http.HttpRequest request, String format, List<org.apache.http.Header> headers) Method adds required request headers. TODO handle JSON request as well.- Parameters:
request
-
-
sendPayload
protected org.apache.http.HttpResponse sendPayload(org.apache.http.client.methods.HttpEntityEnclosingRequestBase request, byte[] payload, org.apache.http.HttpHost proxy, int timeoutLoading) Method posts request payload- Parameters:
request
-payload
-- Returns:
-
sendRequest
protected org.apache.http.HttpResponse sendRequest(org.apache.http.client.methods.HttpUriRequest request) - Parameters:
request
-payload
-- Returns:
-
unmarshalReference
protected <T extends Resource> T unmarshalReference(org.apache.http.HttpResponse response, String format) Unmarshals a resource from the response stream.- Parameters:
response
-- Returns:
-
unmarshalFeed
Unmarshals Bundle from response stream.- Parameters:
response
-- Returns:
-
getLocationHeader
-
buildConnection
Client connection methods -
buildConnection
-
getResourceAsByteArray
public <T extends Resource> byte[] getResourceAsByteArray(T resource, boolean pretty, boolean isJson) Other general helper methods -
getFeedAsByteArray
-
getLastModifiedResponseHeaderAsCalendarObject
-
getParser
-
issuePostFeedRequest
public Bundle issuePostFeedRequest(URI resourceUri, Map<String, String> parameters, String resourceName, Resource resource, String resourceFormat) throws IOException- Throws:
IOException
-
sendPayload
protected org.apache.http.HttpResponse sendPayload(org.apache.http.client.methods.HttpEntityEnclosingRequestBase request, byte[] payload) Method posts request payload- Parameters:
request
-payload
-- Returns:
-
getLogger
-
setLogger
-
writeInputStreamAsString
Used for debugging- Parameters:
instream
-- Returns:
-
getRetryCount
-
setRetryCount
-
getUserAgent
-
setUserAgent
-
setAcceptLanguage
-
setContentLanguage
-