Package org.kie.server.client.impl
Class AbstractKieServicesClientImpl
- java.lang.Object
-
- org.kie.server.client.impl.AbstractKieServicesClientImpl
-
- Direct Known Subclasses:
CaseAdminServicesClientImpl,CaseServicesClientImpl,DMNServicesClientImpl,DocumentServicesClientImpl,JobServicesClientImpl,KieServicesClientImpl,ProcessAdminServicesClientImpl,ProcessServicesClientImpl,QueryServicesClientImpl,RuleServicesClientImpl,ScenarioSimulationServicesClientImpl,SolverServicesClientImpl,TaskAssigningRuntimeClientImpl,UIServicesClientImpl,UserTaskAdminServicesClientImpl,UserTaskServicesClientImpl
public abstract class AbstractKieServicesClientImpl extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected static BooleanBYPASS_AUTH_USERprotected ClassLoaderclassLoaderprotected KieServicesConfigurationconfigprotected LoadBalancerloadBalancerprotected org.kie.server.api.marshalling.Marshallermarshallerprotected KieServicesClientImplowner
-
Constructor Summary
Constructors Constructor Description AbstractKieServicesClientImpl(KieServicesConfiguration config)AbstractKieServicesClientImpl(KieServicesConfiguration config, ClassLoader classLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringbuildQueryString(String paramName, List<?> items)protected voidcheckResultType(org.kie.server.api.model.ServiceResponse<?> serviceResponse, Class<?> expectedResultType)Checks whether the specifiedServiceResponsecontains the expected result type.protected voidclose()protected RuntimeExceptioncreateExceptionForUnexpectedResponseCode(org.kie.server.common.rest.KieServerHttpRequest request, org.kie.server.common.rest.KieServerHttpResponse response)protected <T> Tdeserialize(String content, Class<T> type)protected Stringencode(String value)protected org.kie.server.api.model.ServiceResponsesListexecuteJmsCommand(org.kie.server.api.commands.CommandScript command)Method to communicate with the backend via JMS.protected org.kie.server.api.model.ServiceResponsesListexecuteJmsCommand(org.kie.server.api.commands.CommandScript command, String classType)protected org.kie.server.api.model.ServiceResponsesListexecuteJmsCommand(org.kie.server.api.commands.CommandScript command, String classType, String targetCapability)protected org.kie.server.api.model.ServiceResponsesListexecuteJmsCommand(org.kie.server.api.commands.CommandScript command, String classType, String targetCapability, String containerId)protected StringgetAdditionalParams(String inQueryString, String name, List<?> values)StringgetConversationId()protected Map<String,String>getHeaders(Object object)LoadBalancergetLoadBalancer()protected StringgetMediaType(org.kie.server.api.marshalling.MarshallingFormat format)protected StringgetMessage(org.kie.server.common.rest.KieServerHttpResponse response)protected StringgetPagingQueryString(String inQueryString, Integer page, Integer pageSize)ResponseHandlergetResponseHandler()protected StringgetSortingQueryString(String inQueryString, String sort, boolean sortOrder)protected StringgetUserAndAdditionalParam(String userId, String name, String value)protected StringgetUserAndAdditionalParams(String userId, String name, List<?> values)protected StringgetUserAndPagingQueryString(String userId, Integer page, Integer pageSize)protected StringgetUserQueryStr(String userId)protected StringgetUserQueryStr(String userId, char prefix)protected StringinitializeURI(URL url, String servicePrefix)Initializes the URL that will be used for web service accessprotected org.kie.server.common.rest.KieServerHttpRequestinvoke(String url, org.kie.server.client.impl.AbstractKieServicesClientImpl.RemoteHttpOperation operation)protected <T> org.kie.server.api.model.ServiceResponse<T>makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(String uri, Object body, Class<T> resultType, Map<String,String> headers)protected <T> org.kie.server.api.model.ServiceResponse<T>makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(String uri, Object body, Class<T> resultType, Map<String,String> headers, javax.ws.rs.core.Response.Status expectedStatus)protected <T> org.kie.server.api.model.ServiceResponse<T>makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(String uri, String body, Class<T> resultType)protected <T> TmakeHttpDeleteRequestAndCreateCustomResponse(String uri, Class<T> resultType)protected <T> org.kie.server.api.model.ServiceResponse<T>makeHttpDeleteRequestAndCreateServiceResponse(String uri, Class<T> resultType)protected <T> TmakeHttpGetRequestAndCreateCustomResponse(String uri, Class<T> resultType)protected <T> TmakeHttpGetRequestAndCreateCustomResponseWithHandleNotFound(String uri, Class<T> resultType)protected StringmakeHttpGetRequestAndCreateRawResponse(String uri)protected StringmakeHttpGetRequestAndCreateRawResponse(String uri, Map<String,String> headers)protected <T> org.kie.server.api.model.ServiceResponse<T>makeHttpGetRequestAndCreateServiceResponse(String uri, Class<T> resultType)protected <T> TmakeHttpPostRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType)protected <T> TmakeHttpPostRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType, Map<String,String> headers)protected <T> TmakeHttpPostRequestAndCreateCustomResponse(String uri, String body, Class<T> resultType, Map<String,String> headers)protected <T> org.kie.server.api.model.ServiceResponse<T>makeHttpPostRequestAndCreateServiceResponse(String uri, Object bodyObject, Class<T> resultType)protected <T> org.kie.server.api.model.ServiceResponse<T>makeHttpPostRequestAndCreateServiceResponse(String uri, Object bodyObject, Class<T> resultType, Map<String,String> headers)protected <T> org.kie.server.api.model.ServiceResponse<T>makeHttpPostRequestAndCreateServiceResponse(String uri, Object bodyObject, Class<T> resultType, Map<String,String> headers, javax.ws.rs.core.Response.Status status)protected <T> org.kie.server.api.model.ServiceResponse<T>makeHttpPostRequestAndCreateServiceResponse(String uri, String body, Class<T> resultType)protected <T> org.kie.server.api.model.ServiceResponse<T>makeHttpPostRequestAndCreateServiceResponse(String uri, String body, Class<T> resultType, Map<String,String> headers)protected <T> org.kie.server.api.model.ServiceResponse<T>makeHttpPostRequestAndCreateServiceResponse(String uri, String body, Class<T> resultType, Map<String,String> headers, javax.ws.rs.core.Response.Status status)protected <T> TmakeHttpPutRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType, Map<String,String> headers)protected <T> TmakeHttpPutRequestAndCreateCustomResponse(String uri, String body, Class<T> resultType, Map<String,String> headers)protected <T> org.kie.server.api.model.ServiceResponse<T>makeHttpPutRequestAndCreateServiceResponse(String uri, Object bodyObject, Class<T> resultType)protected <T> org.kie.server.api.model.ServiceResponse<T>makeHttpPutRequestAndCreateServiceResponse(String uri, String body, Class<T> resultType)protected org.kie.server.common.rest.KieServerHttpRequestnewRequest(String uri)protected List<?>safeList(List<?> list)protected Map<?,?>safeMap(Map<?,?> map)protected voidsendTaskOperation(String containerId, Long taskId, String operation, String queryString)protected voidsendTaskOperation(String containerId, Long taskId, String operation, String queryString, Object data)protected Stringserialize(Object object)voidsetOwner(KieServicesClientImpl owner)voidsetResponseHandler(ResponseHandler responseHandler)protected booleanshouldReturnWithNullResponse(org.kie.server.api.model.ServiceResponse<?> serviceResponse)protected voidthrowExceptionOnFailure(org.kie.server.api.model.ServiceResponse<?> serviceResponse)
-
-
-
Field Detail
-
BYPASS_AUTH_USER
protected static final Boolean BYPASS_AUTH_USER
-
loadBalancer
protected LoadBalancer loadBalancer
-
config
protected final KieServicesConfiguration config
-
marshaller
protected final org.kie.server.api.marshalling.Marshaller marshaller
-
classLoader
protected ClassLoader classLoader
-
owner
protected KieServicesClientImpl owner
-
-
Constructor Detail
-
AbstractKieServicesClientImpl
public AbstractKieServicesClientImpl(KieServicesConfiguration config)
-
AbstractKieServicesClientImpl
public AbstractKieServicesClientImpl(KieServicesConfiguration config, ClassLoader classLoader)
-
-
Method Detail
-
initializeURI
protected String initializeURI(URL url, String servicePrefix)
Initializes the URL that will be used for web service access- Parameters:
url- URL of the server instance- Returns:
- An URL that can be used for the web services
-
setOwner
public void setOwner(KieServicesClientImpl owner)
-
getLoadBalancer
public LoadBalancer getLoadBalancer()
-
getResponseHandler
public ResponseHandler getResponseHandler()
-
setResponseHandler
public void setResponseHandler(ResponseHandler responseHandler)
-
throwExceptionOnFailure
protected void throwExceptionOnFailure(org.kie.server.api.model.ServiceResponse<?> serviceResponse)
-
shouldReturnWithNullResponse
protected boolean shouldReturnWithNullResponse(org.kie.server.api.model.ServiceResponse<?> serviceResponse)
-
sendTaskOperation
protected void sendTaskOperation(String containerId, Long taskId, String operation, String queryString)
-
sendTaskOperation
protected void sendTaskOperation(String containerId, Long taskId, String operation, String queryString, Object data)
-
makeHttpGetRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeHttpGetRequestAndCreateServiceResponse(String uri, Class<T> resultType)
-
makeHttpGetRequestAndCreateCustomResponse
protected <T> T makeHttpGetRequestAndCreateCustomResponse(String uri, Class<T> resultType)
-
makeHttpGetRequestAndCreateCustomResponseWithHandleNotFound
protected <T> T makeHttpGetRequestAndCreateCustomResponseWithHandleNotFound(String uri, Class<T> resultType)
-
makeHttpGetRequestAndCreateRawResponse
protected String makeHttpGetRequestAndCreateRawResponse(String uri)
-
makeHttpGetRequestAndCreateRawResponse
protected String makeHttpGetRequestAndCreateRawResponse(String uri, Map<String,String> headers)
-
makeHttpPostRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeHttpPostRequestAndCreateServiceResponse(String uri, Object bodyObject, Class<T> resultType)
-
makeHttpPostRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeHttpPostRequestAndCreateServiceResponse(String uri, Object bodyObject, Class<T> resultType, Map<String,String> headers)
-
makeHttpPostRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeHttpPostRequestAndCreateServiceResponse(String uri, Object bodyObject, Class<T> resultType, Map<String,String> headers, javax.ws.rs.core.Response.Status status)
-
makeHttpPostRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeHttpPostRequestAndCreateServiceResponse(String uri, String body, Class<T> resultType)
-
makeHttpPostRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeHttpPostRequestAndCreateServiceResponse(String uri, String body, Class<T> resultType, Map<String,String> headers)
-
makeHttpPostRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeHttpPostRequestAndCreateServiceResponse(String uri, String body, Class<T> resultType, Map<String,String> headers, javax.ws.rs.core.Response.Status status)
-
makeHttpPostRequestAndCreateCustomResponse
protected <T> T makeHttpPostRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType, Map<String,String> headers)
-
makeHttpPostRequestAndCreateCustomResponse
protected <T> T makeHttpPostRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType)
-
makeHttpPostRequestAndCreateCustomResponse
protected <T> T makeHttpPostRequestAndCreateCustomResponse(String uri, String body, Class<T> resultType, Map<String,String> headers)
-
makeHttpPutRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeHttpPutRequestAndCreateServiceResponse(String uri, Object bodyObject, Class<T> resultType)
-
makeHttpPutRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeHttpPutRequestAndCreateServiceResponse(String uri, String body, Class<T> resultType)
-
makeHttpPutRequestAndCreateCustomResponse
protected <T> T makeHttpPutRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType, Map<String,String> headers)
-
makeHttpPutRequestAndCreateCustomResponse
protected <T> T makeHttpPutRequestAndCreateCustomResponse(String uri, String body, Class<T> resultType, Map<String,String> headers)
-
makeHttpDeleteRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeHttpDeleteRequestAndCreateServiceResponse(String uri, Class<T> resultType)
-
makeHttpDeleteRequestAndCreateCustomResponse
protected <T> T makeHttpDeleteRequestAndCreateCustomResponse(String uri, Class<T> resultType)
-
newRequest
protected org.kie.server.common.rest.KieServerHttpRequest newRequest(String uri)
-
executeJmsCommand
protected org.kie.server.api.model.ServiceResponsesList executeJmsCommand(org.kie.server.api.commands.CommandScript command)
Method to communicate with the backend via JMS.- Parameters:
command- TheCommandobject to be executed.- Returns:
- The result of the
Commandobject execution.
-
executeJmsCommand
protected org.kie.server.api.model.ServiceResponsesList executeJmsCommand(org.kie.server.api.commands.CommandScript command, String classType)
-
executeJmsCommand
protected org.kie.server.api.model.ServiceResponsesList executeJmsCommand(org.kie.server.api.commands.CommandScript command, String classType, String targetCapability)
-
executeJmsCommand
protected org.kie.server.api.model.ServiceResponsesList executeJmsCommand(org.kie.server.api.commands.CommandScript command, String classType, String targetCapability, String containerId)
-
getMediaType
protected String getMediaType(org.kie.server.api.marshalling.MarshallingFormat format)
-
checkResultType
protected void checkResultType(org.kie.server.api.model.ServiceResponse<?> serviceResponse, Class<?> expectedResultType)Checks whether the specifiedServiceResponsecontains the expected result type. In case the type is different,KieServicesClientExceptionis thrown. This catches the errors early, before returning the result from the client. Without this check users could experienceClassCastExceptionwhen retrieving the result that does not have the expected type.
-
createExceptionForUnexpectedResponseCode
protected RuntimeException createExceptionForUnexpectedResponseCode(org.kie.server.common.rest.KieServerHttpRequest request, org.kie.server.common.rest.KieServerHttpResponse response)
-
getMessage
protected String getMessage(org.kie.server.common.rest.KieServerHttpResponse response)
-
getUserAndPagingQueryString
protected String getUserAndPagingQueryString(String userId, Integer page, Integer pageSize)
-
getUserAndAdditionalParam
protected String getUserAndAdditionalParam(String userId, String name, String value)
-
getUserAndAdditionalParams
protected String getUserAndAdditionalParams(String userId, String name, List<?> values)
-
getPagingQueryString
protected String getPagingQueryString(String inQueryString, Integer page, Integer pageSize)
-
getSortingQueryString
protected String getSortingQueryString(String inQueryString, String sort, boolean sortOrder)
-
getAdditionalParams
protected String getAdditionalParams(String inQueryString, String name, List<?> values)
-
makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(String uri, Object body, Class<T> resultType, Map<String,String> headers)
-
makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(String uri, Object body, Class<T> resultType, Map<String,String> headers, javax.ws.rs.core.Response.Status expectedStatus)
-
makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse
protected <T> org.kie.server.api.model.ServiceResponse<T> makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(String uri, String body, Class<T> resultType)
-
getConversationId
public String getConversationId()
-
invoke
protected org.kie.server.common.rest.KieServerHttpRequest invoke(String url, org.kie.server.client.impl.AbstractKieServicesClientImpl.RemoteHttpOperation operation)
-
close
protected void close()
-
-