use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project synopsys-detect by blackducksoftware.
the class ImpactAnalysisMapCodeLocationsOperation method mapCodeLocation.
// TODO: Use the method provided in blackduck-common:49.2.0
private void mapCodeLocation(HttpUrl projectVersionUrl, HttpUrl codeLocationUrl) throws IntegrationException {
// Retrieving a Code Location with just the Project Code Scanner role is not possible so we must construct it ourselves.
CodeLocationView codeLocationView = new CodeLocationView();
ResourceMetadata resourceMetadata = new ResourceMetadata();
resourceMetadata.setHref(codeLocationUrl);
codeLocationView.setMeta(resourceMetadata);
NullNode pathJsonNode = new JsonNodeFactory(false).nullNode();
codeLocationView.setPatch(pathJsonNode);
codeLocationView.setMappedProjectVersion(projectVersionUrl.string());
blackDuckService.put(codeLocationView);
}
use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project synopsys-detect by blackducksoftware.
the class UnmapCodeLocationsOperation method unmapCodeLocations.
public void unmapCodeLocations(ProjectVersionView projectVersionView) throws DetectUserFriendlyException {
try {
List<CodeLocationView> codeLocationViews = blackDuckService.getAllResponses(projectVersionView.metaCodelocationsLink());
for (CodeLocationView codeLocationView : codeLocationViews) {
codeLocationService.unmapCodeLocation(codeLocationView);
}
logger.info("Successfully unmapped (" + codeLocationViews.size() + ") code locations.");
} catch (IntegrationException e) {
String errorMessage = String.format("There was a problem unmapping Code Locations: %s", e.getMessage());
throw new DetectUserFriendlyException(errorMessage, e, ExitCodeType.FAILURE_GENERAL_ERROR);
}
}
use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project synopsys-detect by blackducksoftware.
the class BlackDuckAssertions method deleteProjectAndCodeLocations.
public void deleteProjectAndCodeLocations() throws IntegrationException {
Optional<ProjectVersionWrapper> optionalProjectVersionWrapper = projectService.getProjectVersion(projectNameVersion);
if (!optionalProjectVersionWrapper.isPresent()) {
return;
}
ProjectVersionWrapper projectVersionWrapper = optionalProjectVersionWrapper.get();
List<CodeLocationView> codeLocationsToDelete = blackDuckApiClient.getAllResponses(projectVersionWrapper.getProjectVersionView().metaCodelocationsLink());
for (CodeLocationView toDelete : codeLocationsToDelete) {
blackDuckApiClient.delete(toDelete);
}
blackDuckApiClient.delete(projectVersionWrapper.getProjectView());
}
use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project synopsys-detect by blackducksoftware.
the class BlackDuckAssertions method emptyOnBlackDuck.
public ProjectVersionWrapper emptyOnBlackDuck() throws IntegrationException {
Optional<ProjectVersionWrapper> optionalProjectVersionWrapper = projectService.getProjectVersion(projectNameVersion);
if (optionalProjectVersionWrapper.isPresent()) {
blackDuckApiClient.delete(optionalProjectVersionWrapper.get().getProjectView());
}
ProjectSyncModel projectSyncModel = ProjectSyncModel.createWithDefaults(projectNameVersion);
projectService.syncProjectAndVersion(projectSyncModel);
optionalProjectVersionWrapper = projectService.getProjectVersion(projectNameVersion);
assertTrue(optionalProjectVersionWrapper.isPresent());
List<CodeLocationView> codeLocations = blackDuckApiClient.getAllResponses(optionalProjectVersionWrapper.get().getProjectVersionView().metaCodelocationsLink());
assertEquals(0, codeLocations.size());
List<ProjectVersionComponentVersionView> bomComponents = projectBomService.getComponentsForProjectVersion(optionalProjectVersionWrapper.get().getProjectVersionView());
assertEquals(0, bomComponents.size());
return optionalProjectVersionWrapper.get();
}
use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project synopsys-detect by blackducksoftware.
the class ReportService method getDateTimeOfLatestScanForProjectVersion.
private LocalDateTime getDateTimeOfLatestScanForProjectVersion(ProjectVersionView projectVersion, String projectName) throws IntegrationException {
List<CodeLocationView> codeLocations = blackDuckApiClient.getAllResponses(projectVersion.metaCodelocationsLink());
if (codeLocations.isEmpty()) {
logger.info(String.format("Could not find any code locations for %s - %s", projectName, projectVersion.getVersionName()));
return null;
}
Date dateOfLatestScan = Collections.max(codeLocations.stream().map(CodeLocationView::getUpdatedAt).collect(Collectors.toList()));
return convertDateToLocalDateTime(dateOfLatestScan);
}
Aggregations