use of com.synopsys.integration.alert.api.channel.issue.model.IssueCommentModel in project hub-alert by blackducksoftware.
the class ProjectIssueModelConverter method toIssueCommentModel.
public <T extends Serializable> IssueCommentModel<T> toIssueCommentModel(ExistingIssueDetails<T> existingIssueDetails, ProjectIssueModel projectIssueModel) {
ChunkedStringBuilder commentBuilder = new ChunkedStringBuilder(formatter.getMaxCommentLength());
LinkableItem provider = projectIssueModel.getProvider();
String commentHeader = String.format("The component was updated in %s[%s]", provider.getLabel(), provider.getValue());
commentBuilder.append(formatter.encode(commentHeader));
commentBuilder.append(formatter.getLineSeparator());
commentBuilder.append(formatter.getSectionSeparator());
commentBuilder.append(formatter.getLineSeparator());
createVulnerabilitySeverityStatusSectionPieces(projectIssueModel).forEach(commentBuilder::append);
createProjectIssueModelConcernSectionPieces(projectIssueModel, true).forEach(commentBuilder::append);
IssueBomComponentDetails bomComponent = projectIssueModel.getBomComponentDetails();
List<String> attributeStrings = bomComponentDetailConverter.gatherAttributeStrings(bomComponent);
for (String attributeString : attributeStrings) {
commentBuilder.append(formatter.getNonBreakingSpace());
commentBuilder.append(formatter.encode("-"));
commentBuilder.append(formatter.getNonBreakingSpace());
commentBuilder.append(attributeString);
commentBuilder.append(formatter.getLineSeparator());
}
List<String> chunkedComments = commentBuilder.collectCurrentChunks();
return new IssueCommentModel<>(existingIssueDetails, chunkedComments, projectIssueModel);
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueCommentModel in project hub-alert by blackducksoftware.
the class IssueTrackerIssueTransitioner method transitionIssue.
public final Optional<IssueTrackerIssueResponseModel<T>> transitionIssue(IssueTransitionModel<T> issueTransitionModel) throws AlertException {
IssueOperation issueOperation = issueTransitionModel.getIssueOperation();
ExistingIssueDetails<T> existingIssueDetails = issueTransitionModel.getExistingIssueDetails();
Optional<IssueTrackerIssueResponseModel<T>> transitionResponse = Optional.empty();
Optional<String> optionalTransitionName = retrieveJobTransitionName(issueOperation);
if (optionalTransitionName.isPresent()) {
String transitionName = optionalTransitionName.get();
boolean shouldAttemptTransition = isTransitionRequired(existingIssueDetails, issueOperation);
if (shouldAttemptTransition) {
attemptTransition(issueOperation, existingIssueDetails, transitionName);
IssueTrackerIssueResponseModel<T> transitionResponseModel = issueResponseCreator.createIssueResponse(issueTransitionModel.getSource(), existingIssueDetails, issueOperation);
transitionResponse = Optional.of(transitionResponseModel);
} else {
logger.debug("The issue is already in the status category that would result from this transition ({}). Issue Details: {}", transitionName, existingIssueDetails);
}
} else {
logger.debug("No transition name was provided so no '{}' transition will be performed. Issue Details: {}", issueOperation.name(), existingIssueDetails);
}
IssueCommentModel<T> commentRequestModel = new IssueCommentModel<>(existingIssueDetails, issueTransitionModel.getPostTransitionComments(), issueTransitionModel.getSource());
commenter.commentOnIssue(commentRequestModel);
return transitionResponse;
}
Aggregations