Search in sources :

Example 1 with UploadOutput

use of com.synopsys.integration.blackduck.codelocation.bdioupload.UploadOutput 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;
}
Also used : UploadBatchOutput(com.synopsys.integration.blackduck.codelocation.bdioupload.UploadBatchOutput) DetectUserFriendlyException(com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException) UploadTarget(com.synopsys.integration.blackduck.codelocation.bdioupload.UploadTarget) BdioUploadCodeLocationCreationRequest(com.synopsys.integration.blackduck.codelocation.bdioupload.BdioUploadCodeLocationCreationRequest) UploadBatch(com.synopsys.integration.blackduck.codelocation.bdioupload.UploadBatch) UploadOutput(com.synopsys.integration.blackduck.codelocation.bdioupload.UploadOutput)

Aggregations

DetectUserFriendlyException (com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException)1 BdioUploadCodeLocationCreationRequest (com.synopsys.integration.blackduck.codelocation.bdioupload.BdioUploadCodeLocationCreationRequest)1 UploadBatch (com.synopsys.integration.blackduck.codelocation.bdioupload.UploadBatch)1 UploadBatchOutput (com.synopsys.integration.blackduck.codelocation.bdioupload.UploadBatchOutput)1 UploadOutput (com.synopsys.integration.blackduck.codelocation.bdioupload.UploadOutput)1 UploadTarget (com.synopsys.integration.blackduck.codelocation.bdioupload.UploadTarget)1