package rest; import dto.ConnectDB; import org.eclipse.microprofile.rest.client.inject.RestClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.Path; import javax.ws.rs.DELETE; import javax.ws.rs.PathParam; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; @Path("/deleteScan") public class RemoveScan { private static final Logger logger = LoggerFactory.getLogger(RemoveScan.class); // @Inject @RestClient CreateScanService createScanService; @DELETE @Path("/{scanId}") public boolean invokeScanAnalyze(@PathParam("scanId") String scanId) { boolean rc = false; //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 String qry = "DELETE FROM scans WHERE scan_id=?"; ConnectDB connectDB = new ConnectDB(); try(Connection conn = connectDB.connect(); PreparedStatement pstmt = conn.prepareStatement(qry)) { pstmt.setString(1, scanId); pstmt.executeUpdate(); rc = true; } catch (SQLException e) { logger.error(e.getMessage()); } return rc; } }