@Test public void testInvalidTask() { try { taskService.claim(-1, "Darth Vader"); } catch (PermissionDeniedException e) { if ("Task '-1' not found".equals(e.getMessage())) { return; } else { throw e; } } }
@Override public Task execute(Context cntxt) { TaskContext context = (TaskContext) cntxt; Task task = context.getTaskQueryService().getTaskInstanceById(taskId); if (task == null) { throw new IllegalStateException("Unable to find task with id " + taskId); } if (!checkUserPermissions(userId, task, context)) { throw new PermissionDeniedException("User " + userId + " isn't allowed to see the task " + taskId); } return task; }
@Override public void abortWorkItem(WorkItem workItem, WorkItemManager manager) { Task task = taskService.getTaskByWorkItemId(workItem.getId()); if (task != null) { try { String adminUser = ADMIN_USER; List<OrganizationalEntity> businessAdmins = task.getPeopleAssignments().getBusinessAdministrators(); for (OrganizationalEntity admin : businessAdmins) { if (admin instanceof Group) { continue; } if (!admin.getId().equals(ADMIN_USER)) { adminUser = admin.getId(); break; } } logger.debug("Task {} is going to be exited by {} who is business admin", task.getId(), adminUser); taskService.exit(task.getId(), adminUser); } catch (PermissionDeniedException e) { logger.info(e.getMessage()); } } }
throw new PermissionDeniedException("Can only assign task owner if status is Created!");
@Override public void abortWorkItem(WorkItem workItem, WorkItemManager manager) { RuntimeEngine runtime = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get(workItem.getProcessInstanceId())); Task task = runtime.getTaskService().getTaskByWorkItemId(workItem.getId()); if (task != null) { try { String adminUser = ADMIN_USER; List<OrganizationalEntity> businessAdmins = task.getPeopleAssignments().getBusinessAdministrators(); for (OrganizationalEntity admin : businessAdmins) { if (admin instanceof Group) { continue; } if (!admin.getId().equals(ADMIN_USER)) { adminUser = admin.getId(); break; } } logger.debug("Task {} is going to be exited by {} who is business admin", task.getId(), adminUser); runtime.getTaskService().exit(task.getId(), adminUser); } catch (PermissionDeniedException e) { logger.info(e.getMessage()); } } }
String errorMessage = "User '" + user + "' does not have permissions to execute operation '" + operation + "' on task id " + task.getId(); throw new PermissionDeniedException(errorMessage); throw new PermissionDeniedException(errorMessage); throw new PermissionDeniedException(errorMessage); throw new PermissionDeniedException(errorMessage);
assertTrue(e.getMessage().indexOf("Mary is not allowed to complete task with approved false") != -1);
throw new PermissionDeniedException("Task '" + taskId + "' not found");
@Override public void abortWorkItem(WorkItem workItem, WorkItemManager manager) { Task task = taskService.getTaskByWorkItemId(workItem.getId()); if (task != null) { try { String adminUser = ADMIN_USER; List<OrganizationalEntity> businessAdmins = task.getPeopleAssignments().getBusinessAdministrators(); for (OrganizationalEntity admin : businessAdmins) { if (admin instanceof Group) { continue; } if (!admin.getId().equals(ADMIN_USER)) { adminUser = admin.getId(); break; } } logger.debug("Task {} is going to be exited by {} who is business admin", task.getId(), adminUser); taskService.exit(task.getId(), adminUser); } catch (PermissionDeniedException e) { logger.info(e.getMessage()); } } }
throw new PermissionDeniedException(errorMessage); if (task.getPeopleAssignments().getPotentialOwners().stream().anyMatch(oe -> oe instanceof Group)) { throw new PermissionDeniedException("Task forward operation not allowed for task with group assignment");
@Override public void abortWorkItem(WorkItem workItem, WorkItemManager manager) { RuntimeEngine runtime = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get(workItem.getProcessInstanceId())); Task task = runtime.getTaskService().getTaskByWorkItemId(workItem.getId()); if (task != null) { try { String adminUser = ADMIN_USER; List<OrganizationalEntity> businessAdmins = task.getPeopleAssignments().getBusinessAdministrators(); for (OrganizationalEntity admin : businessAdmins) { if (admin instanceof Group) { continue; } if (!admin.getId().equals(ADMIN_USER)) { adminUser = admin.getId(); break; } } logger.debug("Task {} is going to be exited by {} who is business admin", task.getId(), adminUser); runtime.getTaskService().exit(task.getId(), adminUser); } catch (PermissionDeniedException e) { logger.info(e.getMessage()); } } }