use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.
the class WebSocketKieServerClient method updateScanner.
@Override
public ServiceResponse<KieScannerResource> updateScanner(String id, KieScannerResource resource) {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new UpdateScannerCommand(id, resource)));
ServiceResponse<KieScannerResource> response = (ServiceResponse<KieScannerResource>) sendCommandToAllSessions(script, new WebSocketServiceResponse(true, (message) -> {
ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
return list.getResponses().get(0);
})).getResponses().get(0);
return response;
}
use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.
the class CommandScriptMessageHandler method onMessage.
@Override
public String onMessage(String message) {
CommandScript script = deserialize(message, CommandScript.class);
String capability = TARGET_CAPABILITY;
boolean hasBPMCommand = script.getCommands().stream().anyMatch(cmd -> cmd instanceof DescriptorCommand);
if (hasBPMCommand) {
capability = KieServerConstants.CAPABILITY_BPM;
}
KieContainerCommandService<?> executor = null;
for (KieServerExtension extension : context.getServerExtensions()) {
KieContainerCommandService<?> tmp = extension.getAppComponents(KieContainerCommandService.class);
if (tmp != null && extension.getImplementedCapability().equalsIgnoreCase(capability)) {
executor = tmp;
logger.debug("Extension {} returned command executor {} with capability {}", extension, executor, extension.getImplementedCapability());
break;
}
}
if (executor == null) {
throw new IllegalStateException("No executor found for script execution");
}
// 4. process request
ServiceResponsesList response = executor.executeScript(script, MarshallingFormat.JSON, null);
String reply = serialize(response);
return reply;
}
use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.
the class WebSocketKieServerClient method getServerInfo.
@Override
public ServiceResponse<KieServerInfo> getServerInfo() {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new GetServerInfoCommand()));
ServiceResponse<KieServerInfo> response = (ServiceResponse<KieServerInfo>) sendCommand(script, new WebSocketServiceResponse(true, (message) -> {
ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
return list.getResponses().get(0);
})).getResponses().get(0);
return response;
}
use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.
the class WebSocketKieServerClient method listContainers.
@Override
public ServiceResponse<KieContainerResourceList> listContainers(KieContainerResourceFilter containerFilter) {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new ListContainersCommand(containerFilter)));
ServiceResponse<KieContainerResourceList> response = (ServiceResponse<KieContainerResourceList>) sendCommand(script, new WebSocketServiceResponse(true, (message) -> {
ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
return list.getResponses().get(0);
})).getResponses().get(0);
return response;
}
use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.
the class WebSocketKieServerClient method disposeContainer.
@Override
public ServiceResponse<Void> disposeContainer(String id) {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DisposeContainerCommand(id)));
ServiceResponse<Void> response = (ServiceResponse<Void>) sendCommandToAllSessions(script, new WebSocketServiceResponse(true, (message) -> {
ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
return list.getResponses().get(0);
})).getResponses().get(0);
return response;
}
Aggregations