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