use of com.synopsys.integration.blackduck.api.generated.view.ProjectView in project hub-alert by blackducksoftware.
the class BomEditNotificationDetailExtractorTest method createCache.
private NotificationExtractorBlackDuckServicesFactoryCache createCache(Long blackDuckConfigId, String projectName, String projectVersionName) throws IntegrationException {
ProjectView projectView = Mockito.mock(ProjectView.class);
Mockito.when(projectView.getName()).thenReturn(projectName);
ProjectVersionView projectVersionView = Mockito.mock(ProjectVersionView.class);
Mockito.when(projectVersionView.getVersionName()).thenReturn(projectVersionName);
BlackDuckApiClient blackDuckApiClient = Mockito.mock(BlackDuckApiClient.class);
Mockito.when(blackDuckApiClient.getResponse(Mockito.any(HttpUrl.class), Mockito.eq(ProjectVersionView.class))).thenReturn(projectVersionView);
Mockito.when(blackDuckApiClient.getResponse(Mockito.eq(projectVersionView.metaProjectLink()))).thenReturn(projectView);
BlackDuckServicesFactory blackDuckServicesFactory = Mockito.mock(BlackDuckServicesFactory.class);
Mockito.when(blackDuckServicesFactory.getBlackDuckApiClient()).thenReturn(blackDuckApiClient);
NotificationExtractorBlackDuckServicesFactoryCache cache = Mockito.mock(NotificationExtractorBlackDuckServicesFactoryCache.class);
Mockito.when(cache.retrieveBlackDuckServicesFactory(Mockito.eq(blackDuckConfigId))).thenReturn(blackDuckServicesFactory);
return cache;
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectView in project hub-alert by blackducksoftware.
the class BlackDuckDataSyncTask method getEmailsPerProject.
private Map<ProviderProject, Set<String>> getEmailsPerProject(Map<ProjectView, ProviderProject> blackDuckToAlertProjects, ProjectUsersService projectUsersService) {
Map<ProviderProject, Set<String>> projectToEmailAddresses = new ConcurrentHashMap<>();
blackDuckToAlertProjects.entrySet().parallelStream().forEach(entry -> {
try {
ProjectView blackDuckProjectView = entry.getKey();
ProviderProject alertProject = entry.getValue();
Set<String> projectUserEmailAddresses = projectUsersService.getAllActiveUsersForProject(blackDuckProjectView).stream().filter(UserView::getActive).map(UserView::getEmail).filter(StringUtils::isNotBlank).collect(Collectors.toSet());
if (StringUtils.isNotBlank(alertProject.getProjectOwnerEmail())) {
projectUserEmailAddresses.add(alertProject.getProjectOwnerEmail());
}
projectToEmailAddresses.put(alertProject, projectUserEmailAddresses);
} catch (IntegrationException e) {
// We do this to break out of the stream
throw new AlertRuntimeException(e.getMessage(), e);
}
});
return projectToEmailAddresses;
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectView in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method getProjectsForProvider.
private List<ProviderProject> getProjectsForProvider(ConfigurationModel blackDuckConfigurationModel) throws IntegrationException {
BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(blackDuckConfigurationModel);
ProjectService projectService = blackDuckServicesFactory.createProjectService();
List<ProjectView> allProjects = projectService.getAllProjects();
return convertBlackDuckProjects(allProjects, blackDuckServicesFactory.getBlackDuckApiClient());
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectView in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method getEmailAddressesForProjectHref.
@Override
public Set<String> getEmailAddressesForProjectHref(Long providerConfigId, String projectHref) {
Optional<ConfigurationModel> providerConfigOptional = configurationModelConfigurationAccessor.getConfigurationById(providerConfigId);
if (providerConfigOptional.isPresent()) {
try {
BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(providerConfigOptional.get());
BlackDuckApiClient blackDuckService = blackDuckServicesFactory.getBlackDuckApiClient();
ProjectView projectView = blackDuckService.getResponse(new HttpUrl(projectHref), ProjectView.class);
return getEmailAddressesForProject(projectView, blackDuckServicesFactory.createProjectUsersService());
} catch (IntegrationException e) {
logger.errorAndDebug(createProjectNotFoundString(providerConfigId, e.getMessage()), e);
}
}
return Set.of();
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectView in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method getProjectByHref.
@Override
public Optional<ProviderProject> getProjectByHref(Long providerConfigId, String projectHref) {
try {
Optional<ConfigurationModel> providerConfigOptional = configurationModelConfigurationAccessor.getConfigurationById(providerConfigId);
if (providerConfigOptional.isPresent()) {
BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(providerConfigOptional.get());
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
ProjectView foundProject = blackDuckApiClient.getResponse(new HttpUrl(projectHref), ProjectView.class);
return convertBlackDuckProjects(List.of(foundProject), blackDuckApiClient).stream().findFirst();
}
} catch (IntegrationException e) {
logger.errorAndDebug(createProjectNotFoundString(providerConfigId, e.getMessage()), e);
}
return Optional.empty();
}
Aggregations