protected ServerConfig retrieveServerConfig(EndpointType endpointType) { List<ServerConfig> serverConfigs = configRepository.getByEndpointType(endpointType); if (serverConfigs == null) { throw new BadRequestException("No server config found"); } if (serverConfigs.size() > 1) { throw new BadRequestException("Only one server config per endpoint type allowed"); } return serverConfigs.get(0); }
@RequestMapping(value = "/rest/admin/process-instances/{processInstanceId}/variables", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void createVariable(@PathVariable String processInstanceId, @RequestBody ObjectNode body) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { clientService.createVariable(serverConfig, processInstanceId, body); } catch (FlowableServiceException e) { LOGGER.error("Error creating variable for process instance {}", processInstanceId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/process-instances/{processInstanceId}/variables/{variableName}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.OK) public void deleteVariable(@PathVariable String processInstanceId, @PathVariable String variableName) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { clientService.deleteVariable(serverConfig, processInstanceId, variableName); } catch (FlowableServiceException e) { LOGGER.error("Error deleting variable for process instance {}", processInstanceId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/case-instances/{caseInstanceId}/variables", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void createVariable(@PathVariable String caseInstanceId, @RequestBody ObjectNode body) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.CMMN); try { clientService.createVariable(serverConfig, caseInstanceId, body); } catch (FlowableServiceException e) { LOGGER.error("Error creating variable for case instance {}", caseInstanceId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/task-form-instance/{taskId}", method = RequestMethod.GET, produces = "application/json") public JsonNode getTaskFormInstance(@PathVariable String taskId) { ServerConfig serverConfig = retrieveServerConfig(EndpointType.FORM); try { ObjectNode bodyNode = objectMapper.createObjectNode(); bodyNode.put("taskId", taskId); return clientService.getFormInstances(serverConfig, bodyNode); } catch (FlowableServiceException e) { LOGGER.error("Error getting form instance for task id {}", taskId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/process-instances/{processInstanceId}", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void executeAction(@PathVariable String processInstanceId, @RequestBody JsonNode actionBody) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { clientService.executeAction(serverConfig, processInstanceId, actionBody); } catch (FlowableServiceException e) { LOGGER.error("Error executing action on process instance {}", processInstanceId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/cmmn-tasks/{taskId}", method = RequestMethod.PUT) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateTask(@PathVariable String taskId, @RequestBody ObjectNode actionBody) { ServerConfig serverConfig = retrieveServerConfig(EndpointType.CMMN); try { clientService.updateTask(serverConfig, taskId, actionBody); } catch (FlowableServiceException e) { LOGGER.error("Error updating task {}", taskId); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/process-form-instances/{processInstanceId}", method = RequestMethod.GET, produces = "application/json") public JsonNode getProcessFormInstances(@PathVariable String processInstanceId) { ServerConfig serverConfig = retrieveServerConfig(EndpointType.FORM); try { ObjectNode bodyNode = objectMapper.createObjectNode(); bodyNode.put("processInstanceId", processInstanceId); return clientService.getFormInstances(serverConfig, bodyNode); } catch (FlowableServiceException e) { LOGGER.error("Error getting form instances for process instance id {}", processInstanceId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/case-instances/{caseInstanceId}", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void executeAction(@PathVariable String caseInstanceId, @RequestBody JsonNode actionBody) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.CMMN); try { clientService.executeAction(serverConfig, caseInstanceId, actionBody); } catch (FlowableServiceException e) { LOGGER.error("Error executing action on case instance {}", caseInstanceId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/case-definitions/{definitionId}/jobs", method = RequestMethod.GET, produces = "application/json") public JsonNode getJobs(@PathVariable String definitionId) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.CMMN); try { return jobService.listJobs(serverConfig, Collections.singletonMap("caseDefinitionId", new String[] { definitionId })); } catch (FlowableServiceException e) { LOGGER.error("Error getting jobs for case definition {}", definitionId, e); throw new BadRequestException(e.getMessage()); } } }
@RequestMapping(value = "/rest/admin/tasks/{taskId}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void deleteTask(@PathVariable String taskId) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { clientService.deleteTask(serverConfig, taskId); } catch (FlowableServiceException e) { LOGGER.error("Error deleting task {}", taskId); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/cmmn-tasks/{taskId}", method = RequestMethod.GET, produces = "application/json") public JsonNode getTask(@PathVariable String taskId, @RequestParam(required = false, defaultValue = "false") boolean runtime) { ServerConfig serverConfig = retrieveServerConfig(EndpointType.CMMN); try { return clientService.getTask(serverConfig, taskId, runtime); } catch (FlowableServiceException e) { LOGGER.error("Error getting task {}", taskId); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/case-instances/{caseInstanceId}", method = RequestMethod.GET, produces = "application/json") public JsonNode getProcessInstance(@PathVariable String caseInstanceId, @RequestParam(required = false, defaultValue = "false") boolean runtime) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.CMMN); try { return clientService.getCaseInstance(serverConfig, caseInstanceId); } catch (FlowableServiceException e) { LOGGER.error("Error getting case instance {}", caseInstanceId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/process-definitions/{definitionId}/jobs", method = RequestMethod.GET, produces = "application/json") public JsonNode getJobs(@PathVariable String definitionId) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { return jobService.listJobs(serverConfig, Collections.singletonMap("processDefinitionId", new String[] { definitionId })); } catch (FlowableServiceException e) { LOGGER.error("Error getting jobs for process definition {}", definitionId, e); throw new BadRequestException(e.getMessage()); } } }
@RequestMapping(value = "/rest/admin/process-instances/{processInstanceId}/jobs", method = RequestMethod.GET) public JsonNode getJobs(@PathVariable String processInstanceId) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { return clientService.getJobs(serverConfig, processInstanceId); } catch (FlowableServiceException e) { LOGGER.error("Error getting jobs for process instance {}", processInstanceId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/decision-tables/{decisionTableId}", method = RequestMethod.GET, produces = "application/json") public JsonNode getDecisionTable(@PathVariable String decisionTableId) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.DMN); try { return clientService.getDecisionTable(serverConfig, decisionTableId); } catch (FlowableServiceException e) { LOGGER.error("Error getting decision table {}", decisionTableId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/cmmn-tasks/{taskId}/subtasks", method = RequestMethod.GET) public JsonNode getSubtasks(@PathVariable String taskId) { ServerConfig serverConfig = retrieveServerConfig(EndpointType.CMMN); try { return clientService.getSubTasks(serverConfig, taskId); } catch (FlowableServiceException e) { LOGGER.error("Error getting sub tasks {}", taskId); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/decision-tables/{decisionTableId}/editorJson", method = RequestMethod.GET, produces = "application/json") public JsonNode getEditorJsonForDecisionTable(@PathVariable String decisionTableId) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.DMN); try { return clientService.getEditorJsonForDecisionTable(serverConfig, decisionTableId); } catch (FlowableServiceException e) { LOGGER.error("Error getting editor json for decision table {}", decisionTableId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/tasks/{taskId}/variables", method = RequestMethod.GET) public JsonNode getVariables(@PathVariable String taskId) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { return clientService.getVariables(serverConfig, taskId); } catch (FlowableServiceException e) { throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/editor/models", method = RequestMethod.POST, produces = "application/json") public ModelRepresentation createModel(@RequestBody ModelRepresentation modelRepresentation) { modelRepresentation.setKey(modelRepresentation.getKey().replaceAll(" ", "")); ModelKeyRepresentation modelKeyInfo = modelService.validateModelKey(null, modelRepresentation.getModelType(), modelRepresentation.getKey()); if (modelKeyInfo.isKeyAlreadyExists()) { throw new BadRequestException("Provided model key already exists: " + modelRepresentation.getKey()); } String json = modelService.createModelJson(modelRepresentation); Model newModel = modelService.createModel(modelRepresentation, json, SecurityUtils.getCurrentUserObject()); return new ModelRepresentation(newModel); }