private List<IssueService.IssueResult> simpleTravel( User user, Issue issue, Status to, MultiMap<String, Object, ? extends List> params, final List<IssueService.TransitionValidationResult> errorResults) { List<IssueService.IssueResult> resultList = new ArrayList<IssueService.IssueResult>(); User oldUser = jiraAuthenticationContext.getLoggedInUser(); jiraAuthenticationContext.setLoggedInUser(user); List<IssueService.TransitionValidationResult> validResults = getValidResults(user, issue, to, params, errorResults); if (!validResults.isEmpty()) { for (IssueService.TransitionValidationResult validResult : validResults) { IssueService.IssueResult result = issueService.transition(user, validResult); if (result.getErrorCollection() != null && result.getErrorCollection().hasAnyErrors()) { log.warn( "result of transition for issue : " + validResult.getIssue().getKey() + " and transition : " + to.getName() + " is not so valid, something wrong here : " + (result.getErrorCollection().getErrorMessages() != null ? Arrays.toString(result.getErrorCollection().getErrorMessages().toArray()) : " dunno what")); errorResults.add(validResult); } else { resultList.add(result); return resultList; } } // TODO: do something with multiple results } jiraAuthenticationContext.setLoggedInUser(oldUser); return resultList; }
private List<IssueService.TransitionValidationResult> getSimpleTransitionResults( User user, Issue issue, Status to, MultiMap<String, Object, ? extends List> params) { List<IssueService.TransitionValidationResult> result = new ArrayList<IssueService.TransitionValidationResult>(); Map<String, Object> simpleParams = getSimpleMap(params); Set<Integer> nextStatusActionIds = getNextStatusActionIds(issue, to); if (nextStatusActionIds.size() == 0) throw new IllegalArgumentException( "to status is not valid for issue : " + issue.getKey() + " and status : " + to.getName()); if (nextStatusActionIds.size() > 1) log.warn( "found more than one actions for next status transition : " + issue.getKey() + " and status : " + to.getName()); for (Integer actionId : nextStatusActionIds) { IssueInputParameters issueInputParameters = newIssueInputParameters(simpleParams); issueInputParameters.setSkipScreenCheck(true); log.debug( "traveling to status : " + to.getName() + " with action id : " + actionId + "; user : "******" ; issueInputParameters : " + issueInputParameters + " : " + to.getId() + " and logged in user : "******"validation result status : " + transitionValidationResult.getIssue().getStatusObject().getName() + " and action id : " + transitionValidationResult.getActionId()); result.add(transitionValidationResult); } return result; }
private List<IssueService.TransitionValidationResult> getValidResults( User user, Issue issue, Status to, MultiMap<String, Object, ? extends List> params, List<IssueService.TransitionValidationResult> errorResults) { List<IssueService.TransitionValidationResult> result = new ArrayList<IssueService.TransitionValidationResult>(); List<IssueService.TransitionValidationResult> simpleTransitionResults = getSimpleTransitionResults(user, issue, to, params); for (IssueService.TransitionValidationResult transitionValidationResult : simpleTransitionResults) { if (transitionValidationResult.isValid()) result.add(transitionValidationResult); else errorResults.add(transitionValidationResult); } // TODO : add not simple return result; }
protected void doValidation() { try { // just checking that the issue exists and that the user has permission to see it. getIssue(); } catch (IssuePermissionException ipe) { return; } catch (IssueNotFoundException infe) { return; } final IssueInputParameters issueInputParameters = new IssueInputParametersImpl(ActionContext.getParameters()); issueInputParameters.setRetainExistingValuesWhenParameterNotProvided(false); transitionResult = issueService.validateTransition( getRemoteUser(), getIssueObject().getId(), action, issueInputParameters); setFieldValuesHolder(transitionResult.getFieldValuesHolder()); if (!transitionResult.isValid()) { addErrorCollection(transitionResult.getErrorCollection()); } }