use of com.synopsys.integration.alert.common.persistence.model.ProviderProject in project hub-alert by blackducksoftware.
the class EmailTestActionHelper method createUpdatedEmailAddresses.
public Set<String> createUpdatedEmailAddresses(DistributionJobModel distributionJobModel) throws AlertException {
Set<String> emailAddresses = new HashSet<>();
DistributionJobDetailsModel distributionJobDetails = distributionJobModel.getDistributionJobDetails();
EmailJobDetailsModel emailJobDetails = distributionJobDetails.getAs(DistributionJobDetailsModel.EMAIL);
Long providerConfigId = distributionJobModel.getBlackDuckGlobalConfigId();
boolean onlyAdditionalEmails = emailJobDetails.isAdditionalEmailAddressesOnly();
if (null != providerConfigId && !onlyAdditionalEmails) {
Set<ProviderProject> providerProjects = retrieveProviderProjects(distributionJobModel, providerConfigId);
if (CollectionUtils.isNotEmpty(providerProjects)) {
Set<String> providerEmailAddresses = addEmailAddresses(providerConfigId, providerProjects, distributionJobModel, emailJobDetails);
emailAddresses.addAll(providerEmailAddresses);
}
}
return emailAddresses;
}
use of com.synopsys.integration.alert.common.persistence.model.ProviderProject in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method retrieveProjectsForProvider.
private AlertPagedModel<ProviderProject> retrieveProjectsForProvider(ConfigurationModel blackDuckConfigurationModel, int pageNumber, int pageSize, String searchTerm) throws IntegrationException {
BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(blackDuckConfigurationModel);
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
ApiDiscovery apiDiscovery = blackDuckServicesFactory.getApiDiscovery();
BlackDuckQuery nameQuery = new BlackDuckQuery("name", searchTerm);
BlackDuckPageDefinition blackDuckPageDefinition = new BlackDuckPageDefinition(pageSize, pageNumber * pageSize);
BlackDuckMultipleRequest<ProjectView> projectSpec = new BlackDuckRequestBuilder().commonGet().addBlackDuckQuery(nameQuery).setBlackDuckPageDefinition(blackDuckPageDefinition).buildBlackDuckRequest(apiDiscovery.metaProjectsLink());
BlackDuckPageResponse<ProjectView> pageOfProjects = blackDuckApiClient.getPageResponse(projectSpec);
List<ProviderProject> foundProjects = convertBlackDuckProjects(pageOfProjects.getItems(), blackDuckApiClient);
int totalPageCount = computeTotalCount(pageOfProjects, pageSize);
return new AlertPagedModel<>(totalPageCount, pageNumber, pageSize, foundProjects);
}
use of com.synopsys.integration.alert.common.persistence.model.ProviderProject in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method convertBlackDuckProjects.
private List<ProviderProject> convertBlackDuckProjects(List<ProjectView> projectViews, BlackDuckApiClient blackDuckService) {
List<ProviderProject> providerProjects = new ArrayList<>();
for (ProjectView projectView : projectViews) {
ProviderProject providerProject = createProviderProject(projectView, blackDuckService);
providerProjects.add(providerProject);
}
return providerProjects;
}
use of com.synopsys.integration.alert.common.persistence.model.ProviderProject in project hub-alert by blackducksoftware.
the class BlackDuckGlobalApiAction method afterDeleteAction.
@Override
public void afterDeleteAction(FieldModel fieldModel) {
Map<String, FieldValueModel> keyToValues = fieldModel.getKeyToValues();
FieldValueModel fieldValueModel = keyToValues.get(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME);
String blackDuckGlobalConfigName = fieldValueModel.getValue().orElse("");
Long configId = Long.parseLong(fieldModel.getId());
providerLifecycleManager.unscheduleTasksForProviderConfig(configId);
List<ProviderProject> blackDuckProjects = providerDataAccessor.getProjectsByProviderConfigName(blackDuckGlobalConfigName);
providerDataAccessor.deleteProjects(blackDuckProjects);
}
use of com.synopsys.integration.alert.common.persistence.model.ProviderProject in project hub-alert by blackducksoftware.
the class BlackDuckDataSyncTask method mapBlackDuckProjectsToAlertProjects.
private Map<ProjectView, ProviderProject> mapBlackDuckProjectsToAlertProjects(List<ProjectView> projectViews, BlackDuckApiClient blackDuckApiClient) {
Map<ProjectView, ProviderProject> projectMap = new ConcurrentHashMap<>();
projectViews.parallelStream().forEach(projectView -> {
String projectOwnerEmail = null;
if (StringUtils.isNotBlank(projectView.getProjectOwner())) {
try {
HttpUrl projectOwnerHttpUrl = new HttpUrl(projectView.getProjectOwner());
UserView projectOwner = blackDuckApiClient.getResponse(projectOwnerHttpUrl, UserView.class);
projectOwnerEmail = projectOwner.getEmail();
} catch (IntegrationException e) {
logger.error(String.format("Could not get the project owner for Project: %s. Error: %s", projectView.getName(), e.getMessage()), e);
}
}
projectMap.put(projectView, new ProviderProject(projectView.getName(), StringUtils.trimToEmpty(projectView.getDescription()), projectView.getMeta().getHref().toString(), projectOwnerEmail));
});
return projectMap;
}
Aggregations