Search in sources :

Example 1 with ProjectVersionIssuesView

use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionIssuesView in project hub-alert by blackducksoftware.

the class BlackDuckProviderIssueHandler method retrieveExistingIssue.

private Optional<ProjectVersionIssuesView> retrieveExistingIssue(String projectVersionUrl, String blackDuckIssueId) throws IntegrationException {
    HttpUrl projectVersionHttpUrl = new HttpUrl(projectVersionUrl);
    ProjectVersionView projectVersion = blackDuckApiClient.getResponse(projectVersionHttpUrl, ProjectVersionView.class);
    List<ProjectVersionIssuesView> bomComponentIssues = issueService.getIssuesForProjectVersion(projectVersion);
    return bomComponentIssues.stream().filter(issue -> issue.getIssueId().equals(blackDuckIssueId)).findAny();
}
Also used : IntegrationException(com.synopsys.integration.exception.IntegrationException) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder) IssueRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.IssueRequest) Date(java.util.Date) StringBodyContent(com.synopsys.integration.rest.body.StringBodyContent) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) Instant(java.time.Instant) HttpUrl(com.synopsys.integration.rest.HttpUrl) Nullable(org.jetbrains.annotations.Nullable) ProjectVersionIssuesView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionIssuesView) List(java.util.List) HttpMethod(com.synopsys.integration.rest.HttpMethod) Gson(com.google.gson.Gson) Optional(java.util.Optional) IssueService(com.synopsys.integration.blackduck.service.dataservice.IssueService) BlackDuckResponseRequest(com.synopsys.integration.blackduck.service.request.BlackDuckResponseRequest) BodyContentConverter(com.synopsys.integration.rest.body.BodyContentConverter) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) ProjectVersionIssuesView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionIssuesView) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 2 with ProjectVersionIssuesView

use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionIssuesView 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)

Aggregations

ProjectVersionIssuesView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionIssuesView)2 IssueRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.IssueRequest)2 HttpUrl (com.synopsys.integration.rest.HttpUrl)2 Date (java.util.Date)2 Gson (com.google.gson.Gson)1 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)1 BlackDuckRequestBuilder (com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)1 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)1 IssueService (com.synopsys.integration.blackduck.service.dataservice.IssueService)1 BlackDuckResponseRequest (com.synopsys.integration.blackduck.service.request.BlackDuckResponseRequest)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 HttpMethod (com.synopsys.integration.rest.HttpMethod)1 BodyContentConverter (com.synopsys.integration.rest.body.BodyContentConverter)1 StringBodyContent (com.synopsys.integration.rest.body.StringBodyContent)1 Instant (java.time.Instant)1 List (java.util.List)1 Optional (java.util.Optional)1 Nullable (org.jetbrains.annotations.Nullable)1