use of com.synopsys.integration.blackduck.http.BlackDuckRequestFilter in project blackduck-common by blackducksoftware.
the class NotificationEditor method edit.
@Override
public void edit(BlackDuckRequestBuilder blackDuckRequestBuilder) {
SimpleDateFormat sdf = new SimpleDateFormat(RestConstants.JSON_DATE_FORMAT);
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
String startDateString = sdf.format(startDate);
String endDateString = sdf.format(endDate);
BlackDuckRequestFilter notificationTypeFilter = createFilterForNotificationsTypes(notificationTypesToInclude);
blackDuckRequestBuilder.addQueryParameter("startDate", startDateString).addQueryParameter("endDate", endDateString).addBlackDuckFilter(notificationTypeFilter);
}
use of com.synopsys.integration.blackduck.http.BlackDuckRequestFilter in project synopsys-detect by blackducksoftware.
the class MapToParentOperation method mapToParentProjectVersion.
public void mapToParentProjectVersion(String parentProjectName, String parentVersionName, ProjectVersionWrapper projectVersionWrapper) throws DetectUserFriendlyException {
logger.debug("Will attempt to add this project to a parent.");
String projectName = projectVersionWrapper.getProjectView().getName();
String projectVersionName = projectVersionWrapper.getProjectVersionView().getVersionName();
if (StringUtils.isBlank(parentProjectName) || StringUtils.isBlank(parentVersionName)) {
String errorReason = "Both the parent project name and the parent project version name must be specified if either is specified.";
throw new DetectUserFriendlyException(errorReason, ExitCodeType.FAILURE_CONFIGURATION);
}
try {
Optional<ProjectVersionWrapper> parentWrapper = projectService.getProjectVersion(parentProjectName, parentVersionName);
if (parentWrapper.isPresent()) {
ProjectVersionView parentProjectVersionView = parentWrapper.get().getProjectVersionView();
BlackDuckRequestFilter filter = BlackDuckRequestFilter.createFilterWithSingleValue("bomComponentSource", "custom_project");
BlackDuckMultipleRequest<ProjectVersionComponentVersionView> spec = new BlackDuckRequestBuilder().commonGet().addBlackDuckFilter(filter).buildBlackDuckRequest(parentProjectVersionView.metaComponentsLink());
List<ProjectVersionComponentVersionView> components = blackDuckService.getAllResponses(spec);
Optional<ProjectVersionComponentVersionView> existingProjectComponent = components.stream().filter(component -> component.getComponentName().equals(projectName)).filter(component -> component.getComponentVersionName().equals(projectVersionName)).findFirst();
if (existingProjectComponent.isPresent()) {
logger.debug("This project already exists on the parent so it will not be added to the parent again.");
} else {
projectBomService.addProjectVersionToProjectVersion(projectVersionWrapper.getProjectVersionView(), parentWrapper.get().getProjectVersionView());
}
} else {
throw new DetectUserFriendlyException("Unable to find parent project or parent project version on the server.", ExitCodeType.FAILURE_BLACKDUCK_FEATURE_ERROR);
}
} catch (IntegrationException e) {
String errorReason = "Unable to add project to parent.";
throw new DetectUserFriendlyException(errorReason, e, ExitCodeType.FAILURE_BLACKDUCK_FEATURE_ERROR);
}
}
Aggregations