Search in sources :

Example 1 with JiraIssueSearchProperties

use of com.synopsys.integration.alert.api.channel.jira.JiraIssueSearchProperties 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)

Example 2 with JiraIssueSearchProperties

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

the class JiraIssueCreator method assignAlertSearchProperties.

@Override
protected final void assignAlertSearchProperties(ExistingIssueDetails<String> createdIssueDetails, ProjectIssueModel alertIssueSource) throws AlertException {
    JiraIssueSearchProperties searchProperties = createSearchProperties(alertIssueSource);
    issuePropertiesManager.assignIssueProperties(createdIssueDetails.getIssueKey(), searchProperties);
}
Also used : JiraIssueSearchProperties(com.synopsys.integration.alert.api.channel.jira.JiraIssueSearchProperties)

Example 3 with JiraIssueSearchProperties

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

the class JiraIssueSearchResultCreator method createResultFromProjectIssue.

public ProjectIssueSearchResult<String> createResultFromProjectIssue(JiraSearcherResponseModel issue, ProviderDetails providerDetails, LinkableItem project) throws AlertException {
    JiraIssueSearchProperties issueProperties = issuePropertiesManager.retrieveIssueProperties(issue.getIssueKey());
    String nullableSubComponentName = issueProperties.getSubComponentName();
    String nullableSubComponentValue = issueProperties.getSubComponentValue();
    LinkableItem componentVersion = null;
    if (StringUtils.isNotBlank(nullableSubComponentName) && StringUtils.isNotBlank(nullableSubComponentValue)) {
        componentVersion = new LinkableItem(nullableSubComponentName, nullableSubComponentValue);
    }
    LinkableItem projectVersion = new LinkableItem(issueProperties.getSubTopicName(), issueProperties.getSubTopicValue());
    IssueBomComponentDetails bomComponentDetails = IssueBomComponentDetails.fromSearchResults(new LinkableItem(issueProperties.getComponentName(), issueProperties.getComponentValue()), componentVersion);
    ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(providerDetails, project, projectVersion, bomComponentDetails);
    return createIssueResult(issue, projectIssueModel);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) JiraIssueSearchProperties(com.synopsys.integration.alert.api.channel.jira.JiraIssueSearchProperties) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)

Aggregations

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