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);
}
Aggregations