package rest; import dto.ConnectDB; import dto.ScanObjPayload; import dto.ScanObj; import dto.ScanObjPayload; import org.eclipse.microprofile.rest.client.inject.RestClient; import org.json.JSONObject; import org.eclipse.microprofile.rest.client.inject.RestClient; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.net.URISyntaxException; import io.quarkus.security.Authenticated; import javax.validation.Valid; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; @Path("/") public class CreateScanResource { private static final Logger logger = LoggerFactory.getLogger(CreateScanResource.class); @RestClient CreateScanService createScanService; @POST @Consumes({ "application/json" }) //in theory should take List to clean it up 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; } }