|
|
|
@ -16,12 +16,21 @@ import java.util.List; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.UUID; |
|
|
|
import org.json.JSONObject; |
|
|
|
import org.json.JSONObject; |
|
|
|
import org.json.JSONArray; |
|
|
|
import org.json.JSONArray; |
|
|
|
|
|
|
|
import dto.ScanObj; |
|
|
|
|
|
|
|
import dto.ConnectDB; |
|
|
|
import dto.ScanObjPayload; |
|
|
|
import dto.ScanObjPayload; |
|
|
|
|
|
|
|
|
|
|
|
import static constants.HttpHeaders.AUTHORIZATION_STRING; |
|
|
|
import static constants.HttpHeaders.AUTHORIZATION_STRING; |
|
|
|
|
|
|
|
import java.sql.Connection; |
|
|
|
|
|
|
|
import java.sql.DriverManager; |
|
|
|
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection; |
|
|
|
|
|
|
|
import java.sql.DriverManager; |
|
|
|
|
|
|
|
import java.sql.ResultSet; |
|
|
|
|
|
|
|
import java.sql.Statement; |
|
|
|
|
|
|
|
|
|
|
|
@Path("/createScan") |
|
|
|
@Path("/") |
|
|
|
public class CreateScanResource { |
|
|
|
public class CreateScanResource { |
|
|
|
|
|
|
|
|
|
|
|
// @Inject
|
|
|
|
// @Inject
|
|
|
|
@ -31,14 +40,20 @@ public class CreateScanResource { |
|
|
|
|
|
|
|
|
|
|
|
@POST |
|
|
|
@POST |
|
|
|
@Consumes({ "application/json" }) |
|
|
|
@Consumes({ "application/json" }) |
|
|
|
//in theory should take List<String> but something weird is happening, didnt want to fix it specifically before adding the DB dto
|
|
|
|
//in theory should take List<String> to clean it up
|
|
|
|
public ScanObj invokeScanAnalyze(@Valid String scanInvocation) throws URISyntaxException { |
|
|
|
public ScanObj invokeScanAnalyze(@Valid String scanInvocation) throws URISyntaxException { |
|
|
|
|
|
|
|
|
|
|
|
//weird work around is currently being fixed
|
|
|
|
|
|
|
|
JSONObject jsonData = new JSONObject(scanInvocation); |
|
|
|
JSONObject jsonData = new JSONObject(scanInvocation); |
|
|
|
System.out.println(jsonData); |
|
|
|
|
|
|
|
//ignore all of this, temporary for testing purposes, "parser" will be in ScanObjPayload
|
|
|
|
|
|
|
|
ScanObj scanObj = ScanObjPayload.constructScanPayload(jsonData); |
|
|
|
ScanObj scanObj = ScanObjPayload.constructScanPayload(jsonData); |
|
|
|
|
|
|
|
ConnectDB connectDB = new ConnectDB(); |
|
|
|
|
|
|
|
Connection conn = connectDB.connect(); |
|
|
|
|
|
|
|
Statement stmt = null; |
|
|
|
|
|
|
|
String sql = "INSERT INTO scans (scanid, productid, eventid, ismanagedservice, componentlist) VALUES ('" +scanObj.scanId+"', '"+scanObj.productId+"', '"+scanObj.eventId+"', '"+scanObj.isManagedService+"', '"+scanObj.componentList+"')"; |
|
|
|
|
|
|
|
try{ |
|
|
|
|
|
|
|
stmt = conn.createStatement(); |
|
|
|
|
|
|
|
ResultSet rs = stmt.executeQuery(sql); |
|
|
|
|
|
|
|
} catch (SQLException e){ |
|
|
|
|
|
|
|
System.out.println(e); |
|
|
|
|
|
|
|
} |
|
|
|
return scanObj; |
|
|
|
return scanObj; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|