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); }
public BadRequestException(String message, String messageKey) { this(message); setMessageKey(messageKey); }
@RequestMapping(value = "/values", method = RequestMethod.GET, produces = "application/json") public List<DecisionTableRepresentation> getDecisionTables(HttpServletRequest request) { String[] decisionTableIds = request.getParameterValues("decisionTableId"); if (decisionTableIds == null || decisionTableIds.length == 0) { throw new BadRequestException("No decisionTableId parameter(s) provided in the request"); } return decisionTableService.getDecisionTables(decisionTableIds); }
/** * POST /rest/models/{modelId}/editor/newversion -> create a new model version */ @RequestMapping(value = "/rest/models/{modelId}/newversion", method = RequestMethod.POST) public ModelRepresentation importNewVersion(@PathVariable String modelId, @RequestParam("file") MultipartFile file) { InputStream modelStream = null; try { modelStream = file.getInputStream(); } catch (Exception e) { throw new BadRequestException("Error reading file inputstream", e); } return modelService.importNewVersion(modelId, file.getOriginalFilename(), modelStream); }
@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}/variables/{variableName}", method = RequestMethod.PUT) @ResponseStatus(value = HttpStatus.OK) public void updateVariable(@PathVariable String processInstanceId, @PathVariable String variableName, @RequestBody ObjectNode body) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { clientService.updateVariable(serverConfig, processInstanceId, variableName, body); } catch (FlowableServiceException e) { LOGGER.error("Error updating variable {} for process instance {}", variableName, processInstanceId, 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-instances/{caseInstanceId}/variables/{variableName}", method = RequestMethod.PUT) @ResponseStatus(value = HttpStatus.OK) public void updateVariable(@PathVariable String caseInstanceId, @PathVariable String variableName, @RequestBody ObjectNode body) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.CMMN); try { clientService.updateVariable(serverConfig, caseInstanceId, variableName, body); } catch (FlowableServiceException e) { LOGGER.error("Error updating variable {} for case instance {}", variableName, 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/form-definition-form-instances/{formDefinitionId}", method = RequestMethod.GET, produces = "application/json") public JsonNode listFormInstances(HttpServletRequest request, @PathVariable String formDefinitionId) { ServerConfig serverConfig = retrieveServerConfig(EndpointType.FORM); try { ObjectNode bodyNode = objectMapper.createObjectNode(); bodyNode.put("formDefinitionId", formDefinitionId); return clientService.getFormInstances(serverConfig, bodyNode); } catch (FlowableServiceException e) { LOGGER.error("Error getting form instance", e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/tasks/{taskId}", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void executeTaskAction(@PathVariable String taskId, @RequestBody ObjectNode actionBody) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { clientService.executeTaskAction(serverConfig, taskId, actionBody); } catch (FlowableServiceException e) { LOGGER.error("Error executing action on task {}", taskId); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/process-instances/{processInstanceId}/change-state", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void changeActivityState(@PathVariable String processInstanceId, @RequestBody JsonNode changeStateBody) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { clientService.changeActivityState(serverConfig, processInstanceId, changeStateBody); } catch (FlowableServiceException e) { LOGGER.error("Error changing activity state for process instance {}", processInstanceId, e); throw new BadRequestException(e.getMessage()); } }
@RequestMapping(value = "/rest/admin/process-instances/{processInstanceId}/migrate", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void migrateProcessInstance(@PathVariable String processInstanceId, @RequestBody String migrationDocument) throws BadRequestException { ServerConfig serverConfig = retrieveServerConfig(EndpointType.PROCESS); try { clientService.migrateProcessInstance(serverConfig, processInstanceId, migrationDocument); } catch (FlowableServiceException e) { LOGGER.error("Error migrating process instance {}", processInstanceId, e); throw new BadRequestException(e.getMessage()); } }