|
|
|
|
@ -9,13 +9,15 @@ import dto.PncObj;
|
|
|
|
|
import dto.PncObjPayload; |
|
|
|
|
|
|
|
|
|
import org.eclipse.microprofile.rest.client.inject.RestClient; |
|
|
|
|
import org.json.JSONException; |
|
|
|
|
import org.json.JSONObject; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
|
import javax.ws.rs.Consumes; |
|
|
|
|
import javax.ws.rs.POST; |
|
|
|
|
import javax.ws.rs.Path; |
|
|
|
|
import java.net.URISyntaxException; |
|
|
|
|
import java.sql.Connection; |
|
|
|
|
import java.sql.PreparedStatement; |
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
@ -23,6 +25,8 @@ import java.sql.SQLException;
|
|
|
|
|
@Path("/scanRequest") |
|
|
|
|
public class CreateScanRequest { |
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(CreateScanRequest.class); |
|
|
|
|
|
|
|
|
|
@RestClient |
|
|
|
|
CreateScanService createScanService; |
|
|
|
|
|
|
|
|
|
@ -30,7 +34,7 @@ public class CreateScanRequest {
|
|
|
|
|
@Path("/brew") |
|
|
|
|
@Consumes({ "application/json" }) |
|
|
|
|
// in theory should take List<String> to clean it up
|
|
|
|
|
public BrewObj invokeBrewScanAnalyze(@Valid String scanInvocation) throws URISyntaxException { |
|
|
|
|
public BrewObj invokeBrewScanAnalyze(@Valid String scanInvocation) throws JSONException { |
|
|
|
|
JSONObject jsonData = new JSONObject(scanInvocation); |
|
|
|
|
BrewObj brewObj = BrewObjPayload.constructScanPayload(jsonData); |
|
|
|
|
ConnectDB connectDB = new ConnectDB(); |
|
|
|
|
@ -45,7 +49,7 @@ public class CreateScanRequest {
|
|
|
|
|
pstmt.setBoolean(7, brewObj.getBuiltFromSource()); |
|
|
|
|
pstmt.executeUpdate(); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
System.out.println(e.getMessage()); |
|
|
|
|
logger.error(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
return brewObj; |
|
|
|
|
} |
|
|
|
|
@ -53,7 +57,7 @@ public class CreateScanRequest {
|
|
|
|
|
@POST |
|
|
|
|
@Path("/git") |
|
|
|
|
@Consumes({ "application/json" }) |
|
|
|
|
public GitObj invokeGitScanAnalyze(@Valid String scanInvocation)throws URISyntaxException { |
|
|
|
|
public GitObj invokeGitScanAnalyze(@Valid String scanInvocation)throws JSONException { |
|
|
|
|
JSONObject jsonData = new JSONObject(scanInvocation); |
|
|
|
|
GitObj gitObj = GitObjPayload.constructScanPayload(jsonData); |
|
|
|
|
ConnectDB connectDB = new ConnectDB(); |
|
|
|
|
@ -65,7 +69,7 @@ public class CreateScanRequest {
|
|
|
|
|
pstmt.setString(4, gitObj.getCommitId()); |
|
|
|
|
pstmt.executeUpdate(); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
System.out.println(e.getMessage()); |
|
|
|
|
logger.error(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
return gitObj; |
|
|
|
|
} |
|
|
|
|
@ -73,7 +77,7 @@ public class CreateScanRequest {
|
|
|
|
|
@POST |
|
|
|
|
@Path("/pnc") |
|
|
|
|
@Consumes({ "application/json" }) |
|
|
|
|
public PncObj invokePncScanAnalyze(@Valid String scanInvocation)throws URISyntaxException { |
|
|
|
|
public PncObj invokePncScanAnalyze(@Valid String scanInvocation)throws JSONException { |
|
|
|
|
JSONObject jsonData = new JSONObject(scanInvocation); |
|
|
|
|
PncObj pncObj = PncObjPayload.constructScanPayload(jsonData); |
|
|
|
|
ConnectDB connectDB = new ConnectDB(); |
|
|
|
|
@ -83,7 +87,7 @@ public class CreateScanRequest {
|
|
|
|
|
pstmt.setString(2, pncObj.getBuildId()); |
|
|
|
|
pstmt.executeUpdate(); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
System.out.println(e.getMessage()); |
|
|
|
|
logger.error(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
return pncObj; |
|
|
|
|
} |
|
|
|
|
|