You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.0 KiB
70 lines
2.0 KiB
package rest; |
|
|
|
import org.eclipse.microprofile.rest.client.inject.RestClient; |
|
import dto.ScanObj; |
|
|
|
import javax.inject.Inject; |
|
import javax.validation.Valid; |
|
import javax.ws.rs.Consumes; |
|
import javax.ws.rs.POST; |
|
import javax.ws.rs.Path; |
|
import javax.ws.rs.PUT; |
|
import javax.ws.rs.DELETE; |
|
import java.net.URI; |
|
import java.net.URISyntaxException; |
|
import java.util.ArrayList; |
|
import java.util.Arrays; |
|
import java.util.List; |
|
import java.util.UUID; |
|
import org.json.JSONObject; |
|
import org.json.JSONArray; |
|
import dto.ScanObj; |
|
import dto.ConnectDB; |
|
import dto.ScanObjPayload; |
|
|
|
import javax.ws.rs.PathParam; |
|
|
|
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("/deleteScan") |
|
public class RemoveScan { |
|
|
|
// @Inject |
|
@RestClient |
|
CreateScanService createScanService; |
|
// ScanObjPayload scanObjPayload; |
|
|
|
@DELETE |
|
@Path("/{scanId}") |
|
public boolean invokeScanAnalyze(@PathParam("scanId") String scanId) throws URISyntaxException { |
|
ConnectDB connectDB = new ConnectDB(); |
|
Connection conn = connectDB.connect(); |
|
//this is ugly needs to berewritten |
|
Statement stmt = null; |
|
ScanObj finalScan = null; |
|
//fix this |
|
Boolean success = false; |
|
String sql = "DELETE FROM scans WHERE scanid=" + scanId; |
|
//need to add figure out an archieve system and wether its nessacery (archieve value??) |
|
try{ |
|
stmt = conn.createStatement(); |
|
//TODO add proper checks |
|
stmt.executeUpdate(sql); |
|
//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); |
|
} |
|
success = true; |
|
return success; |
|
} |
|
}
|
|
|