protected ErrorInfo createInfoFromException(BaseModelerRestException exception, String defaultMessageKey) { ErrorInfo result = null; result = new ErrorInfo(exception.getMessage()); if (exception.getCustomData() != null) { result.setCustomData(exception.getCustomData()); } if (exception.getMessageKey() != null) { result.setMessageKey(exception.getMessageKey()); } else { result.setMessageKey(defaultMessageKey); } return result; }
public ConflictingRequestException(String message, String messageKey) { this(message); setMessageKey(messageKey); }
public BadRequestException(String message, String messageKey) { this(message); setMessageKey(messageKey); }
public void deleteContent(String contentId, HttpServletResponse response) { ContentItem contentItem = contentService.createContentItemQuery().id(contentId).singleResult(); if (contentItem == null) { throw new NotFoundException("No content found with id: " + contentId); } if (!permissionService.hasWritePermissionOnRelatedContent(SecurityUtils.getCurrentUserObject(), contentItem)) { throw new NotPermittedException("You are not allowed to delete the content with id: " + contentId); } if (contentItem.getField() != null) { // Not allowed to delete content that has been added as part of a form throw new NotPermittedException("You are not allowed to delete the content with id: " + contentId); } contentService.deleteContentItem(contentItem.getId()); }
public Group updateGroupName(String groupId, String name) { if (StringUtils.isBlank(name)) { throw new BadRequestException("Group name required"); } Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new NotFoundException(); } group.setName(name); identityService.saveGroup(group); return group; }
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); }
protected ObjectNode deleteEmbededReferencesFromBPMNModel(ObjectNode editorJsonNode) { try { internalDeleteNodeByNameFromBPMNModel(editorJsonNode, "formreference"); internalDeleteNodeByNameFromBPMNModel(editorJsonNode, "subprocessreference"); return editorJsonNode; } catch (Exception e) { throw new InternalServerErrorException("Cannot delete the external references"); } }
public void deleteGroup(String groupId) { Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new NotFoundException(); } identityService.deleteGroup(groupId); }
protected void checkForDuplicateKey(ModelRepresentation modelRepresentation) { ModelKeyRepresentation modelKeyInfo = modelService.validateModelKey(null, modelRepresentation.getModelType(), modelRepresentation.getKey()); if (modelKeyInfo.isKeyAlreadyExists()) { throw new ConflictingRequestException("Provided model key already exists: " + modelRepresentation.getKey()); } }
public ContentItemRepresentation createContentItemOnCase(String caseId, MultipartFile file) { User user = SecurityUtils.getCurrentUserObject(); if (!permissionService.canAddRelatedContentToCase(user, caseId)) { throw new NotPermittedException("You are not allowed to read the case with id: " + caseId); } return uploadFile(user, file, null, null, caseId); }
public ContentItemRepresentation getContent(String contentId) { ContentItem contentItem = contentService.createContentItemQuery().id(contentId).singleResult(); if (contentItem == null) { throw new NotFoundException("No content found with id: " + contentId); } if (!permissionService.canDownloadContent(SecurityUtils.getCurrentUserObject(), contentItem)) { throw new NotPermittedException("You are not allowed to view the content with id: " + contentId); } return createContentItemResponse(contentItem); }
@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); }
protected ObjectNode deleteEmbededReferencesFromStepModel(ObjectNode editorJsonNode) { try { JsonNode startFormNode = editorJsonNode.get("startForm"); if (startFormNode != null) { editorJsonNode.remove("startForm"); } internalDeleteNodeByNameFromStepModel(editorJsonNode.get("steps"), "formDefinition"); internalDeleteNodeByNameFromStepModel(editorJsonNode.get("steps"), "subProcessDefinition"); return editorJsonNode; } catch (Exception e) { throw new InternalServerErrorException("Cannot delete the external references"); } }
public ContentItemRepresentation createContentItemOnProcessInstance(String processInstanceId, ContentItemRepresentation contentItem) { User user = SecurityUtils.getCurrentUserObject(); if (!permissionService.canAddRelatedContentToProcessInstance(user, processInstanceId)) { throw new NotPermittedException("You are not allowed to read the process with id: " + processInstanceId); } return addContentItem(contentItem, null, processInstanceId, true); }
public ContentItemRepresentation createContentItemOnTask(String taskId, ContentItemRepresentation contentItem) { User user = SecurityUtils.getCurrentUserObject(); Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); if (task == null) { throw new NotFoundException("Task not found or already completed: " + taskId); } if (!permissionService.canAddRelatedContentToTask(user, taskId)) { throw new NotPermittedException("You are not allowed to read the task with id: " + taskId); } return addContentItem(contentItem, taskId, task.getProcessInstanceId(), true); }
public void getProcessModelBpmn20Xml(HttpServletResponse response, String processModelId) throws IOException { if (processModelId == null) { throw new BadRequestException("No process model id provided"); } Model model = modelService.getModel(processModelId); generateBpmn20Xml(response, model); }
public ContentItemRepresentation createContentItemOnTask(String taskId, MultipartFile file) { User user = SecurityUtils.getCurrentUserObject(); Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); if (task == null) { throw new NotFoundException("Task not found or already completed: " + taskId); } if (!permissionService.canAddRelatedContentToTask(user, taskId)) { throw new NotPermittedException("You are not allowed to read the task with id: " + taskId); } return uploadFile(user, file, taskId, task.getProcessInstanceId(), null); }
public void getHistoricProcessModelBpmn20Xml(HttpServletResponse response, String processModelId, String processModelHistoryId) throws IOException { if (processModelId == null) { throw new BadRequestException("No process model id provided"); } ModelHistory historicModel = modelService.getModelHistory(processModelId, processModelHistoryId); generateBpmn20Xml(response, historicModel); }
public void getCaseModelCmmnXml(HttpServletResponse response, String caseModelId) throws IOException { if (caseModelId == null) { throw new BadRequestException("No case model id provided"); } Model model = modelService.getModel(caseModelId); generateCmmnXml(response, model); }
public void getHistoricCaseModelCmmnXml(HttpServletResponse response, String caseModelId, String caseModelHistoryId) throws IOException { if (caseModelId == null) { throw new BadRequestException("No case model id provided"); } ModelHistory historicModel = modelService.getModelHistory(caseModelId, caseModelHistoryId); generateCmmnXml(response, historicModel); }