From afde9df9a6053dd8cc51c5fc45b7687806a4f432 Mon Sep 17 00:00:00 2001 From: leif stawnyczy Date: Tue, 6 Aug 2024 16:23:59 -0400 Subject: [PATCH] cleaning up --- .../fhir/rest/client/api/IGenericClient.java | 108 ++++++++++++++---- .../uhn/fhir/rest/client/api/IHttpClient.java | 16 +-- .../param/HttpClientRequestParameters.java | 60 +++++++--- .../rest/client/apache/ApacheHttpClient.java | 10 +- .../apache/ApacheRestfulClientFactory.java | 3 +- .../rest/client/apache/BaseHttpClient.java | 7 -- .../uhn/fhir/rest/client/impl/BaseClient.java | 3 +- .../client/impl/BaseHttpClientInvocation.java | 16 ++- .../fhir/rest/client/impl/GenericClient.java | 44 +++---- .../BaseHttpClientInvocationWithContents.java | 2 - .../method/HttpDeleteClientInvocation.java | 5 +- .../method/HttpGetClientInvocation.java | 2 - .../method/HttpPatchClientInvocation.java | 6 +- .../method/HttpSimpleClientInvocation.java | 6 +- .../client/model/AsHttpRequestParams.java | 15 +++ 15 files changed, 195 insertions(+), 108 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IGenericClient.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IGenericClient.java index efa393e66d8..c517f192b35 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IGenericClient.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IGenericClient.java @@ -43,38 +43,64 @@ import org.hl7.fhir.instance.model.api.IBaseResource; public interface IGenericClient extends IRestfulClient { public enum ClientType { + /** + * Preserves the client across the chain, + * thus preserving the client *settings* (socket timeout, etc). + */ PRESERVED, - DEPRECATED + /** + * Legacy client; + * client might be created and recreated before a call, + * destroying any settings. + * Please use "PRESERVED" + */ + LEGACY } + /** + * Use {@link #capabilities(ClientType)} instead + */ + @Deprecated(since = "7.5.0") + IFetchConformanceUntyped capabilities(); + /** * Fetch the capability statement for the server */ - IFetchConformanceUntyped capabilities(); - IFetchConformanceUntyped capabilities(ClientType theClientType); + /** + * Use {@link #create(ClientType)} instead. + */ + @Deprecated(since = "7.5.0") + ICreate create(); + /** * Fluent method for the "create" operation, which creates a new resource instance on the server */ - ICreate create(); - ICreate create(ClientType theClientType); + /** + * Use {@link #delete(ClientType)} instead. + */ + @Deprecated(since = "7.5.0") + IDelete delete(); + /** * Fluent method for the "delete" operation, which performs a logical delete on a server resource */ - IDelete delete(); - IDelete delete(ClientType theClientType); + /** + * @deprecated + */ + @Deprecated(since = "7.5.0") + IFetchConformanceUntyped fetchConformance(); + /** * Retrieves the server's conformance statement * * @deprecated As of HAPI 3.0.0 this method has been deprecated, as the operation is now called "capabilities". Use {@link #capabilities()} instead */ - IFetchConformanceUntyped fetchConformance(); - IFetchConformanceUntyped fetchConformance(ClientType theClientType); /** @@ -88,48 +114,72 @@ public interface IGenericClient extends IRestfulClient { void forceConformanceCheck() throws FhirClientConnectionException; /** - * Implementation of the "history" method + * Use {@link #history(ClientType)} instead */ + @Deprecated(since = "7.5.0") IHistory history(); + /** + * Implementation of the "history" method + */ IHistory history(ClientType theClientType); + /** + * Use {@link #loadPage(ClientType)} instead + */ + @Deprecated(since = "7.5.0") + IGetPage loadPage(); + /** * Loads the previous/next bundle of resources from a paged set, using the link specified in the "link type=next" tag within the atom bundle. */ - IGetPage loadPage(); - IGetPage loadPage(ClientType theClientType); + /** + * Use {@link #meta(ClientType)} instead. + */ + @Deprecated(since = "7.5.0") + IMeta meta(); + /** * Fluent method for the "meta" operations, which can be used to get, add and remove tags and other * Meta elements from a resource or across the server. * * @since 1.1 */ - IMeta meta(); - IMeta meta(ClientType theClientType); + /** + * Use {@link #operation(ClientType)} instead + */ + @Deprecated(since = "7.5.0") + IOperation operation(); + /** * Implementation of the FHIR "extended operations" action */ - IOperation operation(); - IOperation operation(ClientType theClientType); + /** + * Use {@link #patch(ClientType)} instead + */ + @Deprecated(since = "7.5.0") + IPatch patch(); + /** * Fluent method for the "patch" operation, which performs a logical patch on a server resource */ - IPatch patch(); - IPatch patch(ClientType theClientType); + /** + * Use {@link #read(ClientType)} instead. + */ + @Deprecated(since = "7.5.0") + IRead read(); + /** * Fluent method for "read" and "vread" methods. */ - IRead read(); - IRead read(ClientType theClientType); /** @@ -200,10 +250,14 @@ public interface IGenericClient extends IRestfulClient { void setLogRequestAndResponse(boolean theLogRequestAndResponse); /** - * Send a transaction (collection of resources) to the server to be executed as a single unit + * Use {@link #transaction(ClientType)} instead */ + @Deprecated(since = "7.5.0") ITransaction transaction(); + /** + * Send a transaction (collection of resources) to the server to be executed as a single unit + */ ITransaction transaction(ClientType theClientType); /** @@ -213,10 +267,14 @@ public interface IGenericClient extends IRestfulClient { void unregisterInterceptor(Object theInterceptor); /** - * Fluent method for the "update" operation, which updates a resource instance on the server + * Use {@link #update(ClientType)} instead */ + @Deprecated(since = "7.5.0") IUpdate update(); + /** + * Fluent method for the "update" operation, which updates a resource instance on the server + */ IUpdate update(ClientType theClientType); /** @@ -246,10 +304,14 @@ public interface IGenericClient extends IRestfulClient { MethodOutcome update(String theId, IBaseResource theResource); /** - * Validate a resource + * use {@link #validate(ClientType)} instead */ + @Deprecated(since = "7.5.0") IValidate validate(); + /** + * Validate a resource + */ IValidate validate(ClientType theClientType); /** diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IHttpClient.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IHttpClient.java index de3b625c600..347b3e76e80 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IHttpClient.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IHttpClient.java @@ -61,15 +61,14 @@ public interface IHttpClient { */ IHttpRequest createBinaryRequest(FhirContext theContext, IBaseBinary theBinary); - /** - * Create a normal http get request - * @param theContext TODO - * @param theEncoding the request encoding - * @return the http request to be executed - */ + @Deprecated IHttpRequest createGetRequest(FhirContext theContext, EncodingEnum theEncoding); + /** + * Create a normal http request. The RequestType in the parameters will determine the type. + * @return the http request to be executed + */ IHttpRequest createRequest(HttpClientRequestParameters theParameters); void addHeadersToRequest(IHttpRequest theRequest, EncodingEnum theEncodingEnum, FhirContext theContext); @@ -78,7 +77,10 @@ public interface IHttpClient { * Updates the client's url; * This is used when we reuse a client for multiple different requests * (ex, searches, or fetching the /metadata endpoint followed by whatever - * the actual endpoint is, etc) + * the actual endpoint is, etc). + * + * Deprecated / Legacy clients do not use this (they create new clients for + * every request) */ void setNewUrl(StringBuilder theUrl); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/HttpClientRequestParameters.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/HttpClientRequestParameters.java index d83a8bd04ef..ff8c2a8827d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/HttpClientRequestParameters.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/HttpClientRequestParameters.java @@ -10,28 +10,66 @@ import java.util.List; import java.util.Map; public class HttpClientRequestParameters { - + /** + * The fhir context used. + */ private FhirContext myFhirContext; - + /** + * The encoding type (JSON, XML, etc) to use for the request. + */ private EncodingEnum myEncodingEnum; - + /** + * The request type (GET, POST, PUT, etc) + * Generally a required field. + */ private RequestTypeEnum myRequestTypeEnum; + /** + * Parameters + */ private Map> myParams; + /** + * The content type to use (application/json, etc) + */ private String myContentType; + /** + * If the payload is a String, this is the content to attach. + * + * Only one of String/byte[]/form encoded url parameters can be used. + * String contents will be used before byte contents which will be used + * before FormUrlEncoded parameters. + */ private String myContents; + /** + * If the payload is a binary, this is the binary to attach + */ private IBaseBinary myBaseBinary; - private String myUrl; - - // only for non-get requests - private String myStringContents; + /** + * The URL where the request is to be made. + */ + private final String myUrl; + /** + * If the payload is a byte[], this is the content to attach. + * + * Only one of String/byte[]/form encoded url parameters can be used. + * String contents will be used before byte contents which will be used + * before FormUrlEncoded parameters. + */ private byte[] myByteContents; + /** + * If the payload is a set of form encoded url parameters, these are the + * parameters to use. + * + * Only one of String/byte[]/form encoded url parameters can be used. + * String contents will be used before byte contents which will be used + * before FormUrlEncoded parameters. + */ private Map> myFormParams; public HttpClientRequestParameters(String theUrl, @Nonnull RequestTypeEnum theRequestTypeEnum) { @@ -99,14 +137,6 @@ public class HttpClientRequestParameters { return myUrl; } - public String getStringContents() { - return myStringContents; - } - - public void setStringContents(String theStringContents) { - myStringContents = theStringContents; - } - public byte[] getByteContents() { return myByteContents; } diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/ApacheHttpClient.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/ApacheHttpClient.java index f3d38424b4f..01e750749dc 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/ApacheHttpClient.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/ApacheHttpClient.java @@ -79,11 +79,19 @@ public class ApacheHttpClient extends BaseHttpClient implements IHttpClient { && !theParameters.getFormParams().isEmpty()) { return entityFromFormParams(theParameters.getFormParams()); } - // could be a get request + /* + * Could be a get request. + * This fallthrough is for legacy purposes; ideally we would use the request type + * but legacy clients don't have it defined always. + */ return null; } private HttpRequestBase constructRequestBase(HttpClientRequestParameters theParameters, HttpEntity theEntity) { + // we default to the parameters request type; + // but if that's not provided (as in legacy clients case) + // we'll use the client's request type instead. + // one of these will definitely be provided though. RequestTypeEnum requestTypeEnum = theParameters.getRequestTypeEnum(); if (requestTypeEnum == null) { requestTypeEnum = myRequestType; diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/ApacheRestfulClientFactory.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/ApacheRestfulClientFactory.java index 0cdddef2e41..cc2dd63e019 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/ApacheRestfulClientFactory.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/ApacheRestfulClientFactory.java @@ -87,8 +87,6 @@ public class ApacheRestfulClientFactory extends RestfulClientFactory { public HttpClient getNativeHttpClient() { if (myHttpClient == null) { - System.out.println("yyyy Socket timeout " + getSocketTimeout()); - // TODO: Use of a deprecated method should be resolved. RequestConfig defaultRequestConfig = RequestConfig.custom() .setSocketTimeout(getSocketTimeout()) .setConnectTimeout(getConnectTimeout()) @@ -107,6 +105,7 @@ public class ApacheRestfulClientFactory extends RestfulClientFactory { connectionManager.setDefaultMaxPerRoute(getPoolMaxPerRoute()); // default value for stale connection check // this can be disabled (with a -ve value) if performance is bad + // but currently we are using the default for whatever reason connectionManager.setValidateAfterInactivity(2000); builder.setConnectionManager(connectionManager); diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/BaseHttpClient.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/BaseHttpClient.java index 691da48de63..8605a463599 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/BaseHttpClient.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/BaseHttpClient.java @@ -119,13 +119,6 @@ public abstract class BaseHttpClient implements IHttpClient { return retVal; } - // @Override - // public IHttpRequest createRequest(HttpClientRequestParameters theParameters) { - // - // } - - // protected abstract IHttpRequest createHttpRequest(CreateHttpRequestParameters theCreateHttpRequestParameters); - @Deprecated protected abstract IHttpRequest createHttpRequest(); diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseClient.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseClient.java index 48e5c0ebe39..1dffdb5ed41 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseClient.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseClient.java @@ -344,8 +344,7 @@ public abstract class BaseClient implements IRestfulClient { .setEncodingEnum(encoding) .setClient(myClient); httpRequest = clientInvocation.asHttpRequest(asHttpRequestParams); - // httpRequest = clientInvocation.asHttpRequest(myUrlBase, params, encoding, thePrettyPrint); - // + if (isNotBlank(theCustomAcceptHeader)) { httpRequest.removeHeaders(Constants.HEADER_ACCEPT); httpRequest.addHeader(Constants.HEADER_ACCEPT, theCustomAcceptHeader); diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseHttpClientInvocation.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseHttpClientInvocation.java index 2845e988866..8d787e5bf93 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseHttpClientInvocation.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseHttpClientInvocation.java @@ -51,7 +51,7 @@ public abstract class BaseHttpClientInvocation { } /** - * Create an HTTP request out of this client request + * Create an HTTP request out of this client request. * * @param theUrlBase * The FHIR server base url (with a trailing "/") @@ -60,17 +60,19 @@ public abstract class BaseHttpClientInvocation { * @param theEncoding * The encoding to use for any serialized content sent to the * server + * + * @deprecated Use/Override {@link #asHttpRequest(AsHttpRequestParams)} instead. */ - @Deprecated + @Deprecated(since = "7.5.0") public abstract IHttpRequest asHttpRequest( String theUrlBase, Map> theExtraParams, EncodingEnum theEncoding, Boolean thePrettyPrint); - // TODO implement public IHttpRequest asHttpRequest(AsHttpRequestParams theParams) { - + // default passes back to deprecated; + // this is to allow existing clients not to break return asHttpRequest( theParams.getUrlBase(), theParams.getExtraParams(), @@ -95,8 +97,11 @@ public abstract class BaseHttpClientInvocation { protected IHttpRequest createHttpRequest(CreateRequestParameters theParameters) { IHttpClient httpClient; if (theParameters.getClient() != null) { + // reuse existing client httpClient = theParameters.getClient(); + httpClient.setNewUrl(new StringBuilder(theParameters.getUrl())); } else { + // make a new client httpClient = getRestfulClientFactory() .getHttpClient( new StringBuilder(theParameters.getUrl()), @@ -105,14 +110,13 @@ public abstract class BaseHttpClientInvocation { theParameters.getRequestTypeEnum(), myHeaders); } - // todo + HttpClientRequestParameters clientRequestParameters = new HttpClientRequestParameters(theParameters.getUrl(), theParameters.getRequestTypeEnum()); clientRequestParameters.setEncodingEnum(theParameters.getEncodingEnum()); IHttpRequest request = httpClient.createRequest(clientRequestParameters); httpClient.addHeadersToRequest(request, theParameters.getEncodingEnum(), getContext()); return request; - // return httpClient.createGetRequest(getContext(), theParameters.getEncodingEnum()); } /** diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java index 92abc6688e5..4d651b73552 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java @@ -196,7 +196,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IFetchConformanceUntyped capabilities() { - return capabilities(ClientType.DEPRECATED); + return capabilities(ClientType.LEGACY); } @Override @@ -209,7 +209,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public ICreate create() { - return create(ClientType.DEPRECATED); + return create(ClientType.LEGACY); } @Override @@ -222,7 +222,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IDelete delete() { - return delete(ClientType.DEPRECATED); + return delete(ClientType.LEGACY); } @Override @@ -272,8 +272,6 @@ public class GenericClient extends BaseClient implements IGenericClient { .setClient(myClient) .setEncodingEnum(getEncoding()) .setPrettyPrint(isPrettyPrint()); - // myLastRequest = invocation.asHttpRequest( - // getServerBase(), createExtraParams(theCustomAcceptHeaderValue), getEncoding(), isPrettyPrint()); myLastRequest = invocation.asHttpRequest(params); } @@ -286,18 +284,6 @@ public class GenericClient extends BaseClient implements IGenericClient { new ResourceResponseHandler<>(theType, (Class) null, id, allowHtmlResponse); if (theNotModifiedHandler == null) { - // return invokeClient( - // myContext, - // binding, - // invocation, - // theEncoding, - // thePrettyPrint, - // myLogRequestAndResponse, - // theSummary, - // theSubsetElements, - // null, - // theCustomAcceptHeaderValue, - // theCustomHeaders); return invokeClient(new InvokeClientParameters() .setContext(myContext) .setBinding(binding) @@ -330,7 +316,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IFetchConformanceUntyped fetchConformance() { - return fetchConformance(ClientType.DEPRECATED); + return fetchConformance(ClientType.LEGACY); } @Override @@ -371,7 +357,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IHistory history() { - return history(ClientType.DEPRECATED); + return history(ClientType.LEGACY); } @Override @@ -400,7 +386,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IGetPage loadPage() { - return loadPage(ClientType.DEPRECATED); + return loadPage(ClientType.LEGACY); } @Override @@ -413,7 +399,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IMeta meta() { - return meta(ClientType.DEPRECATED); + return meta(ClientType.LEGACY); } @Override @@ -426,7 +412,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IOperation operation() { - return operation(ClientType.DEPRECATED); + return operation(ClientType.LEGACY); } @Override @@ -439,7 +425,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IPatch patch() { - return patch(ClientType.DEPRECATED); + return patch(ClientType.LEGACY); } @Override @@ -452,7 +438,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IRead read() { - return read(ClientType.DEPRECATED); + return read(ClientType.LEGACY); } @Override @@ -460,7 +446,6 @@ public class GenericClient extends BaseClient implements IGenericClient { if (theClientType == ClientType.PRESERVED && myClient != null) { return new ReadInternal(myClient); } - // deprecated return new ReadInternal(null); } @@ -505,7 +490,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @SuppressWarnings({"rawtypes", "unchecked"}) @Override public IUntypedQuery search() { - return search(ClientType.DEPRECATED); + return search(ClientType.LEGACY); } private String toResourceName(Class theType) { @@ -514,7 +499,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public ITransaction transaction() { - return transaction(ClientType.DEPRECATED); + return transaction(ClientType.LEGACY); } @Override @@ -527,7 +512,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IUpdate update() { - return update(ClientType.DEPRECATED); + return update(ClientType.LEGACY); } @Override @@ -558,7 +543,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @Override public IValidate validate() { - return validate(ClientType.DEPRECATED); + return validate(ClientType.LEGACY); } @Override @@ -719,7 +704,6 @@ public class GenericClient extends BaseClient implements IGenericClient { IClientResponseHandler theHandler, BaseHttpClientInvocation theInvocation) { if (isKeepResponses()) { -// myLastRequest = theInvocation.asHttpRequest(getServerBase(), theParams, getEncoding(), myPrettyPrint); myLastRequest = theInvocation.asHttpRequest( new AsHttpRequestParams() .setUrlBase(getServerBase()) diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java index 1e65fa0eb2b..03561e6a498 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java @@ -28,7 +28,6 @@ import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory; import ca.uhn.fhir.rest.api.RequestTypeEnum; -import ca.uhn.fhir.rest.client.apache.ApacheHttpClient; import ca.uhn.fhir.rest.client.api.Header; import ca.uhn.fhir.rest.client.api.IHttpClient; import ca.uhn.fhir.rest.client.api.IHttpRequest; @@ -191,7 +190,6 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca httpClient.addHeadersToRequest(request, theEncoding, parameters.getFhirContext()); request.addHeader(Constants.HEADER_CONTENT_TYPE, contentType + Constants.HEADER_SUFFIX_CT_UTF_8); return request; -// return httpClient.createByteRequest(getContext(), contents, contentType, encoding); } private String getContentType(EncodingEnum encoding) { diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpDeleteClientInvocation.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpDeleteClientInvocation.java index 6b064357377..5dc8a5fafbd 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpDeleteClientInvocation.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpDeleteClientInvocation.java @@ -33,8 +33,8 @@ import java.util.Map; public class HttpDeleteClientInvocation extends BaseHttpClientInvocation { - private String myUrlPath; - private Map> myParams; + private final String myUrlPath; + private final Map> myParams; public HttpDeleteClientInvocation( FhirContext theContext, IIdType theId, Map> theAdditionalParams) { @@ -82,7 +82,6 @@ public class HttpDeleteClientInvocation extends BaseHttpClientInvocation { appendExtraParamsWithQuestionMark(myParams, b, b.indexOf("?") == -1); appendExtraParamsWithQuestionMark(theExtraParams, b, b.indexOf("?") == -1); -// return createHttpRequest(b.toString(), theEncoding, RequestTypeEnum.DELETE); CreateRequestParameters requestParameters = new CreateRequestParameters(); requestParameters.setClient(theParams.getClient()); requestParameters.setRequestTypeEnum(RequestTypeEnum.DELETE); diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpGetClientInvocation.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpGetClientInvocation.java index 235be95d6d2..17d8a58055a 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpGetClientInvocation.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpGetClientInvocation.java @@ -124,14 +124,12 @@ public class HttpGetClientInvocation extends BaseHttpClientInvocation { appendExtraParamsWithQuestionMark(theExtraParams, b, first); - // TODO - pass client down here CreateRequestParameters createRequestParameters = new CreateRequestParameters() .setRequestTypeEnum(RequestTypeEnum.GET) .setEncodingEnum(theEncoding) .setUrl(b.toString()) .setClient(theAsHttpRequestParams.getClient()); IHttpRequest retVal = super.createHttpRequest(createRequestParameters); - // IHttpRequest retVal = super.createHttpRequest(b.toString(), theEncoding, RequestTypeEnum.GET); retVal.setUrlSource(myUrlSource); return retVal; diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpPatchClientInvocation.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpPatchClientInvocation.java index 5938e9b286a..e4c70268968 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpPatchClientInvocation.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpPatchClientInvocation.java @@ -34,10 +34,10 @@ import java.util.Map; public class HttpPatchClientInvocation extends BaseHttpClientInvocation { - private String myUrlPath; + private final String myUrlPath; private Map> myParams; - private String myContents; - private String myContentType; + private final String myContents; + private final String myContentType; public HttpPatchClientInvocation(FhirContext theContext, IIdType theId, String theContentType, String theContents) { super(theContext); diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpSimpleClientInvocation.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpSimpleClientInvocation.java index f5a9e61ea42..592439a9c96 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpSimpleClientInvocation.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HttpSimpleClientInvocation.java @@ -36,7 +36,7 @@ public class HttpSimpleClientInvocation extends BaseHttpClientInvocation { private final String myUrl; private UrlSourceEnum myUrlSource = UrlSourceEnum.EXPLICIT; - private PagingHttpMethodEnum myPagingHttpMethod; + private final PagingHttpMethodEnum myPagingHttpMethod; public HttpSimpleClientInvocation( FhirContext theContext, String theUrlPath, PagingHttpMethodEnum thePagingHttpMethod) { @@ -63,7 +63,6 @@ public class HttpSimpleClientInvocation extends BaseHttpClientInvocation { @Override public IHttpRequest asHttpRequest(AsHttpRequestParams theParams) { CreateRequestParameters parameters = new CreateRequestParameters(); -// parameters.setUrl(myUrl == null ? theParams.getUrlBase() : myUrl); parameters.setUrl(myUrl); parameters.setEncodingEnum(theParams.getEncodingEnum()); parameters.setRequestTypeEnum(myPagingHttpMethod.getRequestType()); @@ -71,9 +70,6 @@ public class HttpSimpleClientInvocation extends BaseHttpClientInvocation { IHttpRequest request = createHttpRequest(parameters); request.setUrlSource(myUrlSource); return request; -// IHttpRequest retVal = createHttpRequest(myUrl, theEncoding, myPagingHttpMethod.getRequestType()); -// retVal.setUrlSource(myUrlSource); -// return retVal; } public void setUrlSource(UrlSourceEnum theUrlSource) { diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/model/AsHttpRequestParams.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/model/AsHttpRequestParams.java index e87b5960221..3d43f332294 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/model/AsHttpRequestParams.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/model/AsHttpRequestParams.java @@ -9,14 +9,29 @@ import java.util.List; import java.util.Map; public class AsHttpRequestParams { + /** + * The URL for the request + */ private String myUrlBase; + /** + * Extra parameters + */ private Map> myExtraParams; + /** + * Encoding to use (JSON, fhir+json, etc) + */ private EncodingEnum myEncodingEnum; + /** + * Whether logs should print pretty or not (for request parsing only) + */ private Boolean myPrettyPrint; + /** + * The client to use for this request + */ private IHttpClient myClient; public String getUrlBase() {