Browse Source

change db table field names from mixed naming convention to pythonic convention xxx_yyy_zzz and stop using CamelCase

db_schema
Leonid Bossis 3 years ago
parent
commit
8975fff63d
  1. 12
      .gitignore
  2. 252
      schema/populate.sql
  3. 60
      schema/schema.sql
  4. 2
      src/main/java/dto/BrewObj.java
  5. 14
      src/main/java/dto/BrewObjPayload.java
  6. 4
      src/main/java/dto/ConnectDB.java
  7. 2
      src/main/java/dto/GitObj.java
  8. 4
      src/main/java/dto/GitObjPayload.java
  9. 2
      src/main/java/dto/PncObj.java
  10. 4
      src/main/java/dto/PncObjPayload.java
  11. 12
      src/main/java/dto/ScanObj.java
  12. 10
      src/main/java/dto/ScanObjPayload.java
  13. 12
      src/main/java/rest/CreateGetResource.java
  14. 1
      src/main/java/rest/CreateScanRequest.java
  15. 14
      src/main/java/rest/CreateScanResource.java
  16. 45
      src/main/java/rest/CreateStartScan.java
  17. 4
      src/main/java/rest/RemoveScan.java
  18. 69
      src/test/java/dto/TestPayload.java

12
.gitignore vendored

@ -0,0 +1,12 @@
.dcignore
.idea
*.iml
dev/
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties

252
schema/populate.sql

