Search in sources :

Example 1 with IssueRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.IssueRequest in project hub-alert by blackducksoftware.

the class BlackDuckProviderIssueHandler method createIssueRequestModel.

private IssueRequest createIssueRequestModel(BlackDuckProviderIssueModel issueModel) {
    IssueRequest blackDuckIssueRequest = new IssueRequest();
    blackDuckIssueRequest.setIssueId(issueModel.getKey());
    blackDuckIssueRequest.setIssueLink(issueModel.getLink());
    blackDuckIssueRequest.setIssueAssignee(issueModel.getAssignee());
    blackDuckIssueRequest.setIssueStatus(issueModel.getStatus());
    blackDuckIssueRequest.setIssueDescription(issueModel.getSummary());
    return blackDuckIssueRequest;
}
Also used : IssueRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.IssueRequest)

Example 2 with IssueRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.IssueRequest 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

IssueRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.IssueRequest)2 ProjectVersionIssuesView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionIssuesView)1 HttpUrl (com.synopsys.integration.rest.HttpUrl)1 Date (java.util.Date)1