if ("CaseService".equals(descriptorCommand.getService())) { handler = caseManagementServiceBase; } else if ("CaseQueryService".equals(descriptorCommand.getService())) { handler = caseManagementRuntimeDataService; } else if ("CaseAdminService".equals(descriptorCommand.getService())) { handler = caseAdminServiceBase; } else { throw new IllegalStateException("Unable to find handler for " + descriptorCommand.getService() + " service"); for (Object arg : descriptorCommand.getArguments()) { logger.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { if (descriptorCommand.getPayload() != null && !descriptorCommand.getPayload().isEmpty()) { arguments.add(descriptorCommand.getPayload()); if (descriptorCommand.getMarshallerFormat() != null && !descriptorCommand.getMarshallerFormat().isEmpty()) { arguments.add(descriptorCommand.getMarshallerFormat()); logger.debug("About to execute {} operation on {} with args {}", descriptorCommand.getMethod(), handler, arguments); result = MethodUtils.invokeMethod(handler, descriptorCommand.getMethod(), arguments.toArray()); logger.debug("Handler {} returned response {}", handler, result);
@Override public void removeBusinessAdminGroups(String containerId, Long taskId, String... groups) { if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(TASK_INSTANCE_ID, taskId); valuesMap.put(ENTITY_ID, Arrays.stream(groups).collect(Collectors.joining(","))); makeHttpDeleteRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_ADMINS_GROUPS_DELETE_URI, valuesMap), null); } else { List<String> entities = new ArrayList<>(Arrays.asList(groups)); CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskAdminService", "removeBusinessAdmins", new Object[]{containerId, taskId, entities, false}))); ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
if ("FormService".equals(descriptorCommand.getService())) { handler = formServiceBase; } else if ("ImageService".equals(descriptorCommand.getService())) { handler = imageServiceBase; } else if ("FormRendererService".equals(descriptorCommand.getService())) { handler = formRendererBase; } else { throw new IllegalStateException("Unable to find handler for " + descriptorCommand.getService() + " service"); for (Object arg : descriptorCommand.getArguments()) { logger.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { logger.debug("About to execute {} operation on {} with args {}", descriptorCommand.getMethod(), handler, arguments); result = MethodUtils.invokeMethod(handler, descriptorCommand.getMethod(), arguments.toArray()); logger.debug("Handler {} returned response {}", handler, result);
public static Object wrapSkipPrimitives(Object object) { if (object == null) { return null; } if (object instanceof List) { return new JaxbList((List) object); } else if (object instanceof Map) { return new JaxbMap((Map) object); } else if (object instanceof Date) { return new JaxbDate((Date) object); } else if (object instanceof CommandScript) { for (KieServerCommand cmd : ((CommandScript) object).getCommands()) { if (cmd instanceof DescriptorCommand) { List<Object> arguments = new ArrayList<Object>(); for (Object o : ((DescriptorCommand) cmd).getArguments()) { arguments.add(wrap(o)); } ((DescriptorCommand) cmd).setArguments(arguments); } } } return object; }
private void verifyServiceMethods(final Class service) throws Exception { final String name = service.getName(); final Method[] methods = service.getMethods(); for (int i = 0; i < methods.length; i++) { final Method m = methods[i]; MethodUtils.invokeMethod(controllerClient, m.getName(), new Object[m.getParameterCount()]); ArgumentCaptor<String> contentCaptor = ArgumentCaptor.forClass(String.class); verify(client).sendTextWithInternalHandler(contentCaptor.capture(), any(InternalMessageHandler.class)); final DescriptorCommand command = WebSocketUtils.unmarshal(contentCaptor.getValue(), DescriptorCommand.class); assertNotNull(command); assertEquals(name, command.getService()); assertEquals(m.getName(), command.getMethod()); reset(client); } }
if ("DMNService".equals(descriptorCommand.getService())) { handler = modelEvaluatorServiceBase; } else { throw new IllegalStateException("Unable to find handler for " + descriptorCommand.getService() + " service"); for (Object arg : descriptorCommand.getArguments()) { LOG.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { if (descriptorCommand.getPayload() != null && !descriptorCommand.getPayload().isEmpty()) { arguments.add(descriptorCommand.getPayload()); if (descriptorCommand.getMarshallerFormat() != null && !descriptorCommand.getMarshallerFormat().isEmpty()) { arguments.add(descriptorCommand.getMarshallerFormat()); LOG.debug("About to execute {} operation on {} with args {}", descriptorCommand.getMethod(), handler, arguments); result = (ServiceResponse<?>) MethodUtils.invokeMethod(handler, descriptorCommand.getMethod(), arguments.toArray()); LOG.debug("Handler {} returned response {}", handler, result);
@Override public void removeBusinessAdminUsers(String containerId, Long taskId, String... users) { if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(TASK_INSTANCE_ID, taskId); valuesMap.put(ENTITY_ID, Arrays.stream(users).collect(Collectors.joining(","))); makeHttpDeleteRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_ADMINS_USERS_DELETE_URI, valuesMap), null); } else { List<String> entities = new ArrayList<>(Arrays.asList(users)); CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskAdminService", "removeBusinessAdmins", new Object[]{containerId, taskId, entities, true}))); ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
if ("TaskSearchService".equals(descriptorCommand.getService())) { handler = taskSearchServiceBase; } else if ("ProcessInstanceSeachService".equals(descriptorCommand.getService())) { handler = processInstanceSearchServiceBase; } else { throw new IllegalStateException("Unable to find handler for " + descriptorCommand.getService() + " service"); for (Object arg : descriptorCommand.getArguments()) { logger.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { if (descriptorCommand.getPayload() != null && !descriptorCommand.getPayload().isEmpty()) { arguments.add(descriptorCommand.getPayload()); if (descriptorCommand.getMarshallerFormat() != null && !descriptorCommand.getMarshallerFormat().isEmpty()) { arguments.add(descriptorCommand.getMarshallerFormat()); logger.debug("About to execute {} operation on {} with args {}", descriptorCommand.getMethod(), handler, arguments); result = MethodUtils.invokeMethod(handler, descriptorCommand.getMethod(), arguments.toArray()); logger.debug("Handler {} returned response {}", handler, result);
@Override public void removePotentialOwnerUsers(String containerId, Long taskId, String... users) { if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(TASK_INSTANCE_ID, taskId); valuesMap.put(ENTITY_ID, Arrays.stream(users).collect(Collectors.joining(","))); makeHttpDeleteRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_POT_OWNERS_USERS_DELETE_URI, valuesMap), null); } else { List<String> entities = new ArrayList<>(Arrays.asList(users)); CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskAdminService", "removePotentialOwners", new Object[]{containerId, taskId, entities, true}))); ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
if ("DefinitionService".equals(descriptorCommand.getService())) { handler = definitionServiceBase; } else if ("ProcessService".equals(descriptorCommand.getService())) { handler = processServiceBase; } else if ("UserTaskService".equals(descriptorCommand.getService())) { handler = userTaskServiceBase; } else if ("QueryService".equals(descriptorCommand.getService())) { handler = runtimeDataServiceBase; } else if ("JobService".equals(descriptorCommand.getService())) { handler = executorServiceBase; } else if ("QueryDataService".equals(descriptorCommand.getService())) { handler = queryDataServiceBase; } else if ("DocumentService".equals(descriptorCommand.getService())) { handler = documentServiceBase; } else if ("ProcessAdminService".equals(descriptorCommand.getService())) { handler = processAdminServiceBase; } else if ("UserTaskAdminService".equals(descriptorCommand.getService())) { handler = userTaskAdminServiceBase; } else { throw new IllegalStateException("Unable to find handler for " + descriptorCommand.getService() + " service"); for (Object arg : descriptorCommand.getArguments()) { logger.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { if (descriptorCommand.getPayload() != null && !descriptorCommand.getPayload().isEmpty()) { arguments.add(descriptorCommand.getPayload());
@Override public void removeExcludedOwnerGroups(String containerId, Long taskId, String... groups) { if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(TASK_INSTANCE_ID, taskId); valuesMap.put(ENTITY_ID, Arrays.stream(groups).collect(Collectors.joining(","))); makeHttpDeleteRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_EXL_OWNERS_GROUPS_DELETE_URI, valuesMap), null); } else { List<String> entities = new ArrayList<>(Arrays.asList(groups)); CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskAdminService", "removeExcludedOwners", new Object[]{containerId, taskId, entities, false}))); ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
@Override public void unregisterQuery(String queryName) { if (config.isRest()) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(QUERY_NAME, queryName); makeHttpDeleteRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + DROP_QUERY_DEF_DELETE_URI, valuesMap), null); } else { CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "unregisterQuery", new Object[]{queryName}))); ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0); throwExceptionOnFailure(response); } }
@Override public void removeExcludedOwnerUsers(String containerId, Long taskId, String... users) { if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(TASK_INSTANCE_ID, taskId); valuesMap.put(ENTITY_ID, Arrays.stream(users).collect(Collectors.joining(","))); makeHttpDeleteRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_EXL_OWNERS_USERS_DELETE_URI, valuesMap), null); } else { List<String> entities = new ArrayList<>(Arrays.asList(users)); CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskAdminService", "removeExcludedOwners", new Object[]{containerId, taskId, entities, true}))); ServiceResponse<?> response = (ServiceResponse<MigrationReportInstance>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
@Override public void removePotentialOwnerGroups(String containerId, Long taskId, String... groups) { if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(TASK_INSTANCE_ID, taskId); valuesMap.put(ENTITY_ID, Arrays.stream(groups).collect(Collectors.joining(","))); makeHttpDeleteRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_POT_OWNERS_GROUPS_DELETE_URI, valuesMap), null); } else { List<String> entities = new ArrayList<>(Arrays.asList(groups)); CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskAdminService", "removePotentialOwners", new Object[]{containerId, taskId, entities, false}))); ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
@Override public void claimTask(String containerId, Long taskId, String userId) { if( config.isRest() ) { sendTaskOperation(containerId, taskId, TASK_URI + "/" + TASK_INSTANCE_CLAIM_PUT_URI, getUserQueryStr(userId)); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskService", "claim", new Object[]{containerId, taskId, userId}) ) ); ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
@Override public void resumeTask(String containerId, Long taskId, String userId) { if( config.isRest() ) { sendTaskOperation(containerId, taskId, TASK_URI + "/" + TASK_INSTANCE_RESUME_PUT_URI, getUserQueryStr(userId)); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskService", "resume", new Object[]{containerId, taskId, userId}) ) ); ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
@Override public void delegateTask(String containerId, Long taskId, String userId, String targetUserId) { if( config.isRest() ) { sendTaskOperation(containerId, taskId, TASK_URI + "/" + TASK_INSTANCE_DELEGATE_PUT_URI, getUserAndAdditionalParam(userId, "targetUser", targetUserId)); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskService", "delegate", new Object[]{containerId, taskId, userId, targetUserId}) ) ); ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
@Override public void forwardTask(String containerId, Long taskId, String userId, String targetEntityId) { if( config.isRest() ) { sendTaskOperation(containerId, taskId, TASK_URI + "/" + TASK_INSTANCE_FORWARD_PUT_URI, getUserAndAdditionalParam(userId, "targetUser", targetEntityId)); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskService", "forward", new Object[]{containerId, taskId, userId, targetEntityId}) ) ); ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
@Override public void suspendTask(String containerId, Long taskId, String userId) { if( config.isRest() ) { sendTaskOperation(containerId, taskId, TASK_URI + "/" + TASK_INSTANCE_SUSPEND_PUT_URI, getUserQueryStr(userId)); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskService", "suspend", new Object[]{containerId, taskId, userId}) ) ); ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }
@Override public void releaseTask(String containerId, Long taskId, String userId) { if( config.isRest() ) { sendTaskOperation(containerId, taskId, TASK_URI + "/" + TASK_INSTANCE_RELEASE_PUT_URI, getUserQueryStr(userId)); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "UserTaskService", "release", new Object[]{containerId, taskId, userId}) ) ); ServiceResponse<TaskOutputsDefinition> response = (ServiceResponse<TaskOutputsDefinition>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); } }