Search in sources :

Example 1 with RapidScanOptions

use of com.synopsys.integration.detect.workflow.blackduck.developer.RapidScanOptions in project synopsys-detect by blackducksoftware.

the class OperationFactory method performRapidUpload.

// Rapid
public final List<HttpUrl> performRapidUpload(BlackDuckRunData blackDuckRunData, BdioResult bdioResult, @Nullable File rapidScanConfig) throws OperationException {
    return auditLog.namedInternal("Rapid Upload", () -> {
        BlackDuckServicesFactory blackDuckServicesFactory = blackDuckRunData.getBlackDuckServicesFactory();
        RapidScanOptions rapidScanOptions = detectConfigurationFactory.createRapidScanOptions();
        RapidModeUploadOperation operation = new RapidModeUploadOperation(DetectRapidScanService.fromBlackDuckServicesFactory(directoryManager, blackDuckServicesFactory));
        return operation.run(bdioResult, rapidScanOptions, rapidScanConfig);
    });
}
Also used : RapidScanOptions(com.synopsys.integration.detect.workflow.blackduck.developer.RapidScanOptions) RapidModeUploadOperation(com.synopsys.integration.detect.workflow.blackduck.developer.RapidModeUploadOperation) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)

Example 2 with RapidScanOptions

use of com.synopsys.integration.detect.workflow.blackduck.developer.RapidScanOptions in project synopsys-detect by blackducksoftware.

the class RapidScanUploadService method uploadFiles.

private HttpUrl uploadFiles(UploadTarget uploadTarget, List<BdioFileContent> bdioFiles, RapidScanOptions rapidScanOptions, @Nullable NameVersion nameVersion, @Nullable File rapidScanConfig, @Nullable File rapidScanWorkingDirectory) throws IntegrationException, IOException {
    if (bdioFiles.isEmpty()) {
        throw new IllegalArgumentException("BDIO files cannot be empty.");
    }
    BdioFileContent header = bdioFiles.stream().filter(content -> content.getFileName().equals(FILE_NAME_BDIO_HEADER_JSONLD)).findFirst().orElseThrow(() -> new BlackDuckIntegrationException("Cannot find BDIO header file" + FILE_NAME_BDIO_HEADER_JSONLD + "."));
    List<BdioFileContent> remainingFiles = bdioFiles.stream().filter(content -> !content.getFileName().equals(FILE_NAME_BDIO_HEADER_JSONLD)).collect(Collectors.toList());
    int count = remainingFiles.size();
    logger.debug("BDIO upload file count = " + count);
    BlackDuckRequestBuilderEditor editor = builder -> {
        builder.addHeader(RapidCompareMode.HEADER_NAME, rapidScanOptions.getCompareMode().getHeaderValue());
        if (nameVersion != null) {
            builder.addHeader(Bdio2StreamUploader.PROJECT_NAME_HEADER, nameVersion.getName()).addHeader(Bdio2StreamUploader.VERSION_NAME_HEADER, nameVersion.getVersion());
        }
    };
    HttpUrl url;
    if (rapidScanConfig != null) {
        url = bdio2Uploader.startWithConfig(zip(uploadTarget, rapidScanConfig, header, rapidScanWorkingDirectory), editor);
    } else {
        url = bdio2Uploader.start(header, editor);
    }
    for (BdioFileContent content : remainingFiles) {
        bdio2Uploader.append(url, count, content, editor);
    }
    bdio2Uploader.finish(url, count, editor);
    return url;
}
Also used : FileNameUtils(org.apache.commons.compress.utils.FileNameUtils) IntegrationException(com.synopsys.integration.exception.IntegrationException) DataService(com.synopsys.integration.blackduck.service.DataService) ApiDiscovery(com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery) HashMap(java.util.HashMap) IntLogger(com.synopsys.integration.log.IntLogger) HttpUrl(com.synopsys.integration.rest.HttpUrl) NameVersion(com.synopsys.integration.util.NameVersion) RapidScanOptions(com.synopsys.integration.detect.workflow.blackduck.developer.RapidScanOptions) Charset(java.nio.charset.Charset) Map(java.util.Map) BdioFileContent(com.synopsys.integration.blackduck.bdio2.model.BdioFileContent) Path(java.nio.file.Path) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) RapidCompareMode(com.synopsys.integration.detect.configuration.enumeration.RapidCompareMode) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable) Bdio2ContentExtractor(com.synopsys.integration.blackduck.bdio2.util.Bdio2ContentExtractor) List(java.util.List) BlackDuckRequestBuilderEditor(com.synopsys.integration.blackduck.service.request.BlackDuckRequestBuilderEditor) Bdio2StreamUploader(com.synopsys.integration.blackduck.bdio2.Bdio2StreamUploader) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException) DetectZipUtil(com.synopsys.integration.detect.util.DetectZipUtil) UploadTarget(com.synopsys.integration.blackduck.codelocation.upload.UploadTarget) BlackDuckRequestBuilderEditor(com.synopsys.integration.blackduck.service.request.BlackDuckRequestBuilderEditor) BdioFileContent(com.synopsys.integration.blackduck.bdio2.model.BdioFileContent) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Aggregations

RapidScanOptions (com.synopsys.integration.detect.workflow.blackduck.developer.RapidScanOptions)2 ApiDiscovery (com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery)1 Bdio2StreamUploader (com.synopsys.integration.blackduck.bdio2.Bdio2StreamUploader)1 BdioFileContent (com.synopsys.integration.blackduck.bdio2.model.BdioFileContent)1 Bdio2ContentExtractor (com.synopsys.integration.blackduck.bdio2.util.Bdio2ContentExtractor)1 UploadTarget (com.synopsys.integration.blackduck.codelocation.upload.UploadTarget)1 BlackDuckIntegrationException (com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)1 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)1 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)1 DataService (com.synopsys.integration.blackduck.service.DataService)1 BlackDuckRequestBuilderEditor (com.synopsys.integration.blackduck.service.request.BlackDuckRequestBuilderEditor)1 RapidCompareMode (com.synopsys.integration.detect.configuration.enumeration.RapidCompareMode)1 DetectZipUtil (com.synopsys.integration.detect.util.DetectZipUtil)1 RapidModeUploadOperation (com.synopsys.integration.detect.workflow.blackduck.developer.RapidModeUploadOperation)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 IntLogger (com.synopsys.integration.log.IntLogger)1 HttpUrl (com.synopsys.integration.rest.HttpUrl)1 NameVersion (com.synopsys.integration.util.NameVersion)1 File (java.io.File)1 IOException (java.io.IOException)1