use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult in project sechub by mercedes-benz.
the class ScanServiceTest method scanservice_does_cleanup_storage_of_job__when_not_failed.
@Test
public void scanservice_does_cleanup_storage_of_job__when_not_failed() throws Exception {
/* execute */
DomainMessageSynchronousResult result = serviceToTest.receiveSynchronMessage(prepareValidRequest());
/* test */
verify(jobStorage).deleteAll();
assertFalse(result.hasFailed());
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult in project sechub by mercedes-benz.
the class ScanMessageHandler method purgeDone.
@IsSendingSyncMessageAnswer(value = MessageID.JOB_RESULT_PURGE_DONE, answeringTo = MessageID.REQUEST_PURGE_JOB_RESULTS, branchName = "success")
private DomainMessageSynchronousResult purgeDone(UUID jobUUID) {
DomainMessageSynchronousResult result = new DomainMessageSynchronousResult(MessageID.JOB_RESULT_PURGE_DONE);
result.set(MessageDataKeys.SECHUB_UUID, jobUUID);
return result;
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult in project sechub by mercedes-benz.
the class ScanMessageHandler method purgeFailed.
@IsSendingSyncMessageAnswer(value = MessageID.JOB_RESULT_PURGE_FAILED, answeringTo = MessageID.REQUEST_PURGE_JOB_RESULTS, branchName = "failed")
private DomainMessageSynchronousResult purgeFailed(UUID jobUUID, Exception e) {
DomainMessageSynchronousResult result = new DomainMessageSynchronousResult(MessageID.JOB_RESULT_PURGE_FAILED, e);
result.set(MessageDataKeys.SECHUB_UUID, jobUUID);
return result;
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult in project sechub by mercedes-benz.
the class ScanProgressMonitor method sendRequestBatchJobStatusRequestSynchron.
@IsSendingSyncMessage(MessageID.REQUEST_BATCH_JOB_STATUS)
protected BatchJobMessage sendRequestBatchJobStatusRequestSynchron() {
DomainMessage request = new DomainMessage(MessageID.REQUEST_BATCH_JOB_STATUS);
BatchJobMessage statusRequestMessage = new BatchJobMessage();
statusRequestMessage.setBatchJobId(batchJobId);
request.set(MessageDataKeys.BATCH_JOB_STATUS, statusRequestMessage);
/* ask for status */
DomainMessageSynchronousResult response = eventBus.sendSynchron(request);
BatchJobMessage jobStatusRepsonse = response.get(MessageDataKeys.BATCH_JOB_STATUS);
return jobStatusRepsonse;
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult in project sechub by mercedes-benz.
the class ScanService method startScan.
@IsSendingSyncMessageAnswer(value = MessageID.SCAN_DONE, answeringTo = MessageID.START_SCAN, branchName = "success")
@IsSendingSyncMessageAnswer(value = MessageID.SCAN_FAILED, answeringTo = MessageID.START_SCAN, branchName = "failure")
@IsSendingSyncMessageAnswer(value = MessageID.SCAN_ABANDONDED, answeringTo = MessageID.START_SCAN, branchName = "failure")
DomainMessageSynchronousResult startScan(DomainMessage request) {
SecHubExecutionContext context = null;
try {
context = createExecutionContext(request);
executeScan(context, request);
ScanReport report = reportService.createReport(context);
DomainMessageSynchronousResult response = new DomainMessageSynchronousResult(MessageID.SCAN_DONE);
response.set(REPORT_TRAFFIC_LIGHT, report.getTrafficLightAsString());
return response;
} catch (ScanReportException e) {
LOG.error("Execution was possible, but report failed." + traceLogID(request), e);
return new DomainMessageSynchronousResult(MessageID.SCAN_FAILED, e);
} catch (SecHubExecutionAbandonedException e) {
LOG.info("Execution abandoned on scan {} - message: {}", traceLogID(request), e.getMessage());
return new DomainMessageSynchronousResult(MessageID.SCAN_ABANDONDED, e);
} catch (SecHubExecutionException e) {
LOG.error("Execution problems on scan." + traceLogID(request), e);
return new DomainMessageSynchronousResult(MessageID.SCAN_FAILED, e);
} catch (Exception e) {
LOG.error("Was not able to start scan." + traceLogID(request), e);
return new DomainMessageSynchronousResult(MessageID.SCAN_FAILED, e);
} finally {
if (context == null) {
LOG.warn("No sechub execution context available, so cannot check state or cleanup storage");
} else {
if (!context.isAbandonded()) {
cleanupStorage(context);
}
}
}
}
Aggregations