public void put(@Nonnull final Long id, @Nonnull Optional<MutableIssue> issue) { byId.put(id, issue); issue.ifPresent(i -> byKey.put(i.getKey(), Optional.of(i))); }
@Override public void apply(final MutableIssue issue) { try { issueIndexManager.reIndex(issue, IssueIndexingParams.INDEX_ISSUE_ONLY); } catch (IndexException e) { log.error(String.format("Error during reindex of issue %s", issue.getKey()), e); } } });
private ActionDescriptor retrieveActionDescriptor() { // Impersonate user just in case if DefaultJiraWorkflow or others use JiraAuthenticationContext ;) final ActionDescriptor retrievedActionDescriptor = impersonateUser(new Supplier<ActionDescriptor>() { @Override public ActionDescriptor get() { return workflowManager.getWorkflow(getIssue()).getDescriptor().getAction(actionId); } }); if (retrievedActionDescriptor == null) { throw new IllegalArgumentException("No workflow action with id '" + actionId + "' available for issue " + getIssue().getKey()); } else { return retrievedActionDescriptor; } }
private ActionDescriptor retrieveActionDescriptorWithPermissionCheck() { try { if (!hasTransitionPermission()) { throw new IllegalArgumentException(String.format( "User %s doesn't have permission transition for issue %s.", getUserKey(), getIssue().getKey())); } return retrieveActionDescriptor(); } catch (final WorkflowException e) { throw new IllegalArgumentException("Cannot find workflow transition with id '" + actionId + "'.", e); } }
public String getIssuePath() { MutableIssue targetIssue = issueManager.getIssueObject(getIssue().getId()); targetIssue = issueFactory.cloneIssueNoParent(targetIssue); return "/browse/" + targetIssue.getKey(); }
return Either.error(CommitHookErrors.fromSingleError(CMD_TYPE.getName(), issue.getKey(), i18nHelper.getText(NO_COMMAND_PROVIDED_TEMPLATE, issue.getKey()))); getValidActions(actions, user, issue, new IssueInputParametersImpl()); if (validActions.isEmpty()) { return Either.error(CommitHookErrors.fromSingleError(CMD_TYPE.getName(), issue.getKey(), i18nHelper.getText(NO_ALLOWED_ACTIONS_TEMPLATE, issue.getKey()))); return Either.error(CommitHookErrors.fromSingleError(CMD_TYPE.getName(), issue.getKey(), i18nHelper.getText(NO_MATCHING_ACTIONS_TEMPLATE, issue.getKey(), getIssueState(issue), cmd, validActionNames))); return Either.error(CommitHookErrors.fromSingleError(CMD_TYPE.getName(), issue.getKey(), i18nHelper.getText(MULTIPLE_ACTIONS_TEMPLATE, cmd, issue.getKey(), getIssueState(issue), validActionNames))); } else { if (!result.isValid()) { return Either.error(CommitHookErrors.fromErrorCollection( CMD_TYPE.getName(), issue.getKey(), result.getErrorCollection()));
public Either<CommitHookErrors, Comment> handle(ApplicationUser user, MutableIssue issue, String commandName, List<String> args) { JiraServiceContextImpl jiraServiceContext = new JiraServiceContextImpl(user); Comment comment = commentService.create(user, issue, args.isEmpty() ? null : args.get(0), true, jiraServiceContext.getErrorCollection()); if (jiraServiceContext.getErrorCollection().hasAnyErrors()) { return Either.error(CommitHookErrors.fromErrorCollection( CMD_TYPE.getName(), issue.getKey(), jiraServiceContext.getErrorCollection())); } else { return Either.value(comment); } } }
public void preStoreUpdates(JiraServiceContext context, IssueChangeHolder changeHolder, Issue currentIssue, MutableIssue targetIssue) { final Issue parentIssue = targetIssue.getParentObject(); changeHolder.addChangeItem(new ChangeItemBean(ChangeItemBean.STATIC_FIELD, "Parent", null, null, parentIssue.getId().toString(), parentIssue.getKey())); updateTargetIssueSecurityLevel(changeHolder, currentIssue, targetIssue, parentIssue); try { subtaskManager.createSubTaskIssueLink(parentIssue, targetIssue, context.getLoggedInUser()); } catch (CreateException e) { String msg = "Could not create sub-task issue link for '" + targetIssue.getKey() + "' (issue) and '" + parentIssue.getKey() + "' (parent)"; log.error(msg, e); throw new DataAccessException(msg, e); } }
public Response createIssue(IssueUpdateBean createRequest, @Context UriInfo uriInfo) { IssueInputParametersAssembler.Result result = issueInputParametersAssembler.makeCreateAssembler(createRequest); if (result.getErrors().hasAnyErrors()) { throw error(ErrorCollection.of(result.getErrors())); } IssueInputParameters parameters = result.getParameters(); MutableIssue issue; if (result.getParentIdorKey() == null) { issue = createIssue(parameters); } else { issue = createSubtask(parameters, result.getParentIdorKey()); } IssueCreateResponse response = new IssueCreateResponse() .id(issue.getId().toString()) .key(issue.getKey()) .self(resourceUriBuilder.build(uriInfo, IssueResource.class, String.valueOf(issue.getId())).toString()); return status(CREATED).entity(response).build(); }
/** * Looks at the issues we are about to move/migrate, and if any have been moved in the meantime, then * we will return the key of the fist issue which has been moved. * * @return issue key of the first issue that has been moved. * or null if none have been moved. */ private String findFirstMovedIssueKey() { // Check whether the user has the move permission on all original selected issues final List<Issue> selectedIssues = getBulkEditBean().getSelectedIssues(); for (final Issue selectedIssue : selectedIssues) { // Now get the latest value in the DB for this Issue. final MutableIssue latestIssue = getIssueManager().getIssueObject(selectedIssue.getId()); if (!latestIssue.getKey().equals(selectedIssue.getKey())) { return selectedIssue.getKey(); } } return null; }
public Either<CommitHookErrors, Worklog> handle(ApplicationUser user, MutableIssue issue, String commandName, List<String> args) { JiraServiceContextImpl jiraServiceContext = new JiraServiceContextImpl(user); WorklogResult result = worklogService.validateCreate( jiraServiceContext, WorklogInputParametersImpl.builder() .issue(issue) .timeSpent(args.isEmpty() ? null : args.get(0)) .comment(args.size() > 1 ? args.get(1) : null) .startDate(new Date()) .build()); if (!jiraServiceContext.getErrorCollection().hasAnyErrors()) { return Either.value(worklogService.createAndAutoAdjustRemainingEstimate( jiraServiceContext, result, true)); } else { return Either.error(CommitHookErrors.fromErrorCollection( CMD_TYPE.getName(), issue.getKey(), jiraServiceContext.getErrorCollection())); } } }
@Override public IssueResult assign(final ApplicationUser user, AssignValidationResult assignResult) { final MutableIssue issue = assignResult.getIssue(); // update the assignee system field OrderableField field = (OrderableField) fieldManager.getField(IssueFieldConstants.ASSIGNEE); FieldLayoutItem fieldLayoutItem = fieldLayoutManager.getFieldLayout(issue).getFieldLayoutItem(field); field.updateIssue(fieldLayoutItem, issue, EasyMap.build(field.getId(), assignResult.getAssigneeId())); final SimpleErrorCollection errorCollection = new SimpleErrorCollection(); try { issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_ASSIGNED, true); } catch (RuntimeException e) { log.error("There was an exception while trying to update the issue '" + issue.getKey() + "'.", e); errorCollection.addErrorMessage(getI18n(user).getText("admin.errors.issues.exception.occured", issue.getKey())); } return new IssueResult(issue, errorCollection); }
"No transitions were available with name \"" + command + "\" on " + issue.getKey());
private ErrorCollection validateBrowseIssuePermission(final ApplicationUser user, final Long issueId) { final ErrorCollection errors = new SimpleErrorCollection(); final MutableIssue issue = issueManager.getIssueObject(issueId); if (issue == null) { errors.addErrorMessage(beanFactory.getInstance(user).getText("label.service.error.issue.doesnt.exist", issueId)); return errors; } if (!permissionManager.hasPermission(Permissions.BROWSE, issue, user)) { errors.addErrorMessage(beanFactory.getInstance(user).getText("label.service.error.issue.no.permission", issue.getKey())); } return errors; }
private void triggerEventsForManualTransition(IssueResult issueResult, TransitionValidationResult transitionResult) { TransitionOptions transitionOptions = TransitionOptions.toTransitionOptions(transitionResult.getAdditionInputs()); if (!transitionOptions.isAutomaticTransition()) { eventPublisher.publish(new WorkflowManualTransitionExecutionEvent(issueResult.getIssue().getKey(), transitionResult.getActionId(), issueResult.isValid())); Instrumentation.pullCounter(InstrumentationName.WORKFLOW_MANUAL_TRANSITION).incrementAndGet(); } else { Instrumentation.pullCounter(InstrumentationName.WORKFLOW_AUTOMATIC_TRANSITION).incrementAndGet(); } }
private void moveIssueInTxn(Transaction txn, MutableIssue originalIssueObject, MutableIssue updatedIssueObject, String originalWfId) throws GenericEntityException { // Only migrate the issue if the target workflow is different from the current workflow if (!isWorkflowMatch(getCurrentIssueType(), getTargetIssueType())) { migrateIssueToWorkflow(updatedIssueObject, getIssue().getString("type"), getWorkflowForType(getTargetPid(), getTargetIssueType()), getTargetStatus()); } // Log and set new details for target updatedIssueObject.setUpdated(new Timestamp(System.currentTimeMillis())); IssueChangeHolder issueChangeHolder = moveIssueDetails(updatedIssueObject, originalIssueObject.getKey(), originalWfId); //create and store the changelog for this whole process GenericValue updateLog = ChangeLogUtils.createChangeGroup(getLoggedInUser(), originalIssueObject.getGenericValue(), updatedIssueObject.getGenericValue(), issueChangeHolder.getChangeItems(), false); // remember the old issue key so we can do fast URL redirects if (projectIsMoved()) issueManager.recordMovedIssueKey(originalIssueObject); txn.commit(); dispatchIssueUpdateEvents(updatedIssueObject, updateLog, issueChangeHolder); }
@RequiresXsrfCheck protected String doExecute() throws Exception { MutableIssue issue = getMutableIssue(); // update the assignee system field OrderableField field = (OrderableField) fieldManager.getField(IssueFieldConstants.ASSIGNEE); FieldLayoutItem fieldLayoutItem = fieldLayoutManager.getFieldLayout(issue).getFieldLayoutItem(field); field.updateIssue(fieldLayoutItem, issue, getFieldValuesHolder()); // This hack is here until the comment field becomes placeable on screens by the users OrderableField commentField = (OrderableField) fieldManager.getField(IssueFieldConstants.COMMENT); FieldLayoutItem fieldLayoutItem2 = fieldLayoutManager.getFieldLayout(issue.getProjectObject(), issue.getIssueTypeId()).getFieldLayoutItem(commentField); commentField.updateIssue(fieldLayoutItem2, issue, getFieldValuesHolder()); issueManager.updateIssue(getLoggedInUser(), issue, ISSUE_ASSIGNED, true); if (isInlineDialogMode()) { return returnComplete(); } return getRedirect("/browse/" + issue.getKey()); }