Search in sources :

Example 11 with NotFoundException

use of com.mercedesbenz.sechub.sharedkernel.error.NotFoundException in project sechub by mercedes-benz.

the class IntegrationTestSchedulerService method revertJobAsStillNotApproved.

public void revertJobAsStillNotApproved(UUID sechubJobUUID) {
    Optional<ScheduleSecHubJob> found = repository.findById(sechubJobUUID);
    if (!found.isPresent()) {
        throw new NotFoundException("Job not found!");
    }
    ScheduleSecHubJob job = found.get();
    job.setExecutionResult(ExecutionResult.NONE);
    job.setExecutionState(ExecutionState.INITIALIZING);
    job.setEnded(null);
    job.setTrafficLight(null);
    repository.save(job);
}
Also used : NotFoundException(com.mercedesbenz.sechub.sharedkernel.error.NotFoundException) ScheduleSecHubJob(com.mercedesbenz.sechub.domain.schedule.job.ScheduleSecHubJob)

Example 12 with NotFoundException

use of com.mercedesbenz.sechub.sharedkernel.error.NotFoundException in project sechub by mercedes-benz.

the class FullScanDataRestController method getFullScanZipFileForJob.

/* @formatter:off */
@UseCaseAdminDownloadsFullScanDataForJob(@Step(number = 1, next = 2, name = "REST API call to zip file containing full scan data", needsRestDoc = true))
@RequestMapping(path = "/scan/download/{sechubJobUUID}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
public void getFullScanZipFileForJob(@PathVariable("sechubJobUUID") UUID sechubJobUUID, HttpServletResponse response) {
    /* @formatter:on */
    auditLogService.log("Starts downloading full scan logs for sechub job {}", logSanitizer.sanitize(sechubJobUUID, -1));
    response.setContentType("application/zip");
    response.setHeader("Content-Disposition", "attachment; filename=full_scandata_" + sechubJobUUID.toString() + ".zip");
    FullScanData fullScanData = fullScanDataService.getFullScanData(sechubJobUUID);
    try (OutputStream outputStream = response.getOutputStream()) {
        FullScanDataToZipOutputSupport support = new FullScanDataToZipOutputSupport();
        support.writeScanData(fullScanData, outputStream);
    } catch (IOException e) {
        LOG.error("Was not able to provide zip file for full scan data of {}", logSanitizer.sanitize(sechubJobUUID, -1), e);
        throw new NotFoundException("Was not able to support zip file, see logs for details");
    }
}
Also used : OutputStream(java.io.OutputStream) NotFoundException(com.mercedesbenz.sechub.sharedkernel.error.NotFoundException) IOException(java.io.IOException) UseCaseAdminDownloadsFullScanDataForJob(com.mercedesbenz.sechub.sharedkernel.usecases.admin.project.UseCaseAdminDownloadsFullScanDataForJob) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

NotFoundException (com.mercedesbenz.sechub.sharedkernel.error.NotFoundException)12 ScheduleSecHubJob (com.mercedesbenz.sechub.domain.schedule.job.ScheduleSecHubJob)3 AlreadyExistsException (com.mercedesbenz.sechub.sharedkernel.error.AlreadyExistsException)2 Test (org.junit.Test)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 SecHubRuntimeException (com.mercedesbenz.sechub.commons.model.SecHubRuntimeException)1 ProjectMetaData (com.mercedesbenz.sechub.domain.administration.project.ProjectJsonInput.ProjectMetaData)1 User (com.mercedesbenz.sechub.domain.administration.user.User)1 UserRepository (com.mercedesbenz.sechub.domain.administration.user.UserRepository)1 ProjectAccessCompositeKey (com.mercedesbenz.sechub.domain.scan.access.ScanAccess.ProjectAccessCompositeKey)1 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)1 ScanReport (com.mercedesbenz.sechub.domain.scan.report.ScanReport)1 ScanSecHubReport (com.mercedesbenz.sechub.domain.scan.report.ScanSecHubReport)1 ProjectAccessCompositeKey (com.mercedesbenz.sechub.domain.schedule.access.ScheduleAccess.ProjectAccessCompositeKey)1 RoleConstants (com.mercedesbenz.sechub.sharedkernel.RoleConstants)1 Step (com.mercedesbenz.sechub.sharedkernel.Step)1 UserContextService (com.mercedesbenz.sechub.sharedkernel.UserContextService)1 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)1 DomainMessageFactory (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageFactory)1 DomainMessageService (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageService)1