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