Search in sources :

Example 6 with BlackDuckRequestBuilder

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);
}
Also used : BlackDuckPageDefinition(com.synopsys.integration.blackduck.http.BlackDuckPageDefinition) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) AlertPagedModel(com.synopsys.integration.alert.common.rest.model.AlertPagedModel) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ApiDiscovery(com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery) BlackDuckQuery(com.synopsys.integration.blackduck.http.BlackDuckQuery) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder) ProjectView(com.synopsys.integration.blackduck.api.generated.view.ProjectView) ProviderProject(com.synopsys.integration.alert.common.persistence.model.ProviderProject)

Example 7 with BlackDuckRequestBuilder

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);
}
Also used : ApiDiscovery(com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) PolicyRuleView(com.synopsys.integration.blackduck.api.generated.view.PolicyRuleView) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder) BlackDuckQuery(com.synopsys.integration.blackduck.http.BlackDuckQuery)

Example 8 with BlackDuckRequestBuilder

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;
}
Also used : NotificationUserView(com.synopsys.integration.blackduck.api.manual.view.NotificationUserView) UserView(com.synopsys.integration.blackduck.api.generated.view.UserView) NotificationUserView(com.synopsys.integration.blackduck.api.manual.view.NotificationUserView) NotificationEditor(com.synopsys.integration.blackduck.service.request.NotificationEditor) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)

Aggregations

BlackDuckRequestBuilder (com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)8 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)3 ApiDiscovery (com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery)2 ProjectView (com.synopsys.integration.blackduck.api.generated.view.ProjectView)2 BlackDuckPageDefinition (com.synopsys.integration.blackduck.http.BlackDuckPageDefinition)2 BlackDuckQuery (com.synopsys.integration.blackduck.http.BlackDuckQuery)2 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)2 IntegrationException (com.synopsys.integration.exception.IntegrationException)2 HttpUrl (com.synopsys.integration.rest.HttpUrl)2 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)1 ProviderProject (com.synopsys.integration.alert.common.persistence.model.ProviderProject)1 AlertPagedModel (com.synopsys.integration.alert.common.rest.model.AlertPagedModel)1 UrlMultipleResponses (com.synopsys.integration.blackduck.api.core.response.UrlMultipleResponses)1 UrlSingleResponse (com.synopsys.integration.blackduck.api.core.response.UrlSingleResponse)1 PolicyRuleView (com.synopsys.integration.blackduck.api.generated.view.PolicyRuleView)1 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)1 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)1 NotificationUserView (com.synopsys.integration.blackduck.api.manual.view.NotificationUserView)1 BlackDuckResponsesTransformer (com.synopsys.integration.blackduck.http.transform.BlackDuckResponsesTransformer)1