|
|
|
|
@ -1,14 +1,13 @@
|
|
|
|
|
package com.redhat.pctsec.rest.v1alpha1; |
|
|
|
|
|
|
|
|
|
import com.redhat.pctsec.model.Scan; |
|
|
|
|
import com.redhat.pctsec.model.ScanRequest; |
|
|
|
|
import com.redhat.pctsec.model.ScanRequests; |
|
|
|
|
import com.redhat.pctsec.model.jpa.ScanRequestRepository; |
|
|
|
|
import com.redhat.pctsec.model.osh.paramMapper; |
|
|
|
|
import io.quarkus.security.Authenticated; |
|
|
|
|
import jakarta.enterprise.context.ApplicationScoped; |
|
|
|
|
import jakarta.inject.Inject; |
|
|
|
|
import jakarta.transaction.Transactional; |
|
|
|
|
import jakarta.ws.rs.*; |
|
|
|
|
import org.eclipse.microprofile.config.inject.ConfigProperty; |
|
|
|
|
import picocli.CommandLine; |
|
|
|
|
|
|
|
|
|
import java.util.UUID; |
|
|
|
|
@ -16,14 +15,14 @@ import java.util.UUID;
|
|
|
|
|
@Path("/api/v1a/ScanRequest/{id}") |
|
|
|
|
public class ScanRequestResource { |
|
|
|
|
@Inject |
|
|
|
|
ScanRequestRepository sr; |
|
|
|
|
ScanRequestRepository scanRequestRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GET |
|
|
|
|
@Produces({"application/json"}) |
|
|
|
|
public ScanRequest getScanRequest(String id) |
|
|
|
|
{ |
|
|
|
|
ScanRequest scanRequest = sr.findById(UUID.fromString(id)); |
|
|
|
|
ScanRequest scanRequest = scanRequestRepository.findById(UUID.fromString(id)); |
|
|
|
|
return scanRequest; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -31,18 +30,20 @@ public class ScanRequestResource {
|
|
|
|
|
@Path("ScanProperties/{scanProperties}") |
|
|
|
|
@Consumes({"application/octet-stream"}) |
|
|
|
|
@Produces({"application/json"}) |
|
|
|
|
@Authenticated |
|
|
|
|
@Transactional |
|
|
|
|
public ScanRequest patchScanRequest(String id, String scanProperties) |
|
|
|
|
{ |
|
|
|
|
ScanRequest scanRequest = sr.findById(UUID.fromString(id)); |
|
|
|
|
ScanRequest scanRequest = scanRequestRepository.findById(UUID.fromString(id)); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
paramMapper pm = new paramMapper(scanProperties); |
|
|
|
|
} catch(CommandLine.UnmatchedArgumentException e) |
|
|
|
|
}catch(CommandLine.UnmatchedArgumentException e) |
|
|
|
|
{ |
|
|
|
|
throw new BadRequestException("Invalid OSH Parameter"); |
|
|
|
|
} |
|
|
|
|
scanRequest.scanProperties = scanProperties; |
|
|
|
|
sr.persist(scanRequest); |
|
|
|
|
scanRequest.setScanProperties(scanProperties); |
|
|
|
|
scanRequestRepository.persist(scanRequest); |
|
|
|
|
return scanRequest; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|