@Override public ServiceResponse<String> executeCommands(String id, String payload) { if( config.isRest() ) { return makeHttpPostRequestAndCreateServiceResponse( baseURI + "/containers/" + id, payload, String.class ); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new CallContainerCommand( id, payload ) ) ); return (ServiceResponse<String>) executeJmsCommand( script ).getResponses().get( 0 ); } }
public ServiceResponsesList executeScript(CommandScript commands) { List<ServiceResponse<? extends Object>> responses = new ArrayList<ServiceResponse<? extends Object>>(); if( commands != null ) { for (KieServerCommand command : commands.getCommands()) { if (command instanceof CreateContainerCommand) { responses.add(createContainer(((CreateContainerCommand) command).getContainer().getContainerId(), ((CreateContainerCommand) command).getContainer())); } else if (command instanceof GetServerInfoCommand) { responses.add(getInfo()); } else if (command instanceof ListContainersCommand) { responses.add(listContainers()); } else if (command instanceof CallContainerCommand) { responses.add(callContainer(((CallContainerCommand) command).getContainerId(), ((CallContainerCommand) command).getPayload())); } else if (command instanceof DisposeContainerCommand) { responses.add(disposeContainer(((DisposeContainerCommand) command).getContainerId())); } else if (command instanceof GetContainerInfoCommand ) { responses.add(getContainerInfo(((GetContainerInfoCommand) command).getContainerId())); } else if (command instanceof GetScannerInfoCommand ) { responses.add(getScannerInfo(((GetScannerInfoCommand) command).getContainerId())); } else if (command instanceof UpdateScannerCommand ) { responses.add(updateScanner(((UpdateScannerCommand) command).getContainerId(), ((UpdateScannerCommand) command).getScanner())); } else if (command instanceof UpdateReleaseIdCommand ) { responses.add(updateContainerReleaseId(((UpdateReleaseIdCommand) command).getContainerId(), ((UpdateReleaseIdCommand) command).getReleaseId())); } } } return new ServiceResponsesList(responses); }
responses.add(this.kieServer.listContainers(((ListContainersCommand)command).getKieContainerResourceFilter())); } else if (command instanceof CallContainerCommand) { ServiceResponse response = callContainer(((CallContainerCommand) command).getContainerId(), ((CallContainerCommand) command).getPayload(), marshallingFormat, classType, true);
/** * @deprecated use #executeCommandsWithResults */ @Deprecated @Override public ServiceResponse<String> executeCommands(String id, String payload) { if( config.isRest() ) { return makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(loadBalancer.getUrl() + "/containers/instances/" + id, payload, String.class); } else { CommandScript script = new CommandScript( Collections.singletonList((KieServerCommand) new CallContainerCommand(id, payload)) ); return (ServiceResponse<String>) executeJmsCommand( script, null, null, id ).getResponses().get( 0 ); } }
/** * @deprecated use #executeCommandsWithResults */ @Deprecated @Override public ServiceResponse<String> executeCommands(String id, Command<?> cmd) { if( config.isRest() ) { return makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse( loadBalancer.getUrl() + "/containers/instances/" + id, cmd, String.class, getHeaders(cmd) ); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new CallContainerCommand( id, serialize(cmd) ) ) ); return (ServiceResponse<String>) executeJmsCommand( script, cmd.getClass().getName(), null, id ).getResponses().get( 0 ); } }
/** * This method is deprecated on KieServicesClient as it was moved to RuleServicesClient * * @see RuleServicesClient#executeCommands(String, String) * @deprecated */ @Deprecated @Override public ServiceResponse<String> executeCommands(String id, String payload) { if( config.isRest() ) { return makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(loadBalancer.getUrl() + "/containers/instances/" + id, payload, String.class); } else { CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new CallContainerCommand(id, payload))); ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, null, null, id).getResponses().get(0); return getResponseOrNullIfNoResponse(response); } }
/** * 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) { if( config.isRest() ) { return makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(loadBalancer.getUrl() + "/containers/instances/" + id, cmd, String.class, getHeaders(cmd) ); } 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); } }
@Override public ServiceResponse<ExecutionResults> executeCommandsWithResults(String id, Command<?> cmd) { if( config.isRest() ) { return makeHttpPostRequestAndCreateServiceResponse( loadBalancer.getUrl() + "/containers/instances/" + id, cmd, (Class)ExecutionResultImpl.class, getHeaders(cmd) ); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new CallContainerCommand( id, serialize(cmd) ) ) ); ServiceResponse response = executeJmsCommand( script, cmd.getClass().getName(), null, id ).getResponses().get( 0 ); if (shouldReturnWithNullResponse(response)) { return null; } if (response.getResult() instanceof String) { response.setResult(deserialize((String) response.getResult(), (Class) ExecutionResultImpl.class)); } return response; } }
@Override public ServiceResponse<ExecutionResults> executeCommandsWithResults(String id, String payload) { if( config.isRest() ) { return makeHttpPostRequestAndCreateServiceResponse( loadBalancer.getUrl() + "/containers/instances/" + id, payload, (Class) ExecutionResultImpl.class); } else { CommandScript script = new CommandScript( Collections.singletonList((KieServerCommand) new CallContainerCommand(id, payload)) ); ServiceResponse response = executeJmsCommand( script, null, null, id ).getResponses().get( 0 ); if (shouldReturnWithNullResponse(response)) { return null; } if (response.getResult() instanceof String) { response.setResult(deserialize((String) response.getResult(), (Class) ExecutionResultImpl.class)); } return response; } }