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 Boolean
BYPASS_AUTH_USER
protected ClassLoader
classLoader
protected KieServicesConfiguration
config
protected LoadBalancer
loadBalancer
protected org.kie.server.api.marshalling.Marshaller
marshaller
protected KieServicesClientImpl
owner
-
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 String
buildQueryString(String paramName, List<?> items)
protected void
checkResultType(org.kie.server.api.model.ServiceResponse<?> serviceResponse, Class<?> expectedResultType)
Checks whether the specifiedServiceResponse
contains the expected result type.protected void
close()
protected RuntimeException
createExceptionForUnexpectedResponseCode(org.kie.server.common.rest.KieServerHttpRequest request, org.kie.server.common.rest.KieServerHttpResponse response)
protected <T> T
deserialize(String content, Class<T> type)
protected String
encode(String value)
protected org.kie.server.api.model.ServiceResponsesList
executeJmsCommand(org.kie.server.api.commands.CommandScript command)
Method to communicate with the backend via JMS.protected org.kie.server.api.model.ServiceResponsesList
executeJmsCommand(org.kie.server.api.commands.CommandScript command, String classType)
protected org.kie.server.api.model.ServiceResponsesList
executeJmsCommand(org.kie.server.api.commands.CommandScript command, String classType, String targetCapability)
protected org.kie.server.api.model.ServiceResponsesList
executeJmsCommand(org.kie.server.api.commands.CommandScript command, String classType, String targetCapability, String containerId)
protected String
getAdditionalParams(String inQueryString, String name, List<?> values)
String
getConversationId()
protected Map<String,String>
getHeaders(Object object)
LoadBalancer
getLoadBalancer()
protected String
getMediaType(org.kie.server.api.marshalling.MarshallingFormat format)
protected String
getMessage(org.kie.server.common.rest.KieServerHttpResponse response)
protected String
getPagingQueryString(String inQueryString, Integer page, Integer pageSize)
ResponseHandler
getResponseHandler()
protected String
getSortingQueryString(String inQueryString, String sort, boolean sortOrder)
protected String
getUserAndAdditionalParam(String userId, String name, String value)
protected String
getUserAndAdditionalParams(String userId, String name, List<?> values)
protected String
getUserAndPagingQueryString(String userId, Integer page, Integer pageSize)
protected String
getUserQueryStr(String userId)
protected String
getUserQueryStr(String userId, char prefix)
protected String
initializeURI(URL url, String servicePrefix)
Initializes the URL that will be used for web service accessprotected org.kie.server.common.rest.KieServerHttpRequest
invoke(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> T
makeHttpDeleteRequestAndCreateCustomResponse(String uri, Class<T> resultType)
protected <T> org.kie.server.api.model.ServiceResponse<T>
makeHttpDeleteRequestAndCreateServiceResponse(String uri, Class<T> resultType)
protected <T> T
makeHttpGetRequestAndCreateCustomResponse(String uri, Class<T> resultType)
protected <T> T
makeHttpGetRequestAndCreateCustomResponseWithHandleNotFound(String uri, Class<T> resultType)
protected String
makeHttpGetRequestAndCreateRawResponse(String uri)
protected String
makeHttpGetRequestAndCreateRawResponse(String uri, Map<String,String> headers)
protected <T> org.kie.server.api.model.ServiceResponse<T>
makeHttpGetRequestAndCreateServiceResponse(String uri, Class<T> resultType)
protected <T> T
makeHttpPostRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType)
protected <T> T
makeHttpPostRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType, Map<String,String> headers)
protected <T> T
makeHttpPostRequestAndCreateCustomResponse(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> T
makeHttpPutRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType, Map<String,String> headers)
protected <T> T
makeHttpPutRequestAndCreateCustomResponse(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.KieServerHttpRequest
newRequest(String uri)
protected List<?>
safeList(List<?> list)
protected Map<?,?>
safeMap(Map<?,?> map)
protected void
sendTaskOperation(String containerId, Long taskId, String operation, String queryString)
protected void
sendTaskOperation(String containerId, Long taskId, String operation, String queryString, Object data)
protected String
serialize(Object object)
void
setOwner(KieServicesClientImpl owner)
void
setResponseHandler(ResponseHandler responseHandler)
protected boolean
shouldReturnWithNullResponse(org.kie.server.api.model.ServiceResponse<?> serviceResponse)
protected void
throwExceptionOnFailure(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
- TheCommand
object to be executed.- Returns:
- The result of the
Command
object 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 specifiedServiceResponse
contains the expected result type. In case the type is different,KieServicesClientException
is thrown. This catches the errors early, before returning the result from the client. Without this check users could experienceClassCastException
when 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()
-
-