@ -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 Unsupport edOperationE xception( "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;
}
}