Search in sources :

Example 11 with ProviderDetails

use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails in project hub-alert by blackducksoftware.

the class ProjectVersionNotificationMessageExtractor method extract.

@Override
protected ProviderMessageHolder extract(NotificationContentWrapper notificationContentWrapper, ProjectVersionNotificationContent notificationContent) {
    AlertNotificationModel alertNotificationModel = notificationContentWrapper.getAlertNotificationModel();
    Long providerConfigId = alertNotificationModel.getProviderConfigId();
    String providerUrl;
    try {
        BlackDuckServicesFactory blackDuckServicesFactory = servicesFactoryCache.retrieveBlackDuckServicesFactory(providerConfigId);
        providerUrl = blackDuckServicesFactory.getBlackDuckHttpClient().getBlackDuckUrl().string();
    } catch (AlertConfigurationException e) {
        logger.warn("Invalid BlackDuck configuration for notification. ID: {}. Name: {}", providerConfigId, alertNotificationModel.getProviderConfigName(), e);
        return ProviderMessageHolder.empty();
    }
    LinkableItem providerItem = new LinkableItem(blackDuckProviderKey.getDisplayName(), alertNotificationModel.getProviderConfigName(), providerUrl);
    ProviderDetails providerDetails = new ProviderDetails(alertNotificationModel.getProviderConfigId(), providerItem);
    LinkableItem project = new LinkableItem(BlackDuckMessageLabels.LABEL_PROJECT, notificationContent.getProjectName(), notificationContent.getProject());
    LinkableItem projectVersion = new LinkableItem(BlackDuckMessageLabels.LABEL_PROJECT_VERSION, notificationContent.getProjectVersionName(), notificationContent.getProjectVersion());
    ProjectOperation operation = ProjectOperation.fromOperationType(notificationContent.getOperationType());
    ProjectMessage projectVersionMessage = ProjectMessage.projectVersionStatusInfo(providerDetails, project, projectVersion, operation);
    return new ProviderMessageHolder(List.of(projectVersionMessage), List.of());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) AlertConfigurationException(com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)

Example 12 with ProviderDetails

use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails in project hub-alert by blackducksoftware.

the class ProjectNotificationMessageExtractor method extract.

@Override
protected ProviderMessageHolder extract(NotificationContentWrapper notificationContentWrapper, ProjectNotificationContent notificationContent) {
    AlertNotificationModel alertNotificationModel = notificationContentWrapper.getAlertNotificationModel();
    Long providerConfigId = alertNotificationModel.getProviderConfigId();
    String providerUrl;
    try {
        BlackDuckServicesFactory blackDuckServicesFactory = servicesFactoryCache.retrieveBlackDuckServicesFactory(providerConfigId);
        providerUrl = blackDuckServicesFactory.getBlackDuckHttpClient().getBlackDuckUrl().string();
    } catch (AlertConfigurationException e) {
        logger.warn("Invalid BlackDuck configuration for notification. ID: {}. Name: {}", providerConfigId, alertNotificationModel.getProviderConfigName(), e);
        return ProviderMessageHolder.empty();
    }
    LinkableItem providerItem = new LinkableItem(blackDuckProviderKey.getDisplayName(), alertNotificationModel.getProviderConfigName(), providerUrl);
    ProviderDetails providerDetails = new ProviderDetails(alertNotificationModel.getProviderConfigId(), providerItem);
    LinkableItem project = new LinkableItem(BlackDuckMessageLabels.LABEL_PROJECT, notificationContent.getProjectName(), notificationContent.getProject());
    ProjectOperation operation = ProjectOperation.fromOperationType(notificationContent.getOperationType());
    ProjectMessage projectMessage = ProjectMessage.projectStatusInfo(providerDetails, project, operation);
    return new ProviderMessageHolder(List.of(projectMessage), List.of());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) AlertConfigurationException(com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)

Example 13 with ProviderDetails

use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails in project hub-alert by blackducksoftware.

the class LicenseLimitNotificationMessageExtractor method extract.

