use of com.synopsys.integration.blackduck.codelocation.bdioupload.UploadTarget in project hub-detect by blackducksoftware.
the class DetectBdioUploadService method uploadBdioFiles.
public CodeLocationCreationData<UploadBatchOutput> uploadBdioFiles(List<UploadTarget> uploadTargets) throws IntegrationException, DetectUserFriendlyException {
UploadBatch uploadBatch = new UploadBatch();
for (UploadTarget uploadTarget : uploadTargets) {
logger.info(String.format("uploading %s to %s", uploadTarget.getUploadFile().getName(), detectConfiguration.getProperty(DetectProperty.BLACKDUCK_URL, PropertyAuthority.None)));
uploadBatch.addUploadTarget(uploadTarget);
}
BdioUploadCodeLocationCreationRequest uploadRequest = bdioUploadService.createUploadRequest(uploadBatch);
CodeLocationCreationData<UploadBatchOutput> response = bdioUploadService.uploadBdio(uploadRequest);
for (UploadOutput uploadOutput : response.getOutput()) {
if (uploadOutput.getResult() == Result.FAILURE) {
logger.error("Failed to upload code location: " + uploadOutput.getCodeLocationName());
logger.error("Reason: " + uploadOutput.getErrorMessage().orElse("Unknown reason."));
throw new DetectUserFriendlyException("An error occurred uploading a bdio file.", uploadOutput.getException().orElse(null), ExitCodeType.FAILURE_BLACKDUCK_FEATURE_ERROR);
}
}
return response;
}
use of com.synopsys.integration.blackduck.codelocation.bdioupload.UploadTarget in project hub-detect by blackducksoftware.
the class CodeLocationBdioCreator method createBdioFiles.
public List<UploadTarget> createBdioFiles(File bdioOutput, final List<BdioCodeLocation> bdioCodeLocations, NameVersion projectNameVersion) throws DetectUserFriendlyException {
final List<UploadTarget> uploadTargets = new ArrayList<>();
for (final BdioCodeLocation bdioCodeLocation : bdioCodeLocations) {
String codeLocationName = bdioCodeLocation.codeLocationName;
ExternalId externalId = bdioCodeLocation.codeLocation.getExternalId();
DependencyGraph dependencyGraph = bdioCodeLocation.codeLocation.getDependencyGraph();
final SimpleBdioDocument simpleBdioDocument = simpleBdioFactory.createSimpleBdioDocument(codeLocationName, projectNameVersion.getName(), projectNameVersion.getVersion(), externalId, dependencyGraph);
final File outputFile = new File(bdioOutput, bdioCodeLocation.bdioName);
detectBdioWriter.writeBdioFile(outputFile, simpleBdioDocument);
uploadTargets.add(UploadTarget.createDefault(codeLocationName, outputFile));
}
return uploadTargets;
}
use of com.synopsys.integration.blackduck.codelocation.bdioupload.UploadTarget in project hub-detect by blackducksoftware.
the class BdioManager method createBdioFiles.
public BdioResult createBdioFiles(String aggregateName, NameVersion projectNameVersion, List<DetectCodeLocation> codeLocations) throws DetectUserFriendlyException {
DetectBdioWriter detectBdioWriter = new DetectBdioWriter(simpleBdioFactory, detectInfo);
if (StringUtils.isBlank(aggregateName)) {
logger.info("Creating BDIO code locations.");
final BdioCodeLocationResult codeLocationResult = bdioCodeLocationCreator.createFromDetectCodeLocations(codeLocations, projectNameVersion);
codeLocationResult.getFailedBomToolGroupTypes().forEach(it -> eventSystem.publishEvent(Event.StatusSummary, new DetectorStatus(it, StatusType.FAILURE)));
logger.info("Creating BDIO files from code locations.");
CodeLocationBdioCreator codeLocationBdioCreator = new CodeLocationBdioCreator(detectBdioWriter, simpleBdioFactory);
final List<UploadTarget> uploadTargets = codeLocationBdioCreator.createBdioFiles(directoryManager.getBdioOutputDirectory(), codeLocationResult.getBdioCodeLocations(), projectNameVersion);
return new BdioResult(uploadTargets);
} else {
logger.info("Creating aggregate BDIO file.");
AggregateBdioCreator aggregateBdioCreator = new AggregateBdioCreator(simpleBdioFactory, integrationEscapeUtil, codeLocationNameManager, detectConfiguration, detectBdioWriter);
final Optional<UploadTarget> uploadTarget = aggregateBdioCreator.createAggregateBdioFile(directoryManager.getSourceDirectory(), directoryManager.getBdioOutputDirectory(), codeLocations, projectNameVersion);
if (uploadTarget.isPresent()) {
return new BdioResult(Arrays.asList(uploadTarget.get()));
} else {
return new BdioResult(Collections.emptyList());
}
}
}
Aggregations