use of com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder 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.blackduck.http.BlackDuckRequestBuilder in project hub-alert by blackducksoftware.
the class PolicyNotificationFilterCustomFunctionAction method retrievePolicyRules.
private BlackDuckPageResponse<PolicyRuleView> retrievePolicyRules(BlackDuckServicesFactory blackDuckServicesFactory, int pageNumber, int pageSize, String searchTerm) throws IntegrationException {
ApiDiscovery apiDiscovery = blackDuckServicesFactory.getApiDiscovery();
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
BlackDuckMultipleRequest<PolicyRuleView> spec = new BlackDuckRequestBuilder().commonGet().setLimitAndOffset(pageSize, pageNumber * pageSize).addBlackDuckQuery(new BlackDuckQuery("name", searchTerm)).addBlackDuckFilter(BlackDuckRequestFilter.createFilterWithSingleValue("policyRuleEnabled", "true")).buildBlackDuckRequest(apiDiscovery.metaPolicyRulesLink());
return blackDuckApiClient.getPageResponse(spec);
}
use of com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder in project hub-alert by blackducksoftware.
the class BlackDuckNotificationRetriever method createNotificationsRequest.
private BlackDuckMultipleRequest<NotificationUserView> createNotificationsRequest(DateRange dateRange, List<String> notificationTypesToInclude) throws IntegrationException {
UserView currentUser = blackDuckApiClient.getResponse(apiDiscovery.metaCurrentUserLink());
UrlMultipleResponses<NotificationUserView> currentUserNotificationsUrl = currentUser.metaNotificationsLink();
NotificationEditor notificationEditor = new NotificationEditor(dateRange.getStart(), dateRange.getEnd(), notificationTypesToInclude);
BlackDuckMultipleRequest<NotificationUserView> spec = new BlackDuckRequestBuilder().commonGet().apply(notificationEditor).addQueryParameter("sort", String.format("%s asc", PAGE_SORT_FIELD)).buildBlackDuckRequest(currentUserNotificationsUrl);
return spec;
}
Aggregations