Browse Source

destroy connections correctly and return some of the objects correctly

exception_work
Nicholas Caughey 3 years ago
parent
commit
5f3b63fd4d
  1. 2
      src/main/java/dto/ScanObj.java
  2. 1
      src/main/java/rest/CreateGetResource.java
  3. 6
      src/main/java/rest/CreateScanRequest.java
  4. 1
      src/main/java/rest/CreateScanResource.java
  5. 17
      src/main/java/rest/CreateStartScan.java
  6. 1
      src/main/java/rest/RemoveScan.java

2
src/main/java/dto/ScanObj.java

@ -7,7 +7,7 @@ import lombok.ToString;
import lombok.extern.jackson.Jacksonized;
// import org.jboss.pnc.api.dto.Request;
//still need to fix all the scan objects to be significantly less poorly written
import java.io.Serializable;
@ToString

1
src/main/java/rest/CreateGetResource.java

@ -61,6 +61,7 @@ public class CreateGetResource {
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);

6
src/main/java/rest/CreateScanRequest.java

@ -38,7 +38,7 @@ import java.sql.Statement;
@Path("/scanRequest")
public class CreateScanRequest {
//all of these need cleaning up to be a more sensible soution
@RestClient
CreateScanService createScanService;
@ -58,6 +58,7 @@ public class CreateScanRequest {
try{
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
conn.close();
} catch (SQLException e){
System.out.println(e);
}
@ -78,10 +79,10 @@ public class CreateScanRequest {
try{
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
conn.close();
} catch (SQLException e){
System.out.println(e);
}
gitObj = null;
return gitObj;
}
@ -99,6 +100,7 @@ public class CreateScanRequest {
try{
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
conn.close();
} catch (SQLException e){
System.out.println(e);
}

1
src/main/java/rest/CreateScanResource.java

@ -49,6 +49,7 @@ public class CreateScanResource {
try{
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
conn.close();
} catch (SQLException e){
System.out.println(e);
}

17
src/main/java/rest/CreateStartScan.java

@ -56,21 +56,8 @@ public class CreateStartScan {
ResultSet rs = stmt.executeQuery(sql);
//fix for individual results (not resultset)
String a = null;
String b = null;
String c = null;
String d = null;
String e = null;
//still kind of needed for now since theres no established primary key, needs to be do
while (rs.next()) {
a = rs.getString("scanid");
b = rs.getString("productid");
c = rs.getString("eventid");
d = rs.getString("ismanagedservice");
e = rs.getString("componentlist");
}
//TODO: need to add unique keys to DBs
finalScan = new ScanObj(a,b,c,d,e);
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);
@ -80,7 +67,7 @@ public class CreateStartScan {
//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);
}

1
src/main/java/rest/RemoveScan.java

@ -60,6 +60,7 @@ public class RemoveScan {
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);
}

Loading…
Cancel
Save