spotless
This commit is contained in:
parent
534de22b04
commit
0110242f6f
|
@ -28,7 +28,6 @@ import ca.uhn.fhir.rest.client.api.HttpClientUtil;
|
||||||
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;
|
||||||
import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation;
|
import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation;
|
||||||
import ca.uhn.fhir.rest.client.impl.RestfulClientFactory;
|
|
||||||
import ca.uhn.fhir.rest.client.method.MethodUtil;
|
import ca.uhn.fhir.rest.client.method.MethodUtil;
|
||||||
import ca.uhn.fhir.rest.param.HttpClientRequestParameters;
|
import ca.uhn.fhir.rest.param.HttpClientRequestParameters;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
|
@ -88,11 +87,7 @@ public class OkHttpRestfulClient implements IHttpClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBaseRequest(
|
private void initBaseRequest(
|
||||||
FhirContext theContext,
|
FhirContext theContext, EncodingEnum theEncoding, RequestBody body, RequestTypeEnum theRequestType) {
|
||||||
EncodingEnum theEncoding,
|
|
||||||
RequestBody body,
|
|
||||||
RequestTypeEnum theRequestType
|
|
||||||
) {
|
|
||||||
RequestTypeEnum requestType = theRequestType != null ? theRequestType : myRequestType;
|
RequestTypeEnum requestType = theRequestType != null ? theRequestType : myRequestType;
|
||||||
String sanitisedUrl = withTrailingQuestionMarkRemoved(myUrl.toString());
|
String sanitisedUrl = withTrailingQuestionMarkRemoved(myUrl.toString());
|
||||||
myRequest = new OkHttpRestfulRequest(myClient, sanitisedUrl, requestType, body);
|
myRequest = new OkHttpRestfulRequest(myClient, sanitisedUrl, requestType, body);
|
||||||
|
@ -123,7 +118,11 @@ public class OkHttpRestfulClient implements IHttpClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IHttpRequest createBinaryRequest(FhirContext theContext, IBaseBinary theBinary) {
|
public IHttpRequest createBinaryRequest(FhirContext theContext, IBaseBinary theBinary) {
|
||||||
initBaseRequest(theContext, null, createPostBody(theBinary.getContent(), theBinary.getContentType()), RequestTypeEnum.POST);
|
initBaseRequest(
|
||||||
|
theContext,
|
||||||
|
null,
|
||||||
|
createPostBody(theBinary.getContent(), theBinary.getContentType()),
|
||||||
|
RequestTypeEnum.POST);
|
||||||
return myRequest;
|
return myRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,25 +142,29 @@ public class OkHttpRestfulClient implements IHttpClient {
|
||||||
switch (theParameters.getRequestTypeEnum()) {
|
switch (theParameters.getRequestTypeEnum()) {
|
||||||
case POST:
|
case POST:
|
||||||
case PUT:
|
case PUT:
|
||||||
if (theParameters.getFormParams() != null && !theParameters.getFormParams().isEmpty()) {
|
if (theParameters.getFormParams() != null
|
||||||
|
&& !theParameters.getFormParams().isEmpty()) {
|
||||||
requestBody = getFormBodyFromParams(theParameters.getFormParams());
|
requestBody = getFormBodyFromParams(theParameters.getFormParams());
|
||||||
} else if (theParameters.getByteContents() != null) {
|
} else if (theParameters.getByteContents() != null) {
|
||||||
requestBody = createPostBody(theParameters.getByteContents(), theParameters.getContentType());
|
requestBody = createPostBody(theParameters.getByteContents(), theParameters.getContentType());
|
||||||
} else if (isNotBlank(theParameters.getContents())) {
|
} else if (isNotBlank(theParameters.getContents())) {
|
||||||
requestBody = createPostBody(theParameters.getContents(), theParameters.getContentType());
|
requestBody = createPostBody(theParameters.getContents(), theParameters.getContentType());
|
||||||
} else if (theParameters.getBaseBinary() != null) {
|
} else if (theParameters.getBaseBinary() != null) {
|
||||||
requestBody = createPostBody(theParameters.getBaseBinary().getContent(), theParameters.getContentType());
|
requestBody =
|
||||||
|
createPostBody(theParameters.getBaseBinary().getContent(), theParameters.getContentType());
|
||||||
} else {
|
} else {
|
||||||
ourLog.debug("No body contents found for HTTP-{}", theParameters.getRequestTypeEnum().name());
|
ourLog.debug(
|
||||||
|
"No body contents found for HTTP-{}",
|
||||||
|
theParameters.getRequestTypeEnum().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
initBaseRequest(
|
initBaseRequest(
|
||||||
theParameters.getFhirContext(),
|
theParameters.getFhirContext(),
|
||||||
theParameters.getEncodingEnum(),
|
theParameters.getEncodingEnum(),
|
||||||
requestBody,
|
requestBody,
|
||||||
theParameters.getRequestTypeEnum());
|
theParameters.getRequestTypeEnum());
|
||||||
return myRequest;
|
return myRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +174,8 @@ public class OkHttpRestfulClient implements IHttpClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNewUrl(StringBuilder theUrl, String theIfNoneExistString, Map<String, List<String>> theIfNoneExistParams) {
|
public void setNewUrl(
|
||||||
|
StringBuilder theUrl, String theIfNoneExistString, Map<String, List<String>> theIfNoneExistParams) {
|
||||||
myUrl = theUrl;
|
myUrl = theUrl;
|
||||||
myIfNoneExistString = theIfNoneExistString;
|
myIfNoneExistString = theIfNoneExistString;
|
||||||
myIfNoneExistParams = theIfNoneExistParams;
|
myIfNoneExistParams = theIfNoneExistParams;
|
||||||
|
|
|
@ -60,7 +60,8 @@ public abstract class BaseHttpClient implements IHttpClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNewUrl(StringBuilder theUrl, String theIfNoneExistString, Map<String, List<String>> theIfNoneExistParams) {
|
public void setNewUrl(
|
||||||
|
StringBuilder theUrl, String theIfNoneExistString, Map<String, List<String>> theIfNoneExistParams) {
|
||||||
myUrl = theUrl;
|
myUrl = theUrl;
|
||||||
myIfNoneExistString = theIfNoneExistString;
|
myIfNoneExistString = theIfNoneExistString;
|
||||||
myIfNoneExistParams = theIfNoneExistParams;
|
myIfNoneExistParams = theIfNoneExistParams;
|
||||||
|
|
|
@ -118,7 +118,8 @@ public class HttpPatchClientInvocation extends BaseHttpClientInvocation {
|
||||||
client.setNewUrl(new StringBuilder(theParameters.getUrl()), null, null);
|
client.setNewUrl(new StringBuilder(theParameters.getUrl()), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpClientRequestParameters params = new HttpClientRequestParameters(theParameters.getUrl(), RequestTypeEnum.PATCH);
|
HttpClientRequestParameters params =
|
||||||
|
new HttpClientRequestParameters(theParameters.getUrl(), RequestTypeEnum.PATCH);
|
||||||
params.setContents(myContents);
|
params.setContents(myContents);
|
||||||
params.setContentType(myContentType);
|
params.setContentType(myContentType);
|
||||||
params.setFhirContext(getContext());
|
params.setFhirContext(getContext());
|
||||||
|
|
|
@ -166,7 +166,8 @@ public class JaxRsHttpClient implements IHttpClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNewUrl(StringBuilder theUrl, String theIfNoneExistString, Map<String, List<String>> theIfNoneExistParams) {
|
public void setNewUrl(
|
||||||
|
StringBuilder theUrl, String theIfNoneExistString, Map<String, List<String>> theIfNoneExistParams) {
|
||||||
myUrl = theUrl;
|
myUrl = theUrl;
|
||||||
myIfNoneExistString = theIfNoneExistString;
|
myIfNoneExistString = theIfNoneExistString;
|
||||||
myIfNoneExistParams = theIfNoneExistParams;
|
myIfNoneExistParams = theIfNoneExistParams;
|
||||||
|
|
Loading…
Reference in New Issue