Search in sources :

Example 1 with ProjectBomService

use of com.synopsys.integration.blackduck.service.dataservice.ProjectBomService in project hub-alert by blackducksoftware.

the class BlackDuckProviderService method triggerBlackDuckNotification.

public void triggerBlackDuckNotification(Supplier<ExternalId> externalIdSupplier, Predicate<ProjectVersionComponentVersionView> componentFilter) throws IntegrationException {
    setupBlackDuckServicesFactory();
    BlackDuckApiClient blackDuckService = blackDuckServicesFactory.getBlackDuckApiClient();
    ProjectService projectService = blackDuckServicesFactory.createProjectService();
    ProjectVersionWrapper projectVersion = projectService.getProjectVersion(blackDuckProjectName, blackDuckProjectVersion).orElseThrow(() -> new IntegrationException(String.format("Could not find the Black Duck project '%s' version '%s'", blackDuckProjectName, blackDuckProjectVersion)));
    ProjectVersionView projectVersionView = projectVersion.getProjectVersionView();
    List<ProjectVersionComponentVersionView> bomComponents = blackDuckService.getAllResponses(projectVersionView.metaComponentsLink());
    Optional<ProjectVersionComponentVersionView> apacheCommonsFileUpload = bomComponents.stream().filter(componentFilter).findFirst();
    if (apacheCommonsFileUpload.isPresent()) {
        blackDuckService.delete(apacheCommonsFileUpload.get());
    // Thread.currentThread().wait(1000);
    }
    ExternalId externalId = externalIdSupplier.get();
    ProjectBomService projectBomService = blackDuckServicesFactory.createProjectBomService();
    projectBomService.addComponentToProjectVersion(externalId, projectVersionView);
}
Also used : IntegrationException(com.synopsys.integration.exception.IntegrationException) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) ProjectService(com.synopsys.integration.blackduck.service.dataservice.ProjectService) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ProjectBomService(com.synopsys.integration.blackduck.service.dataservice.ProjectBomService) ProjectVersionComponentVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView)

Aggregations

ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 ProjectVersionComponentVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView)1 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)1 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)1 ProjectBomService (com.synopsys.integration.blackduck.service.dataservice.ProjectBomService)1 ProjectService (com.synopsys.integration.blackduck.service.dataservice.ProjectService)1 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1