use of com.synopsys.integration.alert.common.channel.message.RechunkedModel in project hub-alert by blackducksoftware.
the class IssueTrackerSimpleMessageConverter method convertToIssueCreationModel.
public IssueCreationModel convertToIssueCreationModel(SimpleMessage simpleMessage, String jobName) {
LinkableItem provider = simpleMessage.getProvider();
String rawTitle = String.format("%s[%s] | %s", provider.getLabel(), provider.getValue(), simpleMessage.getSummary());
String truncatedTitle = StringUtils.truncate(rawTitle, formatter.getMaxTitleLength());
List<String> descriptionChunks = simpleMessageConverter.convertToFormattedMessageChunks(simpleMessage, jobName);
RechunkedModel rechunkedDescription = ChunkedStringBuilderRechunker.rechunk(descriptionChunks, "No description", formatter.getMaxDescriptionLength(), formatter.getMaxCommentLength());
return IssueCreationModel.simple(truncatedTitle, rechunkedDescription.getFirstChunk(), rechunkedDescription.getRemainingChunks(), simpleMessage.getProvider());
}
use of com.synopsys.integration.alert.common.channel.message.RechunkedModel in project hub-alert by blackducksoftware.
the class ProjectIssueModelConverter method toIssueCreationModel.
public IssueCreationModel toIssueCreationModel(ProjectIssueModel projectIssueModel, String jobName) {
String title = createTruncatedTitle(projectIssueModel);
ChunkedStringBuilder descriptionBuilder = new ChunkedStringBuilder(formatter.getMaxDescriptionLength());
String nonBreakingSpace = formatter.getNonBreakingSpace();
String jobLine = String.format("Job%sname:%s%s", nonBreakingSpace, nonBreakingSpace, jobName);
String formattedJobName = formatter.emphasize(jobLine);
descriptionBuilder.append(formattedJobName);
descriptionBuilder.append(formatter.getLineSeparator());
String projectString = linkableItemConverter.convertToString(projectIssueModel.getProject(), true);
descriptionBuilder.append(projectString);
descriptionBuilder.append(formatter.getLineSeparator());
LinkableItem projectVersion = projectIssueModel.getProjectVersion().orElse(MISSING_PROJECT_VERSION_PLACEHOLDER);
String projectVersionString = linkableItemConverter.convertToString(projectVersion, true);
descriptionBuilder.append(projectVersionString);
descriptionBuilder.append(formatter.getLineSeparator());
descriptionBuilder.append(formatter.getSectionSeparator());
descriptionBuilder.append(formatter.getLineSeparator());
IssueBomComponentDetails bomComponent = projectIssueModel.getBomComponentDetails();
List<String> bomComponentPieces = bomComponentDetailConverter.gatherAbstractBomComponentSectionPieces(bomComponent);
bomComponentPieces.forEach(descriptionBuilder::append);
createVulnerabilitySeverityStatusSectionPieces(projectIssueModel).forEach(descriptionBuilder::append);
descriptionBuilder.append(formatter.getLineSeparator());
createProjectIssueModelConcernSectionPieces(projectIssueModel, false).forEach(descriptionBuilder::append);
int newChunkSize = formatter.getMaxCommentLength() - DESCRIPTION_CONTINUED_TEXT.length() - formatter.getLineSeparator().length();
RechunkedModel rechunkedDescription = ChunkedStringBuilderRechunker.rechunk(descriptionBuilder, "No description", newChunkSize);
List<String> postCreateComments = rechunkedDescription.getRemainingChunks().stream().map(comment -> String.format("%s%s%s", DESCRIPTION_CONTINUED_TEXT, formatter.getLineSeparator(), comment)).collect(Collectors.toList());
return IssueCreationModel.project(title, rechunkedDescription.getFirstChunk(), postCreateComments, projectIssueModel);
}
Aggregations