3 changed files with 122 additions and 0 deletions
@ -0,0 +1,26 @@
|
||||
package dto; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Getter; |
||||
import lombok.ToString; |
||||
import lombok.extern.jackson.Jacksonized; |
||||
|
||||
// import org.jboss.pnc.api.dto.Request;
|
||||
|
||||
import java.io.Serializable; |
||||
|
||||
@ToString |
||||
@Getter |
||||
@AllArgsConstructor |
||||
@Jacksonized |
||||
@Builder |
||||
public class BrewObj implements Serializable { |
||||
public String buildSysyemType; |
||||
public String brewId; |
||||
public String brewNvr; |
||||
public String pncId; |
||||
public String artifactType; |
||||
public String fileName; |
||||
public String buildFromSource; |
||||
} |
||||
@ -0,0 +1,23 @@
|
||||
package dto; |
||||
|
||||
import org.eclipse.microprofile.config.ConfigProvider; |
||||
// import org.jboss.pnc.api.deliverablesanalyzer.dto.AnalyzePayload;
|
||||
// import org.jboss.pnc.api.dto.HeartbeatConfig;
|
||||
// import org.jboss.pnc.api.dto.Request;
|
||||
|
||||
import java.net.URI; |
||||
import java.net.URISyntaxException; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.sql.Struct; |
||||
import java.util.*; |
||||
|
||||
import org.json.JSONObject; |
||||
import org.json.JSONArray; |
||||
|
||||
import static constants.HttpHeaders.AUTHORIZATION_STRING; |
||||
|
||||
public class BrewObjPayload { |
||||
public static BrewObj constructScanPayload(JSONObject brewObj) throws URISyntaxException { |
||||
return new BrewObj(brewObj.getString("buildSystemType"),brewObj.getString("brewId"),brewObj.getString("brewNvr"),brewObj.getString("pncId"),brewObj.getString("artifactType"),brewObj.getString("fileName"),brewObj.getString("builtFromSource")); |
||||
} |
||||
} |
||||
@ -0,0 +1,73 @@
|
||||
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 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.BrewObj; |
||||
import dto.ConnectDB; |
||||
import dto.ScanObjPayload; |
||||
import dto.BrewObjPayload; |
||||
|
||||
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("/scanRequest") |
||||
public class CreateScanRequest { |
||||
|
||||
// @Inject
|
||||
@RestClient |
||||
CreateScanService createScanService; |
||||
// ScanObjPayload scanObjPayload;
|
||||
|
||||
@POST |
||||
@Path("/{scanChoice}") |
||||
@Consumes({ "application/json" }) |
||||
//in theory should take List<String> to clean it up
|
||||
public BrewObj invokeScanAnalyze(@Valid String scanInvocation) throws URISyntaxException { |
||||
JSONObject jsonData = new JSONObject(scanInvocation); |
||||
BrewObj brewObj = BrewObjPayload.constructScanPayload(jsonData); |
||||
|
||||
// scanBrewObj();
|
||||
|
||||
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);
|
||||
// } catch (SQLException e){
|
||||
// System.out.println(e);
|
||||
// }
|
||||
brewObj = null; |
||||
return brewObj; |
||||
} |
||||
|
||||
private BrewObj scanBrewObj(JSONObject jsonData){ |
||||
System.out.println(jsonData.getString("buildSystemType")); |
||||
BrewObj aa = null; |
||||
return aa; |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue