Search in sources :

Example 96 with ServiceResponse

use of org.kie.server.api.model.ServiceResponse in project droolsjbpm-integration by kiegroup.

the class JobServicesClientImpl method cancelRequest.

@Override
public void cancelRequest(String containerId, long requestId) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(JOB_ID, requestId);
        String queryString = "";
        if (containerId != null && !containerId.isEmpty()) {
            queryString = "?containerId=" + containerId;
        }
        makeHttpDeleteRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), JOB_URI + "/" + CANCEL_JOB_DEL_URI, valuesMap) + queryString, null);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("JobService", "cancelRequest", new Object[] { requestId })));
        ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
    }
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 97 with ServiceResponse

use of org.kie.server.api.model.ServiceResponse in project droolsjbpm-integration by kiegroup.

the class KieServicesClientImpl method listContainers.

@Override
public ServiceResponse<KieContainerResourceList> listContainers(KieContainerResourceFilter containerFilter) {
    if (config.isRest()) {
        String queryParams = containerFilter.toURLQueryString();
        String uri = loadBalancer.getUrl() + "/containers" + (queryParams.isEmpty() ? "" : "?" + queryParams);
        return makeHttpGetRequestAndCreateServiceResponse(uri, KieContainerResourceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new ListContainersCommand(containerFilter)));
        ServiceResponse<KieContainerResourceList> response = (ServiceResponse<KieContainerResourceList>) executeJmsCommand(script).getResponses().get(0);
        return getResponseOrNullIfNoResponse(response);
    }
}
Also used : ListContainersCommand(org.kie.server.api.commands.ListContainersCommand) KieContainerResourceList(org.kie.server.api.model.KieContainerResourceList) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) CommandScript(org.kie.server.api.commands.CommandScript)

Example 98 with ServiceResponse

use of org.kie.server.api.model.ServiceResponse in project droolsjbpm-integration by kiegroup.

the class KieServicesClientImpl method updateScanner.

@Override
public ServiceResponse<KieScannerResource> updateScanner(String id, KieScannerResource resource) {
    if (config.isRest()) {
        return makeHttpPostRequestAndCreateServiceResponse(loadBalancer.getUrl() + "/containers/" + id + "/scanner", resource, KieScannerResource.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new UpdateScannerCommand(id, resource)));
        ServiceResponse<KieScannerResource> response = (ServiceResponse<KieScannerResource>) executeJmsCommand(script, null, null, id).getResponses().get(0);
        return getResponseOrNullIfNoResponse(response);
    }
}
Also used : ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) UpdateScannerCommand(org.kie.server.api.commands.UpdateScannerCommand) KieScannerResource(org.kie.server.api.model.KieScannerResource) CommandScript(org.kie.server.api.commands.CommandScript)

Example 99 with ServiceResponse

use of org.kie.server.api.model.ServiceResponse in project droolsjbpm-integration by kiegroup.

the class KieServicesClientImpl method executeCommands.

/**
 * This method is deprecated on KieServicesClient as it was moved to RuleServicesClient
 *
 * @see RuleServicesClient#executeCommands(String, Command)
 * @deprecated
 */
@Deprecated
@Override
public ServiceResponse<String> executeCommands(String id, Command<?> cmd, Status status) {
    if (config.isRest()) {
        return makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(loadBalancer.getUrl() + "/containers/instances/" + id, cmd, String.class, getHeaders(cmd), status);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new CallContainerCommand(id, serialize(cmd))));
        ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, cmd.getClass().getName(), null, id).getResponses().get(0);
        return getResponseOrNullIfNoResponse(response);
    }
}
Also used : CallContainerCommand(org.kie.server.api.commands.CallContainerCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) CommandScript(org.kie.server.api.commands.CommandScript)

Example 100 with ServiceResponse

use of org.kie.server.api.model.ServiceResponse in project droolsjbpm-integration by kiegroup.

the class KieServicesClientImpl method disposeContainer.

@Override
public ServiceResponse<Void> disposeContainer(String id) {
    if (config.isRest()) {
        return makeHttpDeleteRequestAndCreateServiceResponse(loadBalancer.getUrl() + "/containers/" + id, Void.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DisposeContainerCommand(id)));
        ServiceResponse<Void> response = (ServiceResponse<Void>) executeJmsCommand(script, null, null, id).getResponses().get(0);
        return getResponseOrNullIfNoResponse(response);
    }
}
Also used : ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) CommandScript(org.kie.server.api.commands.CommandScript) DisposeContainerCommand(org.kie.server.api.commands.DisposeContainerCommand)

Aggregations

ServiceResponse (org.kie.server.api.model.ServiceResponse)315 CommandScript (org.kie.server.api.commands.CommandScript)269 KieServerCommand (org.kie.server.api.model.KieServerCommand)261 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)234 HashMap (java.util.HashMap)224 ArrayList (java.util.ArrayList)41 Wrapped (org.kie.server.api.model.Wrapped)32 ServiceResponsesList (org.kie.server.api.model.ServiceResponsesList)23 KieContainerResource (org.kie.server.api.model.KieContainerResource)18 ProcessInstanceList (org.kie.server.api.model.instance.ProcessInstanceList)18 TaskSummaryList (org.kie.server.api.model.instance.TaskSummaryList)17 NodeInstanceList (org.kie.server.api.model.instance.NodeInstanceList)15 Map (java.util.Map)13 Message (org.kie.server.api.model.Message)13 WebSocketServiceResponse (org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse)13 Test (org.junit.Test)11 List (java.util.List)9 ReleaseId (org.kie.server.api.model.ReleaseId)9 ProcessDefinitionList (org.kie.server.api.model.definition.ProcessDefinitionList)9 ExecutionErrorInstanceList (org.kie.server.api.model.admin.ExecutionErrorInstanceList)8