Search in sources :

Example 1 with BinaryScanBatch

use of com.synopsys.integration.blackduck.codelocation.binaryscanner.BinaryScanBatch in project synopsys-detect by blackducksoftware.

the class BinaryUploadOperation method uploadBinaryScanFile.

public CodeLocationCreationData<BinaryScanBatchOutput> uploadBinaryScanFile(File binaryScanFile, BinaryScanUploadService binaryScanUploadService, NameVersion projectNameVersion) throws DetectUserFriendlyException {
    String codeLocationName = codeLocationNameManager.createBinaryScanCodeLocationName(binaryScanFile, projectNameVersion.getName(), projectNameVersion.getVersion());
    try {
        logger.info("Preparing to upload binary scan file: " + binaryScanFile.getAbsolutePath());
        BinaryScan binaryScan = new BinaryScan(binaryScanFile, projectNameVersion.getName(), projectNameVersion.getVersion(), codeLocationName);
        BinaryScanBatch binaryScanBatch = new BinaryScanBatch(binaryScan);
        CodeLocationCreationData<BinaryScanBatchOutput> codeLocationCreationData = binaryScanUploadService.uploadBinaryScan(binaryScanBatch);
        BinaryScanBatchOutput binaryScanBatchOutput = codeLocationCreationData.getOutput();
        // The throwExceptionForError() in BinaryScanBatchOutput has a bug, so doing that work here
        throwExceptionForError(binaryScanBatchOutput);
        logger.info("Successfully uploaded binary scan file: " + binaryScanFile.getAbsolutePath());
        statusEventPublisher.publishStatusSummary(new Status(STATUS_KEY, StatusType.SUCCESS));
        return codeLocationCreationData;
    } catch (IntegrationException e) {
        statusEventPublisher.publishStatusSummary(new Status(STATUS_KEY, StatusType.FAILURE));
        throw new DetectUserFriendlyException("Failed to upload binary scan file.", e, ExitCodeType.FAILURE_BLACKDUCK_CONNECTIVITY);
    }
}
Also used : Status(com.synopsys.integration.detect.workflow.status.Status) DetectUserFriendlyException(com.synopsys.integration.detect.configuration.DetectUserFriendlyException) IntegrationException(com.synopsys.integration.exception.IntegrationException) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException) BinaryScanBatch(com.synopsys.integration.blackduck.codelocation.binaryscanner.BinaryScanBatch) BinaryScanBatchOutput(com.synopsys.integration.blackduck.codelocation.binaryscanner.BinaryScanBatchOutput) BinaryScan(com.synopsys.integration.blackduck.codelocation.binaryscanner.BinaryScan)

Aggregations

BinaryScan (com.synopsys.integration.blackduck.codelocation.binaryscanner.BinaryScan)1 BinaryScanBatch (com.synopsys.integration.blackduck.codelocation.binaryscanner.BinaryScanBatch)1 BinaryScanBatchOutput (com.synopsys.integration.blackduck.codelocation.binaryscanner.BinaryScanBatchOutput)1 BlackDuckIntegrationException (com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)1 DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)1 Status (com.synopsys.integration.detect.workflow.status.Status)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1