cleaning up

This commit is contained in:
leif stawnyczy 2024-08-06 16:23:59 -04:00
parent acab578bc5
commit afde9df9a6
15 changed files with 195 additions and 108 deletions

View File

@ -43,38 +43,64 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
public interface IGenericClient extends IRestfulClient { public interface IGenericClient extends IRestfulClient {
public enum ClientType { public enum ClientType {
/**
* Preserves the client across the chain,
* thus preserving the client *settings* (socket timeout, etc).
*/
PRESERVED, 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 * Fetch the capability statement for the server
*/ */
IFetchConformanceUntyped capabilities();
IFetchConformanceUntyped capabilities(ClientType theClientType); 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 * Fluent method for the "create" operation, which creates a new resource instance on the server
*/ */
ICreate create();
ICreate create(ClientType theClientType); 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 * Fluent method for the "delete" operation, which performs a logical delete on a server resource
*/ */
IDelete delete();
IDelete delete(ClientType theClientType); IDelete delete(ClientType theClientType);
/**
* @deprecated
*/
@Deprecated(since = "7.5.0")
IFetchConformanceUntyped fetchConformance();
/** /**
* Retrieves the server's conformance statement * 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 * @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); IFetchConformanceUntyped fetchConformance(ClientType theClientType);
/** /**
@ -88,48 +114,72 @@ public interface IGenericClient extends IRestfulClient {
void forceConformanceCheck() throws FhirClientConnectionException; void forceConformanceCheck() throws FhirClientConnectionException;
/** /**
* Implementation of the "history" method * Use {@link #history(ClientType)} instead
*/ */
@Deprecated(since = "7.5.0")
IHistory history(); IHistory history();
/**
* Implementation of the "history" method
*/
IHistory history(ClientType theClientType); 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. * 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); 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 * 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. * Meta elements from a resource or across the server.
* *
* @since 1.1 * @since 1.1
*/ */
IMeta meta();
IMeta meta(ClientType theClientType); IMeta meta(ClientType theClientType);
/**
* Use {@link #operation(ClientType)} instead
*/
@Deprecated(since = "7.5.0")
IOperation operation();
/** /**
* Implementation of the FHIR "extended operations" action * Implementation of the FHIR "extended operations" action
*/ */
IOperation operation();
IOperation operation(ClientType theClientType); 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 * Fluent method for the "patch" operation, which performs a logical patch on a server resource
*/ */
IPatch patch();
IPatch patch(ClientType theClientType); IPatch patch(ClientType theClientType);
/**
* Use {@link #read(ClientType)} instead.
*/
@Deprecated(since = "7.5.0")
IRead read();
/** /**
* Fluent method for "read" and "vread" methods. * Fluent method for "read" and "vread" methods.
*/ */
IRead read();
IRead read(ClientType theClientType); IRead read(ClientType theClientType);
/** /**
@ -200,10 +250,14 @@ public interface IGenericClient extends IRestfulClient {
void setLogRequestAndResponse(boolean theLogRequestAndResponse); 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(); ITransaction transaction();
/**
* Send a transaction (collection of resources) to the server to be executed as a single unit
*/
ITransaction transaction(ClientType theClientType); ITransaction transaction(ClientType theClientType);
/** /**
@ -213,10 +267,14 @@ public interface IGenericClient extends IRestfulClient {
void unregisterInterceptor(Object theInterceptor); 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(); IUpdate update();
/**
* Fluent method for the "update" operation, which updates a resource instance on the server
*/
IUpdate update(ClientType theClientType); IUpdate update(ClientType theClientType);
/** /**
@ -246,10 +304,14 @@ public interface IGenericClient extends IRestfulClient {
MethodOutcome update(String theId, IBaseResource theResource); MethodOutcome update(String theId, IBaseResource theResource);
/** /**
* Validate a resource * use {@link #validate(ClientType)} instead
*/ */
@Deprecated(since = "7.5.0")
IValidate validate(); IValidate validate();
/**
* Validate a resource
*/
IValidate validate(ClientType theClientType); IValidate validate(ClientType theClientType);
/** /**

View File

@ -61,15 +61,14 @@ public interface IHttpClient {
*/ */
IHttpRequest createBinaryRequest(FhirContext theContext, IBaseBinary theBinary); 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 @Deprecated
IHttpRequest createGetRequest(FhirContext theContext, EncodingEnum theEncoding); 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); IHttpRequest createRequest(HttpClientRequestParameters theParameters);
void addHeadersToRequest(IHttpRequest theRequest, EncodingEnum theEncodingEnum, FhirContext theContext); void addHeadersToRequest(IHttpRequest theRequest, EncodingEnum theEncodingEnum, FhirContext theContext);
@ -78,7 +77,10 @@ public interface IHttpClient {
* Updates the client's url; * Updates the client's url;
* This is used when we reuse a client for multiple different requests * This is used when we reuse a client for multiple different requests
* (ex, searches, or fetching the /metadata endpoint followed by whatever * (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); void setNewUrl(StringBuilder theUrl);
} }

View File

@ -10,28 +10,66 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class HttpClientRequestParameters { public class HttpClientRequestParameters {
/**
* The fhir context used.
*/
private FhirContext myFhirContext; private FhirContext myFhirContext;
/**
* The encoding type (JSON, XML, etc) to use for the request.
*/
private EncodingEnum myEncodingEnum; private EncodingEnum myEncodingEnum;
/**
* The request type (GET, POST, PUT, etc)
* Generally a required field.
*/
private RequestTypeEnum myRequestTypeEnum; private RequestTypeEnum myRequestTypeEnum;
/**
* Parameters
*/
private Map<String, List<String>> myParams; private Map<String, List<String>> myParams;
/**
* The content type to use (application/json, etc)
*/
private String myContentType; 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; private String myContents;
/**
* If the payload is a binary, this is the binary to attach
*/
private IBaseBinary myBaseBinary; private IBaseBinary myBaseBinary;
private String myUrl; /**
* The URL where the request is to be made.
// only for non-get requests */
private String myStringContents; 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; 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<String, List<String>> myFormParams; private Map<String, List<String>> myFormParams;
public HttpClientRequestParameters(String theUrl, @Nonnull RequestTypeEnum theRequestTypeEnum) { public HttpClientRequestParameters(String theUrl, @Nonnull RequestTypeEnum theRequestTypeEnum) {
@ -99,14 +137,6 @@ public class HttpClientRequestParameters {
return myUrl; return myUrl;
} }
public String getStringContents() {
return myStringContents;
}
public void setStringContents(String theStringContents) {
myStringContents = theStringContents;
}
public byte[] getByteContents() { public byte[] getByteContents() {
return myByteContents; return myByteContents;
} }

View File

@ -79,11 +79,19 @@ public class ApacheHttpClient extends BaseHttpClient implements IHttpClient {
&& !theParameters.getFormParams().isEmpty()) { && !theParameters.getFormParams().isEmpty()) {
return entityFromFormParams(theParameters.getFormParams()); 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; return null;
} }
private HttpRequestBase constructRequestBase(HttpClientRequestParameters theParameters, HttpEntity theEntity) { 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(); RequestTypeEnum requestTypeEnum = theParameters.getRequestTypeEnum();
if (requestTypeEnum == null) { if (requestTypeEnum == null) {
requestTypeEnum = myRequestType; requestTypeEnum = myRequestType;

View File

@ -87,8 +87,6 @@ public class ApacheRestfulClientFactory extends RestfulClientFactory {
public HttpClient getNativeHttpClient() { public HttpClient getNativeHttpClient() {
if (myHttpClient == null) { if (myHttpClient == null) {
System.out.println("yyyy Socket timeout " + getSocketTimeout());
// TODO: Use of a deprecated method should be resolved.
RequestConfig defaultRequestConfig = RequestConfig.custom() RequestConfig defaultRequestConfig = RequestConfig.custom()
.setSocketTimeout(getSocketTimeout()) .setSocketTimeout(getSocketTimeout())
.setConnectTimeout(getConnectTimeout()) .setConnectTimeout(getConnectTimeout())
@ -107,6 +105,7 @@ public class ApacheRestfulClientFactory extends RestfulClientFactory {
connectionManager.setDefaultMaxPerRoute(getPoolMaxPerRoute()); connectionManager.setDefaultMaxPerRoute(getPoolMaxPerRoute());
// default value for stale connection check // default value for stale connection check
// this can be disabled (with a -ve value) if performance is bad // 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); connectionManager.setValidateAfterInactivity(2000);
builder.setConnectionManager(connectionManager); builder.setConnectionManager(connectionManager);

View File

@ -119,13 +119,6 @@ public abstract class BaseHttpClient implements IHttpClient {
return retVal; return retVal;
} }
// @Override
// public IHttpRequest createRequest(HttpClientRequestParameters theParameters) {
//
// }
// protected abstract IHttpRequest createHttpRequest(CreateHttpRequestParameters theCreateHttpRequestParameters);
@Deprecated @Deprecated
protected abstract IHttpRequest createHttpRequest(); protected abstract IHttpRequest createHttpRequest();

View File

@ -344,8 +344,7 @@ public abstract class BaseClient implements IRestfulClient {
.setEncodingEnum(encoding) .setEncodingEnum(encoding)
.setClient(myClient); .setClient(myClient);
httpRequest = clientInvocation.asHttpRequest(asHttpRequestParams); httpRequest = clientInvocation.asHttpRequest(asHttpRequestParams);
// httpRequest = clientInvocation.asHttpRequest(myUrlBase, params, encoding, thePrettyPrint);
//
if (isNotBlank(theCustomAcceptHeader)) { if (isNotBlank(theCustomAcceptHeader)) {
httpRequest.removeHeaders(Constants.HEADER_ACCEPT); httpRequest.removeHeaders(Constants.HEADER_ACCEPT);
httpRequest.addHeader(Constants.HEADER_ACCEPT, theCustomAcceptHeader); httpRequest.addHeader(Constants.HEADER_ACCEPT, theCustomAcceptHeader);

View File

@ -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 * @param theUrlBase
* The FHIR server base url (with a trailing "/") * The FHIR server base url (with a trailing "/")
@ -60,17 +60,19 @@ public abstract class BaseHttpClientInvocation {
* @param theEncoding * @param theEncoding
* The encoding to use for any serialized content sent to the * The encoding to use for any serialized content sent to the
* server * server
*
* @deprecated Use/Override {@link #asHttpRequest(AsHttpRequestParams)} instead.
*/ */
@Deprecated @Deprecated(since = "7.5.0")
public abstract IHttpRequest asHttpRequest( public abstract IHttpRequest asHttpRequest(
String theUrlBase, String theUrlBase,
Map<String, List<String>> theExtraParams, Map<String, List<String>> theExtraParams,
EncodingEnum theEncoding, EncodingEnum theEncoding,
Boolean thePrettyPrint); Boolean thePrettyPrint);
// TODO implement
public IHttpRequest asHttpRequest(AsHttpRequestParams theParams) { public IHttpRequest asHttpRequest(AsHttpRequestParams theParams) {
// default passes back to deprecated;
// this is to allow existing clients not to break
return asHttpRequest( return asHttpRequest(
theParams.getUrlBase(), theParams.getUrlBase(),
theParams.getExtraParams(), theParams.getExtraParams(),
@ -95,8 +97,11 @@ public abstract class BaseHttpClientInvocation {
protected IHttpRequest createHttpRequest(CreateRequestParameters theParameters) { protected IHttpRequest createHttpRequest(CreateRequestParameters theParameters) {
IHttpClient httpClient; IHttpClient httpClient;
if (theParameters.getClient() != null) { if (theParameters.getClient() != null) {
// reuse existing client
httpClient = theParameters.getClient(); httpClient = theParameters.getClient();
httpClient.setNewUrl(new StringBuilder(theParameters.getUrl()));
} else { } else {
// make a new client
httpClient = getRestfulClientFactory() httpClient = getRestfulClientFactory()
.getHttpClient( .getHttpClient(
new StringBuilder(theParameters.getUrl()), new StringBuilder(theParameters.getUrl()),
@ -105,14 +110,13 @@ public abstract class BaseHttpClientInvocation {
theParameters.getRequestTypeEnum(), theParameters.getRequestTypeEnum(),
myHeaders); myHeaders);
} }
// todo
HttpClientRequestParameters clientRequestParameters = HttpClientRequestParameters clientRequestParameters =
new HttpClientRequestParameters(theParameters.getUrl(), theParameters.getRequestTypeEnum()); new HttpClientRequestParameters(theParameters.getUrl(), theParameters.getRequestTypeEnum());
clientRequestParameters.setEncodingEnum(theParameters.getEncodingEnum()); clientRequestParameters.setEncodingEnum(theParameters.getEncodingEnum());
IHttpRequest request = httpClient.createRequest(clientRequestParameters); IHttpRequest request = httpClient.createRequest(clientRequestParameters);
httpClient.addHeadersToRequest(request, theParameters.getEncodingEnum(), getContext()); httpClient.addHeadersToRequest(request, theParameters.getEncodingEnum(), getContext());
return request; return request;
// return httpClient.createGetRequest(getContext(), theParameters.getEncodingEnum());
} }
/** /**

View File

@ -196,7 +196,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IFetchConformanceUntyped capabilities() { public IFetchConformanceUntyped capabilities() {
return capabilities(ClientType.DEPRECATED); return capabilities(ClientType.LEGACY);
} }
@Override @Override
@ -209,7 +209,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public ICreate create() { public ICreate create() {
return create(ClientType.DEPRECATED); return create(ClientType.LEGACY);
} }
@Override @Override
@ -222,7 +222,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IDelete delete() { public IDelete delete() {
return delete(ClientType.DEPRECATED); return delete(ClientType.LEGACY);
} }
@Override @Override
@ -272,8 +272,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
.setClient(myClient) .setClient(myClient)
.setEncodingEnum(getEncoding()) .setEncodingEnum(getEncoding())
.setPrettyPrint(isPrettyPrint()); .setPrettyPrint(isPrettyPrint());
// myLastRequest = invocation.asHttpRequest(
// getServerBase(), createExtraParams(theCustomAcceptHeaderValue), getEncoding(), isPrettyPrint());
myLastRequest = invocation.asHttpRequest(params); myLastRequest = invocation.asHttpRequest(params);
} }
@ -286,18 +284,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
new ResourceResponseHandler<>(theType, (Class<? extends IBaseResource>) null, id, allowHtmlResponse); new ResourceResponseHandler<>(theType, (Class<? extends IBaseResource>) null, id, allowHtmlResponse);
if (theNotModifiedHandler == null) { if (theNotModifiedHandler == null) {
// return invokeClient(
// myContext,
// binding,
// invocation,
// theEncoding,
// thePrettyPrint,
// myLogRequestAndResponse,
// theSummary,
// theSubsetElements,
// null,
// theCustomAcceptHeaderValue,
// theCustomHeaders);
return invokeClient(new InvokeClientParameters<T>() return invokeClient(new InvokeClientParameters<T>()
.setContext(myContext) .setContext(myContext)
.setBinding(binding) .setBinding(binding)
@ -330,7 +316,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IFetchConformanceUntyped fetchConformance() { public IFetchConformanceUntyped fetchConformance() {
return fetchConformance(ClientType.DEPRECATED); return fetchConformance(ClientType.LEGACY);
} }
@Override @Override
@ -371,7 +357,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IHistory history() { public IHistory history() {
return history(ClientType.DEPRECATED); return history(ClientType.LEGACY);
} }
@Override @Override
@ -400,7 +386,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IGetPage loadPage() { public IGetPage loadPage() {
return loadPage(ClientType.DEPRECATED); return loadPage(ClientType.LEGACY);
} }
@Override @Override
@ -413,7 +399,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IMeta meta() { public IMeta meta() {
return meta(ClientType.DEPRECATED); return meta(ClientType.LEGACY);
} }
@Override @Override
@ -426,7 +412,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IOperation operation() { public IOperation operation() {
return operation(ClientType.DEPRECATED); return operation(ClientType.LEGACY);
} }
@Override @Override
@ -439,7 +425,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IPatch patch() { public IPatch patch() {
return patch(ClientType.DEPRECATED); return patch(ClientType.LEGACY);
} }
@Override @Override
@ -452,7 +438,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IRead read() { public IRead read() {
return read(ClientType.DEPRECATED); return read(ClientType.LEGACY);
} }
@Override @Override
@ -460,7 +446,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
if (theClientType == ClientType.PRESERVED && myClient != null) { if (theClientType == ClientType.PRESERVED && myClient != null) {
return new ReadInternal(myClient); return new ReadInternal(myClient);
} }
// deprecated
return new ReadInternal(null); return new ReadInternal(null);
} }
@ -505,7 +490,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
@Override @Override
public IUntypedQuery search() { public IUntypedQuery search() {
return search(ClientType.DEPRECATED); return search(ClientType.LEGACY);
} }
private String toResourceName(Class<? extends IBaseResource> theType) { private String toResourceName(Class<? extends IBaseResource> theType) {
@ -514,7 +499,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public ITransaction transaction() { public ITransaction transaction() {
return transaction(ClientType.DEPRECATED); return transaction(ClientType.LEGACY);
} }
@Override @Override
@ -527,7 +512,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IUpdate update() { public IUpdate update() {
return update(ClientType.DEPRECATED); return update(ClientType.LEGACY);
} }
@Override @Override
@ -558,7 +543,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override @Override
public IValidate validate() { public IValidate validate() {
return validate(ClientType.DEPRECATED); return validate(ClientType.LEGACY);
} }
@Override @Override
@ -719,7 +704,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
IClientResponseHandler<Z> theHandler, IClientResponseHandler<Z> theHandler,
BaseHttpClientInvocation theInvocation) { BaseHttpClientInvocation theInvocation) {
if (isKeepResponses()) { if (isKeepResponses()) {
// myLastRequest = theInvocation.asHttpRequest(getServerBase(), theParams, getEncoding(), myPrettyPrint);
myLastRequest = theInvocation.asHttpRequest( myLastRequest = theInvocation.asHttpRequest(
new AsHttpRequestParams() new AsHttpRequestParams()
.setUrlBase(getServerBase()) .setUrlBase(getServerBase())

View File

@ -28,7 +28,6 @@ import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory; import ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory;
import ca.uhn.fhir.rest.api.RequestTypeEnum; 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.Header;
import ca.uhn.fhir.rest.client.api.IHttpClient; import ca.uhn.fhir.rest.client.api.IHttpClient;
import ca.uhn.fhir.rest.client.api.IHttpRequest; import ca.uhn.fhir.rest.client.api.IHttpRequest;
@ -191,7 +190,6 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
httpClient.addHeadersToRequest(request, theEncoding, parameters.getFhirContext()); httpClient.addHeadersToRequest(request, theEncoding, parameters.getFhirContext());
request.addHeader(Constants.HEADER_CONTENT_TYPE, contentType + Constants.HEADER_SUFFIX_CT_UTF_8); request.addHeader(Constants.HEADER_CONTENT_TYPE, contentType + Constants.HEADER_SUFFIX_CT_UTF_8);
return request; return request;
// return httpClient.createByteRequest(getContext(), contents, contentType, encoding);
} }
private String getContentType(EncodingEnum encoding) { private String getContentType(EncodingEnum encoding) {

View File

@ -33,8 +33,8 @@ import java.util.Map;
public class HttpDeleteClientInvocation extends BaseHttpClientInvocation { public class HttpDeleteClientInvocation extends BaseHttpClientInvocation {
private String myUrlPath; private final String myUrlPath;
private Map<String, List<String>> myParams; private final Map<String, List<String>> myParams;
public HttpDeleteClientInvocation( public HttpDeleteClientInvocation(
FhirContext theContext, IIdType theId, Map<String, List<String>> theAdditionalParams) { FhirContext theContext, IIdType theId, Map<String, List<String>> theAdditionalParams) {
@ -82,7 +82,6 @@ public class HttpDeleteClientInvocation extends BaseHttpClientInvocation {
appendExtraParamsWithQuestionMark(myParams, b, b.indexOf("?") == -1); appendExtraParamsWithQuestionMark(myParams, b, b.indexOf("?") == -1);
appendExtraParamsWithQuestionMark(theExtraParams, b, b.indexOf("?") == -1); appendExtraParamsWithQuestionMark(theExtraParams, b, b.indexOf("?") == -1);
// return createHttpRequest(b.toString(), theEncoding, RequestTypeEnum.DELETE);
CreateRequestParameters requestParameters = new CreateRequestParameters(); CreateRequestParameters requestParameters = new CreateRequestParameters();
requestParameters.setClient(theParams.getClient()); requestParameters.setClient(theParams.getClient());
requestParameters.setRequestTypeEnum(RequestTypeEnum.DELETE); requestParameters.setRequestTypeEnum(RequestTypeEnum.DELETE);

View File

@ -124,14 +124,12 @@ public class HttpGetClientInvocation extends BaseHttpClientInvocation {
appendExtraParamsWithQuestionMark(theExtraParams, b, first); appendExtraParamsWithQuestionMark(theExtraParams, b, first);
// TODO - pass client down here
CreateRequestParameters createRequestParameters = new CreateRequestParameters() CreateRequestParameters createRequestParameters = new CreateRequestParameters()
.setRequestTypeEnum(RequestTypeEnum.GET) .setRequestTypeEnum(RequestTypeEnum.GET)
.setEncodingEnum(theEncoding) .setEncodingEnum(theEncoding)
.setUrl(b.toString()) .setUrl(b.toString())
.setClient(theAsHttpRequestParams.getClient()); .setClient(theAsHttpRequestParams.getClient());
IHttpRequest retVal = super.createHttpRequest(createRequestParameters); IHttpRequest retVal = super.createHttpRequest(createRequestParameters);
// IHttpRequest retVal = super.createHttpRequest(b.toString(), theEncoding, RequestTypeEnum.GET);
retVal.setUrlSource(myUrlSource); retVal.setUrlSource(myUrlSource);
return retVal; return retVal;

View File

@ -34,10 +34,10 @@ import java.util.Map;
public class HttpPatchClientInvocation extends BaseHttpClientInvocation { public class HttpPatchClientInvocation extends BaseHttpClientInvocation {
private String myUrlPath; private final String myUrlPath;
private Map<String, List<String>> myParams; private Map<String, List<String>> myParams;
private String myContents; private final String myContents;
private String myContentType; private final String myContentType;
public HttpPatchClientInvocation(FhirContext theContext, IIdType theId, String theContentType, String theContents) { public HttpPatchClientInvocation(FhirContext theContext, IIdType theId, String theContentType, String theContents) {
super(theContext); super(theContext);

View File

@ -36,7 +36,7 @@ public class HttpSimpleClientInvocation extends BaseHttpClientInvocation {
private final String myUrl; private final String myUrl;
private UrlSourceEnum myUrlSource = UrlSourceEnum.EXPLICIT; private UrlSourceEnum myUrlSource = UrlSourceEnum.EXPLICIT;
private PagingHttpMethodEnum myPagingHttpMethod; private final PagingHttpMethodEnum myPagingHttpMethod;
public HttpSimpleClientInvocation( public HttpSimpleClientInvocation(
FhirContext theContext, String theUrlPath, PagingHttpMethodEnum thePagingHttpMethod) { FhirContext theContext, String theUrlPath, PagingHttpMethodEnum thePagingHttpMethod) {
@ -63,7 +63,6 @@ public class HttpSimpleClientInvocation extends BaseHttpClientInvocation {
@Override @Override
public IHttpRequest asHttpRequest(AsHttpRequestParams theParams) { public IHttpRequest asHttpRequest(AsHttpRequestParams theParams) {
CreateRequestParameters parameters = new CreateRequestParameters(); CreateRequestParameters parameters = new CreateRequestParameters();
// parameters.setUrl(myUrl == null ? theParams.getUrlBase() : myUrl);
parameters.setUrl(myUrl); parameters.setUrl(myUrl);
parameters.setEncodingEnum(theParams.getEncodingEnum()); parameters.setEncodingEnum(theParams.getEncodingEnum());
parameters.setRequestTypeEnum(myPagingHttpMethod.getRequestType()); parameters.setRequestTypeEnum(myPagingHttpMethod.getRequestType());
@ -71,9 +70,6 @@ public class HttpSimpleClientInvocation extends BaseHttpClientInvocation {
IHttpRequest request = createHttpRequest(parameters); IHttpRequest request = createHttpRequest(parameters);
request.setUrlSource(myUrlSource); request.setUrlSource(myUrlSource);
return request; return request;
// IHttpRequest retVal = createHttpRequest(myUrl, theEncoding, myPagingHttpMethod.getRequestType());
// retVal.setUrlSource(myUrlSource);
// return retVal;
} }
public void setUrlSource(UrlSourceEnum theUrlSource) { public void setUrlSource(UrlSourceEnum theUrlSource) {

View File

@ -9,14 +9,29 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class AsHttpRequestParams { public class AsHttpRequestParams {
/**
* The URL for the request
*/
private String myUrlBase; private String myUrlBase;
/**
* Extra parameters
*/
private Map<String, List<String>> myExtraParams; private Map<String, List<String>> myExtraParams;
/**
* Encoding to use (JSON, fhir+json, etc)
*/
private EncodingEnum myEncodingEnum; private EncodingEnum myEncodingEnum;
/**
* Whether logs should print pretty or not (for request parsing only)
*/
private Boolean myPrettyPrint; private Boolean myPrettyPrint;
/**
* The client to use for this request
*/
private IHttpClient myClient; private IHttpClient myClient;
public String getUrlBase() { public String getUrlBase() {