Search in sources :

Example 1 with NotificationType

use of com.synopsys.integration.blackduck.api.manual.enumeration.NotificationType in project hub-alert by blackducksoftware.

the class JobNotificationFilterUtils method doesNotificationApplyToJob.

public static boolean doesNotificationApplyToJob(FilteredDistributionJobResponseModel filteredDistributionJobResponseModel, DetailedNotificationContent detailedNotificationContent) {
    String notificationType = detailedNotificationContent.getNotificationContentWrapper().extractNotificationType();
    NotificationType notificationTypeEnum = NotificationType.valueOf(notificationType);
    if (!doesNotificationTypeMatch(filteredDistributionJobResponseModel, notificationType)) {
        return false;
    }
    String projectName = detailedNotificationContent.getProjectName().orElse("");
    String projectVersionName = detailedNotificationContent.getProjectVersionName().orElse("");
    if (!doesProjectApplyToJob(filteredDistributionJobResponseModel, projectName, projectVersionName)) {
        return false;
    }
    switch(notificationTypeEnum) {
        case VULNERABILITY:
            List<String> notificationSeverities = detailedNotificationContent.getVulnerabilitySeverities();
            return doVulnerabilitySeveritiesApplyToJob(filteredDistributionJobResponseModel, notificationSeverities);
        case POLICY_OVERRIDE:
        case RULE_VIOLATION:
        case RULE_VIOLATION_CLEARED:
            String policyName = detailedNotificationContent.getPolicyName().orElse("");
            return doesPolicyApplyToJob(filteredDistributionJobResponseModel, policyName);
        default:
            break;
    }
    return true;
}
Also used : NotificationType(com.synopsys.integration.blackduck.api.manual.enumeration.NotificationType)

Example 2 with NotificationType

use of com.synopsys.integration.blackduck.api.manual.enumeration.NotificationType in project hub-alert by blackducksoftware.

the class ProviderMessageExtractionDelegator method extract.

public ProcessedProviderMessageHolder extract(NotificationContentWrapper notificationContentWrapper) {
    String notificationTypeString = notificationContentWrapper.extractNotificationType();
    NotificationType filteredNotificationType = EnumUtils.getEnum(NotificationType.class, notificationTypeString);
    if (null == filteredNotificationType) {
        logger.warn("Notification did not match any existing notification type: {}", notificationTypeString);
        return ProcessedProviderMessageHolder.empty();
    }
    ProviderMessageExtractor providerMessageExtractor = notificationTypeToExtractor.get(filteredNotificationType);
    if (null == providerMessageExtractor) {
        logger.warn("No matching extractor for notification type: {}", notificationTypeString);
        return ProcessedProviderMessageHolder.empty();
    }
    return providerMessageExtractor.extract(notificationContentWrapper);
}
Also used : NotificationType(com.synopsys.integration.blackduck.api.manual.enumeration.NotificationType)

Aggregations

NotificationType (com.synopsys.integration.blackduck.api.manual.enumeration.NotificationType)2