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.
71 lines
2.0 KiB
71 lines
2.0 KiB
package rest; |
|
|
|
import java.util.Collections; |
|
import java.util.LinkedHashMap; |
|
import java.util.Set; |
|
import dto.ScanObj; |
|
import dto.ConnectDB; |
|
|
|
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; |
|
|
|
import javax.ws.rs.DELETE; |
|
import javax.ws.rs.GET; |
|
import javax.ws.rs.POST; |
|
import javax.ws.rs.Path; |
|
import javax.inject.Inject; |
|
import javax.ws.rs.GET; |
|
import javax.ws.rs.Path; |
|
import javax.ws.rs.PathParam; |
|
import java.util.Set; |
|
import java.util.stream.Collectors; |
|
import javax.inject.Inject; |
|
import javax.ws.rs.Consumes; |
|
|
|
import java.sql.*; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
import com.fasterxml.jackson.databind.ObjectWriter; |
|
|
|
// @Path("/api/v1/[osh-scan]") |
|
@Path("/scanGet") |
|
public class CreateGetResource { |
|
|
|
CreateScanService createScanService; |
|
|
|
private Set<ScanObj> Scans = Collections.newSetFromMap(Collections.synchronizedMap(new LinkedHashMap<>())); |
|
|
|
|
|
public CreateGetResource() { |
|
|
|
} |
|
|
|
@GET |
|
@Path("/{scanId}") |
|
public Set<ScanObj> list(@PathParam("scanId") String scanId) { |
|
//use to return specific scanIds just use usual fetch from sets, will be querying hte db directly here |
|
try { |
|
ConnectDB connectDB = new ConnectDB(); |
|
Connection conn = connectDB.connect(); |
|
Statement stmt = null; |
|
String sql = "SELECT * FROM scans WHERE scanid=" +scanId; |
|
stmt = conn.createStatement(); |
|
ResultSet rs = stmt.executeQuery(sql); |
|
|
|
while (rs.next()) { |
|
//very ugly solution needs some change to where we put the query |
|
Scans.add(new ScanObj(rs.getString("scanid"),rs.getString("productid"),rs.getString("eventid"),rs.getString("ismanagedservice"),rs.getString("componentlist"))); |
|
conn.close(); |
|
} |
|
} catch (SQLException e){ |
|
System.out.println(e); |
|
} |
|
return Scans; |
|
} |
|
} |