use of com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput in project blackduck-common by blackducksoftware.
the class UploadBatchRunner method uploadTargets.
private UploadBatchOutput uploadTargets(UploadBatch uploadBatch) throws BlackDuckIntegrationException {
List<UploadOutput> uploadOutputs = new ArrayList<>();
try {
List<UploadCallable> callables = createCallables(uploadBatch);
List<Future<UploadOutput>> submitted = new ArrayList<>();
for (UploadCallable callable : callables) {
submitted.add(executorService.submit(callable));
}
for (Future<UploadOutput> future : submitted) {
UploadOutput uploadOutput = future.get();
uploadOutputs.add(uploadOutput);
}
} catch (Exception e) {
throw new BlackDuckIntegrationException(String.format("Encountered a problem uploading a file: %s", e.getMessage()), e);
}
return new UploadBatchOutput(uploadOutputs);
}
use of com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput in project blackduck-common by blackducksoftware.
the class IntelligentPersistenceBatchRunner method executeUploads.
public UploadBatchOutput executeUploads(UploadBatch uploadBatch, long timeout) throws BlackDuckIntegrationException {
logger.info("Starting the codelocation file uploads.");
UploadBatchOutput uploadBatchOutput = uploadTargets(uploadBatch, timeout);
logger.info("Completed the codelocation file uploads.");
return uploadBatchOutput;
}
use of com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput in project blackduck-common by blackducksoftware.
the class UploadBdio2BatchRunner method executeUploads.
public UploadBatchOutput executeUploads(UploadBatch uploadBatch) throws BlackDuckIntegrationException {
logger.info("Starting the codelocation file uploads.");
UploadBatchOutput uploadBatchOutput = uploadTargets(uploadBatch);
logger.info("Completed the codelocation file uploads.");
return uploadBatchOutput;
}
use of com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput in project blackduck-common by blackducksoftware.
the class CreateProjectWithBdioAndVerifyBOMTest method uploadAndVerifyBdio.
private void uploadAndVerifyBdio(UploadBatch uploadBatch, Set<String> expectedCodeLocationNames) throws IntegrationException, InterruptedException {
Date startDate = blackDuckServices.notificationService.getLatestUserNotificationDate(currentUser);
System.out.println("start date: ");
System.out.println(RestConstants.formatDate(startDate));
BdioUploadService bdioUploadService = blackDuckServices.blackDuckServicesFactory.createBdioUploadService();
CodeLocationCreationData<UploadBatchOutput> creationData = bdioUploadService.uploadBdio(uploadBatch);
Date endDate = Date.from(new Date().toInstant().plus(7, ChronoUnit.DAYS));
assertCodeLocationsAddedToBOM(expectedCodeLocationNames, startDate, endDate);
}
use of com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput in project blackduck-common by blackducksoftware.
the class IntelligentPersistenceRecipeTest method uploadBdio2.
@Test
void uploadBdio2() throws IOException, IntegrationException, InterruptedException {
Bdio2Factory bdio2Factory = new Bdio2Factory();
// create the bdio2 metadata
ZonedDateTime now = Instant.now().atZone(ZoneId.of("EST5EDT"));
ProjectInfo projectInfo = ProjectInfo.nameVersion(PROJECT);
BdioMetadata bdio2Metadata = bdio2Factory.createBdioMetadata(CODE_LOCATION_NAME, projectInfo, now);
// create the bdio2 project
Dependency projectDependency = Dependency.FACTORY.createMavenDependency("com.synopsys.integration", PROJECT.getName(), PROJECT.getVersion());
// create a graph of one dependency
Dependency dependency = Dependency.FACTORY.createMavenDependency("org.apache.commons", "commons-lang3", "3.11");
ProjectDependencyGraph dependencyGraph = new ProjectDependencyGraph(projectDependency);
dependencyGraph.addDirectDependency(dependency);
// now, with metadata, a project, and a graph, we can create a bdio2 document and write out the file
Bdio2Document bdio2Document = bdio2Factory.createBdio2Document(bdio2Metadata, dependencyGraph);
File bdio2File = File.createTempFile("test_bdio2", ".bdio");
bdio2File.createNewFile();
bdio2File.deleteOnExit();
Bdio2Writer bdio2Writer = new Bdio2Writer();
bdio2Writer.writeBdioDocument(new FileOutputStream(bdio2File), bdio2Document);
// using the file and the previously set values, we create the UploadBatch for uploading to Black Duck
UploadBatch uploadBatch = new UploadBatch();
uploadBatch.addUploadTarget(UploadTarget.createDefault(PROJECT, CODE_LOCATION_NAME, bdio2File));
// now all the setup is done, we can upload the bdio2 file
IntelligentPersistenceService intelligentPersistenceService = blackDuckServicesFactory.createIntelligentPersistenceService();
UploadBatchOutput uploadBatchOutput = intelligentPersistenceService.uploadBdioAndWait(uploadBatch, 120);
assertFalse(uploadBatchOutput.hasAnyFailures());
// verify that we now have a bom with 1 component
Optional<ProjectVersionWrapper> projectVersionWrapper = projectService.getProjectVersion(PROJECT);
assertTrue(projectVersionWrapper.isPresent());
List<ProjectVersionComponentVersionView> bomComponents = projectBomService.getComponentsForProjectVersion(projectVersionWrapper.get().getProjectVersionView());
assertEquals(1, bomComponents.size());
}
Aggregations