Hi,
I work on a plugin that has to update the linked Issues (Dependency on) of one issue with the Summary/Description/Priority. The linkedIssue are on N others projects. The code I wrote work only partially and I can't understand why. Because there is no logic behind them that works and them that not works. I have scenarios where when I update the main Issue, all linked issues are updated. Other scenarios where only some linked Issues are updated, and other scenarios where nothing is updated. I perform this in a for loop:
IssueService issueService = ComponentAccessor.getIssueService();
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters.setSummary(summary);
JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
ApplicationUser currentUser = jiraAuthenticationContext.getLoggedInUser();
UpdateValidationResult result =issueService.validateUpdate(currentUser, issueId, issueInputParameters);
if(result.isValid()){
IssueResult updateRes =issueService.update(currentUser, result,
com.atlassian.jira.event.type.EventDispatchOption.DO_NOT_DISPATCH, false);
logErrorAndWarnings(UPDATE, updateRes, true);
}else {
logErrorAndWarnings(VALIDATION_UPDATE, result, true);
}
and the helper method logErrorWarnings:
private void logErrorAndWarnings(String action, ServiceResultImpl results, boolean throwException) throws Exception {
Collection<String> errorMessages = results.getErrorCollection().getErrorMessages();
Collection<String> warningsMessages =results.getWarningCollection().getWarnings();
log.info("RESULT of " + action+ ": " + results.isValid() +" and has "+ errorMessages.size()+" ERRORS, and "+ warningsMessages.size()+ " WARNINGS" );
if(!errorMessages.isEmpty()){
String exceptionMessage = "ERROR: ";
for (String error: errorMessages){
exceptionMessage.concat("Can't "+action+" Issue while errors: "+ error);
log.error("Can't "+action+" Issue while errors: {}", error);
}
if(throwException){
throw new Exception(exceptionMessage);
}
}
if(!warningsMessages.isEmpty()){
String exceptionMessage = "WARNING: ";
for (String error: errorMessages){
exceptionMessage.concat("Can't "+action+" Issue while errors: "+ error);
log.warn("Can't "+action+" Issue while warnings: {}", error);
}
if(throwException){
throw new Exception(exceptionMessage);
}
}So by debugging locally I have trouble. But in test environment yes (There I have replicated the production Data).
What I can read out from the logs is that when the update fails, then I have as result that the update validation is false, but no warnings and no errors are present, and this don't helps me out to find why I can't update the issue. I can't start the test environment in debug mode to attach me and debug it.
How I sayed: in some scenarios it works in other no, but I have no Idea how I could figure out why. Some tips or tricks?
Thanks in advance.