cleaning up
This commit is contained in:
parent
acab578bc5
commit
afde9df9a6
|
@ -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);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<String, List<String>> 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<String, List<String>> 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<String, List<String>> 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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<? extends IBaseResource>) null, id, allowHtmlResponse);
|
||||
|
||||
if (theNotModifiedHandler == null) {
|
||||
// return invokeClient(
|
||||
// myContext,
|
||||
// binding,
|
||||
// invocation,
|
||||
// theEncoding,
|
||||
// thePrettyPrint,
|
||||
// myLogRequestAndResponse,
|
||||
// theSummary,
|
||||
// theSubsetElements,
|
||||
// null,
|
||||
// theCustomAcceptHeaderValue,
|
||||
// theCustomHeaders);
|
||||
return invokeClient(new InvokeClientParameters<T>()
|
||||
.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<? extends IBaseResource> 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<Z> theHandler,
|
||||
BaseHttpClientInvocation theInvocation) {
|
||||
if (isKeepResponses()) {
|
||||
// myLastRequest = theInvocation.asHttpRequest(getServerBase(), theParams, getEncoding(), myPrettyPrint);
|
||||
myLastRequest = theInvocation.asHttpRequest(
|
||||
new AsHttpRequestParams()
|
||||
.setUrlBase(getServerBase())
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -33,8 +33,8 @@ import java.util.Map;
|
|||
|
||||
public class HttpDeleteClientInvocation extends BaseHttpClientInvocation {
|
||||
|
||||
private String myUrlPath;
|
||||
private Map<String, List<String>> myParams;
|
||||
private final String myUrlPath;
|
||||
private final Map<String, List<String>> myParams;
|
||||
|
||||
public HttpDeleteClientInvocation(
|
||||
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(theExtraParams, b, b.indexOf("?") == -1);
|
||||
|
||||
// return createHttpRequest(b.toString(), theEncoding, RequestTypeEnum.DELETE);
|
||||
CreateRequestParameters requestParameters = new CreateRequestParameters();
|
||||
requestParameters.setClient(theParams.getClient());
|
||||
requestParameters.setRequestTypeEnum(RequestTypeEnum.DELETE);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -34,10 +34,10 @@ import java.util.Map;
|
|||
|
||||
public class HttpPatchClientInvocation extends BaseHttpClientInvocation {
|
||||
|
||||
private String myUrlPath;
|
||||
private final String myUrlPath;
|
||||
private Map<String, List<String>> 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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<String, List<String>> 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() {
|
||||
|
|
Loading…
Reference in New Issue