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);
}
}
Aggregations