Search in sources :

Example 41 with HttpUrl

use of com.synopsys.integration.rest.HttpUrl in project hub-alert by blackducksoftware.

the class BlackDuckProviderIssueHandler method createOrUpdateBlackDuckIssue.

public void createOrUpdateBlackDuckIssue(BlackDuckProviderIssueModel issueModel, @Nullable String bomComponentVersionIssuesUrl, String projectVersionUrl) throws IntegrationException {
    Optional<ProjectVersionIssuesView> optionalExistingIssue = retrieveExistingIssue(projectVersionUrl, issueModel.getKey());
    Date currentDate = Date.from(Instant.now());
    IssueRequest issueRequestModel = createIssueRequestModel(issueModel);
    if (optionalExistingIssue.isPresent()) {
        ProjectVersionIssuesView existingIssue = optionalExistingIssue.get();
        issueRequestModel.setIssueDescription(existingIssue.getIssueDescription());
        issueRequestModel.setIssueCreatedAt(existingIssue.getIssueCreatedAt());
        issueRequestModel.setIssueUpdatedAt(currentDate);
        // The request uri should point at the specific issue for PUT requests
        HttpUrl requestUri = existingIssue.getHref();
        performRequest(requestUri, HttpMethod.PUT, issueRequestModel);
    } else if (null != bomComponentVersionIssuesUrl) {
        issueRequestModel.setIssueCreatedAt(currentDate);
        issueRequestModel.setIssueUpdatedAt(null);
        HttpUrl requestUri = new HttpUrl(bomComponentVersionIssuesUrl);
        performRequest(requestUri, HttpMethod.POST, issueRequestModel);
    }
}
Also used : ProjectVersionIssuesView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionIssuesView) IssueRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.IssueRequest) Date(java.util.Date) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 42 with HttpUrl

use of com.synopsys.integration.rest.HttpUrl 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;
}
Also used : IntegrationException(com.synopsys.integration.exception.IntegrationException) UserView(com.synopsys.integration.blackduck.api.generated.view.UserView) ProjectView(com.synopsys.integration.blackduck.api.generated.view.ProjectView) ProviderProject(com.synopsys.integration.alert.common.persistence.model.ProviderProject) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 43 with HttpUrl

use of com.synopsys.integration.rest.HttpUrl in project hub-alert by blackducksoftware.

the class ProviderDataAccessorTest method createProjectView2.

private ProjectView createProjectView2() throws IntegrationException {
    String href2 = "https://localhost:8443";
    ProjectView projectView2 = new ProjectView();
    ResourceMetadata resourceMetadata2 = new ResourceMetadata();
    resourceMetadata2.setHref(new HttpUrl(href2));
    projectView2.setMeta(resourceMetadata2);
    return projectView2;
}
Also used : ProjectView(com.synopsys.integration.blackduck.api.generated.view.ProjectView) ResourceMetadata(com.synopsys.integration.blackduck.api.core.ResourceMetadata) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 44 with HttpUrl

use of com.synopsys.integration.rest.HttpUrl in project hub-alert by blackducksoftware.

the class ProviderDataAccessorTest method createProjectViewWithVersionsLink.

private ProjectView createProjectViewWithVersionsLink() throws IntegrationException {
    ProjectView projectView = new ProjectView();
    ResourceMetadata resourceMetadata = new ResourceMetadata();
    resourceMetadata.setHref(new HttpUrl(HREF_1));
    ResourceLink versionLink = new ResourceLink();
    versionLink.setRel(ProjectView.VERSIONS_LINK);
    versionLink.setHref(new HttpUrl("https://versionsHref.com"));
    resourceMetadata.setLinks(List.of(versionLink));
    projectView.setMeta(resourceMetadata);
    return projectView;
}
Also used : ResourceLink(com.synopsys.integration.blackduck.api.core.ResourceLink) ProjectView(com.synopsys.integration.blackduck.api.generated.view.ProjectView) ResourceMetadata(com.synopsys.integration.blackduck.api.core.ResourceMetadata) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 45 with HttpUrl

use of com.synopsys.integration.rest.HttpUrl in project hub-alert by blackducksoftware.

the class ProviderDataAccessorTest method createProjectView1.

private ProjectView createProjectView1() throws IntegrationException {
    ProjectView projectView = new ProjectView();
    ResourceMetadata resourceMetadata = new ResourceMetadata();
    resourceMetadata.setHref(new HttpUrl(HREF_1));
    projectView.setMeta(resourceMetadata);
    return projectView;
}
Also used : ProjectView(com.synopsys.integration.blackduck.api.generated.view.ProjectView) ResourceMetadata(com.synopsys.integration.blackduck.api.core.ResourceMetadata) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Aggregations

HttpUrl (com.synopsys.integration.rest.HttpUrl)65 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)35 ProjectVersionComponentVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView)29 Test (org.junit.jupiter.api.Test)28 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)23 ResourceMetadata (com.synopsys.integration.blackduck.api.core.ResourceMetadata)21 BomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)18 IntegrationException (com.synopsys.integration.exception.IntegrationException)15 IntegrationRestException (com.synopsys.integration.rest.exception.IntegrationRestException)15 ComponentUpgradeGuidance (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentUpgradeGuidance)13 ResourceLink (com.synopsys.integration.blackduck.api.core.ResourceLink)9 ProjectView (com.synopsys.integration.blackduck.api.generated.view.ProjectView)9 UrlSingleResponse (com.synopsys.integration.blackduck.api.core.response.UrlSingleResponse)7 ProjectVersionComponentVersionLicensesView (com.synopsys.integration.blackduck.api.generated.component.ProjectVersionComponentVersionLicensesView)7 ComponentPolicy (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentPolicy)6 ComponentVersionUpgradeGuidanceView (com.synopsys.integration.blackduck.api.generated.response.ComponentVersionUpgradeGuidanceView)6 ComponentPolicyRulesView (com.synopsys.integration.blackduck.api.generated.view.ComponentPolicyRulesView)6 PolicyRuleView (com.synopsys.integration.blackduck.api.generated.view.PolicyRuleView)6 BlackDuckMessageBomComponentDetailsCreator (com.synopsys.integration.alert.provider.blackduck.processor.message.service.BlackDuckMessageBomComponentDetailsCreator)5 ComponentVersionView (com.synopsys.integration.blackduck.api.generated.view.ComponentVersionView)5