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();
}
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);
}
}
Aggregations