Browse Source

updated exceptions to throw on unimplemented fu nctionality

exception_work
Nicholas Caughey 3 years ago
parent
commit
5de2051b86
  1. 65
      src/main/java/rest/CreateScanRequest.java
  2. 33
      src/main/java/rest/CreateScanResource.java
  3. 56
      src/main/java/rest/CreateStartScan.java

65
src/main/java/rest/CreateScanRequest.java

@ -68,44 +68,45 @@ public class CreateScanRequest {
@POST
@Path("/git")
@Consumes({ "application/json" })
public GitObj invokeGitScanAnalyze(@Valid String scanInvocation)throws URISyntaxException {
throw new exception ("unImplemented fucntionality");
JSONObject jsonData = new JSONObject(scanInvocation);
GitObj gitObj = GitObjPayload.constructScanPayload(jsonData);
public void invokeGitScanAnalyze(@Valid String scanInvocation)throws URISyntaxException {
throw new UnsupportedOperationException("unImplemented fucntionality");
ConnectDB connectDB = new ConnectDB();
Connection conn = connectDB.connect();
Statement stmt = null;
String sql = "INSERT INTO gitscans (buildsystemtype, repository, reference, commitid) VALUES ('"+gitObj.buildSystemType+"','"+gitObj.repository+"','"+gitObj.reference+"','"+gitObj.commitId+"')";
try{
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
conn.close();
} catch (SQLException e){
System.out.println(e);
}
return gitObj;
// JSONObject jsonData = new JSONObject(scanInvocation);
// GitObj gitObj = GitObjPayload.constructScanPayload(jsonData);
// ConnectDB connectDB = new ConnectDB();
// Connection conn = connectDB.connect();
// Statement stmt = null;
// String sql = "INSERT INTO gitscans (buildsystemtype, repository, reference, commitid) VALUES ('"+gitObj.buildSystemType+"','"+gitObj.repository+"','"+gitObj.reference+"','"+gitObj.commitId+"')";
// try{
// stmt = conn.createStatement();
// ResultSet rs = stmt.executeQuery(sql);
// conn.close();
// } catch (SQLException e){
// System.out.println(e);
// }
// return gitObj;
}
@POST
@Path("/pnc")
@Consumes({ "application/json" })
public PncObj invokePncScanAnalyze(@Valid String scanInvocation)throws URISyntaxException {
throw new exception ("unImplemented fucntionality");
JSONObject jsonData = new JSONObject(scanInvocation);
PncObj pncObj = PncObjPayload.constructScanPayload(jsonData);
public void invokePncScanAnalyze(@Valid String scanInvocation)throws URISyntaxException {
throw new UnsupportedOperationException("unImplemented fucntionality");
// JSONObject jsonData = new JSONObject(scanInvocation);
// PncObj pncObj = PncObjPayload.constructScanPayload(jsonData);
ConnectDB connectDB = new ConnectDB();
Connection conn = connectDB.connect();
Statement stmt = null;
String sql = "INSERT INTO pncscans (buildsystemtype, buildid) VALUES ('"+pncObj.buildSystemType+"','"+pncObj.buildId+"')";
try{
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
conn.close();
} catch (SQLException e){
System.out.println(e);
}
return pncObj;
// ConnectDB connectDB = new ConnectDB();
// Connection conn = connectDB.connect();
// Statement stmt = null;
// String sql = "INSERT INTO pncscans (buildsystemtype, buildid) VALUES ('"+pncObj.buildSystemType+"','"+pncObj.buildId+"')";
// try{
// stmt = conn.createStatement();
// ResultSet rs = stmt.executeQuery(sql);
// conn.close();
// } catch (SQLException e){
// System.out.println(e);
// }
// return pncObj;
}
}

33
src/main/java/rest/CreateScanResource.java

@ -39,22 +39,21 @@ public class CreateScanResource {
@POST
@Consumes({ "application/json" })
//in theory should take List<String> to clean it up
public ScanObj invokeScanAnalyze(@Valid String scanInvocation) throws URISyntaxException {
throw new exception ("unImplemented fucntionality");
JSONObject jsonData = new JSONObject(scanInvocation);
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);
conn.close();
} catch (SQLException e){
System.out.println(e);
}
return scanObj;
public void invokeScanAnalyze(@Valid String scanInvocation) throws URISyntaxException {
throw new UnsupportedOperationException("unImplemented fucntionality");
// JSONObject jsonData = new JSONObject(scanInvocation);
// 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);
// conn.close();
// } catch (SQLException e){
// System.out.println(e);
// }
// return scanObj;
}
}

56
src/main/java/rest/CreateStartScan.java

@ -41,37 +41,37 @@ public class CreateStartScan {
@PUT
@Path("/{scanId}")
public ScanObj invokeScanAnalyze(@PathParam("scanId") String scanId) throws URISyntaxException {
throw new exception ("unImplemented fucntionality");
ConnectDB connectDB = new ConnectDB();
Connection conn = connectDB.connect();
//this is ugly needs to berewritten
Statement stmt = null;
ScanObj finalScan = null;
public void invokeScanAnalyze(@PathParam("scanId") String scanId) throws URISyntaxException {
throw new UnsupportedOperationException("unImplemented fucntionality");
// ConnectDB connectDB = new ConnectDB();
// Connection conn = connectDB.connect();
// //this is ugly needs to berewritten
// Statement stmt = null;
// ScanObj finalScan = null;
String sql = "SELECT * FROM scans WHERE scanid=" + scanId;
//need to add figure out an archieve system and wether its nessacery (archieve value??)
try{
stmt = conn.createStatement();
//terrible solution has to be a better way of doing this
ResultSet rs = stmt.executeQuery(sql);
// String sql = "SELECT * FROM scans WHERE scanid=" + scanId;
// //need to add figure out an archieve system and wether its nessacery (archieve value??)
// try{
// stmt = conn.createStatement();
// //terrible solution has to be a better way of doing this
// ResultSet rs = stmt.executeQuery(sql);
//fix for individual results (not resultset)
//TODO: need to add unique keys to DBs
finalScan = new ScanObj(rs.getString("scanid"),rs.getString("productid"),rs.getString("eventid"),rs.getString("ismanagedservice"),rs.getString("componentlist"));
String copySql = "INSERT INTO archive (scanid, productid, eventid, ismanagedservice, componentlist) VALUES ('" +finalScan.scanId+"', '"+finalScan.productId+"', '"+finalScan.eventId+"', '"+finalScan.isManagedService+"', '"+finalScan.componentList+"')";
stmt.executeUpdate(copySql);
// //fix for individual results (not resultset)
// //TODO: need to add unique keys to DBs
// finalScan = new ScanObj(rs.getString("scanid"),rs.getString("productid"),rs.getString("eventid"),rs.getString("ismanagedservice"),rs.getString("componentlist"));
// String copySql = "INSERT INTO archive (scanid, productid, eventid, ismanagedservice, componentlist) VALUES ('" +finalScan.scanId+"', '"+finalScan.productId+"', '"+finalScan.eventId+"', '"+finalScan.isManagedService+"', '"+finalScan.componentList+"')";
// stmt.executeUpdate(copySql);
//TODO add proper checks
String deleteSql = "DELETE FROM scans WHERE scanid=" + scanId;
stmt.executeUpdate(deleteSql);
// //TODO add proper checks
// String deleteSql = "DELETE FROM scans WHERE scanid=" + scanId;
// stmt.executeUpdate(deleteSql);
//send task to the actual interface here using the resultset returned (should multiple scanids be allowed):
//once the task is complete AND we have confirmation that the scan is done run the following sql
conn.close();
} catch (SQLException e){
System.out.println(e);
}
return finalScan;
// //send task to the actual interface here using the resultset returned (should multiple scanids be allowed):
// //once the task is complete AND we have confirmation that the scan is done run the following sql
// conn.close();
// } catch (SQLException e){
// System.out.println(e);
// }
// return finalScan;
}
}

Loading…
Cancel
Save