@Override
protected ProviderMessageHolder extract(NotificationContentWrapper notificationContentWrapper, LicenseLimitNotificationContent notificationContent) {
    AlertNotificationModel alertNotificationModel = notificationContentWrapper.getAlertNotificationModel();
    LinkableItem providerItem = new LinkableItem(blackDuckProviderKey.getDisplayName(), alertNotificationModel.getProviderConfigName());
    ProviderDetails providerDetails = new ProviderDetails(alertNotificationModel.getProviderConfigId(), providerItem);
    String summary = "License Limit Event";
    List<LinkableItem> details = new LinkedList<>();
    String marketingPageUrl = notificationContent.getMarketingPageUrl();
    if (StringUtils.isNotBlank(marketingPageUrl)) {
        LinkableItem marketingDetail = new LinkableItem("Marketing Page", "Visit", marketingPageUrl);
        details.add(marketingDetail);
    }
    Long usedCodeSize = notificationContent.getUsedCodeSize();
    if (null != usedCodeSize) {
        LinkableItem usedCodeSizeDetail = new LinkableItem("Used Code Size", usedCodeSize.toString());
        details.add(usedCodeSizeDetail);
    }
    Long hardLimit = notificationContent.getHardLimit();
    if (null != hardLimit) {
        LinkableItem hardLimitDetail = new LinkableItem("Hard Limit", hardLimit.toString());
        details.add(hardLimitDetail);
    }
    Long softLimit = notificationContent.getSoftLimit();
    if (null != softLimit) {
        LinkableItem softLimitDetail = new LinkableItem("Soft Limit", softLimit.toString());
        details.add(softLimitDetail);
    }
    SimpleMessage licenseLimitMessage = SimpleMessage.original(providerDetails, summary, notificationContent.getMessage(), details);
    return new ProviderMessageHolder(List.of(), List.of(licenseLimitMessage));
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) LinkedList(java.util.LinkedList)

Example 14 with ProviderDetails

use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails in project hub-alert by blackducksoftware.

the class AbstractBlackDuckComponentConcernMessageExtractor method extract.

@Override
protected final ProviderMessageHolder extract(NotificationContentWrapper notificationContentWrapper, T notificationContent) {
    AlertNotificationModel notificationModel = notificationContentWrapper.getAlertNotificationModel();
    Long providerConfigId = notificationModel.getProviderConfigId();
    String providerUrl;
    List<BomComponentDetails> bomComponentDetails;
    try {
        BlackDuckServicesFactory blackDuckServicesFactory = servicesFactoryCache.retrieveBlackDuckServicesFactory(providerConfigId);
        providerUrl = blackDuckServicesFactory.getBlackDuckHttpClient().getBlackDuckUrl().string();
        bomComponentDetails = createBomComponentDetails(notificationContent, blackDuckServicesFactory);
    } catch (AlertConfigurationException e) {
        logger.warn("Invalid BlackDuck configuration for notification. ID: {}. Name: {}", providerConfigId, notificationModel.getProviderConfigName(), e);
        return ProviderMessageHolder.empty();
    } catch (IntegrationException e) {
        logger.warn("Failed to retrieve BOM Component(s) from BlackDuck", e);
        return ProviderMessageHolder.empty();
    }
    LinkableItem providerItem = new LinkableItem(blackDuckProviderKey.getDisplayName(), notificationModel.getProviderConfigName(), providerUrl);
    ProviderDetails providerDetails = new ProviderDetails(notificationModel.getProviderConfigId(), providerItem);
    Optional<String> projectUrl = extractProjectUrl(notificationContent.getProjectVersionUrl());
    LinkableItem project = new LinkableItem(BlackDuckMessageLabels.LABEL_PROJECT, notificationContent.getProjectName(), projectUrl.orElse(null));
    LinkableItem projectVersion = new LinkableItem(BlackDuckMessageLabels.LABEL_PROJECT_VERSION, notificationContent.getProjectVersionName(), notificationContent.getProjectVersionUrl());
    // FIXME this is where I should put the additional info
    ProjectMessage projectMessage = createProjectMessage(providerDetails, project, projectVersion, bomComponentDetails);
    return new ProviderMessageHolder(List.of(projectMessage), List.of());
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IntegrationException(com.synopsys.integration.exception.IntegrationException) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) BomComponentDetails(com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails) AlertConfigurationException(com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)

Example 15 with ProviderDetails

use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails in project hub-alert by blackducksoftware.

the class JiraCloudIssueCreatorTest method createIssueCreationModel.

private IssueCreationModel createIssueCreationModel() {
    ProviderDetails providerDetails = new ProviderDetails(1L, null);
    ProjectIssueModel policy = ProjectIssueModel.policy(providerDetails, null, null, null, null);
    return IssueCreationModel.project("title", "description", List.of(), policy);
}
Also used : ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)

Aggregations

ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)27 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)25 Test (org.junit.jupiter.api.Test)13 ProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)8 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)7 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)5 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)5 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)5 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)5 ProjectOperation (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)4 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)3 WorkItemElementOperationModel (com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemElementOperationModel)3 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)3 MockChannelMessageFormatter (com.synopsys.integration.alert.api.channel.convert.mock.MockChannelMessageFormatter)2 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)1 AlertRuntimeException (com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException)1 IssueTrackerCallbackInfo (com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo)1