public void checkTransitionPermission(String transitionKey, DefaultIssue defaultIssue) { String projectUuid = requireNonNull(defaultIssue.projectUuid()); workflow .outTransitions(defaultIssue) .stream() .filter( transition -> transition.key().equals(transitionKey) && isNotBlank(transition.requiredProjectPermission())) .forEach( transition -> userSession.checkComponentUuidPermission( transition.requiredProjectPermission(), projectUuid)); }
private ActivityResponse doHandle(ActivityWsRequest request) { DbSession dbSession = dbClient.openSession(false); try { // if a task searched by uuid is found all other parameters are ignored Optional<WsCe.Task> taskSearchedById = searchTaskByUuid(dbSession, request); if (taskSearchedById.isPresent()) { userSession.checkComponentUuidPermission( UserRole.ADMIN, taskSearchedById.get().getComponentId()); return buildResponse( singletonList(taskSearchedById.get()), Collections.emptyList(), request.getPageSize()); } CeTaskQuery query = buildQuery(dbSession, request); checkPermissions(query); Iterable<WsCe.Task> queuedTasks = loadQueuedTasks(dbSession, request, query); Iterable<WsCe.Task> pastTasks = loadPastTasks(dbSession, request, query); return buildResponse(queuedTasks, pastTasks, request.getPageSize()); } finally { dbClient.closeSession(dbSession); } }