use of org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand in project droolsjbpm-integration by kiegroup.
the class WebSocketKieServerControllerClient method sendCommand.
private <T> T sendCommand(final String service, final String method, final Object... arguments) {
final KieServerControllerDescriptorCommand command = new KieServerControllerDescriptorCommand(service, method, arguments);
LOGGER.debug("About to send descriptor command to kie server controller: {}", command);
final String content = WebSocketUtils.marshal(command);
LOGGER.debug("Content to be sent over Web Socket '{}'", content);
try {
final WebSocketServiceResponse response = getMessageHandler();
client.sendTextWithInternalHandler(content, response);
LOGGER.debug("Message successfully sent to kie server controller");
if (response.getType() == ResponseType.FAILURE) {
throw new KieServerControllerClientException(response.getMsg());
} else {
return (T) response.getResult();
}
} catch (KieServerControllerClientException e) {
LOGGER.warn("Received Web Socket service error with message: {}", e.getMessage());
throw e;
} catch (Exception e) {
LOGGER.error("Error trying to send message to kie server controller", e);
throw new KieServerControllerClientException(e);
}
}
use of org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand in project droolsjbpm-integration by kiegroup.
the class KieServerMgmtCommandServiceImplTest method testStartScanner.
@Test
public void testStartScanner() {
final ContainerSpecKey containerSpecKey = new ContainerSpecKey("id", "name", new ServerTemplateKey("serverTemplateId", "stname"));
KieServerControllerDescriptorCommand command = new KieServerControllerDescriptorCommand(RuleCapabilitiesService.class.getName(), "startScanner", null, null, containerSpecKey, new Long(1));
final String content = WebSocketUtils.marshal(command);
LOGGER.debug("JSON content\n{}", content);
KieServerControllerServiceResponse response = service.executeCommand(WebSocketUtils.unmarshal(content, KieServerControllerDescriptorCommand.class));
assertNotNull(response);
assertEquals(FAILURE, response.getType());
assertEquals("No server template found for id serverTemplateId", response.getMsg());
assertNull(response.getResult());
}
use of org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand in project droolsjbpm-integration by kiegroup.
the class KieServerMgmtCommandServiceImplTest method testCommandWithDomainArguments.
@Test
public void testCommandWithDomainArguments() {
final ContainerSpec containerSpec = new ContainerSpec();
containerSpec.setId(CONTAINER_SPEC_ID);
containerSpec.setContainerName(CONTAINER_SPEC_NAME);
KieServerControllerDescriptorCommand command = new KieServerControllerDescriptorCommand(SpecManagementService.class.getName(), "saveContainerSpec", null, null, "templateId", containerSpec);
final String content = WebSocketUtils.marshal(command);
LOGGER.debug("JSON content\n{}", content);
KieServerControllerServiceResponse response = service.executeCommand(WebSocketUtils.unmarshal(content, KieServerControllerDescriptorCommand.class));
assertNotNull(response);
assertEquals(response.getMsg(), SUCCESS, response.getType());
assertNull(response.getResult());
}
use of org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand in project droolsjbpm-integration by kiegroup.
the class KieServerMgmtCommandServiceImplTest method testCommandUpgradeContainer.
@Test
public void testCommandUpgradeContainer() {
final ContainerSpecKey serverTemplate = new ContainerSpecKey("id", "name", new ServerTemplateKey("stid", "stname"));
final ReleaseId releaseId = new ReleaseId("group", "artifact", "version");
KieServerControllerDescriptorCommand command = new KieServerControllerDescriptorCommand(RuleCapabilitiesService.class.getName(), "upgradeContainer", serverTemplate, releaseId);
final String content = WebSocketUtils.marshal(command);
LOGGER.debug("JSON content\n{}", content);
KieServerControllerServiceResponse response = service.executeCommand(WebSocketUtils.unmarshal(content, KieServerControllerDescriptorCommand.class));
assertNotNull(response);
assertEquals(FAILURE, response.getType());
assertEquals("No server template found for id stid", response.getMsg());
assertNull(response.getResult());
}
use of org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand in project droolsjbpm-integration by kiegroup.
the class KieServerMgmtCommandServiceImplTest method testInvalidService.
@Test
public void testInvalidService() {
final KieServerControllerServiceResponse response = service.executeCommand(new KieServerControllerDescriptorCommand("service", "method"));
assertNotNull(response);
assertEquals(FAILURE, response.getType());
}
Aggregations