Search in sources :

Example 1 with UploadOutput

use of com.synopsys.integration.blackduck.codelocation.upload.UploadOutput 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 UploadOutput

use of com.synopsys.integration.blackduck.codelocation.upload.UploadOutput in project synopsys-detect by blackducksoftware.

the class BdioUploadOperation method checkForUploadFailure.

private void checkForUploadFailure(CodeLocationCreationData<UploadBatchOutput> response) throws DetectUserFriendlyException {
    for (UploadOutput uploadOutput : response.getOutput()) {
        if (uploadOutput.getResult() == Result.FAILURE) {
            logger.error(String.format("Failed to upload code location: %s", uploadOutput.getCodeLocationName()));
            logger.error(String.format("Reason: %s", uploadOutput.getErrorMessage().orElse("Unknown reason.")));
            throw new DetectUserFriendlyException("An error occurred uploading a bdio file.", uploadOutput.getException().orElse(null), ExitCodeType.FAILURE_BLACKDUCK_FEATURE_ERROR);
        }
    }
}
Also used : DetectUserFriendlyException(com.synopsys.integration.detect.configuration.DetectUserFriendlyException) UploadOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadOutput)

Example 3 with UploadOutput

use of com.synopsys.integration.blackduck.codelocation.upload.UploadOutput in project blackduck-common by blackducksoftware.

the class IntelligentPersistenceBatchRunner method uploadTargets.

private UploadBatchOutput uploadTargets(UploadBatch uploadBatch, long timeout) throws BlackDuckIntegrationException {
    List<UploadOutput> uploadOutputs = new ArrayList<>();
    try {
        List<IntelligentPersistenceCallable> callables = createCallables(uploadBatch, timeout);
        List<Future<UploadOutput>> submitted = new ArrayList<>();
        for (IntelligentPersistenceCallable 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 4 with UploadOutput

use of com.synopsys.integration.blackduck.codelocation.upload.UploadOutput in project blackduck-common by blackducksoftware.

the class UploadBdio2BatchRunner method uploadTargets.

private UploadBatchOutput uploadTargets(UploadBatch uploadBatch) throws BlackDuckIntegrationException {
    List<UploadOutput> uploadOutputs = new ArrayList<>();
    try {
        List<UploadBdio2Callable> callables = createCallables(uploadBatch);
        List<Future<UploadOutput>> submitted = new ArrayList<>();
        for (UploadBdio2Callable 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 5 with UploadOutput

use of com.synopsys.integration.blackduck.codelocation.upload.UploadOutput in project blackduck-common by blackducksoftware.

the class ComprehensiveCookbookTestIT method testPolicyStatusFromBdioImport.

@Test
public void testPolicyStatusFromBdioImport() throws Exception {
    String projectName = "ek_mtglist";
    String projectVersionName = "0.0.1";
    String codeLocationName = "ek_mtglist Black Duck I/O Export";
    String policyRuleName = "Test Rule for comprehensive policy status/bdio";
    String componentName = "Apache POI";
    String componentVersion = "3.9";
    String groupId = "org.apache.poi";
    String artifact = "poi";
    CheckPolicyData checkPolicyData = new CheckPolicyData(projectName, projectVersionName, codeLocationName, policyRuleName, componentName, componentVersion, groupId, artifact);
    BlackDuckServices blackDuckServices = new BlackDuckServices(intHttpClientTestHelper);
    setupPolicyCheck(blackDuckServices, checkPolicyData);
    UserView currentUser = blackDuckServices.userService.findCurrentUser();
    Date userStartDate = blackDuckServices.notificationService.getLatestUserNotificationDate(currentUser);
    Date systemStartDate = blackDuckServices.notificationService.getLatestNotificationDate();
    // import the bdio
    File file = intHttpClientTestHelper.getFile("bdio/mtglist_bdio.jsonld");
    UploadBatch uploadBatch = new UploadBatch(UploadTarget.createDefault(new NameVersion(projectName, projectVersionName), codeLocationName, file));
    BdioUploadService bdioUploadService = blackDuckServices.blackDuckServicesFactory.createBdioUploadService();
    UploadBatchOutput uploadBatchOutput = bdioUploadService.uploadBdioAndWait(uploadBatch, 15 * 60);
    for (UploadOutput uploadOutput : uploadBatchOutput) {
        assertEquals(Result.SUCCESS, uploadOutput.getResult());
    }
    VerifyNotifications.verify(currentUser, blackDuckServices.blackDuckRegistrationService, blackDuckServices.notificationService, userStartDate, systemStartDate);
    completePolicyCheck(blackDuckServices, checkPolicyData);
}
Also used : UploadBatchOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput) NameVersion(com.synopsys.integration.util.NameVersion) BdioUploadService(com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadService) UserView(com.synopsys.integration.blackduck.api.generated.view.UserView) UploadBatch(com.synopsys.integration.blackduck.codelocation.upload.UploadBatch) UploadOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadOutput) File(java.io.File) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

UploadOutput (com.synopsys.integration.blackduck.codelocation.upload.UploadOutput)6 UploadBatchOutput (com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput)5 BlackDuckIntegrationException (com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)3 ArrayList (java.util.ArrayList)3 Future (java.util.concurrent.Future)3 BdioUploadService (com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadService)2 UploadBatch (com.synopsys.integration.blackduck.codelocation.upload.UploadBatch)2 NameVersion (com.synopsys.integration.util.NameVersion)2 File (java.io.File)2 ProjectDependencyGraph (com.synopsys.integration.bdio.graph.ProjectDependencyGraph)1 SimpleBdioDocument (com.synopsys.integration.bdio.model.SimpleBdioDocument)1 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)1 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)1 BdioUploadCodeLocationCreationRequest (com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadCodeLocationCreationRequest)1 DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)1 Date (java.util.Date)1 Test (org.junit.jupiter.api.Test)1