Search in sources :

Example 1 with JiraIssueAlertPropertiesUrlCorrector

use of com.synopsys.integration.alert.api.channel.jira.distribution.search.JiraIssueAlertPropertiesUrlCorrector in project hub-alert by blackducksoftware.

the class JiraIssueCreator method createSearchProperties.

private JiraIssueSearchProperties createSearchProperties(ProjectIssueModel alertIssueSource) {
    LinkableItem provider = alertIssueSource.getProvider();
    LinkableItem project = alertIssueSource.getProject();
    LinkableItem projectVersion = alertIssueSource.getProjectVersion().orElseThrow(() -> new AlertRuntimeException("Missing project version"));
    IssueBomComponentDetails bomComponent = alertIssueSource.getBomComponentDetails();
    LinkableItem component = bomComponent.getComponent();
    String componentVersionLabel = bomComponent.getComponentVersion().map(LinkableItem::getLabel).orElse(null);
    String componentVersionName = bomComponent.getComponentVersion().map(LinkableItem::getValue).orElse(null);
    String additionalKey = null;
    ComponentConcernType concernType = ComponentConcernType.VULNERABILITY;
    Optional<String> optionalPolicyName = alertIssueSource.getPolicyDetails().map(IssuePolicyDetails::getName);
    if (optionalPolicyName.isPresent()) {
        concernType = ComponentConcernType.POLICY;
        additionalKey = JiraIssueSearchPropertyStringCompatibilityUtils.createPolicyAdditionalKey(optionalPolicyName.get());
    }
    if (alertIssueSource.getComponentUnknownVersionDetails().isPresent()) {
        concernType = ComponentConcernType.UNKNOWN_VERSION;
    }
    String category = JiraIssueSearchPropertyStringCompatibilityUtils.createCategory(concernType);
    return new JiraIssueSearchProperties(provider.getLabel(), provider.getUrl().flatMap(JiraIssueAlertPropertiesUrlCorrector::correctUrl).orElse(null), project.getLabel(), project.getValue(), projectVersion.getLabel(), projectVersion.getValue(), category, component.getLabel(), component.getValue(), componentVersionLabel, componentVersionName, additionalKey);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ComponentConcernType(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails) JiraIssueSearchProperties(com.synopsys.integration.alert.api.channel.jira.JiraIssueSearchProperties) JiraIssueAlertPropertiesUrlCorrector(com.synopsys.integration.alert.api.channel.jira.distribution.search.JiraIssueAlertPropertiesUrlCorrector) AlertRuntimeException(com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException)

Aggregations

IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)1 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)1 JiraIssueSearchProperties (com.synopsys.integration.alert.api.channel.jira.JiraIssueSearchProperties)1 JiraIssueAlertPropertiesUrlCorrector (com.synopsys.integration.alert.api.channel.jira.distribution.search.JiraIssueAlertPropertiesUrlCorrector)1 AlertRuntimeException (com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException)1 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)1 ComponentConcernType (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType)1