Search in sources :

Example 1 with UploadBatchOutput

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);
}
Also used : UploadBatchOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) UploadOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadOutput) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)

Example 2 with UploadBatchOutput

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;
}
Also used : UploadBatchOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput)

Example 3 with 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;
}
Also used : UploadBatchOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput)

Example 4 with 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);
}
Also used : UploadBatchOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput) BdioUploadService(com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadService) Date(java.util.Date)

Example 5 with UploadBatchOutput

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());
}
Also used : UploadBatchOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput) BdioMetadata(com.blackducksoftware.bdio2.BdioMetadata) Bdio2Writer(com.synopsys.integration.blackduck.bdio2.util.Bdio2Writer) Bdio2Document(com.synopsys.integration.blackduck.bdio2.model.Bdio2Document) ProjectDependencyGraph(com.synopsys.integration.bdio.graph.ProjectDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Bdio2Factory(com.synopsys.integration.blackduck.bdio2.util.Bdio2Factory) IntelligentPersistenceService(com.synopsys.integration.blackduck.codelocation.intelligentpersistence.IntelligentPersistenceService) ZonedDateTime(java.time.ZonedDateTime) FileOutputStream(java.io.FileOutputStream) ProjectInfo(com.synopsys.integration.blackduck.bdio2.model.ProjectInfo) UploadBatch(com.synopsys.integration.blackduck.codelocation.upload.UploadBatch) File(java.io.File) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ProjectVersionComponentVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView) Test(org.junit.jupiter.api.Test)

Aggregations

UploadBatchOutput (com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput)13 UploadBatch (com.synopsys.integration.blackduck.codelocation.upload.UploadBatch)6 UploadOutput (com.synopsys.integration.blackduck.codelocation.upload.UploadOutput)5 BdioUploadService (com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadService)4 File (java.io.File)4 ProjectDependencyGraph (com.synopsys.integration.bdio.graph.ProjectDependencyGraph)3 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)3 BlackDuckIntegrationException (com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)3 NameVersion (com.synopsys.integration.util.NameVersion)3 ArrayList (java.util.ArrayList)3 Future (java.util.concurrent.Future)3 Test (org.junit.jupiter.api.Test)3 BdioMetadata (com.blackducksoftware.bdio2.BdioMetadata)2 ProjectVersionComponentVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView)2 Bdio2Document (com.synopsys.integration.blackduck.bdio2.model.Bdio2Document)2 ProjectInfo (com.synopsys.integration.blackduck.bdio2.model.ProjectInfo)2 Bdio2Factory (com.synopsys.integration.blackduck.bdio2.util.Bdio2Factory)2 Bdio2Writer (com.synopsys.integration.blackduck.bdio2.util.Bdio2Writer)2 BdioUploadCodeLocationCreationRequest (com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadCodeLocationCreationRequest)2 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)2