Search in sources :

Example 1 with KieServerControllerDescriptorCommand

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);
    }
}
Also used : WebSocketServiceResponse(org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse) KieServerControllerDescriptorCommand(org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand) KieServerControllerClientException(org.kie.server.controller.client.exception.KieServerControllerClientException) KieServerControllerClientException(org.kie.server.controller.client.exception.KieServerControllerClientException) IOException(java.io.IOException)

Example 2 with KieServerControllerDescriptorCommand

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());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) RuleCapabilitiesService(org.kie.server.controller.api.service.RuleCapabilitiesService) KieServerControllerDescriptorCommand(org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand) KieServerControllerServiceResponse(org.kie.server.controller.api.model.KieServerControllerServiceResponse) ContainerSpecKey(org.kie.server.controller.api.model.spec.ContainerSpecKey) Test(org.junit.Test)

Example 3 with KieServerControllerDescriptorCommand

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());
}
Also used : ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) KieServerControllerDescriptorCommand(org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand) KieServerControllerServiceResponse(org.kie.server.controller.api.model.KieServerControllerServiceResponse) SpecManagementService(org.kie.server.controller.api.service.SpecManagementService) Test(org.junit.Test)

Example 4 with KieServerControllerDescriptorCommand

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());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) RuleCapabilitiesService(org.kie.server.controller.api.service.RuleCapabilitiesService) KieServerControllerDescriptorCommand(org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand) KieServerControllerServiceResponse(org.kie.server.controller.api.model.KieServerControllerServiceResponse) ReleaseId(org.kie.server.api.model.ReleaseId) ContainerSpecKey(org.kie.server.controller.api.model.spec.ContainerSpecKey) Test(org.junit.Test)

Example 5 with KieServerControllerDescriptorCommand

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());
}
Also used : KieServerControllerServiceResponse(org.kie.server.controller.api.model.KieServerControllerServiceResponse) KieServerControllerDescriptorCommand(org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand) Test(org.junit.Test)

Aggregations

KieServerControllerDescriptorCommand (org.kie.server.controller.api.commands.KieServerControllerDescriptorCommand)10 Test (org.junit.Test)9 KieServerControllerServiceResponse (org.kie.server.controller.api.model.KieServerControllerServiceResponse)8 SpecManagementService (org.kie.server.controller.api.service.SpecManagementService)4 ContainerSpecKey (org.kie.server.controller.api.model.spec.ContainerSpecKey)2 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)2 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)2 RuleCapabilitiesService (org.kie.server.controller.api.service.RuleCapabilitiesService)2 IOException (java.io.IOException)1 ReleaseId (org.kie.server.api.model.ReleaseId)1 Capability (org.kie.server.controller.api.model.spec.Capability)1 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)1 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)1 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)1 KieServerControllerClientException (org.kie.server.controller.client.exception.KieServerControllerClientException)1 WebSocketServiceResponse (org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse)1