Search in sources :

Example 1 with ProjectGroupsView

use of com.synopsys.integration.blackduck.api.generated.view.ProjectGroupsView in project synopsys-detect by blackducksoftware.

the class FindProjectGroupOperation method findProjectGroup.

public HttpUrl findProjectGroup(String projectGroupName) throws IntegrationException, DetectUserFriendlyException {
    BlackDuckRequestBuilder blackDuckRequestBuilder = new BlackDuckRequestBuilder().commonGet().addBlackDuckQuery(new BlackDuckQuery("name", projectGroupName)).addBlackDuckFilter(BlackDuckRequestFilter.createFilterWithSingleValue("exactName", "true"));
    BlackDuckMultipleRequest<ProjectGroupsView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(projectGroupsResponses);
    List<ProjectGroupsView> response = blackDuckApiClient.getAllResponses(requestMultiple);
    if (response.size() != 1) {
        throw new DetectUserFriendlyException("Project Group Name must have exactly 1 match on Black Duck, instead '" + projectGroupName + "' had " + response.size() + " matches.", ExitCodeType.FAILURE_BLACKDUCK_FEATURE_ERROR);
    }
    ProjectGroupsView result = response.get(0);
    return result.getHref();
}
Also used : DetectUserFriendlyException(com.synopsys.integration.detect.configuration.DetectUserFriendlyException) ProjectGroupsView(com.synopsys.integration.blackduck.api.generated.view.ProjectGroupsView) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder) BlackDuckQuery(com.synopsys.integration.blackduck.http.BlackDuckQuery)

Aggregations

ProjectGroupsView (com.synopsys.integration.blackduck.api.generated.view.ProjectGroupsView)1 BlackDuckQuery (com.synopsys.integration.blackduck.http.BlackDuckQuery)1 BlackDuckRequestBuilder (com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)1 DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)1