Search in sources :

Example 76 with KieServerCommand

use of org.kie.server.api.model.KieServerCommand 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 77 with KieServerCommand

use of org.kie.server.api.model.KieServerCommand 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 78 with KieServerCommand

use of org.kie.server.api.model.KieServerCommand 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 79 with KieServerCommand

use of org.kie.server.api.model.KieServerCommand 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 80 with KieServerCommand

use of org.kie.server.api.model.KieServerCommand 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

KieServerCommand (org.kie.server.api.model.KieServerCommand)262 ServiceResponse (org.kie.server.api.model.ServiceResponse)260 CommandScript (org.kie.server.api.commands.CommandScript)256 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)234 HashMap (java.util.HashMap)217 Wrapped (org.kie.server.api.model.Wrapped)31 ArrayList (java.util.ArrayList)27 ServiceResponsesList (org.kie.server.api.model.ServiceResponsesList)18 ProcessInstanceList (org.kie.server.api.model.instance.ProcessInstanceList)18 TaskSummaryList (org.kie.server.api.model.instance.TaskSummaryList)16 NodeInstanceList (org.kie.server.api.model.instance.NodeInstanceList)14 WebSocketServiceResponse (org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse)10 KieContainerResource (org.kie.server.api.model.KieContainerResource)9 ExecutionErrorInstanceList (org.kie.server.api.model.admin.ExecutionErrorInstanceList)8 ProcessDefinitionList (org.kie.server.api.model.definition.ProcessDefinitionList)8 VariableInstanceList (org.kie.server.api.model.instance.VariableInstanceList)8 RequestInfoInstanceList (org.kie.server.api.model.instance.RequestInfoInstanceList)7 CallContainerCommand (org.kie.server.api.commands.CallContainerCommand)6 CaseInstanceList (org.kie.server.api.model.cases.CaseInstanceList)6 Map (java.util.Map)5