Search in sources :

Example 1 with DomainDataTraceLogID

use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainDataTraceLogID in project sechub by mercedes-benz.

the class ScanService method executeScan.

protected void executeScan(SecHubExecutionContext context, DomainMessage request) throws SecHubExecutionException {
    DomainDataTraceLogID sechubJobUUID = traceLogID(request);
    LOG.info("start scan for {}", sechubJobUUID);
    UUID logUUID = scanLogService.logScanStarted(context);
    try {
        BatchJobMessage jobIdMessage = request.get(MessageDataKeys.BATCH_JOB_ID);
        if (jobIdMessage == null) {
            throw new IllegalStateException("no batch job id set for sechub job:" + sechubJobUUID);
        }
        long batchJobId = jobIdMessage.getBatchJobId();
        ProgressMonitor progressMonitor = monitorFactory.createProgressMonitor(batchJobId);
        /* delegate execution : */
        ScanJobExecutor executor = new ScanJobExecutor(this, context, progressMonitor, millisecondsToWaitBeforeCancelCheck);
        executor.execute();
        scanLogService.logScanEnded(logUUID);
    } catch (Exception e) {
        if (context.isAbandonded()) {
            scanLogService.logScanAbandoned(logUUID);
        } else {
            scanLogService.logScanFailed(logUUID);
        }
        /* rethrow when already an execution exception */
        if (e instanceof SecHubExecutionException) {
            SecHubExecutionException exceptionToRethrow = (SecHubExecutionException) e;
            throw exceptionToRethrow;
        }
        /* wrap it */
        throw new SecHubExecutionException("Execute scan failed", e);
    }
}
Also used : ProgressMonitor(com.mercedesbenz.sechub.sharedkernel.ProgressMonitor) SecHubExecutionException(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException) BatchJobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.BatchJobMessage) DomainDataTraceLogID(com.mercedesbenz.sechub.sharedkernel.messaging.DomainDataTraceLogID) UUID(java.util.UUID) JSONConverterException(com.mercedesbenz.sechub.commons.model.JSONConverterException) ScanReportException(com.mercedesbenz.sechub.domain.scan.report.ScanReportException) SecHubExecutionAbandonedException(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionAbandonedException) IOException(java.io.IOException) SecHubExecutionException(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException)

Aggregations

JSONConverterException (com.mercedesbenz.sechub.commons.model.JSONConverterException)1 ScanReportException (com.mercedesbenz.sechub.domain.scan.report.ScanReportException)1 ProgressMonitor (com.mercedesbenz.sechub.sharedkernel.ProgressMonitor)1 SecHubExecutionAbandonedException (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionAbandonedException)1 SecHubExecutionException (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException)1 BatchJobMessage (com.mercedesbenz.sechub.sharedkernel.messaging.BatchJobMessage)1 DomainDataTraceLogID (com.mercedesbenz.sechub.sharedkernel.messaging.DomainDataTraceLogID)1 IOException (java.io.IOException)1 UUID (java.util.UUID)1