use of com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView in project hub-detect by blackducksoftware.
the class HubSignatureScanner method scanPaths.
public ProjectVersionView scanPaths(final HubServerConfig hubServerConfig, final SignatureScannerService signatureScannerService, final DetectProject detectProject) throws IntegrationException {
ProjectVersionView projectVersionView = null;
final ProjectRequest projectRequest = createProjectRequest(detectProject);
Set<String> canonicalPathsToScan = registeredPaths;
if (null != detectProject.getProjectName() && null != detectProject.getProjectVersionName() && null != detectConfiguration.getHubSignatureScannerPaths() && detectConfiguration.getHubSignatureScannerPaths().length > 0) {
canonicalPathsToScan = new HashSet<>();
for (final String path : detectConfiguration.getHubSignatureScannerPaths()) {
try {
canonicalPathsToScan.add(new File(path).getCanonicalPath());
} catch (final IOException e) {
throw new IntegrationException(e.getMessage(), e);
}
}
}
final List<ScanPathCallable> scanPathCallables = new ArrayList<>();
for (final String canonicalPath : canonicalPathsToScan) {
final HubScanConfigBuilder hubScanConfigBuilder = createScanConfigBuilder(detectProject, canonicalPath);
final HubScanConfig hubScanConfig = hubScanConfigBuilder.build();
final ScanPathCallable scanPathCallable = new ScanPathCallable(signatureScannerService, hubServerConfig, hubScanConfig, projectRequest, canonicalPath, scanSummaryResults);
scanPathCallables.add(scanPathCallable);
}
final ExecutorService pool = Executors.newFixedThreadPool(detectConfiguration.getHubSignatureScannerParallelProcessors());
try {
for (final ScanPathCallable scanPathCallable : scanPathCallables) {
pool.submit(scanPathCallable);
}
for (final ScanPathCallable scanPathCallable : scanPathCallables) {
final ProjectVersionWrapper projectVersionWrapperFromScan = scanPathCallable.call();
if (projectVersionWrapperFromScan != null) {
projectVersionView = projectVersionWrapperFromScan.getProjectVersionView();
}
}
} finally {
// get() was called on every java.util.concurrent.Future, no need to wait any longer
pool.shutdownNow();
}
return projectVersionView;
}
use of com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView in project hub-detect by blackducksoftware.
the class HubManager method updateHubProjectVersion.
public ProjectVersionView updateHubProjectVersion(final DetectProject detectProject, final List<File> createdBdioFiles) throws IntegrationException {
final ProjectService projectService = hubServiceWrapper.createProjectService();
ProjectVersionView projectVersionView = ensureProjectVersionExists(detectProject, projectService);
if (null != createdBdioFiles && !createdBdioFiles.isEmpty()) {
final HubServerConfig hubServerConfig = hubServiceWrapper.getHubServerConfig();
final CodeLocationService codeLocationService = hubServiceWrapper.createCodeLocationService();
bdioUploader.uploadBdioFiles(hubServerConfig, codeLocationService, detectProject, createdBdioFiles);
} else {
logger.debug("Did not create any bdio files.");
}
if (!detectConfiguration.getHubSignatureScannerDisabled()) {
final HubServerConfig hubServerConfig = hubServiceWrapper.getHubServerConfig();
final SignatureScannerService signatureScannerService = hubServiceWrapper.createSignatureScannerService();
final ProjectVersionView scanProject = hubSignatureScanner.scanPaths(hubServerConfig, signatureScannerService, detectProject);
if (null == projectVersionView) {
projectVersionView = scanProject;
}
}
return projectVersionView;
}
use of com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView in project hub-fortify-ssc-integration-service by blackducksoftware.
the class BlackDuckFortifyPushThread method getProjectVersionItemsAndMaxBomUpdatedDate.
/**
* Iterate the hub project versions mapper and get the project version view for each item and calculate the max BOM
* updated date
*
* @param hubProjectVersions
* @return
* @throws IllegalArgumentException
* @throws IntegrationException
*/
private List<ProjectVersionView> getProjectVersionItemsAndMaxBomUpdatedDate(final List<HubProjectVersion> hubProjectVersions) throws IllegalArgumentException, IntegrationException {
List<ProjectVersionView> projectVersionItems = new ArrayList<>();
for (HubProjectVersion hubProjectVersion : hubProjectVersions) {
String projectName = hubProjectVersion.getHubProject();
String projectVersion = hubProjectVersion.getHubProjectVersion();
// Get the project version
final ProjectVersionView projectVersionItem = hubServices.getProjectVersion(projectName, projectVersion);
projectVersionItems.add(projectVersionItem);
Date bomUpdatedValueAt = hubServices.getBomLastUpdatedAt(projectVersionItem);
if (maxBomUpdatedDate == null || bomUpdatedValueAt.after(maxBomUpdatedDate)) {
maxBomUpdatedDate = bomUpdatedValueAt;
}
logger.debug("bomUpdatedValueAt::" + bomUpdatedValueAt);
}
return projectVersionItems;
}
use of com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView in project hub-fortify-ssc-integration-service by blackducksoftware.
the class HubServicesTest method getBomLastUpdatedAt.
@Test
public void getBomLastUpdatedAt() throws IllegalArgumentException, IntegrationException {
System.out.println("Executing getBomLastUpdatedAt");
ProjectVersionView projectVersionItem = null;
try {
projectVersionItem = hubServices.getProjectVersion(PROJECT_NAME, VERSION_NAME);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IntegrationException e) {
e.printStackTrace();
}
Date bomLastUpdatedAt = hubServices.getBomLastUpdatedAt(projectVersionItem);
System.out.println("bomLastUpdatedAt::" + bomLastUpdatedAt);
assertNotNull(bomLastUpdatedAt);
}
use of com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView in project hub-fortify-ssc-integration-service by blackducksoftware.
the class HubServicesTest method getProjectVersionWithInvalidProjectName.
@Test
public void getProjectVersionWithInvalidProjectName() {
System.out.println("Executing getProjectVersionWithInvalidProjectName");
ProjectVersionView projectVersionItem = null;
try {
projectVersionItem = hubServices.getProjectVersion("Solr1", VERSION_NAME);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IntegrationException e) {
// e.printStackTrace();
System.out.println("Error message::" + e.getMessage());
assertTrue(e.getMessage().contains("This Project does not exist"));
}
assertNull(projectVersionItem);
}
Aggregations