Search in sources :

Example 6 with SecHubRuntimeException

use of com.mercedesbenz.sechub.commons.model.SecHubRuntimeException in project sechub by mercedes-benz.

the class SchedulerSourcecodeUploadService method storeUploadFileAndSha256Checksum.

private void storeUploadFileAndSha256Checksum(String projectId, UUID jobUUID, MultipartFile file, String checkSum, String traceLogID) {
    JobStorage jobStorage = storageService.getJobStorage(projectId, jobUUID);
    try (InputStream inputStream = file.getInputStream()) {
        jobStorage.store(FILENAME_SOURCECODE_ZIP, inputStream);
        // we also store given checksum - so can be reused by security product
        jobStorage.store(FILENAME_SOURCECODE_ZIP_CHECKSUM, new StringInputStream(checkSum));
    } catch (IOException e) {
        LOG.error("Was not able to store zipped sources! {}", traceLogID, e);
        throw new SecHubRuntimeException("Was not able to upload sources");
    }
}
Also used : StringInputStream(com.amazonaws.util.StringInputStream) StringInputStream(com.amazonaws.util.StringInputStream) InputStream(java.io.InputStream) SecHubRuntimeException(com.mercedesbenz.sechub.commons.model.SecHubRuntimeException) IOException(java.io.IOException) JobStorage(com.mercedesbenz.sechub.storage.core.JobStorage)

Example 7 with SecHubRuntimeException

use of com.mercedesbenz.sechub.commons.model.SecHubRuntimeException in project sechub by mercedes-benz.

the class SerecoReportProductExecutor method importProductResult.

private void importProductResult(UUIDTraceLogID traceLogId, Workspace workspace, ProductResult productResult) {
    String importData = productResult.getResult();
    String productId = productResult.getProductIdentifier().name();
    LOG.debug("{} found product result for '{}'", traceLogId, productId);
    UUID uuid = productResult.getUUID();
    String docId = uuid.toString();
    LOG.debug("{} start to import result '{}' from product '{}' , config:{}", traceLogId, docId, productId, productResult.getProductExecutorConfigUUID());
    /* @formatter:off */
    try {
        workspace.doImport(builder().productId(productId).importData(importData).importId(docId).build());
    } catch (IOException e) {
        throw new SecHubRuntimeException("Import into workspace failed:" + docId, e);
    }
/* @formatter:on */
}
Also used : SecHubRuntimeException(com.mercedesbenz.sechub.commons.model.SecHubRuntimeException) IOException(java.io.IOException) UUID(java.util.UUID)

Example 8 with SecHubRuntimeException

use of com.mercedesbenz.sechub.commons.model.SecHubRuntimeException in project sechub by mercedes-benz.

the class SchedulerUploadService method storeUploadFileAndSha256Checksum.

private void storeUploadFileAndSha256Checksum(String projectId, UUID jobUUID, MultipartFile file, String checkSum, String traceLogID) {
    JobStorage jobStorage = storageService.getJobStorage(projectId, jobUUID);
    try (InputStream inputStream = file.getInputStream()) {
        jobStorage.store(SOURCECODE_ZIP, inputStream);
        // we also store given checksum - so can be reused by security product
        jobStorage.store(SOURCECODE_ZIP_CHECKSUM, new StringInputStream(checkSum));
    } catch (IOException e) {
        LOG.error("Was not able to store zipped sources! {}", traceLogID, e);
        throw new SecHubRuntimeException("Was not able to upload sources");
    }
}
Also used : StringInputStream(com.amazonaws.util.StringInputStream) StringInputStream(com.amazonaws.util.StringInputStream) InputStream(java.io.InputStream) SecHubRuntimeException(com.mercedesbenz.sechub.commons.model.SecHubRuntimeException) IOException(java.io.IOException) JobStorage(com.mercedesbenz.sechub.storage.core.JobStorage)

Aggregations

SecHubRuntimeException (com.mercedesbenz.sechub.commons.model.SecHubRuntimeException)8 IOException (java.io.IOException)4 StringInputStream (com.amazonaws.util.StringInputStream)2 JobStorage (com.mercedesbenz.sechub.storage.core.JobStorage)2 InputStream (java.io.InputStream)2 SecHubDataConfigurationUsageByName (com.mercedesbenz.sechub.commons.model.SecHubDataConfigurationUsageByName)1 NamePatternIdProvider (com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider)1 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)1 NotFoundException (com.mercedesbenz.sechub.sharedkernel.error.NotFoundException)1 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)1 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)1 DomainMessageSynchronousResult (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult)1 IsSendingSyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingSyncMessage)1 UUID (java.util.UUID)1