@ -1,126 +1,126 @@
INSERT INTO osh.offerings(offeringId,description) VALUES ('ansible-automation-platform','Ansible Automation Platform (AAP)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('ansible-automation-platform','Ansible Automation Platform (AAP)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('advisor','Insights Advisor'); INSERT INTO osh.offerings(offering_id,description) VALUES ('advisor','Insights Advisor');
INSERT INTO osh.offerings(offeringId,description) VALUES ('ansible-on-aws','Ansible on AWS'); INSERT INTO osh.offerings(offering_id,description) VALUES ('ansible-on-aws','Ansible on AWS');
INSERT INTO osh.offerings(offeringId,description) VALUES ('ansible-on-azure','Ansible on Azure'); INSERT INTO osh.offerings(offering_id,description) VALUES ('ansible-on-azure','Ansible on Azure');
INSERT INTO osh.offerings(offeringId,description) VALUES ('ansible-on-gcp','Ansible on GCP'); INSERT INTO osh.offerings(offering_id,description) VALUES ('ansible-on-gcp','Ansible on GCP');
INSERT INTO osh.offerings(offeringId,description) VALUES ('ansible-wisdom-service','Ansible Wisdom Service'); INSERT INTO osh.offerings(offering_id,description) VALUES ('ansible-wisdom-service','Ansible Wisdom Service');
INSERT INTO osh.offerings(offeringId,description) VALUES ('cert-manager','cert-manager Operator for Red Hat OpenShift'); INSERT INTO osh.offerings(offering_id,description) VALUES ('cert-manager','cert-manager Operator for Red Hat OpenShift');
INSERT INTO osh.offerings(offeringId,description) VALUES ('compliance','Insights Compliance'); INSERT INTO osh.offerings(offering_id,description) VALUES ('compliance','Insights Compliance');
INSERT INTO osh.offerings(offeringId,description) VALUES ('connected-customer-experience','Connected Customer Experience (CCX)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('connected-customer-experience','Connected Customer Experience (CCX)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('cost-management','Cost Management'); INSERT INTO osh.offerings(offering_id,description) VALUES ('cost-management','Cost Management');
INSERT INTO osh.offerings(offeringId,description) VALUES ('custom-metric-autoscaler','OpenShift Custom Metrics Autoscaler'); INSERT INTO osh.offerings(offering_id,description) VALUES ('custom-metric-autoscaler','OpenShift Custom Metrics Autoscaler');
INSERT INTO osh.offerings(offeringId,description) VALUES ('developer-sandbox-for-red-hat-openshift','Developer Sandbox for Red Hat OpenShift'); INSERT INTO osh.offerings(offering_id,description) VALUES ('developer-sandbox-for-red-hat-openshift','Developer Sandbox for Red Hat OpenShift');
INSERT INTO osh.offerings(offeringId,description) VALUES ('dotnet','.NET'); INSERT INTO osh.offerings(offering_id,description) VALUES ('dotnet','.NET');
INSERT INTO osh.offerings(offeringId,description) VALUES ('drift','Insights Drift'); INSERT INTO osh.offerings(offering_id,description) VALUES ('drift','Insights Drift');
INSERT INTO osh.offerings(offeringId,description) VALUES ('eclipse-vertx','Red Hat build of Eclipse Vert.x'); INSERT INTO osh.offerings(offering_id,description) VALUES ('eclipse-vertx','Red Hat build of Eclipse Vert.x');
INSERT INTO osh.offerings(offeringId,description) VALUES ('edge-management','Edge Management'); INSERT INTO osh.offerings(offering_id,description) VALUES ('edge-management','Edge Management');
INSERT INTO osh.offerings(offeringId,description) VALUES ('eventing','Insights Eventing'); INSERT INTO osh.offerings(offering_id,description) VALUES ('eventing','Insights Eventing');
INSERT INTO osh.offerings(offeringId,description) VALUES ('fastdatapath','RHEL Fast Datapath'); INSERT INTO osh.offerings(offering_id,description) VALUES ('fastdatapath','RHEL Fast Datapath');
INSERT INTO osh.offerings(offeringId,description) VALUES ('host-management-services','Host Management Services'); INSERT INTO osh.offerings(offering_id,description) VALUES ('host-management-services','Host Management Services');
INSERT INTO osh.offerings(offeringId,description) VALUES ('hosted-control-planes','Hosted Control Planes (Hypershift)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('hosted-control-planes','Hosted Control Planes (Hypershift)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('hybrid-application-console','Hybrid Application Console (HAC)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('hybrid-application-console','Hybrid Application Console (HAC)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('insights-essential','Insights Essentials'); INSERT INTO osh.offerings(offering_id,description) VALUES ('insights-essential','Insights Essentials');
INSERT INTO osh.offerings(offeringId,description) VALUES ('kernel-module-management','Kernel Module Management'); INSERT INTO osh.offerings(offering_id,description) VALUES ('kernel-module-management','Kernel Module Management');
INSERT INTO osh.offerings(offeringId,description) VALUES ('logging-subsystem-for-red-hat-openshift','Logging Subsystem for Red Hat OpenShift'); INSERT INTO osh.offerings(offering_id,description) VALUES ('logging-subsystem-for-red-hat-openshift','Logging Subsystem for Red Hat OpenShift');
INSERT INTO osh.offerings(offeringId,description) VALUES ('lvms-operator','LVMS Operator'); INSERT INTO osh.offerings(offering_id,description) VALUES ('lvms-operator','LVMS Operator');
INSERT INTO osh.offerings(offeringId,description) VALUES ('malware-detection','Insights Malware Detection'); INSERT INTO osh.offerings(offering_id,description) VALUES ('malware-detection','Insights Malware Detection');
INSERT INTO osh.offerings(offeringId,description) VALUES ('mgmt-platform','Management Platform'); INSERT INTO osh.offerings(offering_id,description) VALUES ('mgmt-platform','Management Platform');
INSERT INTO osh.offerings(offeringId,description) VALUES ('migration-toolkit-for-applications','Migration Toolkit for Applications (MTA)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('migration-toolkit-for-applications','Migration Toolkit for Applications (MTA)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('migration-toolkit-for-containers','Migration Toolkit for Containers (MTC)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('migration-toolkit-for-containers','Migration Toolkit for Containers (MTC)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('migration-toolkit-for-runtimes','Migration Toolkit for Runtimes (MTR)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('migration-toolkit-for-runtimes','Migration Toolkit for Runtimes (MTR)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('migration-toolkit-for-virtualization','Migration Toolkit for Virtualization (MTV)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('migration-toolkit-for-virtualization','Migration Toolkit for Virtualization (MTV)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('network-observability-operator','Network Observability Operator'); INSERT INTO osh.offerings(offering_id,description) VALUES ('network-observability-operator','Network Observability Operator');
INSERT INTO osh.offerings(offeringId,description) VALUES ('node-healthcheck-operator','Node HealthCheck Operator'); INSERT INTO osh.offerings(offering_id,description) VALUES ('node-healthcheck-operator','Node HealthCheck Operator');
INSERT INTO osh.offerings(offeringId,description) VALUES ('node-maintenance-operator','Node Maintenance Operator'); INSERT INTO osh.offerings(offering_id,description) VALUES ('node-maintenance-operator','Node Maintenance Operator');
INSERT INTO osh.offerings(offeringId,description) VALUES ('nvidia-gpu-add-on','NVIDIA GPU Add-On'); INSERT INTO osh.offerings(offering_id,description) VALUES ('nvidia-gpu-add-on','NVIDIA GPU Add-On');
INSERT INTO osh.offerings(offeringId,description) VALUES ('oadp','OpenShift API for Data Protection'); INSERT INTO osh.offerings(offering_id,description) VALUES ('oadp','OpenShift API for Data Protection');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-container-platform','Openshift Container Platform (OCP)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-container-platform','Openshift Container Platform (OCP)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-container-storage','OpenShift Container Storage (OCS)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-container-storage','OpenShift Container Storage (OCS)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-data-foundation-managed-service','Red Hat OpenShift Data Foundation Managed Service'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-data-foundation-managed-service','Red Hat OpenShift Data Foundation Managed Service');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-dedicated','OpenShift Dedicated (OSD/ROSA)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-dedicated','OpenShift Dedicated (OSD/ROSA)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-developer-tools-and-services-helm','OpenShift Developer Tools and Services (Helm)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-developer-tools-and-services-helm','OpenShift Developer Tools and Services (Helm)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-developer-tools-and-services-jenkins','OpenShift Developer Tools and Services (Jenkins)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-developer-tools-and-services-jenkins','OpenShift Developer Tools and Services (Jenkins)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-distributed-tracing','OpenShift Distributed Tracing'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-distributed-tracing','OpenShift Distributed Tracing');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-on-azure','Openshift on Azure (ARO)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-on-azure','Openshift on Azure (ARO)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-run-once-duration-override-operator','OpenShift Run Once Duration Override Operator'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-run-once-duration-override-operator','OpenShift Run Once Duration Override Operator');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-sandboxed-containers','Openshift Sandboxed Containers'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-sandboxed-containers','Openshift Sandboxed Containers');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-secondary-scheduler-operator','OpenShift Secondary Scheduler Operator'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-secondary-scheduler-operator','OpenShift Secondary Scheduler Operator');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-servicemesh','OpenShift Service Mesh'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-servicemesh','OpenShift Service Mesh');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-virtualization','OpenShift Virtualization (CNV)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-virtualization','OpenShift Virtualization (CNV)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-web-terminal-operator','OpenShift Web Terminal Operator'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-web-terminal-operator','OpenShift Web Terminal Operator');
INSERT INTO osh.offerings(offeringId,description) VALUES ('openshift-winc','Windows Container Support for OpenShift'); INSERT INTO osh.offerings(offering_id,description) VALUES ('openshift-winc','Windows Container Support for OpenShift');
INSERT INTO osh.offerings(offeringId,description) VALUES ('patch','Insights Patch'); INSERT INTO osh.offerings(offering_id,description) VALUES ('patch','Insights Patch');
INSERT INTO osh.offerings(offeringId,description) VALUES ('product-discovery','Product Discovery'); INSERT INTO osh.offerings(offering_id,description) VALUES ('product-discovery','Product Discovery');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-3scale-api-management-platform','Red Hat 3scale API Management Platform'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-3scale-api-management-platform','Red Hat 3scale API Management Platform');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-advanced-cluster-management','Red Hat Advanced Cluster Management (RHACM)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-advanced-cluster-management','Red Hat Advanced Cluster Management (RHACM)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-amq-broker','Red Hat AMQ Broker'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-amq-broker','Red Hat AMQ Broker');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-amq-clients','Red Hat AMQ Clients'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-amq-clients','Red Hat AMQ Clients');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-amq-interconnect','Red Hat AMQ Interconnect'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-amq-interconnect','Red Hat AMQ Interconnect');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-amq-online','Red Hat AMQ Online'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-amq-online','Red Hat AMQ Online');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-amq-streams','Red Hat AMQ Streams'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-amq-streams','Red Hat AMQ Streams');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-build-apicurio-registry','Red Hat build of Apicurio Registry (formerly known as Integration Service Registry)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-build-apicurio-registry','Red Hat build of Apicurio Registry (formerly known as Integration Service Registry)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-build-quarkus','Red Hat Build of Quarkus'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-build-quarkus','Red Hat Build of Quarkus');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-camel-extensions-quarkus','Red Hat Camel Extensions for Quarkus'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-camel-extensions-quarkus','Red Hat Camel Extensions for Quarkus');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-camel-k','Red Hat Camel K'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-camel-k','Red Hat Camel K');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-camel-spring-boot','Red Hat Camel for Spring Boot'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-camel-spring-boot','Red Hat Camel for Spring Boot');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-ceph-storage','Red Hat Ceph Storage'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-ceph-storage','Red Hat Ceph Storage');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-certificate-system','Red Hat Certificate System (RHCS)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-certificate-system','Red Hat Certificate System (RHCS)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-certification-program','Red Hat Certification Program (rhcertification)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-certification-program','Red Hat Certification Program (rhcertification)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-code-quarkus','Red Hat Code Quarkus'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-code-quarkus','Red Hat Code Quarkus');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-core-os','Red Hat CoreOS'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-core-os','Red Hat CoreOS');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-data-grid','Red Hat Data Grid'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-data-grid','Red Hat Data Grid');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-debezium','Red Hat Debezium'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-debezium','Red Hat Debezium');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-decision-manager','Red Hat Decision Manager'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-decision-manager','Red Hat Decision Manager');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-developer-hub','Red Hat Developer Hub'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-developer-hub','Red Hat Developer Hub');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-developer-toolset','Red Hat Developer Toolset (DTS)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-developer-toolset','Red Hat Developer Toolset (DTS)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-devtools-compilers','Red Hat Developer Tools (DevTools Compilers)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-devtools-compilers','Red Hat Developer Tools (DevTools Compilers)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-directory-server','Red Hat Directory Server (RHDS)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-directory-server','Red Hat Directory Server (RHDS)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-enterprise-linux-10','Red Hat Enterprise Linux (RHEL) 10'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-enterprise-linux-10','Red Hat Enterprise Linux (RHEL) 10');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-enterprise-linux-6','Red Hat Enterprise Linux (RHEL) 6'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-enterprise-linux-6','Red Hat Enterprise Linux (RHEL) 6');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-enterprise-linux-7','Red Hat Enterprise Linux (RHEL) 7'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-enterprise-linux-7','Red Hat Enterprise Linux (RHEL) 7');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-enterprise-linux-8','Red Hat Enterprise Linux (RHEL) 8'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-enterprise-linux-8','Red Hat Enterprise Linux (RHEL) 8');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-enterprise-linux-9','Red Hat Enterprise Linux (RHEL) 9'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-enterprise-linux-9','Red Hat Enterprise Linux (RHEL) 9');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-fuse','Red Hat Fuse'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-fuse','Red Hat Fuse');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-gluster-storage','Red Hat Gluster Storage'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-gluster-storage','Red Hat Gluster Storage');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-in-vehicle-os','Red Hat In-Vehicle Operating System (RHIVOS)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-in-vehicle-os','Red Hat In-Vehicle Operating System (RHIVOS)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-jboss-core-services','Red Hat JBoss Core Services'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-jboss-core-services','Red Hat JBoss Core Services');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-jboss-eap','Red Hat JBoss Enterprise Application Platform (EAP)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-jboss-eap','Red Hat JBoss Enterprise Application Platform (EAP)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-jboss-web-server','Red Hat JBoss Web Server'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-jboss-web-server','Red Hat JBoss Web Server');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-observability-service','Red Hat Observability Service'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-observability-service','Red Hat Observability Service');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-open-database-access','Red Hat OpenShift Database Access'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-open-database-access','Red Hat OpenShift Database Access');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-open-shift-data-science','Red Hat OpenShift Data Science (RHODS)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-open-shift-data-science','Red Hat OpenShift Data Science (RHODS)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openjdk','Red Hat OpenJDK'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openjdk','Red Hat OpenJDK');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-api-management','Red Hat OpenShift API Management'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-api-management','Red Hat OpenShift API Management');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-builds-v2','Red Hat OpenShift Builds V2'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-builds-v2','Red Hat OpenShift Builds V2');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-connectors','Red Hat OpenShift Connectors (RHOC)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-connectors','Red Hat OpenShift Connectors (RHOC)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-control-plane-service','Red Hat OpenShift Control Plane Service'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-control-plane-service','Red Hat OpenShift Control Plane Service');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-data-foundation','Red Hat OpenShift Data Foundation'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-data-foundation','Red Hat OpenShift Data Foundation');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-dev-spaces','Red Hat OpenShift Dev Spaces'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-dev-spaces','Red Hat OpenShift Dev Spaces');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-gitops','Red Hat OpenShift GitOps'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-gitops','Red Hat OpenShift GitOps');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-local','Red Hat OpenShift Local'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-local','Red Hat OpenShift Local');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-pipelines','Red Hat OpenShift Pipelines'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-pipelines','Red Hat OpenShift Pipelines');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-serverless','Red Hat OpenShift Serverless'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-serverless','Red Hat OpenShift Serverless');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-service-registry','Red Hat OpenShift Service Registry'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-service-registry','Red Hat OpenShift Service Registry');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openshift-streams-apache-kafka','Red Hat OpenShift Streams for Apache Kafka (RHOSAK)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openshift-streams-apache-kafka','Red Hat OpenShift Streams for Apache Kafka (RHOSAK)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-openstack-platform','Red Hat OpenStack Platform (RHOSP)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-openstack-platform','Red Hat OpenStack Platform (RHOSP)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-optaplanner','Red Hat Optaplanner'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-optaplanner','Red Hat Optaplanner');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-plug-ins-for-backstage','Red Hat Plug-ins for Backstage'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-plug-ins-for-backstage','Red Hat Plug-ins for Backstage');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-process-automation-manager','Red Hat Process Automation Manager'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-process-automation-manager','Red Hat Process Automation Manager');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-quarkus-registry','Red Hat Quarkus Registry'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-quarkus-registry','Red Hat Quarkus Registry');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-quay','Red Hat Quay'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-quay','Red Hat Quay');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-satellite','Red Hat Satellite'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-satellite','Red Hat Satellite');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-service-interconnect','Red Hat Service Interconnect (formerly known as Application Interconnect)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-service-interconnect','Red Hat Service Interconnect (formerly known as Application Interconnect)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-single-sign-on','Red Hat Single Sign-On (RHSSO)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-single-sign-on','Red Hat Single Sign-On (RHSSO)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-software-collections','Red Hat Software Collections'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-software-collections','Red Hat Software Collections');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-support-for-spring-boot','Red Hat support for Spring Boot'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-support-for-spring-boot','Red Hat support for Spring Boot');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-trusted-application-pipeline','Red Hat Trusted Application Pipeline (RHTAP)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-trusted-application-pipeline','Red Hat Trusted Application Pipeline (RHTAP)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-update-infrastructure','Red Hat Update Infrastructure (RHUI)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-update-infrastructure','Red Hat Update Infrastructure (RHUI)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('red-hat-virtualization','Red Hat Virtualization'); INSERT INTO osh.offerings(offering_id,description) VALUES ('red-hat-virtualization','Red Hat Virtualization');
INSERT INTO osh.offerings(offeringId,description) VALUES ('resource-optimization','Insights Resource Optimization (ROS)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('resource-optimization','Insights Resource Optimization (ROS)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('rh-vulnerability-for-ocp','Insights Vulnerability for OCP'); INSERT INTO osh.offerings(offering_id,description) VALUES ('rh-vulnerability-for-ocp','Insights Vulnerability for OCP');
INSERT INTO osh.offerings(offeringId,description) VALUES ('rhacs','Red Hat Advanced Cluster Security for Kubernetes (RHACS)'); INSERT INTO osh.offerings(offering_id,description) VALUES ('rhacs','Red Hat Advanced Cluster Security for Kubernetes (RHACS)');
INSERT INTO osh.offerings(offeringId,description) VALUES ('self-node-remediation','Self Node Remediation'); INSERT INTO osh.offerings(offering_id,description) VALUES ('self-node-remediation','Self Node Remediation');
INSERT INTO osh.offerings(offeringId,description) VALUES ('subscription-central','Subscription Central'); INSERT INTO osh.offerings(offering_id,description) VALUES ('subscription-central','Subscription Central');
INSERT INTO osh.offerings(offeringId,description) VALUES ('subscription-watch','Subscription Watch'); INSERT INTO osh.offerings(offering_id,description) VALUES ('subscription-watch','Subscription Watch');
INSERT INTO osh.offerings(offeringId,description) VALUES ('telco-sw-components','Telco SW Components'); INSERT INTO osh.offerings(offering_id,description) VALUES ('telco-sw-components','Telco SW Components');
INSERT INTO osh.offerings(offeringId,description) VALUES ('vulnerability','Vulnerability'); INSERT INTO osh.offerings(offering_id,description) VALUES ('vulnerability','Vulnerability');

60
schema/schema.sql

@ -3,59 +3,59 @@ CREATE SCHEMA osh;
GRANT USAGE ON SCHEMA osh TO postgres; GRANT USAGE ON SCHEMA osh TO postgres;
CREATE TABLE IF NOT EXISTS osh.offerings( CREATE TABLE IF NOT EXISTS osh.offerings(
offeringId VARCHAR(100), offering_id VARCHAR(100),
description VARCHAR(200), description VARCHAR(200),
PRIMARY KEY (offeringId) PRIMARY KEY (offeringId)
); );
CREATE TABLE IF NOT EXISTS osh.results( CREATE TABLE IF NOT EXISTS osh.results(
resultsId SERIAL, results_id SERIAL,
datetime TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL, datetime TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL,
state BOOLEAN, state BOOLEAN,
logs bytea, logs bytea,
task_reference VARCHAR(50), task_reference VARCHAR(50),
PRIMARY KEY (resultsId) PRIMARY KEY (results_id)
); );
CREATE TABLE IF NOT EXISTS osh.scans( CREATE TABLE IF NOT EXISTS osh.scans(
scanID SERIAL, scan_id SERIAL,
offeringId VARCHAR(100), offering_id VARCHAR(100),
eventID VARCHAR(100) NOT NULL, event_id VARCHAR(100) NOT NULL,
isManagedService BOOLEAN NOT NULL, is_managed_service BOOLEAN NOT NULL,
componentList VARCHAR(100), component_list VARCHAR(100),
datetime TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL, datetime TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL,
owner VARCHAR(50) NOT NULL, owner VARCHAR(50) NOT NULL,
results SERIAL, results SERIAL,
status VARCHAR (50) CONSTRAINT valid_status CHECK(status in ('PENDING', 'DELETED', 'COMPLETED', 'IN PROGRESS')), status VARCHAR (50) CONSTRAINT valid_status CHECK(status in ('PENDING', 'DELETED', 'COMPLETED', 'IN PROGRESS')),
last_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL, last_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL,
PRIMARY KEY(scanID), PRIMARY KEY(scan_id),
FOREIGN KEY (offeringId) REFERENCES osh.offerings(offeringId), FOREIGN KEY (offering_id) REFERENCES osh.offerings(offering_id),
FOREIGN KEY (results) REFERENCES osh.results(resultsId) FOREIGN KEY (results) REFERENCES osh.results(results_id)
); );
CREATE TABLE IF NOT EXISTS osh.archive( CREATE TABLE IF NOT EXISTS osh.archive(
scanID SERIAL, scan_id SERIAL,
offeringId VARCHAR(100), offering_id VARCHAR(100),
eventID VARCHAR(100) NOT NULL, event_id VARCHAR(100) NOT NULL,
isManagedService BOOLEAN NOT NULL, is_managed_service BOOLEAN NOT NULL,
componentList VARCHAR(100), component_list VARCHAR(100),
datetime TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL, datetime TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL,
owner VARCHAR(50) NOT NULL, owner VARCHAR(50) NOT NULL,
results SERIAL, results SERIAL,
status VARCHAR (50) CONSTRAINT valid_status CHECK(status in ('PENDING', 'DELETED', 'COMPLETED', 'IN PROGRESS')), status VARCHAR (50) CONSTRAINT valid_status CHECK(status in ('PENDING', 'DELETED', 'COMPLETED', 'IN PROGRESS')),
last_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL, last_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL,
PRIMARY KEY(scanID), PRIMARY KEY(scan_id),
FOREIGN KEY (offeringId) REFERENCES osh.offerings(offeringId), FOREIGN KEY (offering_id) REFERENCES osh.offerings(offering_id),
FOREIGN KEY (results) REFERENCES osh.results(resultsId) FOREIGN KEY (results) REFERENCES osh.results(results_id)
); );
CREATE TABLE IF NOT EXISTS osh.gitscans ( CREATE TABLE IF NOT EXISTS osh.gitscans (
id SERIAL, id SERIAL,
buildSystemType VARCHAR(80), build_system_type VARCHAR(80),
repository VARCHAR(150), repository VARCHAR(150),
reference VARCHAR(100), reference VARCHAR(100),
commitId VARCHAR(100), commit_id VARCHAR(100),
-- SHA256 has a length of 256 bits, so 256 bits would represent 64 hex characters -- SHA256 has a length of 256 bits, so 256 bits would represent 64 hex characters
hashsum VARCHAR(64), hashsum VARCHAR(64),
PRIMARY KEY(id) PRIMARY KEY(id)
@ -63,19 +63,19 @@ CREATE TABLE IF NOT EXISTS osh.gitscans (
CREATE TABLE IF NOT EXISTS osh.pncscans( CREATE TABLE IF NOT EXISTS osh.pncscans(
id SERIAL, id SERIAL,
buildSystemType VARCHAR(80), build_system_type VARCHAR(80),
buildId VARCHAR(100), build_id VARCHAR(100),
PRIMARY KEY(id) PRIMARY KEY(id)
); );
CREATE TABLE IF NOT EXISTS osh.brewscans( CREATE TABLE IF NOT EXISTS osh.brewscans(
id SERIAL, id SERIAL,
buildSystemType VARCHAR(80), build_system_type VARCHAR(80),
brewId VARCHAR(100), brew_id VARCHAR(100),
brewNVR VARCHAR(100), brew_nvr VARCHAR(100),
pncId VARCHAR(100), pnc_id VARCHAR(100),
artifactType VARCHAR(100), artifact_type VARCHAR(100),
fileName VARCHAR(100), file_name VARCHAR(100),
builtfromSource BOOLEAN, built_from_source BOOLEAN,
PRIMARY KEY(id) PRIMARY KEY(id)
); );

2
src/main/java/dto/BrewObj.java

@ -15,7 +15,7 @@ import java.io.Serializable;
public class BrewObj implements Serializable { public class BrewObj implements Serializable {
public static final String SQL = "INSERT INTO brewscans " + public static final String SQL = "INSERT INTO brewscans " +
"(buildSystemType, brewId, brewNVR, pncId, artifactType, fileName, builtfromSource)" + "(build_system_type, brew_id, brew_nvr, pnc_id, artifact_type, file_name, built_from_source)" +
"VALUES (? ? ? ? ? ? ?)"; "VALUES (? ? ? ? ? ? ?)";
private String buildSystemType; private String buildSystemType;

14
src/main/java/dto/BrewObjPayload.java

@ -7,13 +7,13 @@ public class BrewObjPayload {
public static BrewObj constructScanPayload(JSONObject jsonObj) throws JSONException { public static BrewObj constructScanPayload(JSONObject jsonObj) throws JSONException {
return new BrewObj( return new BrewObj(
jsonObj.getString("buildSystemType"), jsonObj.getString("build_system_type"),
jsonObj.getString("brewId"), jsonObj.getString("brew_id"),
jsonObj.getString("brewNVR"), jsonObj.getString("brew_nvr"),
jsonObj.getString("pncId"), jsonObj.getString("pnc_id"),
jsonObj.getString("artifactType"), jsonObj.getString("artifact_type"),
jsonObj.getString("fileName"), jsonObj.getString("file_name"),
jsonObj.getBoolean("builtfromSource")); jsonObj.getBoolean("built_from_source"));
} }
private BrewObjPayload() {} private BrewObjPayload() {}

4
src/main/java/dto/ConnectDB.java

@ -10,12 +10,14 @@ import static constants.PSGQL.user;
import static constants.PSGQL.password; import static constants.PSGQL.password;
import static constants.PSGQL.url; import static constants.PSGQL.url;
// @TODO Replace hard-coded credentials; make use of our secure db connection practice
public class ConnectDB { public class ConnectDB {
public Connection connect() throws JSONException { public Connection connect() throws JSONException {
try { try {
Connection conn = DriverManager.getConnection(url, user, password); Connection conn = DriverManager.getConnection(url, user, password);
System.out.println("Connected to the PostgreSQL server successfully."); System.out.println("Connected to PostgreSQL server");
return conn; return conn;
} catch (SQLException e) { } catch (SQLException e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());

2
src/main/java/dto/GitObj.java

@ -16,7 +16,7 @@ import java.io.Serializable;
public class GitObj implements Serializable { public class GitObj implements Serializable {
public static final String SQL = "INSERT INTO gitscans " + public static final String SQL = "INSERT INTO gitscans " +
"(buildSystemType, repository, reference, commitId)" + "(build_system_type, repository, reference, commit_id)" +
"VALUES (? ? ? ?)"; "VALUES (? ? ? ?)";
private String buildSystemType; private String buildSystemType;

4
src/main/java/dto/GitObjPayload.java

@ -7,10 +7,10 @@ public class GitObjPayload {
public static GitObj constructScanPayload(JSONObject jsonObj) throws JSONException { public static GitObj constructScanPayload(JSONObject jsonObj) throws JSONException {
return new GitObj( return new GitObj(
jsonObj.getString("buildSystemType"), jsonObj.getString("build_system_type"),
jsonObj.getString("repository"), jsonObj.getString("repository"),
jsonObj.getString("reference"), jsonObj.getString("reference"),
jsonObj.getString("commitId")); jsonObj.getString("commit_id"));
} }
private GitObjPayload() {} private GitObjPayload() {}

2
src/main/java/dto/PncObj.java

@ -14,7 +14,7 @@ import java.io.Serializable;
@Builder @Builder
public class PncObj implements Serializable { public class PncObj implements Serializable {
public static final String SQL = "INSERT INTO pncscans (buildSystemType, buildId) VALUES (? ?)"; public static final String SQL = "INSERT INTO pncscans (build_system_type, build_id) VALUES (? ?)";
private String buildSystemType; private String buildSystemType;
private String buildId; private String buildId;

4
src/main/java/dto/PncObjPayload.java

@ -7,8 +7,8 @@ public class PncObjPayload {
public static PncObj constructScanPayload(JSONObject jsonObj) throws JSONException { public static PncObj constructScanPayload(JSONObject jsonObj) throws JSONException {
return new PncObj( return new PncObj(
jsonObj.getString("buildSystemType"), jsonObj.getString("build_system_type"),
jsonObj.getString("buildId")); jsonObj.getString("build_id"));
} }
private PncObjPayload() {} private PncObjPayload() {}

12
src/main/java/dto/ScanObj.java

@ -19,12 +19,12 @@ import java.io.Serializable;
public class ScanObj implements Serializable { public class ScanObj implements Serializable {
public static final String SQL = "INSERT INTO scans " + public static final String SQL = "INSERT INTO scans " +
"(scanID, offeringId, eventID, isManagedService, componentlist) " + "(scan_id, offering_id, event_id, is_managed_service, component_list) " +
"VALUES (? ? ? ? ?)"; "VALUES (? ? ? ? ?)";
public String scanId; private String scanId;
public String productId; private String productId;
public String eventId; private String eventId;
public String isManagedService; private String isManagedService;
public String componentList; private String componentList;
} }

10
src/main/java/dto/ScanObjPayload.java

@ -6,11 +6,11 @@ import org.json.JSONObject;
public class ScanObjPayload { public class ScanObjPayload {
public static ScanObj constructScanPayload(JSONObject jsonObj) throws JSONException { public static ScanObj constructScanPayload(JSONObject jsonObj) throws JSONException {
return new ScanObj( return new ScanObj(
jsonObj.getString("scanID"), jsonObj.getString("scan_id"),
jsonObj.getString("offeringId"), jsonObj.getString("offering_id"),
jsonObj.getString("eventID"), jsonObj.getString("event_id"),
jsonObj.getString("isManagedService"), jsonObj.getString("is_managed_service"),
jsonObj.getString("componentList")); jsonObj.getString("component_list"));
} }
private ScanObjPayload() {} private ScanObjPayload() {}

12
src/main/java/rest/CreateGetResource.java

@ -34,7 +34,7 @@ public class CreateGetResource {
public Set<ScanObj> list(@PathParam("scanId") String 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 //use to return specific scanIds just use usual fetch from sets, will be querying hte db directly here
ConnectDB connectDB = new ConnectDB(); ConnectDB connectDB = new ConnectDB();
String sql = "SELECT * FROM scans WHERE scanid=?"; String sql = "SELECT * FROM scans WHERE scan_id=?";
try(Connection conn = connectDB.connect(); try(Connection conn = connectDB.connect();
PreparedStatement pstmt = conn.prepareStatement(sql)) { PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, scanId); pstmt.setString(1, scanId);
@ -42,11 +42,11 @@ public class CreateGetResource {
while (rs.next()) { while (rs.next()) {
//very ugly solution needs some change to where we put the query //very ugly solution needs some change to where we put the query
Scans.add(new ScanObj( Scans.add(new ScanObj(
rs.getString("scanID"), rs.getString("scan_id"),
rs.getString("offeringId"), rs.getString("offering_id"),
rs.getString("eventID"), rs.getString("event_id"),
rs.getString("isManagedService"), rs.getString("is_managed_service"),
rs.getString("componentlist"))); rs.getString("component_list")));
} }
} catch (SQLException e) { } catch (SQLException e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());

1
src/main/java/rest/CreateScanRequest.java

@ -23,7 +23,6 @@ import java.sql.SQLException;
@Path("/scanRequest") @Path("/scanRequest")
public class CreateScanRequest { public class CreateScanRequest {
// all of these need cleaning up to be a more sensible solution
@RestClient @RestClient
CreateScanService createScanService; CreateScanService createScanService;

14
src/main/java/rest/CreateScanResource.java

@ -5,13 +5,13 @@ import dto.ScanObjPayload;
import dto.ScanObj; import dto.ScanObj;
import org.eclipse.microprofile.rest.client.inject.RestClient; import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import javax.validation.Valid; import javax.validation.Valid;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import java.net.URISyntaxException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
@ -25,17 +25,17 @@ public class CreateScanResource {
@POST @POST
@Consumes({ "application/json" }) @Consumes({ "application/json" })
//in theory should take List<String> to clean it up //in theory should take List<String> to clean it up
public ScanObj invokeScanAnalyze(@Valid String scanInvocation) throws URISyntaxException { public ScanObj invokeScanAnalyze(@Valid String scanInvocation) throws JSONException {
JSONObject jsonData = new JSONObject(scanInvocation); JSONObject jsonData = new JSONObject(scanInvocation);
ScanObj scanObj = ScanObjPayload.constructScanPayload(jsonData); ScanObj scanObj = ScanObjPayload.constructScanPayload(jsonData);
ConnectDB connectDB = new ConnectDB(); ConnectDB connectDB = new ConnectDB();
try(Connection conn = connectDB.connect(); try(Connection conn = connectDB.connect();
PreparedStatement pstmt = conn.prepareStatement(ScanObj.SQL)) { PreparedStatement pstmt = conn.prepareStatement(ScanObj.SQL)) {
pstmt.setString(1, scanObj.scanId); pstmt.setString(1, scanObj.getScanId());
pstmt.setString(2, scanObj.productId); pstmt.setString(2, scanObj.getProductId());
pstmt.setString(3, scanObj.eventId); pstmt.setString(3, scanObj.getEventId());
pstmt.setString(4, scanObj.isManagedService); pstmt.setString(4, scanObj.getIsManagedService());
pstmt.setString(5, scanObj.componentList); pstmt.setString(5, scanObj.getComponentList());
pstmt.executeUpdate(); pstmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());

45
src/main/java/rest/CreateStartScan.java

@ -8,7 +8,6 @@ import org.eclipse.microprofile.rest.client.inject.RestClient;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PUT; import javax.ws.rs.PUT;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import java.net.URISyntaxException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -22,14 +21,14 @@ public class CreateStartScan {
@PUT @PUT
@Path("/{scanId}") @Path("/{scanId}")
public ScanObj invokeScanAnalyze(@PathParam("scanId") String scanId) throws URISyntaxException { public ScanObj invokeScanAnalyze(@PathParam("scanId") String scanId) {
ScanObj finalScan = null; ScanObj finalScan = null;
ConnectDB connectDB = new ConnectDB(); ConnectDB connectDB = new ConnectDB();
try (Connection conn = connectDB.connect()) { try (Connection conn = connectDB.connect()) {
finalScan = selectDataForArchiving(conn, scanId); finalScan = selectDataForArchiving(conn, scanId);
if (finalScan != null) { if (finalScan != null) {
ArchiveSelectedScans(conn, finalScan); archiveSelectedScans(conn, finalScan);
PostArchivingCleanup(conn, scanId); postArchivingCleanup(conn, scanId);
} else { } else {
System.out.println("No data match found for scan ID=" + scanId); System.out.println("No data match found for scan ID=" + scanId);
} }
@ -41,48 +40,48 @@ public class CreateStartScan {
private ScanObj selectDataForArchiving(Connection conn, String scanId) { private ScanObj selectDataForArchiving(Connection conn, String scanId) {
ScanObj finalScan = null; ScanObj finalScan = null;
String qry = "SELECT * FROM scans WHERE scanid=?"; String sql = "SELECT * FROM scans WHERE scan_id=?";
try (PreparedStatement pstmt = conn.prepareStatement(qry)) { try (PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, scanId); pstmt.setString(1, scanId);
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
//TODO: need to add unique keys to DBs //TODO: need to add unique keys to DBs
//fix for individual results (not resultset) //fix for individual results (not resultset)
finalScan = new ScanObj( finalScan = new ScanObj(
rs.getString("scanID"), rs.getString("scan_id"),
rs.getString("offeringId"), rs.getString("offering_id"),
rs.getString("eventID"), rs.getString("event_id"),
rs.getString("isManagedService"), rs.getString("is_managed_service"),
rs.getString("componentlist")); rs.getString("component_list"));
} catch (SQLException e) { } catch (SQLException e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
return finalScan; return finalScan;
} }
private void ArchiveSelectedScans(Connection conn, ScanObj finalScan) { private void archiveSelectedScans(Connection conn, ScanObj finalScan) {
String qry = "INSERT INTO archive " + String sql = "INSERT INTO archive " +
"(scanID, offeringId, eventID, isManagedService, componentlist) " + "(scan_id, offering_id, event_id, is_managed_service, component_list) " +
"VALUES (? ? ? ? ?)"; "VALUES (? ? ? ? ?)";
try (PreparedStatement pstmt = conn.prepareStatement(qry)) { try (PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, finalScan.scanId); pstmt.setString(1, finalScan.getScanId());
pstmt.setString(2, finalScan.productId); pstmt.setString(2, finalScan.getProductId());
pstmt.setString(3, finalScan.eventId); pstmt.setString(3, finalScan.getEventId());
pstmt.setString(4, finalScan.isManagedService); pstmt.setString(4, finalScan.getIsManagedService());
pstmt.setString(5, finalScan.componentList); pstmt.setString(5, finalScan.getComponentList());
pstmt.executeUpdate(); pstmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
} }
private void PostArchivingCleanup(Connection conn, String scanId) { private void postArchivingCleanup(Connection conn, String scanId) {
//TODO add proper checks //TODO add proper checks
//send task to the actual interface here using the resultset returned (should multiple scanids be allowed): //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 //once the task is complete AND we have confirmation that the scan is done run the following sql
String qry = "DELETE FROM scans WHERE scanid=?"; String sql = "DELETE FROM scans WHERE scan_id=?";
try (PreparedStatement pstmt = conn.prepareStatement(qry)) { try (PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, scanId); pstmt.setString(1, scanId);
pstmt.executeUpdate(); pstmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {

4
src/main/java/rest/RemoveScan.java

@ -20,10 +20,10 @@ public class RemoveScan {
@DELETE @DELETE
@Path("/{scanId}") @Path("/{scanId}")
public boolean invokeScanAnalyze(@PathParam("scanId") String scanId) { public boolean invokeScanAnalyze(@PathParam("scanId") String scanId) {
Boolean rc = false; boolean rc = false;
//send task to the actual interface here using the resultset returned (should multiple scanids be allowed): //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 //once the task is complete AND we have confirmation that the scan is done run the following sql
String qry = "DELETE FROM scans WHERE scanid=?"; String qry = "DELETE FROM scans WHERE scan_id=?";
ConnectDB connectDB = new ConnectDB(); ConnectDB connectDB = new ConnectDB();
try(Connection conn = connectDB.connect(); try(Connection conn = connectDB.connect();
PreparedStatement pstmt = conn.prepareStatement(qry)) { PreparedStatement pstmt = conn.prepareStatement(qry)) {

69
src/test/java/dto/TestPayload.java

@ -8,23 +8,23 @@ class TestPayload {
@Test @Test
void TestBrew() { void TestBrew() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("buildSystemType", "brew"); jsonObject.put("build_system_type", "brew");
jsonObject.put("brewId", "1"); jsonObject.put("brew_id", "1");
jsonObject.put("brewNVR", "1.1.0"); jsonObject.put("brew_nvr", "1.1.0");
jsonObject.put("pncId", "153"); jsonObject.put("pnc_id", "153");
jsonObject.put("artifactType", "arti1"); jsonObject.put("artifact_type", "arti");
jsonObject.put("fileName", "myfile1"); jsonObject.put("file_name", "myfile");
jsonObject.put("builtfromSource", true); jsonObject.put("built_from_source", true);
BrewObj brewObj1 = BrewObjPayload.constructScanPayload(jsonObject); BrewObj brewObj1 = BrewObjPayload.constructScanPayload(jsonObject);
BrewObj brewObj2 = new BrewObj( BrewObj brewObj2 = new BrewObj(
jsonObject.getString("buildSystemType"), jsonObject.getString("build_system_type"),
jsonObject.getString("brewId"), jsonObject.getString("brew_id"),
jsonObject.getString("brewNVR"), jsonObject.getString("brew_nvr"),
jsonObject.getString("pncId"), jsonObject.getString("pnc_id"),
jsonObject.getString("artifactType"), jsonObject.getString("artifact_type"),
jsonObject.getString("fileName"), jsonObject.getString("file_name"),
jsonObject.getBoolean("builtfromSource")); jsonObject.getBoolean("built_from_source"));
System.out.println("BrewObj1: " + brewObj1.toString()); System.out.println("BrewObj1: " + brewObj1.toString());
System.out.println("BrewObj2: " + brewObj2.toString()); System.out.println("BrewObj2: " + brewObj2.toString());
assert(brewObj1.getBuildSystemType().equals(brewObj2.getBuildSystemType())); assert(brewObj1.getBuildSystemType().equals(brewObj2.getBuildSystemType()));
@ -39,17 +39,17 @@ class TestPayload {
@Test @Test
void TestGit() { void TestGit() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("buildSystemType", "git"); jsonObject.put("build_system_type", "git");
jsonObject.put("repository", "repo"); jsonObject.put("repository", "repo");
jsonObject.put("reference", "ref"); jsonObject.put("reference", "ref");
jsonObject.put("commitId", "comid"); jsonObject.put("commit_id", "c6385a754421a57cd0a26ccba187cd687c8d1258");
GitObj gitObj1 = GitObjPayload.constructScanPayload(jsonObject); GitObj gitObj1 = GitObjPayload.constructScanPayload(jsonObject);
GitObj gitObj2 = new GitObj( GitObj gitObj2 = new GitObj(
jsonObject.getString("buildSystemType"), jsonObject.getString("build_system_type"),
jsonObject.getString("repository"), jsonObject.getString("repository"),
jsonObject.getString("reference"), jsonObject.getString("reference"),
jsonObject.getString("commitId")); jsonObject.getString("commit_id"));
System.out.println("GitObj1: " + gitObj1.toString()); System.out.println("GitObj1: " + gitObj1.toString());
System.out.println("GitObj2: " + gitObj2.toString()); System.out.println("GitObj2: " + gitObj2.toString());
assert(gitObj1.getBuildSystemType().equals(gitObj2.getBuildSystemType())); assert(gitObj1.getBuildSystemType().equals(gitObj2.getBuildSystemType()));
@ -61,15 +61,42 @@ class TestPayload {
@Test @Test
void TestPnc() { void TestPnc() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("buildSystemType", "pnc"); jsonObject.put("build_system_type", "pnc");
jsonObject.put("buildId", "153"); jsonObject.put("build_id", "153");
PncObj pncObj1 = PncObjPayload.constructScanPayload(jsonObject); PncObj pncObj1 = PncObjPayload.constructScanPayload(jsonObject);
PncObj pncObj2 = new PncObj(jsonObject.getString("buildSystemType"), jsonObject.getString("buildId")); PncObj pncObj2 = new PncObj(
jsonObject.getString("build_system_type"),
jsonObject.getString("build_id"));
System.out.println("PncObj1: " + pncObj1.toString()); System.out.println("PncObj1: " + pncObj1.toString());
System.out.println("PncObj2: " + pncObj2.toString()); System.out.println("PncObj2: " + pncObj2.toString());
assert(pncObj1.getBuildSystemType().equals(pncObj2.getBuildSystemType())); assert(pncObj1.getBuildSystemType().equals(pncObj2.getBuildSystemType()));
assert(pncObj1.getBuildId().equals(pncObj2.getBuildId())); assert(pncObj1.getBuildId().equals(pncObj2.getBuildId()));
} }
@Test
void TestScan() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("scan_id", "ABC");
jsonObject.put("offering_id", "product#");
jsonObject.put("event_id", "event#");
jsonObject.put("is_managed_service", "TRUE");
jsonObject.put("component_list", "components");
ScanObj scanObj1 = ScanObjPayload.constructScanPayload(jsonObject);
ScanObj scanObj2 = new ScanObj(
jsonObject.getString("scan_id"),
jsonObject.getString("offering_id"),
jsonObject.getString("event_id"),
jsonObject.getString("is_managed_service"),
jsonObject.getString("component_list"));
System.out.println("ScanObj1: " + scanObj1.toString());
System.out.println("ScanObj2: " + scanObj2.toString());
assert(scanObj1.getScanId().equals(scanObj2.getScanId()));
assert(scanObj1.getProductId().equals(scanObj2.getProductId()));
assert(scanObj1.getEventId().equals(scanObj2.getEventId()));
assert(scanObj1.getIsManagedService().equals(scanObj2.getIsManagedService()));
assert(scanObj1.getComponentList().equals(scanObj2.getComponentList()));
}
} }

Loading…
Cancel
Save