Search in sources :

Example 1 with NotificationView

use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-common by blackducksoftware.

the class BlackDuckResponseResolverTest method testGettingRuntimeClass.

@Test
public void testGettingRuntimeClass() throws IOException {
    String projectVersionJson = IOUtils.toString(this.getClass().getResourceAsStream("/json/notifications/project_version.json"), StandardCharsets.UTF_8);
    String vulnerabilityJson = IOUtils.toString(this.getClass().getResourceAsStream("/json/notifications/vulnerability.json"), StandardCharsets.UTF_8);
    BlackDuckResponseResolver blackDuckResponseResolver = new BlackDuckResponseResolver(new Gson());
    NotificationView projectVersionNotificationView = blackDuckResponseResolver.resolve(projectVersionJson, NotificationView.class);
    NotificationView vulnerabilityNotificationView = blackDuckResponseResolver.resolve(vulnerabilityJson, NotificationView.class);
    assertTrue(projectVersionNotificationView instanceof ProjectVersionNotificationView);
    assertTrue(vulnerabilityNotificationView instanceof VulnerabilityNotificationView);
}
Also used : VulnerabilityNotificationView(com.synopsys.integration.blackduck.api.manual.view.VulnerabilityNotificationView) ProjectVersionNotificationView(com.synopsys.integration.blackduck.api.manual.view.ProjectVersionNotificationView) VulnerabilityNotificationView(com.synopsys.integration.blackduck.api.manual.view.VulnerabilityNotificationView) NotificationView(com.synopsys.integration.blackduck.api.manual.view.NotificationView) ProjectVersionNotificationView(com.synopsys.integration.blackduck.api.manual.view.ProjectVersionNotificationView) Gson(com.google.gson.Gson) Test(org.junit.jupiter.api.Test)

Example 2 with NotificationView

use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-common by blackducksoftware.

the class NotificationService method getPageOfNotifications.

public BlackDuckPageResponse<NotificationView> getPageOfNotifications(NotificationEditor notificationEditor, BlackDuckPageDefinition blackDuckPageDefinition) throws IntegrationException {
    BlackDuckRequestBuilder blackDuckRequestBuilder = createNotificationRequestBuilder(notificationEditor).setBlackDuckPageDefinition(blackDuckPageDefinition);
    BlackDuckMultipleRequest<NotificationView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(notificationsResponses);
    return blackDuckApiClient.getPageResponse(requestMultiple);
}
Also used : NotificationView(com.synopsys.integration.blackduck.api.manual.view.NotificationView) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)

Example 3 with NotificationView

use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-common by blackducksoftware.

the class NotificationService method getLatestNotificationDate.

/**
 * @return The java.util.Date of the most recent notification. If there are no notifications, the current date will be returned. This can set an initial start time window for all future notifications.
 * @throws IntegrationException
 */
public Date getLatestNotificationDate() throws IntegrationException {
    BlackDuckRequestBuilder blackDuckRequestBuilder = createLatestDateRequestBuilder();
    BlackDuckMultipleRequest<NotificationView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(notificationsResponses);
    List<NotificationView> notifications = blackDuckApiClient.getSomeResponses(requestMultiple, 1);
    return getFirstCreatedAtDate(notifications);
}
Also used : NotificationView(com.synopsys.integration.blackduck.api.manual.view.NotificationView) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)

Example 4 with NotificationView

use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-common by blackducksoftware.

the class NotificationService method getAllNotifications.

public List<NotificationView> getAllNotifications(NotificationEditor notificationEditor) throws IntegrationException {
    BlackDuckRequestBuilder blackDuckRequestBuilder = createNotificationRequestBuilder(notificationEditor);
    BlackDuckMultipleRequest<NotificationView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(notificationsResponses);
    List<NotificationView> possiblyPoorlyFilteredNotifications = blackDuckApiClient.getAllResponses(requestMultiple);
    return reallyFilterNotifications(possiblyPoorlyFilteredNotifications, notificationEditor.getNotificationTypesToInclude());
}
Also used : NotificationView(com.synopsys.integration.blackduck.api.manual.view.NotificationView) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)

Example 5 with NotificationView

use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-alert by blackducksoftware.

the class NotificationDetailExtractionDelegator method wrapNotification.

public final List<DetailedNotificationContent> wrapNotification(AlertNotificationModel notification) {
    NotificationView notificationView = blackDuckResponseResolver.resolve(notification.getContent(), NotificationView.class);
    Optional<NotificationDetailExtractor> notificationExtractorOptional = getNotificationExtractor(notificationView.getClass());
    if (notificationExtractorOptional.isPresent()) {
        NotificationDetailExtractor notificationDetailExtractor = notificationExtractorOptional.get();
        return notificationDetailExtractor.extractDetailedContent(notification, notificationView);
    }
    logger.warn("Did not find extractor for notification view: {}", notificationView.getClass().getSimpleName());
    return List.of();
}
Also used : NotificationView(com.synopsys.integration.blackduck.api.manual.view.NotificationView)

Aggregations

NotificationView (com.synopsys.integration.blackduck.api.manual.view.NotificationView)9 BlackDuckRequestBuilder (com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)3 Gson (com.google.gson.Gson)1 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)1 VersionBomCodeLocationBomComputedNotificationContent (com.synopsys.integration.blackduck.api.manual.component.VersionBomCodeLocationBomComputedNotificationContent)1 NotificationType (com.synopsys.integration.blackduck.api.manual.temporary.enumeration.NotificationType)1 NotificationUserView (com.synopsys.integration.blackduck.api.manual.view.NotificationUserView)1 ProjectVersionNotificationView (com.synopsys.integration.blackduck.api.manual.view.ProjectVersionNotificationView)1 VersionBomCodeLocationBomComputedNotificationUserView (com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationUserView)1 VersionBomCodeLocationBomComputedNotificationView (com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationView)1 VulnerabilityNotificationView (com.synopsys.integration.blackduck.api.manual.view.VulnerabilityNotificationView)1 BlackDuckRegistrationService (com.synopsys.integration.blackduck.service.dataservice.BlackDuckRegistrationService)1 NotificationService (com.synopsys.integration.blackduck.service.dataservice.NotificationService)1 NotificationEditor (com.synopsys.integration.blackduck.service.request.NotificationEditor)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 ChronoUnit (java.time.temporal.ChronoUnit)1 Arrays (java.util.Arrays)1 Date (java.util.Date)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1