@Override public ServiceResponse<KieScannerResource> updateScanner(String id, KieScannerResource resource) { if( config.isRest() ) { return makeHttpPostRequestAndCreateServiceResponse( baseURI + "/containers/" + id + "/scanner", resource, KieScannerResource.class ); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new UpdateScannerCommand( id, resource ) ) ); return (ServiceResponse<KieScannerResource>) 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.updateScanner(((UpdateScannerCommand) command).getContainerId(), ((UpdateScannerCommand) command).getScanner())); } else if (command instanceof GetReleaseIdCommand) { responses.add(this.kieServer.getContainerReleaseId(((GetReleaseIdCommand) command).getContainerId()));
@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; }
@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); } }