From 781b1a6df324419c846c84ea983c18fc8362bfd3 Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Wed, 13 Dec 2017 11:19:06 -0800 Subject: Third part of onap rename This part of the commit changes the folder structure on all other folders of appc. Change-Id: I8acfa11cdfcdcd36be0e137245d1dd7324f1abd3 Signed-off-by: Patrick Brady Issue-ID: APPC-13 --- .../org/onap/appc/design/data/ArtifactInfo.java | 42 ++ .../java/org/onap/appc/design/data/DesignInfo.java | 115 ++++ .../org/onap/appc/design/data/DesignRequest.java | 132 +++++ .../org/onap/appc/design/data/DesignResponse.java | 77 +++ .../java/org/onap/appc/design/data/StatusInfo.java | 86 +++ .../appc/design/dbervices/DbResponseProcessor.java | 110 ++++ .../org/onap/appc/design/dbervices/DbService.java | 146 +++++ .../appc/design/dbervices/DesignDBService.java | 645 +++++++++++++++++++++ .../appc/design/dbervices/RequestValidator.java | 126 ++++ .../propertyServices/PropertyUpdateService.java | 30 + .../design/services/DesignServiceProvider.java | 72 +++ .../design/services/impl/DesignServicesImpl.java | 160 +++++ .../services/util/ArtifactHandlerClient.java | 187 ++++++ .../services/util/DesignServiceConstants.java | 106 ++++ .../appc/design/services/util/EscapeUtils.java | 44 ++ .../util/SecureRestClientTrustManager.java | 58 ++ .../validator/ValidatorResponseProcessor.java | 38 ++ .../appc/design/validator/ValidatorService.java | 168 ++++++ .../appc/design/xinterface/XInterfaceService.java | 43 ++ .../appc/design/xinterface/XResponseProcessor.java | 38 ++ .../openecomp/appc/design/data/ArtifactInfo.java | 42 -- .../org/openecomp/appc/design/data/DesignInfo.java | 115 ---- .../openecomp/appc/design/data/DesignRequest.java | 132 ----- .../openecomp/appc/design/data/DesignResponse.java | 77 --- .../org/openecomp/appc/design/data/StatusInfo.java | 86 --- .../appc/design/dbervices/DbResponseProcessor.java | 110 ---- .../openecomp/appc/design/dbervices/DbService.java | 146 ----- .../appc/design/dbervices/DesignDBService.java | 645 --------------------- .../appc/design/dbervices/RequestValidator.java | 126 ---- .../propertyServices/PropertyUpdateService.java | 30 - .../design/services/DesignServiceProvider.java | 72 --- .../design/services/impl/DesignServicesImpl.java | 160 ----- .../services/util/ArtifactHandlerClient.java | 187 ------ .../services/util/DesignServiceConstants.java | 106 ---- .../appc/design/services/util/EscapeUtils.java | 44 -- .../util/SecureRestClientTrustManager.java | 58 -- .../validator/ValidatorResponseProcessor.java | 38 -- .../appc/design/validator/ValidatorService.java | 168 ------ .../appc/design/xinterface/XInterfaceService.java | 43 -- .../appc/design/xinterface/XResponseProcessor.java | 38 -- .../design/validator/TestArifactHandlerClient.java | 73 +++ .../onap/appc/design/validator/TestDBService.java | 242 ++++++++ .../onap/appc/design/validator/TestDbResponse.java | 51 ++ .../onap/appc/design/validator/TestDesigndata.java | 102 ++++ .../appc/design/validator/TestEscapeUtils.java | 52 ++ .../design/validator/TestValidatorService.java | 131 +++++ .../design/validator/TestArifactHandlerClient.java | 73 --- .../appc/design/validator/TestDBService.java | 242 -------- .../appc/design/validator/TestDbResponse.java | 51 -- .../appc/design/validator/TestDesigndata.java | 102 ---- .../appc/design/validator/TestEscapeUtils.java | 52 -- .../design/validator/TestValidatorService.java | 131 ----- 52 files changed, 3074 insertions(+), 3074 deletions(-) create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/ArtifactInfo.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignInfo.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignRequest.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignResponse.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/StatusInfo.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbResponseProcessor.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbService.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/RequestValidator.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/propertyServices/PropertyUpdateService.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/DesignServiceProvider.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/impl/DesignServicesImpl.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/ArtifactHandlerClient.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/EscapeUtils.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/SecureRestClientTrustManager.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/validator/ValidatorResponseProcessor.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/validator/ValidatorService.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/xinterface/XInterfaceService.java create mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/xinterface/XResponseProcessor.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/ArtifactInfo.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignInfo.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignRequest.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignResponse.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/StatusInfo.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DbResponseProcessor.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DbService.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DesignDBService.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/RequestValidator.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/propertyServices/PropertyUpdateService.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/DesignServiceProvider.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/impl/DesignServicesImpl.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/ArtifactHandlerClient.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/DesignServiceConstants.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/EscapeUtils.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/SecureRestClientTrustManager.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/validator/ValidatorResponseProcessor.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/validator/ValidatorService.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/xinterface/XInterfaceService.java delete mode 100644 appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/xinterface/XResponseProcessor.java create mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestArifactHandlerClient.java create mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDBService.java create mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDbResponse.java create mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDesigndata.java create mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestEscapeUtils.java create mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestValidatorService.java delete mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java delete mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java delete mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDbResponse.java delete mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java delete mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java delete mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java (limited to 'appc-inbound/appc-design-services/provider/src') diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/ArtifactInfo.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/ArtifactInfo.java new file mode 100644 index 000000000..53f6f02fb --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/ArtifactInfo.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.data; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ArtifactInfo { + + @JsonProperty("artifact-content") + String artifact_content; + + public String getArtifact_content() { + return artifact_content; + } + + public void setArtifact_content(String artifact_content) { + this.artifact_content = artifact_content; + } + +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignInfo.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignInfo.java new file mode 100644 index 000000000..a6d2ba24b --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignInfo.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.data; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class DesignInfo{ + + @JsonProperty("vnf-type") + String vnf_type; + + @JsonProperty("vnfc-type") + String vnfc_type; + + @JsonProperty("protocol") + String protocol; + + @JsonProperty("incart") + String inCart; + + @JsonProperty("action") + String action; + + @JsonProperty("artifact-name") + String artifact_name; + + + @JsonProperty("artifact-type") + String artifact_type; + + public String getArtifact_type() { + return artifact_type; + } + + public void setArtifact_type(String artifact_type) { + this.artifact_type = artifact_type; + } + + public String getArtifact_name() { + return artifact_name; + } + + public void setArtifact_name(String artifact_name) { + this.artifact_name = artifact_name; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getVnf_type() { + return vnf_type; + } + + public void setVnf_type(String vnf_type) { + this.vnf_type = vnf_type; + } + + public String getVnfc_type() { + return vnfc_type; + } + + public void setVnfc_type(String vnfc_type) { + this.vnfc_type = vnfc_type; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getInCart() { + return inCart; + } + + public void setInCart(String inCart) { + this.inCart = inCart; + } + + @Override + public String toString() { + return "DesignInfo [vnf_type=" + vnf_type + ", vnfc_type=" + vnfc_type + ", protocol=" + protocol + ", inCart=" + + inCart + "]"; + } + +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignRequest.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignRequest.java new file mode 100644 index 000000000..d61de0282 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignRequest.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.data; + +import java.io.File; +import java.net.URL; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import javax.sql.rowset.CachedRowSet; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.onap.appc.design.services.util.DesignServiceConstants; +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.onap.ccsdk.sli.core.dblib.DbLibService; + +public class DesignRequest{ + + + @JsonProperty("userID") + String userId ; + + @JsonProperty("vnf-type") + String vnf_type; + + @JsonProperty("vnfc-type") + String vnfc_type; + + @JsonProperty("protocol") + String protocol; + + @JsonProperty("action") + String action; + + @JsonProperty("artifact-name") + String artifact_name; + + @JsonProperty("artifact-contents") + String artifact_contents ; + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getVnf_type() { + return vnf_type; + } + + public void setVnf_type(String vnf_type) { + this.vnf_type = vnf_type; + } + + public String getVnfc_type() { + return vnfc_type; + } + + public void setVnfc_type(String vnfc_type) { + this.vnfc_type = vnfc_type; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getArtifact_name() { + return artifact_name; + } + + public void setArtifact_name(String artifact_name) { + this.artifact_name = artifact_name; + } + + public String getArtifact_contents() { + return artifact_contents; + } + + public void setArtifact_contents(String artifact_contents) { + this.artifact_contents = artifact_contents; + } + + @Override + public String toString() { + return "DesignRequest [userId=" + userId + ", vnf_type=" + vnf_type + ", vnfc_type=" + vnfc_type + ", protocol=" + + protocol + ", action=" + action + ", artifact_name=" + artifact_name + ", artifact_contents=" + + artifact_contents + "]"; + } + +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignResponse.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignResponse.java new file mode 100644 index 000000000..559620d9e --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/DesignResponse.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.data; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class DesignResponse{ + + + @JsonProperty("userID") + String userId ; + + @JsonProperty("designInfo") + List designInfoList; + + @JsonProperty("statusInfo") + List statusInfoList; + + @JsonProperty("artifactInfo") + List artifactInfo; + + + public List getArtifactInfo() { + return artifactInfo; + } + + public void setArtifactInfo(List artifactInfo) { + this.artifactInfo = artifactInfo; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public List getDesignInfoList() { + return designInfoList; + } + + public void setDesignInfoList(List designInfoList) { + this.designInfoList = designInfoList; + } + + public List getStatusInfoList() { + return statusInfoList; + } + + public void setStatusInfoList(List statusInfoList) { + this.statusInfoList = statusInfoList; + } +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/StatusInfo.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/StatusInfo.java new file mode 100644 index 000000000..6d4b1a5a1 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/data/StatusInfo.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.data; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class StatusInfo{ + + @JsonProperty("vnf-type") + String vnf_type; + + @JsonProperty("vnfc-type") + String vnfc_type; + + @JsonProperty("action") + String action; + + @JsonProperty("artifact-status") + String artifact_status; + + @JsonProperty("action-status") + String action_status; + + public String getVnf_type() { + return vnf_type; + } + + public void setVnf_type(String vnf_type) { + this.vnf_type = vnf_type; + } + + public String getVnfc_type() { + return vnfc_type; + } + + public void setVnfc_type(String vnfc_type) { + this.vnfc_type = vnfc_type; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getArtifact_status() { + return artifact_status; + } + + public void setArtifact_status(String artifact_status) { + this.artifact_status = artifact_status; + } + + public String getAction_status() { + return action_status; + } + + public void setAction_status(String action_status) { + this.action_status = action_status; + } + +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbResponseProcessor.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbResponseProcessor.java new file mode 100644 index 000000000..e697a9d4f --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbResponseProcessor.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.dbervices; + +import org.onap.appc.design.services.util.DesignServiceConstants; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class DbResponseProcessor { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(DbResponseProcessor.class); + public String parseResponse(String dbresposne, String action) throws Exception { + + log.info("Starting Parsing the response for action : " + action + "\n data " + dbresposne ); + String response ; + switch (action) { + case DesignServiceConstants.GETDESIGNS: + response = getDesignsResponse(dbresposne); + break; + case DesignServiceConstants.ADDINCART: + response = getAddInCartResponse(dbresposne); + break ; + case DesignServiceConstants.GETARTIFACTREFERENCE: + response= getArtifactReferenceResponse(dbresposne); + break; + case DesignServiceConstants.GETARTIFACT: + response= getArtifactResponse(dbresposne); + break; + case DesignServiceConstants.GETGUIREFERENCE: + response= getGuiReferenceResponse(dbresposne); + break; + case DesignServiceConstants.GETSTATUS: + response= getStatusResponse(dbresposne); + break; + case DesignServiceConstants.UPLOADARTIFACT: + response= getsetStatusResponse(dbresposne); + break; + case DesignServiceConstants.SETPROTOCOLREFERENCE: + response= getsetStatusResponse(dbresposne); + break; + case DesignServiceConstants.SETINCART: + response= getsetStatusResponse(dbresposne); + break; + default: + log.error("Action " + action + " Not Supported by response Parser"); + throw new Exception(" Action " + action + " not found while processing request "); + + } + return response; + + } + + private String getArtifactResponse(String dbresposne) { + // TODO Auto-generated method stub + return dbresposne; + } + + private String getsetStatusResponse(String dbresposne) { + // TODO Auto-generated method stub + return null; + } + + private String getStatusResponse(String dbresposne) { + log.info("Returning reposne from Response Parser " + dbresposne); + return dbresposne; + } + + private String getGuiReferenceResponse(String dbresposne) { + // TODO Auto-generated method stub + return null; + } + + private String getArtifactReferenceResponse(String dbresposne) { + // TODO Auto-generated method stub + return null; + } + + private String getAddInCartResponse(String dbresposne) { + // TODO Auto-generated method stub + return null; + } + + private String getDesignsResponse(String dbresposne) { + return dbresposne; + + } +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbService.java new file mode 100644 index 000000000..a2349196f --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbService.java @@ -0,0 +1,146 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.dbervices; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; +import java.util.UUID; + +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DbService { + + private static final Logger Log = LoggerFactory.getLogger(DbService.class); + private static final String DBLIB_SERVICE = "org.onap.ccsdk.sli.core.dblib.DBResourceManager"; + DbLibService dblibSvc = null; + String errorMsg = null; + + public DbService() throws Exception { + DbLibService dblibSvc = null; + Log.info("Initializing DbService service"); + try + { + dblibSvc = getDbLibService(); + if (dblibSvc == null) { + Log.error("Got Exception While getting DB Connection"); + throw new Exception("Got Exception While getting DB Connection"); + } + this.dblibSvc = dblibSvc; + } + catch (Exception e) { + Log.error(e.getMessage()); + throw e; + } + } + + private static DbLibService getDbLibService() { + + DbLibService dblibSvc = null; + BundleContext bctx = null; + ServiceReference sref = null; + + Bundle bundle = FrameworkUtil.getBundle(SvcLogicService.class); + + if (bundle != null) { + bctx = bundle.getBundleContext(); + } + + if (bctx != null) { + Log.debug("Getting bundle Context"); + sref = bctx.getServiceReference(DBLIB_SERVICE); + } + + if (sref == null) { + Log.warn("Could not find service reference for DBLib service"); + + } else { + dblibSvc = (DbLibService) bctx.getService(sref); + if (dblibSvc == null) { + Log.warn("DBLIB_SERVICE is null"); + } + } + if (dblibSvc == null) { + try { + dblibSvc = new DBResourceManager(System.getProperties()); + } catch (Exception e) { + Log.error("Caught exception trying to create db service", e); + } + + if (dblibSvc == null) { + Log.warn("Could not create new DBResourceManager"); + } + } + return (dblibSvc); + } + + public ResultSet getDBData(String query) throws Exception { + ResultSet resultSet; + StringBuilder sqlBuilder = new StringBuilder(query); + Log.info("Query: " + sqlBuilder.toString()); + try { + resultSet = dblibSvc.getData(sqlBuilder.toString(), null, null); + } catch (Exception e) { + Log.error("SQL query "+sqlBuilder+" :: " + e.getMessage()); + throw e; + } + return resultSet; + } + + public ResultSet getDBData(String query, ArrayList paramList) throws Exception { + ResultSet resultSet; + StringBuilder sqlBuilder = new StringBuilder(query); + Log.info("Query :" + sqlBuilder.toString()); + try { + resultSet = dblibSvc.getData(sqlBuilder.toString(), paramList, null); + } catch (Exception expObj) { + Log.error("query "+sqlBuilder+" :: " + expObj.getMessage()); + throw expObj; + } + return resultSet; + } + + public boolean updateDBData(String query, ArrayList paramList) throws Exception { + boolean update; + StringBuilder sqlBuilder = new StringBuilder(query); + Log.info("Query :" + sqlBuilder.toString()); + try { + update = dblibSvc.writeData(sqlBuilder.toString(), paramList, null); + } catch (Exception expObj) { + Log.error("query "+sqlBuilder+" :: " + expObj.getMessage()); + throw expObj; + } + return update; + } +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java new file mode 100644 index 000000000..64251027f --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java @@ -0,0 +1,645 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.dbervices; + +import java.io.IOException; +import java.security.SecureRandom; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.onap.appc.design.data.ArtifactInfo; +import org.onap.appc.design.data.DesignInfo; +import org.onap.appc.design.data.DesignResponse; +import org.onap.appc.design.data.StatusInfo; +import org.onap.appc.design.services.util.ArtifactHandlerClient; +import org.onap.appc.design.services.util.DesignServiceConstants; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +public class DesignDBService { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(DesignDBService.class); + private SvcLogicResource serviceLogic; + private static DesignDBService dgGeneralDBService = null; + private static DBResourceManager jdbcDataSource; + + DbService dbservice = null; + private static Properties props; + public static DesignDBService initialise() { + if (dgGeneralDBService == null) { + dgGeneralDBService = new DesignDBService(); + } + return dgGeneralDBService; + } + private DesignDBService() { + if (serviceLogic == null) { + serviceLogic = new SqlResource(); + } + } + + public String execute(String action, String payload, String requestID) throws Exception { + + log.info("Received execute request for action : " + action + " with Payload : "+ payload ); + RequestValidator.validate(action, payload); + String response = null; + dbservice = new DbService(); + switch (action) { + case DesignServiceConstants.GETDESIGNS: + response = getDesigns(payload,requestID ); + break; + case DesignServiceConstants.ADDINCART: + response= setInCart(payload, requestID); + break ; + case DesignServiceConstants.GETARTIFACTREFERENCE: + response= getArtifactReference(payload, requestID); + break; + case DesignServiceConstants.GETARTIFACT: + response= getArtifact(payload, requestID); + break; + case DesignServiceConstants.GETGUIREFERENCE: + response= getGuiReference(payload, requestID); + break; + case DesignServiceConstants.GETSTATUS: + response= getStatus(payload, requestID); + break; + case DesignServiceConstants.SETSTATUS: + response= setStatus(payload, requestID); + break; + case DesignServiceConstants.UPLOADARTIFACT: + response= uploadArtifact(payload, requestID); + break; + case DesignServiceConstants.SETPROTOCOLREFERENCE: + response= setProtocolReference(payload, requestID); + break; + default: + throw new Exception(" Action " + action + " not found while processing request "); + + } + return response; + } + + private String setInCart(String payload, String requestID) throws Exception { + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + ArrayList argList = new ArrayList<>(); + argList.add(payloadObject.get(DesignServiceConstants.INCART).textValue()); + argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); + + String queryString = "UPDATE DT_ARTIFACT_TRACKING SET INCART= ? WHERE ASDC_REFERENCE_ID IN " + + " (SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE_ID WHERE VNF_TYPE = ? " ; + + if(payloadObject.get(DesignServiceConstants.VNF_TYPE) != null &&! payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) { + queryString = queryString + " AND VNFC_TYPE = ? ) AND USER = ? " ; + argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue()); + } + else{ + queryString = queryString + " ) AND USER = ? " ; + } + + argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue()); + + log.info("Query String :" + queryString); + boolean data = dbservice.updateDBData(queryString, argList); + + if(!data) + throw new Exception("Error while updating ProtocolReference"); + + return "{\"update\" : \"success\" } "; + + } + private String setProtocolReference(String payload, String requestID) throws Exception { + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + ArrayList argList = new ArrayList<>(); + + argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue()); + argList.add(payloadObject.get(DesignServiceConstants.ACTION_LEVEL).textValue()); + argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); + argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue()); + + String queryString = " DELETE FROM PROTOCOL_REFERENCE WHERE ACTION = ? AND ACTION_LEVEL AND VNF_TYPE= ? AND PROTOCOL = ? " ; + + log.info("Delete Query String :" + queryString); + boolean data = dbservice.updateDBData(queryString, argList); + + log.info("Record Deleted"); + + if((payloadObject.get(DesignServiceConstants.TEMPLATE) != null && !payloadObject.get(DesignServiceConstants.TEMPLATE).textValue().isEmpty())) + argList.add(payloadObject.get(DesignServiceConstants.TEMPLATE).textValue()); + else + argList.add("NO"); + + String insertString = "INSERT INTO PROTOCOL_REFERENCE VALUES (?,?,?,?,?,SYSDATE()) "; + + if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && ! payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){ + queryString = queryString + " AND VNFC_TYPE = ? )" ; + } + else{ + queryString = queryString + " ) "; + } + log.info("Query String :" + queryString); + data = dbservice.updateDBData(queryString, argList); + + if(!data) + throw new Exception("Error while updating ProtocolReference"); + + return "{\"update\" : \"success\" } "; + } + private String uploadArtifact(String payload, String requestID) throws Exception { + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + log.info("Got upload Aritfact with Payload : " + payloadObject.asText()); + try{ + ArtifactHandlerClient ac = new ArtifactHandlerClient(); + String requestString = ac.createArtifactData(payload, requestID); + ac.execute(requestString, "POST"); + int sdc_artifact_id = getSDCArtifactIDbyRequestID(requestID); + int sdc_reference_id = getSDCReferenceID(payload); + createArtifactTrackingRecord(payload, requestID,sdc_artifact_id, sdc_reference_id ); + String status = getDataFromActionStatus(payload, "STATUS"); + if(status == null || status.isEmpty()) + setActionStatus(payload, "Not Tested"); + linkstatusRelationShip(sdc_artifact_id,sdc_reference_id, payload); + + } + catch(Exception e){ + e.printStackTrace(); + throw e; + } + return "{\"update\" : \"success\" } "; + + } + + private void linkstatusRelationShip(int sdc_artifact_id, int sdc_reference_id, String payload) throws Exception { + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + ArrayList argList = new ArrayList<>(); + argList.add(String.valueOf(sdc_artifact_id)); + argList.add(String.valueOf(sdc_reference_id)); + argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); + argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue()); + argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue()); + + String queryString = "INSERT INTO DT_STATUS_RELATIONSHIP (DT_ARTIFACT_TRACKING_ID,DT_ACTION_STATUS_ID) VALUES " + + "(( SELECT DT_ARTIFACT_TRACKING_ID FROM DT_ARTIFACT_TRACKING WHERE ASDC_ARTIFACTS_ID = ? AND ASDC_REFERENCE_ID = ? ) , " + + "( SELECT DT_ACTION_STATUS_ID FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? " ; + + if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && ! payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){ + queryString = queryString + " AND VNFC_TYPE = ? ) )" ; + } + else{ + queryString = queryString + " ) ) "; + } + log.info("Query String :" + queryString); + boolean data = dbservice.updateDBData(queryString, argList); + + if(!data) + throw new Exception("Error while updating RealtionShip table"); + + } + private int getSDCReferenceID(String payload) throws Exception { + + String vnfc_type = null; + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + ArrayList argList = new ArrayList<>(); + argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); + + argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue()); + argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue()); + + String queryString = " SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE WHERE VNF_TYPE = ? " + + " AND ARTIFACT_TYPE = ? AND ARTIFACT_NAME = ? " ; + + if(payloadObject.get(DesignServiceConstants.ACTION) != null && !payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()){ + argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue()); + queryString = queryString + " AND ACTION = ? "; + } + if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){ + argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue()); + queryString = queryString + " AND VNFC_TYPE = ? "; + + } + + log.info("Query String :" + queryString); + ResultSet data = dbservice.getDBData(queryString, argList); + int sdc_reference_id = 0; + while(data.next()) { + sdc_reference_id = data.getInt("ASDC_REFERENCE_ID"); + } + log.info("Got sdc_reference_id = " + sdc_reference_id ); + return sdc_reference_id; + + } + + private String getDataFromActionStatus(String payload, String dataValue) throws Exception { + String status = null ; + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + ArrayList argList = new ArrayList<>(); + argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); + argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue()); + argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue()); + String queryString = " SELECT " + dataValue + " FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? "; + if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){ + argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue()); + queryString = queryString + " AND VNFC_TYPE = ? "; + } + log.info("Query String :" + queryString); + ResultSet data = dbservice.getDBData(queryString, argList); + while(data.next()) { + status = data.getString("STATUS"); + } + log.info("DT_ACTION_STATUS Status = " + status ); + return status; + } + + private boolean setActionStatus(String payload, String status) throws Exception { + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + ArrayList argList = new ArrayList<>(); + argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue()); + argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); + + + String insertQuery = " INSERT INTO DT_ACTION_STATUS (ACTION, VNF_TYPE, VNFC_TYPE, USER, TECHNOLOGY, UPDATED_DATE, STATUS) VALUES (?,?,?,?,?,sysdate() , ?); "; + if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){ + argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue()); + } + else{ + argList.add(null); + } + argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue()); + if(payloadObject.get(DesignServiceConstants.TECHNOLOGY) !=null && !payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()){ + argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue()); + } + else{ + argList.add(null); + } + argList.add(status); + + boolean updateStatus = dbservice.updateDBData(insertQuery, argList); + if(!updateStatus) + throw new Exception("Error while updating Action Status"); + return updateStatus; + } + + private void createArtifactTrackingRecord(String payload, String requestID, int sdc_artifact_id, int sdc_reference_id) throws Exception { + String vnfc_type = null; + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + + ArrayList argList = new ArrayList<>(); + argList.add(String.valueOf(sdc_artifact_id)); + argList.add(String.valueOf(sdc_reference_id)); + argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue()); + if (payloadObject.get(DesignServiceConstants.TECHNOLOGY) != null &&! payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()) + argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue()); + else + argList.add(""); + + if (payloadObject.get(DesignServiceConstants.PROTOCOL) != null &&! payloadObject.get(DesignServiceConstants.PROTOCOL).textValue().isEmpty()) + argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue()); + else + argList.add(""); + + + String queryString = "INSERT INTO DT_ARTIFACT_TRACKING (ASDC_ARTIFACTS_ID, ASDC_REFERENCE_ID, USER, TECHNOLOGY, CREATION_DATE, UPDATED_DATE, ARTIFACT_STATUS, PROTOCOL, IN_CART) VALUES (? , ? , ?, ?, sysdate() , sysdate(), 'Created', ? ,'N' )" ; + + log.info("Query String :" + queryString); + boolean data = dbservice.updateDBData(queryString, argList); + if(!data) + throw new Exception("Error Updating DT_ARTIFACT_TRACKING "); + + + } + + private int getSDCArtifactIDbyRequestID(String requestID) throws Exception { + log.info("Starting getArtifactIDbyRequestID DB Operation"); + int artifact_id = 0; + try{ + ArrayList argList = new ArrayList<>(); + argList.add("TLSUUID" + requestID); + String queryString = " SELECT ASDC_ARTIFACTS_ID FROM ASDC_ARTIFACTS where SERVICE_UUID = ? "; + log.info("Query String :" + queryString); + ResultSet data = dbservice.getDBData(queryString, argList); + while(data.next()){ + artifact_id = data.getInt("ASDC_ARTIFACTS_ID"); + } + } + catch(Exception e){ + e.printStackTrace(); + throw e; + } + log.info("Got SDC_ARTIFACTS_ID As :" + artifact_id); + return artifact_id; + } + + + private String getArtifact(String payload, String requestID) throws Exception { + String fn = "DBService.getStatus "; + log.info("Starting getArtifact DB Operation"); + try{ + String vnfc_type = null; + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + ArrayList argList = new ArrayList<>(); + argList.add(payloadObject.get("artifact-name").textValue()); + argList.add(payloadObject.get("artifact-type").textValue()); + + String queryString = "SELECT INTERNAL_VERSION, ARTIFACT_CONTENT FROM ASDC_ARTIFACTS where " + + " ARTIFACT_NAME = ? AND ARTIFACT_TYPE = ? " ; + + log.info("Query String :" + queryString); + ResultSet data = dbservice.getDBData(queryString, argList); + String artifact_content = null; + int hightestVerion = 0 ; + while(data.next()) { + int version = data.getInt("INTERNAL_VERSION"); + if(hightestVerion < version) + artifact_content = data.getString("ARTIFACT_CONTENT"); + } + + if(artifact_content == null || artifact_content.isEmpty()) + throw new Exception("Sorry !!! I dont have any artifact Named : " + payloadObject.get("artifact-name").textValue()); + DesignResponse designResponse = new DesignResponse(); + designResponse.setUserId(payloadObject.get("userID").textValue()); + List artifactInfoList = new ArrayList(); + ArtifactInfo artifactInfo = new ArtifactInfo(); + artifactInfo.setArtifact_content(artifact_content); + artifactInfoList.add(artifactInfo); + designResponse.setArtifactInfo(artifactInfoList); + + ObjectMapper mapper = new ObjectMapper(); + String jsonString = mapper.writeValueAsString(designResponse); + log.info("Info : " + jsonString); + return jsonString; + } + catch(SQLException e) + { + log.error("Error while DB operation : " + e.getMessage()); + e.printStackTrace(); + throw e; + } + catch(Exception e) + { + log.error("Error while DB operation : " + e.getMessage()); + e.printStackTrace(); + throw e; + } + + } + private String setStatus(String payload, String requestID) throws Exception { + String fn = "DBService.getStatus "; + log.info("Starting getStatus DB Operation"); + try{ + String vnfc_type = null; + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + + + ArrayList argList = new ArrayList<>(); + argList.add(payloadObject.get("artifact_status").textValue()); + argList.add(payloadObject.get("action_status").textValue()); + + argList.add(payloadObject.get("userID").textValue()); + argList.add(payloadObject.get("vnf-type").textValue()); + + String queryString = " UPDATE DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR SET DAT.ARTIFACT_STATUS = ? , DAS.DT_ACTION_STATUS = ? " + + " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID " + + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? " + + " and DAS.VNF_TYPE = ? " ; + + if(payloadObject.get("vnfc-type") !=null && !payloadObject.get("vnfc-type").textValue().isEmpty()){ + argList.add(payloadObject.get("vnfc-type").textValue()); + queryString = queryString + " and DAS.VNFC_TYPE = ? "; + } + + log.info("Query String :" + queryString); + + DesignResponse designResponse = new DesignResponse(); + designResponse.setUserId(payloadObject.get("userID").textValue()); + List statusInfoList = new ArrayList(); + boolean update = dbservice.updateDBData(queryString, argList); + if(!update) + throw new Exception("Sorry .....Something went wrong while updating the Status"); + + ObjectMapper mapper = new ObjectMapper(); + String jsonString = mapper.writeValueAsString(designResponse); + log.info("Info : " + jsonString); + return jsonString; + } + catch(SQLException e) + { + log.error("Error while DB operation : " + e.getMessage()); + e.printStackTrace(); + throw e; + } + catch(Exception e) + { + log.error("Error while DB operation : " + e.getMessage()); + e.printStackTrace(); + throw e; + } + } + private String getStatus(String payload, String requestID) throws Exception { + String fn = "DBService.getStatus "; + log.info("Starting getStatus DB Operation"); + try{ + String vnfc_type = null; + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + String UserID = payloadObject.get("userID").textValue(); + String vnf_type = payloadObject.get("vnf-type").textValue(); + if(payloadObject.get("vnfc-type") != null ) + vnfc_type = payloadObject.get("vnfc-type").textValue(); + ArrayList argList = new ArrayList<>(); + + argList.add(UserID); + argList.add(vnf_type); + + String queryString = "SELECT DAS.VNF_TYPE, DAS.VNFC_TYPE, DAS.STATUS, DAS.ACTION, DAT.ARTIFACT_STATUS " + + "from DT_ACTION_STATUS DAS , DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR " + + " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID " + + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? " + + " and DAS.VNF_TYPE = ? " ; + + if(vnfc_type !=null && ! vnfc_type.isEmpty()){ + argList.add(vnfc_type); + queryString = queryString + " and DAS.VNFC_TYPE = ? "; + } + + log.info("Query String :" + queryString); + + DesignResponse designResponse = new DesignResponse(); + designResponse.setUserId(UserID); + List statusInfoList = new ArrayList(); + ResultSet data = dbservice.getDBData(queryString, argList); + while(data.next()) { + StatusInfo statusInfo = new StatusInfo(); + statusInfo.setAction(data.getString("ACTION")); + statusInfo.setAction_status(data.getString("STATUS")); + statusInfo.setArtifact_status(data.getString("ARTIFACT_STATUS")); + statusInfo.setVnf_type(data.getString("VNF_TYPE")); + statusInfo.setVnfc_type(data.getString("VNFC_TYPE")); + statusInfoList.add(statusInfo); + } + + if(statusInfoList.size() < 1) + throw new Exception("OOPS !!!! No VNF information available for VNF-TYPE : " + vnf_type + " for User : " + UserID); + designResponse.setStatusInfoList(statusInfoList); + ObjectMapper mapper = new ObjectMapper(); + String jsonString = mapper.writeValueAsString(designResponse); + log.info("Info : " + jsonString); + return jsonString; + } + catch(SQLException e) + { + log.error("Error while DB operation : " + e.getMessage()); + e.printStackTrace(); + throw e; + } + catch(Exception e) + { + log.error("Error while DB operation : " + e.getMessage()); + e.printStackTrace(); + throw e; + } + } + private String getGuiReference(String payload, String requestID) { + // TODO Auto-generated method stub + return null; + } + private String getArtifactReference(String payload, String requestID) { + // TODO Auto-generated method stub + return null; + } + private String getAddInCart(String payload, String requestID) { + // TODO Auto-generated method stub + return null; + } + + // private String getDesigns(String payload, String requestID) throws SQLException, JsonProcessingException, IOException, SvcLogicException { + // + // String fn = "DBService.getDesigns "; + // QueryStatus status = null; + // ObjectMapper objectMapper = new ObjectMapper(); + // JsonNode jnode = objectMapper.readTree(payload); + // String UserId = jnode.get("userID").textValue(); + // SvcLogicContext localContext = new SvcLogicContext(); + // localContext.setAttribute("requestID", requestID); + // localContext.setAttribute("userID", UserId); + // if (serviceLogic != null && localContext != null) { + // String queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART from " + + // DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE + + // " AR where DAT.SDC_REFERENCE_ID= AR.SDC_REFERENCE_ID and DAT.USER = $userID" ; + // + // log.info(fn + "Query String : " + queryString); + // try { + // status = serviceLogic.query("SQL", true, null, queryString, null, null, localContext); + // } catch (SvcLogicException e1) { + // // TODO Auto-generated catch block + // e1.printStackTrace(); + // } + // + // if(status.toString().equals("FAILURE")) + // throw new SvcLogicException("Error - while getting FlowReferenceData "); + // + // Properties props = localContext.toProperties(); + // log.info("SvcLogicContext contains the following : " + props.toString()); + // for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) { + // String propName = (String) e.nextElement(); + // log.info(propName+" = "+props.getProperty(propName)); + // + // } + // } + // return requestID; + // + // } + + private String getDesigns(String payload, String requestID) throws Exception { + + String fn = "DBService.getDesigns "; + log.info("Starting getDesgins DB Operation"); + + + try{ + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + String UserID = payloadObject.get("userID").textValue(); + ArrayList argList = new ArrayList<>(); + argList.add(UserID); + + String queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from " + + DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE + + " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? "; + + DesignResponse designResponse = new DesignResponse(); + designResponse.setUserId(UserID); + List designInfoList = new ArrayList(); + ResultSet data = dbservice.getDBData(queryString, argList); + while(data.next()) { + DesignInfo designInfo = new DesignInfo(); + designInfo.setInCart(data.getString("IN_CART")); + designInfo.setProtocol(data.getString("PROTOCOL")); + designInfo.setVnf_type(data.getString("VNF_TYPE")); + designInfo.setVnfc_type(data.getString("VNFC_TYPE")); + designInfo.setAction(data.getString("ACTION")); + designInfo.setArtifact_type(data.getString("ARTIFACT_TYPE")); + designInfo.setArtifact_name(data.getString("ARTIFACT_NAME")); + designInfoList.add(designInfo); + } + if(designInfoList.size() < 1) + throw new Exception(" Welcome to CDT, Looks like you dont have Design Yet... Lets create some...."); + designResponse.setDesignInfoList(designInfoList); + ObjectMapper mapper = new ObjectMapper(); + String jsonString = mapper.writeValueAsString(designResponse); + log.info("Info : " + jsonString); + return jsonString; + } + catch(Exception e) + { + e.printStackTrace(); + throw e; + } + } + +} + + diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/RequestValidator.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/RequestValidator.java new file mode 100644 index 000000000..c0b710deb --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/RequestValidator.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.dbervices; + +import org.onap.appc.design.services.util.ArtifactHandlerClient; +import org.onap.appc.design.services.util.DesignServiceConstants; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class RequestValidator { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(RequestValidator.class); + public static void validate(String action, String payload) throws Exception { + log.info("payload" + payload); + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + log.info("payloadObject" + payloadObject.get(DesignServiceConstants.ARTIFACT_CONTENTS)); + + String errorString = null; + switch (action) { + case DesignServiceConstants.GETDESIGNS: + if(payloadObject.get(DesignServiceConstants.USER_ID) == null || payloadObject.get(DesignServiceConstants.USER_ID).textValue().isEmpty()) + errorString = DesignServiceConstants.USER_ID; + break; + case DesignServiceConstants.GETARTIFACT: + if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) + errorString = DesignServiceConstants.VNF_TYPE; + else if(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue().isEmpty()) + errorString = DesignServiceConstants.ARTIFACT_TYPE; + else if(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue().isEmpty()) + errorString = DesignServiceConstants.ARTIFACT_NAME; + break; + case DesignServiceConstants.GETSTATUS: + if(payloadObject.get(DesignServiceConstants.USER_ID) == null || payloadObject.get(DesignServiceConstants.USER_ID).textValue().isEmpty()) + errorString = DesignServiceConstants.USER_ID; + else if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) + errorString = DesignServiceConstants.VNF_TYPE; + break; + case DesignServiceConstants.SETSTATUS: + if(payloadObject.get(DesignServiceConstants.USER_ID) == null || payloadObject.get(DesignServiceConstants.USER_ID).textValue().isEmpty()) + errorString = DesignServiceConstants.USER_ID; + else if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) + errorString = DesignServiceConstants.VNF_TYPE; + else if(payloadObject.get(DesignServiceConstants.ACTION) == null || payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()) + errorString = DesignServiceConstants.ACTION; + else if(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue().isEmpty()) + errorString = DesignServiceConstants.ARTIFACT_TYPE; + else if(payloadObject.get(DesignServiceConstants.STATUS) == null || payloadObject.get(DesignServiceConstants.STATUS).textValue().isEmpty()) + errorString = DesignServiceConstants.STATUS; + break; + case DesignServiceConstants.UPLOADARTIFACT: + if(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue().isEmpty()) + errorString = DesignServiceConstants.ARTIFACT_NAME; + else if(! payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue().contains("reference")){ + if(payloadObject.get(DesignServiceConstants.ACTION) == null || payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()) + errorString = DesignServiceConstants.ACTION; + } + else if(payloadObject.get(DesignServiceConstants.ARTIFACT_VERSOIN) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_VERSOIN).textValue().isEmpty()) + errorString = DesignServiceConstants.ARTIFACT_VERSOIN; + else if(payloadObject.get(DesignServiceConstants.ARTIFACT_CONTENTS) == null) + errorString = DesignServiceConstants.ARTIFACT_CONTENTS; + else if(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue().isEmpty()) + errorString = DesignServiceConstants.ARTIFACT_TYPE; + + else if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) + errorString = DesignServiceConstants.VNF_TYPE; + + + break; + case DesignServiceConstants.SETPROTOCOLREFERENCE: + if(payloadObject.get(DesignServiceConstants.ACTION) == null || payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()) + errorString = DesignServiceConstants.ACTION; + else if(payloadObject.get(DesignServiceConstants.ACTION_LEVEL) == null || payloadObject.get(DesignServiceConstants.ACTION_LEVEL).textValue().isEmpty()) + errorString = DesignServiceConstants.ACTION_LEVEL; + else if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) + errorString = DesignServiceConstants.VNF_TYPE; + else if(payloadObject.get(DesignServiceConstants.PROTOCOL) == null || payloadObject.get(DesignServiceConstants.PROTOCOL).textValue().isEmpty()) + errorString = DesignServiceConstants.PROTOCOL; + + case DesignServiceConstants.SETINCART: + if(payloadObject.get(DesignServiceConstants.ACTION) == null || payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()) + errorString = DesignServiceConstants.ACTION; + else if(payloadObject.get(DesignServiceConstants.ACTION_LEVEL) == null || payloadObject.get(DesignServiceConstants.ACTION_LEVEL).textValue().isEmpty()) + errorString = DesignServiceConstants.ACTION_LEVEL; + else if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) + errorString = DesignServiceConstants.VNF_TYPE; + else if(payloadObject.get(DesignServiceConstants.PROTOCOL) == null || payloadObject.get(DesignServiceConstants.PROTOCOL).textValue().isEmpty()) + errorString = DesignServiceConstants.PROTOCOL; + break; + default: + throw new Exception(" Action " + action + " not found while processing request "); + + } + if(errorString != null) + throw new Exception(" Missing input parameter :-" + errorString + " -:"); + + } + +} + + diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/propertyServices/PropertyUpdateService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/propertyServices/PropertyUpdateService.java new file mode 100644 index 000000000..87e84d495 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/propertyServices/PropertyUpdateService.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.propertyServices; + +public class PropertyUpdateService { + + // to set the properties this placeholder will be used. +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/DesignServiceProvider.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/DesignServiceProvider.java new file mode 100644 index 000000000..f41bbac46 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/DesignServiceProvider.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.services; + +import java.util.concurrent.Future; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.DesignServicesService; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.onap.appc.design.services.impl.DesignServicesImpl; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class DesignServiceProvider{ + + private static final EELFLogger log = EELFManager.getInstance().getLogger(DesignServiceProvider.class); + + private final DataBroker dataBroker; + private final RpcProviderRegistry rpcProviderRegistry; + private RpcRegistration serviceRegistration; + + + public DesignServiceProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry) { + this.dataBroker = dataBroker; + this.rpcProviderRegistry = rpcProviderRegistry; + } + + /** + * Method called when the blueprint container is created. + */ + public void init() { + // initialize data broker + this.serviceRegistration = this.rpcProviderRegistry.addRpcImplementation(DesignServicesService.class, new DesignServicesImpl()); + log.info("DesignServicesImpl Session Initiated"); + } + + /** + * Method called when the blueprint container is destroyed. + */ + public void close() { + if(this.serviceRegistration != null){ + this.serviceRegistration.close(); + } + log.info("DesignServicesImpl Closed"); + } + + +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/impl/DesignServicesImpl.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/impl/DesignServicesImpl.java new file mode 100644 index 000000000..1787618e6 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/impl/DesignServicesImpl.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.services.impl; + +import java.util.concurrent.Future; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.DbserviceInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.DbserviceOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.DbserviceOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.DesignServicesService; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.ValidatorInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.ValidatorOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.ValidatorOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.XinterfaceserviceInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.XinterfaceserviceOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.XinterfaceserviceOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.data.DataBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.status.StatusBuilder; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.onap.appc.design.dbervices.DbResponseProcessor; +import org.onap.appc.design.dbervices.DesignDBService; +import org.onap.appc.design.services.util.DesignServiceConstants; +import org.onap.appc.design.validator.ValidatorResponseProcessor; +import org.onap.appc.design.validator.ValidatorService; +import org.onap.appc.design.xinterface.XInterfaceService; +import org.onap.appc.design.xinterface.XResponseProcessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.collect.Lists; +import com.google.common.util.concurrent.Futures; + +public class DesignServicesImpl implements DesignServicesService { + + private static final Logger log = LoggerFactory.getLogger(DesignServicesImpl.class); + + @Override + public Future> dbservice(DbserviceInput input) { + + log.info("Received Request: " + input.getDesignRequest().getRequestId() + " Action : " + + input.getDesignRequest().getAction() + " with Payload :" + input.getDesignRequest().getPayload()); + + + DbserviceOutputBuilder outputBuilder = new DbserviceOutputBuilder(); + DataBuilder databuilder = new DataBuilder(); + StatusBuilder statusBuilder = new StatusBuilder(); + + try{ + DesignDBService dbservices = DesignDBService.initialise(); + DbResponseProcessor responseProcessor = new DbResponseProcessor(); + String response = responseProcessor.parseResponse(dbservices.execute(input.getDesignRequest().getAction(), input.getDesignRequest().getPayload(), input.getDesignRequest().getRequestId()), input.getDesignRequest().getAction()); + log.info("Response in for Design Service : " + response); + databuilder.setBlock(response); + databuilder.setRequestId(input.getDesignRequest().getRequestId()); + statusBuilder.setCode("400"); + statusBuilder.setMessage("success"); + } + catch(Exception e){ + log.error("Error" + e.getMessage()); + e.printStackTrace(); + statusBuilder.setCode("401"); + statusBuilder.setMessage(e.getMessage()); + } + + outputBuilder.setData(databuilder.build()); + outputBuilder.setStatus(statusBuilder.build()); + + RpcResult result = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); + return Futures.immediateFuture(result); + } + + @Override + public Future> xinterfaceservice(XinterfaceserviceInput input) { + log.info("Received Request: " + input.getDesignRequest().getRequestId() + " Action : " + + input.getDesignRequest().getAction() + " with Payload :" + input.getDesignRequest().getPayload()); + XinterfaceserviceOutputBuilder outputBuilder = new XinterfaceserviceOutputBuilder(); + DataBuilder databuilder = new DataBuilder(); + StatusBuilder statusBuilder = new StatusBuilder(); + try { + + XInterfaceService xInterfaceService = new XInterfaceService(); + XResponseProcessor responseProcessor = new XResponseProcessor(); + String response = responseProcessor.parseResponse(xInterfaceService.execute(input.getDesignRequest().getAction(), input.getDesignRequest().getPayload()), input.getDesignRequest().getAction()); + databuilder.setBlock(response); + databuilder.setRequestId(input.getDesignRequest().getRequestId()); + statusBuilder.setCode("400"); + statusBuilder.setMessage("success"); + } catch (Exception e) { + e.printStackTrace(); + statusBuilder.setCode("401"); + statusBuilder.setMessage(e.getMessage()); + } + outputBuilder.setData(databuilder.build()); + outputBuilder.setStatus(statusBuilder.build()); + + RpcResult result = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); + return Futures.immediateFuture(result); + } + + @Override + public Future> validator(ValidatorInput input) { + log.info("Received Request: " + input.getDesignRequest().getRequestId() + " Action : " + + input.getDesignRequest().getAction() + " with Payload :" + input.getDesignRequest().getPayload() + " and Data Type = " + input.getDesignRequest().getDataType()); + ValidatorOutputBuilder outputBuilder = new ValidatorOutputBuilder(); + StatusBuilder statusBuilder = new StatusBuilder(); + + + try { + if(input.getDesignRequest().getDataType() == null || input.getDesignRequest().getDataType().isEmpty()) + throw new Exception ("Data Type required for validate Serivce"); + if(input.getDesignRequest().getAction()== null || input.getDesignRequest().getAction().isEmpty()) + throw new Exception ("Action required for validate Serivce"); + + + if(! input.getDesignRequest().getDataType().equals(DesignServiceConstants.DATA_TYPE_JSON) && + ! input.getDesignRequest().getDataType().equals(DesignServiceConstants.DATA_TYPE_YAML) && + ! input.getDesignRequest().getDataType().equals(DesignServiceConstants.DATA_TYPE_XML) && + ! input.getDesignRequest().getDataType().equals(DesignServiceConstants.DATA_TYPE_VELOCITY)) + throw new Exception ("Request Data format " + input.getDesignRequest().getDataType() + + " is not supported by validate Service : Supported data types are : XML, YAML, VELOCITY, JSON "); + + ValidatorService validatorService = new ValidatorService(); + ValidatorResponseProcessor responseProcessor = new ValidatorResponseProcessor(); + String response = validatorService.execute(input.getDesignRequest().getAction(), input.getDesignRequest().getPayload(), input.getDesignRequest().getDataType()); + statusBuilder.setCode("400"); + statusBuilder.setMessage(response); + } catch (Exception e) { + e.printStackTrace(); + statusBuilder.setCode("401"); + statusBuilder.setMessage(e.getMessage()); + } + + outputBuilder.setStatus(statusBuilder.build()); + + RpcResult result = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); + return Futures.immediateFuture(result); + } +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/ArtifactHandlerClient.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/ArtifactHandlerClient.java new file mode 100644 index 000000000..b250faca9 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/ArtifactHandlerClient.java @@ -0,0 +1,187 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.services.util; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.nio.charset.Charset; +import java.security.SecureRandom; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Properties; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.MediaType; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + + +public class ArtifactHandlerClient { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(ArtifactHandlerClient.class); + private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR"; + Properties props = new Properties(); + public ArtifactHandlerClient() throws Exception { + String propDir = System.getenv(SDNC_CONFIG_DIR_VAR); + if (propDir == null) + throw new Exception(" Cannot find Property file -" + SDNC_CONFIG_DIR_VAR); + String propFile = propDir + "/" + DesignServiceConstants.DESIGN_SERVICE_PROPERTIES; + InputStream propStream = new FileInputStream(propFile); + try{ + props.load(propStream); + } + catch (Exception e){ + throw new Exception("Could not load properties file " + propFile, e); + } + finally{ + try{ + propStream.close(); + } + catch (Exception e){ + log.warn("Could not close FileInputStream", e); + } + } + } + + public String createArtifactData(String payload, String requestID) throws JsonProcessingException, IOException { + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(payload); + + ObjectNode json = objectMapper.createObjectNode(); + + String artifact_name = payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue(); + String artifact_version = payloadObject.get(DesignServiceConstants.ARTIFACT_VERSOIN).textValue(); + String artifact_contents = payloadObject.get(DesignServiceConstants.ARTIFACT_CONTENTS).textValue(); + + ObjectNode requestInfo = objectMapper.createObjectNode(); + + requestInfo.put(DesignServiceConstants.REQUETS_ID, requestID); + requestInfo.put(DesignServiceConstants.REQUEST_ACTION, "StoreSdcDocumentRequest"); + requestInfo.put(DesignServiceConstants.SOURCE, DesignServiceConstants.DESIGN_TOOL); + + String random = getRandom(); + + ObjectNode docParams = objectMapper.createObjectNode(); + + docParams.put(DesignServiceConstants.ARTIFACT_VERSOIN, artifact_version); + docParams.put(DesignServiceConstants.ARTIFACT_NAME, artifact_name); + docParams.put(DesignServiceConstants.ARTIFACT_CONTENTS, artifact_contents); + + + json.put(DesignServiceConstants.REQUEST_INFORMATION, requestInfo); + json.put(DesignServiceConstants.DOCUMENT_PARAMETERS, docParams); + log.info("Final data =" + json.toString()); + return String.format("{\"input\": %s}", json.toString()); + } + + public HashMap execute(String payload, String rpc) throws Exception{ + log.info("Configuring Rest Operation for Payload " + payload + " RPC : " + rpc ); + HashMap outputMessage = new HashMap(); + Client client = null; + WebResource webResource = null; + ClientResponse clientResponse = null; + String responseDataType=MediaType.APPLICATION_JSON; + String requestDataType=MediaType.APPLICATION_JSON; + + try{ + DefaultClientConfig defaultClientConfig = new DefaultClientConfig(); + System.setProperty("jsse.enableSNIExtension", "false"); + SSLContext sslContext = null; + SecureRestClientTrustManager secureRestClientTrustManager = new SecureRestClientTrustManager(); + sslContext = SSLContext.getInstance("SSL"); + sslContext.init(null, new javax.net.ssl.TrustManager[] { secureRestClientTrustManager }, null); + defaultClientConfig.getProperties().put( + com.sun.jersey.client.urlconnection.HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, + new com.sun.jersey.client.urlconnection.HTTPSProperties(getHostnameVerifier(), sslContext)); + client = Client.create(defaultClientConfig); + client.addFilter(new HTTPBasicAuthFilter(props.getProperty("appc.upload.user"), props.getProperty("appc.upload.pass"))); + webResource = client.resource(new URI(props.getProperty("appc.upload.provider.url"))); + webResource.setProperty("Content-Type", "application/json;charset=UTF-8"); + + log.info("Starting Rest Operation....."); + if(HttpMethod.GET.equalsIgnoreCase(rpc)){ + clientResponse = webResource.accept(responseDataType).get(ClientResponse.class); + }else if(HttpMethod.POST.equalsIgnoreCase(rpc)){ + clientResponse = webResource.type(requestDataType).post(ClientResponse.class, payload); + }else if(HttpMethod.PUT.equalsIgnoreCase(rpc)){ + clientResponse = webResource.type(requestDataType).put(ClientResponse.class,payload); + }else if(HttpMethod.DELETE.equalsIgnoreCase(rpc)){ + clientResponse = webResource.delete(ClientResponse.class); + } + + if(!(clientResponse.getStatus() == 200)) + throw new Exception("HTTP error code : " + clientResponse.getStatus()); + + + log.info("Completed Rest Operation....."); + + }catch (Exception e) { + e.printStackTrace(); + log.debug("failed in RESTCONT Action with falut message :"+e.getMessage()); + throw new Exception("Error While Sending Rest Request" + e.getMessage()); + } + finally { + // clean up. + webResource = null; + if(client != null){ + client.destroy(); + client = null; + } + } + + return outputMessage; + } + private String getRandom() { + SecureRandom random = new SecureRandom(); + int num = random.nextInt(100000); + String formatted = String.format("%05d", num); + return formatted; + } + + private HostnameVerifier getHostnameVerifier() { + return new HostnameVerifier() { + @Override + public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) { + return true; + } + }; + } +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java new file mode 100644 index 000000000..9ad5e10ac --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.services.util; + +public class DesignServiceConstants { + + public static String STRING_ENCODING = "utf-8"; + public static String Y = "Y"; + public static String N = "N"; + public static String DATA_TYPE_TEXT = "TEXT"; + public static String DATA_TYPE_JSON = "JSON"; + public static String DATA_TYPE_XML = "XML"; + public static String DATA_TYPE_YAML = "YAML"; + public static String DATA_TYPE_VELOCITY = "VELOCITY"; + public static String DATA_TYPE_SQL = "SQL"; + + public static final String GETDESIGNS = "getDesigns"; + public static final String UPLOADARTIFACTS = "uploadArtifacts"; + public static final String VALIDATETEMPLATE = "validateTemplate"; + public static final String GETSTATUS = "getStatus"; + public static final String SETSTATUS = "setStatus"; + public static final String GETGUIREFERENCE = "getGUIReference"; + public static final String GETARTIFACTREFERENCE = "getArtifactReference"; + public static final String GETAAIDATA = "getAAIData"; + public static final String GETINSTARDATA = "getInstarData"; + public static final String PUBLISHARTIFACTS = "publishdArtifacts"; + public static final String ADDINCART = "addInCart"; + + public static final String SUCCESS = "success"; + public static final String DESINGTIME = "DesignTime"; + public static final String RUNTIME = "RunTime"; + public static final String APPC_FLOW_CONTROLLER = "/appc-flow-controller.properties"; + public static final String VNF_TYPE = "vnf-type"; + public static final String ACTION = "action"; + public static final String VNFC_TYPE = "vnfc-type"; + public static final String VM_INSTANCE = "vm-instance"; + public static final String VM = "vm"; + public static final String VNFC = "vnfc"; + + public static final String DOCUMENT_PARAMETERS = "document-parameters"; + public static final String SERVICE_UUID = "service-uuid"; + public static final String DISTRIBUTION_ID = "distribution-id"; + + public static final String SERVICE_NAME = "service-name"; + public static final String SERVICE_DESCRIPTION ="service-description"; + public static final String SERVICE_ARTIFACTS = "service-artifacts"; + public static final String RESOURCE_UUID ="resource-uuid"; + public static final String RESOURCE_INSTANCE_NAME = "resource-instance-name"; + public static final String REOURCE_NAME = "resource-name"; + public static final String RESOURCE_VERSOIN ="resource-version"; + public static final String RESOURCE_TYPE= "resource-type"; + public static final String ARTIFACT_UUID ="artifact-uuid"; + public static final String ARTIFACT_NAME = "artifact-name"; + + public static final String ARTIFACT_VERSOIN = "artifact-version"; + public static final String ARTIFACT_DESRIPTION = "artifact-description"; + public static final String ARTIFACT_CONTENTS = "artifact-contents"; + public static final String REQUEST_INFORMATION = "request-information"; + public static final String INTERNAL_VERSION = "internal-versoin"; + + + + public static final String DB_DT_ARTIFACT_TRACKING = "DT_ARTIFACT_TRACKING"; + public static final String DB_SDC_REFERENCE = "ASDC_REFERENCE"; + public static final String SCHEMA_SDNCTL = "SDNCTL"; + public static final String GETARTIFACT = "getArtifact"; + public static final String USER_ID = "userID"; + public static final String ARTIFACT_TYPE = "artifact-type"; + public static final String STATUS = "status"; + public static final String UPLOADARTIFACT = "uploadArtifact"; + public static final String REQUETS_ID = "request-id"; + public static final String REQUEST_ACTION = "request-action"; + public static final String SOURCE = "source"; + public static final String DESIGN_SERVICE_PROPERTIES = "designService.properties"; + public static final String DESIGN_TOOL = "Design-tool"; + public static final String TECHNOLOGY = "technology"; + public static final String PROTOCOL = "protocol"; + public static final String SETPROTOCOLREFERENCE = "setProtocolReference"; + public static final String ACTION_LEVEL = "action-level"; + public static final String TEMPLATE = "template"; + public static final String SETINCART = "setInCart"; + public static final String INCART = "inCart"; + public static final String STOREPASSWORD = "storeProperty"; + } diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/EscapeUtils.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/EscapeUtils.java new file mode 100644 index 000000000..80f756f3a --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/EscapeUtils.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.services.util; + +import org.apache.commons.lang3.StringUtils; + +public class EscapeUtils { + + public EscapeUtils() { + // TODO Auto-generated constructor stub + } + + public static String escapeSql(String str) { + if (str == null) { + return null; + } + String searchList[] = new String[]{"'","\\", "\"" }; + String replacementList[] = new String[]{ "''","\\\\" ,"\\\""}; + return StringUtils.replaceEach(str,searchList, replacementList); + } + +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/SecureRestClientTrustManager.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/SecureRestClientTrustManager.java new file mode 100644 index 000000000..8e31d9540 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/SecureRestClientTrustManager.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.services.util; + +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +import javax.net.ssl.X509TrustManager; + + +public class SecureRestClientTrustManager implements X509TrustManager { + + @Override + public void checkClientTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + + public boolean isClientTrusted(X509Certificate[] arg0) { + return true; + } + + public boolean isServerTrusted(X509Certificate[] arg0) { + return true; + } + +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/validator/ValidatorResponseProcessor.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/validator/ValidatorResponseProcessor.java new file mode 100644 index 000000000..faea6a5ee --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/validator/ValidatorResponseProcessor.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.validator; + +import org.onap.appc.design.services.impl.DesignServicesImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ValidatorResponseProcessor { + + private static final Logger log = LoggerFactory.getLogger(ValidatorResponseProcessor.class); + public String parseResponse(Object execute, String action) { + return null; + } + +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/validator/ValidatorService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/validator/ValidatorService.java new file mode 100644 index 000000000..6660dd825 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/validator/ValidatorService.java @@ -0,0 +1,168 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.validator; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.validation.Validator; + +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.Velocity; +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.exception.MethodInvocationException; +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.runtime.resource.loader.StringResourceLoader; +import org.apache.velocity.runtime.resource.util.StringResourceRepository; +import org.onap.appc.design.services.util.DesignServiceConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; +import com.fasterxml.jackson.dataformat.yaml.snakeyaml.introspector.BeanAccess; + +public class ValidatorService { + + private static final Logger log = LoggerFactory.getLogger(ValidatorService.class); + public String execute(String action, String payload, String dataType) throws Exception { + + String validateResponse = null; + log.info("Received validation for action= " + action + "Data :" + payload + " dataType = " + dataType); + if(dataType.equals(DesignServiceConstants.DATA_TYPE_XML)) + validateResponse = validateXML(payload); + else if(dataType.equals(DesignServiceConstants.DATA_TYPE_JSON)) + validateResponse = validateJOSN(payload); + else if(dataType.equals(DesignServiceConstants.DATA_TYPE_VELOCITY)) + validateResponse = validateVelocity(payload); + else if(dataType.equals(DesignServiceConstants.DATA_TYPE_YAML)) + validateResponse = validateYAML(payload); + + return validateResponse; + + } + + private String validateYAML(String payload) throws Exception { + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + try{ + InputStream is = new ByteArrayInputStream(payload.getBytes()); + + Reader in = new InputStreamReader(is); + Yaml yaml = new Yaml(); + yaml.setBeanAccess(BeanAccess.FIELD); + yaml.load(in); + return DesignServiceConstants.SUCCESS; + } + catch(Exception e){ + log.error("Not a Valid YAML Format "); + throw e; + } + + } + + private String validateVelocity(String payload) { + + try{ + VelocityEngine engine = new VelocityEngine(); + engine.setProperty(Velocity.RESOURCE_LOADER, "string"); + engine.addProperty("string.resource.loader.class", StringResourceLoader.class.getName()); + engine.addProperty("string.resource.loader.repository.static", "false"); + engine.init(); + StringResourceRepository repo = (StringResourceRepository) engine.getApplicationAttribute(StringResourceLoader.REPOSITORY_NAME_DEFAULT); + repo.putStringResource("TestTemplate", payload); + //Template t = ve.getTemplate(payload); + Template t = engine.getTemplate("TestTemplate"); + + return DesignServiceConstants.SUCCESS; + } + catch(ResourceNotFoundException e ){ + log.error("Not a Valid Velocity Template "); + throw e; + } + catch(ParseErrorException pe){ + log.error("Not a Valid Velocity Template "); + throw pe; + } + catch(MethodInvocationException mi){ + log.error("Not a Valid Velocity Template "); + throw mi; + } + } + + private String validateJOSN(String payload) throws Exception { + + try{ + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.readTree(payload); + return DesignServiceConstants.SUCCESS; + } catch(JsonProcessingException e){ + log.error("Not a Valid JOSN file "); + throw e; + } + + } + + private String validateXML(String payload) throws IOException, SAXException, ParserConfigurationException { + + try{ + + DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = dBF.newDocumentBuilder(); + InputSource is = new InputSource(payload); + builder.parse(new InputSource(new ByteArrayInputStream(payload.getBytes("utf-8")))); + return DesignServiceConstants.SUCCESS; + + } catch(ParserConfigurationException e){ + log.info("Error While parsing Payload : " + e.getMessage()); + throw e; + } + catch(SAXException se){ + log.info("Error While parsing Payload : " + se.getMessage()); + throw se; + } + catch(IOException io){ + log.info("Error While parsing Payload : " + io.getMessage()); + throw io; + } + } +} + diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/xinterface/XInterfaceService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/xinterface/XInterfaceService.java new file mode 100644 index 000000000..157e52937 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/xinterface/XInterfaceService.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.xinterface; + +import java.io.File; +import java.io.IOException; + +import com.google.common.base.Charsets; +import com.google.common.io.Files; + +public class XInterfaceService { + + + public String execute(String action, String payload) throws IOException { + //Remove this once hte interfaces are up and running + File targetFile = new File("/tmp/" + action + "-response.txt" ); + String interfaceResponse = Files.toString(targetFile, Charsets.UTF_8); + return interfaceResponse; + } + +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/xinterface/XResponseProcessor.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/xinterface/XResponseProcessor.java new file mode 100644 index 000000000..aa72e2f09 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/xinterface/XResponseProcessor.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.xinterface; + +import java.io.File; +import java.io.IOException; + +import com.google.common.base.Charsets; +import com.google.common.io.Files; + +public class XResponseProcessor { + + public String parseResponse(Object execute, String action) { + return null; + } +} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/ArtifactInfo.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/ArtifactInfo.java deleted file mode 100644 index 53f6f02fb..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/ArtifactInfo.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.data; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ArtifactInfo { - - @JsonProperty("artifact-content") - String artifact_content; - - public String getArtifact_content() { - return artifact_content; - } - - public void setArtifact_content(String artifact_content) { - this.artifact_content = artifact_content; - } - -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignInfo.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignInfo.java deleted file mode 100644 index a6d2ba24b..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignInfo.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.data; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class DesignInfo{ - - @JsonProperty("vnf-type") - String vnf_type; - - @JsonProperty("vnfc-type") - String vnfc_type; - - @JsonProperty("protocol") - String protocol; - - @JsonProperty("incart") - String inCart; - - @JsonProperty("action") - String action; - - @JsonProperty("artifact-name") - String artifact_name; - - - @JsonProperty("artifact-type") - String artifact_type; - - public String getArtifact_type() { - return artifact_type; - } - - public void setArtifact_type(String artifact_type) { - this.artifact_type = artifact_type; - } - - public String getArtifact_name() { - return artifact_name; - } - - public void setArtifact_name(String artifact_name) { - this.artifact_name = artifact_name; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getVnf_type() { - return vnf_type; - } - - public void setVnf_type(String vnf_type) { - this.vnf_type = vnf_type; - } - - public String getVnfc_type() { - return vnfc_type; - } - - public void setVnfc_type(String vnfc_type) { - this.vnfc_type = vnfc_type; - } - - public String getProtocol() { - return protocol; - } - - public void setProtocol(String protocol) { - this.protocol = protocol; - } - - public String getInCart() { - return inCart; - } - - public void setInCart(String inCart) { - this.inCart = inCart; - } - - @Override - public String toString() { - return "DesignInfo [vnf_type=" + vnf_type + ", vnfc_type=" + vnfc_type + ", protocol=" + protocol + ", inCart=" - + inCart + "]"; - } - -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignRequest.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignRequest.java deleted file mode 100644 index d61de0282..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignRequest.java +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.data; - -import java.io.File; -import java.net.URL; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import javax.sql.rowset.CachedRowSet; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.onap.appc.design.services.util.DesignServiceConstants; -import org.onap.ccsdk.sli.core.dblib.DBResourceManager; -import org.onap.ccsdk.sli.core.dblib.DbLibService; - -public class DesignRequest{ - - - @JsonProperty("userID") - String userId ; - - @JsonProperty("vnf-type") - String vnf_type; - - @JsonProperty("vnfc-type") - String vnfc_type; - - @JsonProperty("protocol") - String protocol; - - @JsonProperty("action") - String action; - - @JsonProperty("artifact-name") - String artifact_name; - - @JsonProperty("artifact-contents") - String artifact_contents ; - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getVnf_type() { - return vnf_type; - } - - public void setVnf_type(String vnf_type) { - this.vnf_type = vnf_type; - } - - public String getVnfc_type() { - return vnfc_type; - } - - public void setVnfc_type(String vnfc_type) { - this.vnfc_type = vnfc_type; - } - - public String getProtocol() { - return protocol; - } - - public void setProtocol(String protocol) { - this.protocol = protocol; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getArtifact_name() { - return artifact_name; - } - - public void setArtifact_name(String artifact_name) { - this.artifact_name = artifact_name; - } - - public String getArtifact_contents() { - return artifact_contents; - } - - public void setArtifact_contents(String artifact_contents) { - this.artifact_contents = artifact_contents; - } - - @Override - public String toString() { - return "DesignRequest [userId=" + userId + ", vnf_type=" + vnf_type + ", vnfc_type=" + vnfc_type + ", protocol=" - + protocol + ", action=" + action + ", artifact_name=" + artifact_name + ", artifact_contents=" - + artifact_contents + "]"; - } - -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignResponse.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignResponse.java deleted file mode 100644 index 559620d9e..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignResponse.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.data; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class DesignResponse{ - - - @JsonProperty("userID") - String userId ; - - @JsonProperty("designInfo") - List designInfoList; - - @JsonProperty("statusInfo") - List statusInfoList; - - @JsonProperty("artifactInfo") - List artifactInfo; - - - public List getArtifactInfo() { - return artifactInfo; - } - - public void setArtifactInfo(List artifactInfo) { - this.artifactInfo = artifactInfo; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public List getDesignInfoList() { - return designInfoList; - } - - public void setDesignInfoList(List designInfoList) { - this.designInfoList = designInfoList; - } - - public List getStatusInfoList() { - return statusInfoList; - } - - public void setStatusInfoList(List statusInfoList) { - this.statusInfoList = statusInfoList; - } -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/StatusInfo.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/StatusInfo.java deleted file mode 100644 index 6d4b1a5a1..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/StatusInfo.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.data; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class StatusInfo{ - - @JsonProperty("vnf-type") - String vnf_type; - - @JsonProperty("vnfc-type") - String vnfc_type; - - @JsonProperty("action") - String action; - - @JsonProperty("artifact-status") - String artifact_status; - - @JsonProperty("action-status") - String action_status; - - public String getVnf_type() { - return vnf_type; - } - - public void setVnf_type(String vnf_type) { - this.vnf_type = vnf_type; - } - - public String getVnfc_type() { - return vnfc_type; - } - - public void setVnfc_type(String vnfc_type) { - this.vnfc_type = vnfc_type; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getArtifact_status() { - return artifact_status; - } - - public void setArtifact_status(String artifact_status) { - this.artifact_status = artifact_status; - } - - public String getAction_status() { - return action_status; - } - - public void setAction_status(String action_status) { - this.action_status = action_status; - } - -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DbResponseProcessor.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DbResponseProcessor.java deleted file mode 100644 index e697a9d4f..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DbResponseProcessor.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.dbervices; - -import org.onap.appc.design.services.util.DesignServiceConstants; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class DbResponseProcessor { - - private static final EELFLogger log = EELFManager.getInstance().getLogger(DbResponseProcessor.class); - public String parseResponse(String dbresposne, String action) throws Exception { - - log.info("Starting Parsing the response for action : " + action + "\n data " + dbresposne ); - String response ; - switch (action) { - case DesignServiceConstants.GETDESIGNS: - response = getDesignsResponse(dbresposne); - break; - case DesignServiceConstants.ADDINCART: - response = getAddInCartResponse(dbresposne); - break ; - case DesignServiceConstants.GETARTIFACTREFERENCE: - response= getArtifactReferenceResponse(dbresposne); - break; - case DesignServiceConstants.GETARTIFACT: - response= getArtifactResponse(dbresposne); - break; - case DesignServiceConstants.GETGUIREFERENCE: - response= getGuiReferenceResponse(dbresposne); - break; - case DesignServiceConstants.GETSTATUS: - response= getStatusResponse(dbresposne); - break; - case DesignServiceConstants.UPLOADARTIFACT: - response= getsetStatusResponse(dbresposne); - break; - case DesignServiceConstants.SETPROTOCOLREFERENCE: - response= getsetStatusResponse(dbresposne); - break; - case DesignServiceConstants.SETINCART: - response= getsetStatusResponse(dbresposne); - break; - default: - log.error("Action " + action + " Not Supported by response Parser"); - throw new Exception(" Action " + action + " not found while processing request "); - - } - return response; - - } - - private String getArtifactResponse(String dbresposne) { - // TODO Auto-generated method stub - return dbresposne; - } - - private String getsetStatusResponse(String dbresposne) { - // TODO Auto-generated method stub - return null; - } - - private String getStatusResponse(String dbresposne) { - log.info("Returning reposne from Response Parser " + dbresposne); - return dbresposne; - } - - private String getGuiReferenceResponse(String dbresposne) { - // TODO Auto-generated method stub - return null; - } - - private String getArtifactReferenceResponse(String dbresposne) { - // TODO Auto-generated method stub - return null; - } - - private String getAddInCartResponse(String dbresposne) { - // TODO Auto-generated method stub - return null; - } - - private String getDesignsResponse(String dbresposne) { - return dbresposne; - - } -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DbService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DbService.java deleted file mode 100644 index a2349196f..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DbService.java +++ /dev/null @@ -1,146 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.dbervices; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Properties; -import java.util.UUID; - -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; -import org.onap.ccsdk.sli.core.dblib.DBResourceManager; -import org.onap.ccsdk.sli.core.dblib.DbLibService; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DbService { - - private static final Logger Log = LoggerFactory.getLogger(DbService.class); - private static final String DBLIB_SERVICE = "org.onap.ccsdk.sli.core.dblib.DBResourceManager"; - DbLibService dblibSvc = null; - String errorMsg = null; - - public DbService() throws Exception { - DbLibService dblibSvc = null; - Log.info("Initializing DbService service"); - try - { - dblibSvc = getDbLibService(); - if (dblibSvc == null) { - Log.error("Got Exception While getting DB Connection"); - throw new Exception("Got Exception While getting DB Connection"); - } - this.dblibSvc = dblibSvc; - } - catch (Exception e) { - Log.error(e.getMessage()); - throw e; - } - } - - private static DbLibService getDbLibService() { - - DbLibService dblibSvc = null; - BundleContext bctx = null; - ServiceReference sref = null; - - Bundle bundle = FrameworkUtil.getBundle(SvcLogicService.class); - - if (bundle != null) { - bctx = bundle.getBundleContext(); - } - - if (bctx != null) { - Log.debug("Getting bundle Context"); - sref = bctx.getServiceReference(DBLIB_SERVICE); - } - - if (sref == null) { - Log.warn("Could not find service reference for DBLib service"); - - } else { - dblibSvc = (DbLibService) bctx.getService(sref); - if (dblibSvc == null) { - Log.warn("DBLIB_SERVICE is null"); - } - } - if (dblibSvc == null) { - try { - dblibSvc = new DBResourceManager(System.getProperties()); - } catch (Exception e) { - Log.error("Caught exception trying to create db service", e); - } - - if (dblibSvc == null) { - Log.warn("Could not create new DBResourceManager"); - } - } - return (dblibSvc); - } - - public ResultSet getDBData(String query) throws Exception { - ResultSet resultSet; - StringBuilder sqlBuilder = new StringBuilder(query); - Log.info("Query: " + sqlBuilder.toString()); - try { - resultSet = dblibSvc.getData(sqlBuilder.toString(), null, null); - } catch (Exception e) { - Log.error("SQL query "+sqlBuilder+" :: " + e.getMessage()); - throw e; - } - return resultSet; - } - - public ResultSet getDBData(String query, ArrayList paramList) throws Exception { - ResultSet resultSet; - StringBuilder sqlBuilder = new StringBuilder(query); - Log.info("Query :" + sqlBuilder.toString()); - try { - resultSet = dblibSvc.getData(sqlBuilder.toString(), paramList, null); - } catch (Exception expObj) { - Log.error("query "+sqlBuilder+" :: " + expObj.getMessage()); - throw expObj; - } - return resultSet; - } - - public boolean updateDBData(String query, ArrayList paramList) throws Exception { - boolean update; - StringBuilder sqlBuilder = new StringBuilder(query); - Log.info("Query :" + sqlBuilder.toString()); - try { - update = dblibSvc.writeData(sqlBuilder.toString(), paramList, null); - } catch (Exception expObj) { - Log.error("query "+sqlBuilder+" :: " + expObj.getMessage()); - throw expObj; - } - return update; - } -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DesignDBService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DesignDBService.java deleted file mode 100644 index 64251027f..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DesignDBService.java +++ /dev/null @@ -1,645 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.dbervices; - -import java.io.IOException; -import java.security.SecureRandom; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.onap.appc.design.data.ArtifactInfo; -import org.onap.appc.design.data.DesignInfo; -import org.onap.appc.design.data.DesignResponse; -import org.onap.appc.design.data.StatusInfo; -import org.onap.appc.design.services.util.ArtifactHandlerClient; -import org.onap.appc.design.services.util.DesignServiceConstants; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.onap.ccsdk.sli.core.dblib.DBResourceManager; -import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class DesignDBService { - - private static final EELFLogger log = EELFManager.getInstance().getLogger(DesignDBService.class); - private SvcLogicResource serviceLogic; - private static DesignDBService dgGeneralDBService = null; - private static DBResourceManager jdbcDataSource; - - DbService dbservice = null; - private static Properties props; - public static DesignDBService initialise() { - if (dgGeneralDBService == null) { - dgGeneralDBService = new DesignDBService(); - } - return dgGeneralDBService; - } - private DesignDBService() { - if (serviceLogic == null) { - serviceLogic = new SqlResource(); - } - } - - public String execute(String action, String payload, String requestID) throws Exception { - - log.info("Received execute request for action : " + action + " with Payload : "+ payload ); - RequestValidator.validate(action, payload); - String response = null; - dbservice = new DbService(); - switch (action) { - case DesignServiceConstants.GETDESIGNS: - response = getDesigns(payload,requestID ); - break; - case DesignServiceConstants.ADDINCART: - response= setInCart(payload, requestID); - break ; - case DesignServiceConstants.GETARTIFACTREFERENCE: - response= getArtifactReference(payload, requestID); - break; - case DesignServiceConstants.GETARTIFACT: - response= getArtifact(payload, requestID); - break; - case DesignServiceConstants.GETGUIREFERENCE: - response= getGuiReference(payload, requestID); - break; - case DesignServiceConstants.GETSTATUS: - response= getStatus(payload, requestID); - break; - case DesignServiceConstants.SETSTATUS: - response= setStatus(payload, requestID); - break; - case DesignServiceConstants.UPLOADARTIFACT: - response= uploadArtifact(payload, requestID); - break; - case DesignServiceConstants.SETPROTOCOLREFERENCE: - response= setProtocolReference(payload, requestID); - break; - default: - throw new Exception(" Action " + action + " not found while processing request "); - - } - return response; - } - - private String setInCart(String payload, String requestID) throws Exception { - - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - ArrayList argList = new ArrayList<>(); - argList.add(payloadObject.get(DesignServiceConstants.INCART).textValue()); - argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); - - String queryString = "UPDATE DT_ARTIFACT_TRACKING SET INCART= ? WHERE ASDC_REFERENCE_ID IN " - + " (SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE_ID WHERE VNF_TYPE = ? " ; - - if(payloadObject.get(DesignServiceConstants.VNF_TYPE) != null &&! payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) { - queryString = queryString + " AND VNFC_TYPE = ? ) AND USER = ? " ; - argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue()); - } - else{ - queryString = queryString + " ) AND USER = ? " ; - } - - argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue()); - - log.info("Query String :" + queryString); - boolean data = dbservice.updateDBData(queryString, argList); - - if(!data) - throw new Exception("Error while updating ProtocolReference"); - - return "{\"update\" : \"success\" } "; - - } - private String setProtocolReference(String payload, String requestID) throws Exception { - - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - ArrayList argList = new ArrayList<>(); - - argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue()); - argList.add(payloadObject.get(DesignServiceConstants.ACTION_LEVEL).textValue()); - argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); - argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue()); - - String queryString = " DELETE FROM PROTOCOL_REFERENCE WHERE ACTION = ? AND ACTION_LEVEL AND VNF_TYPE= ? AND PROTOCOL = ? " ; - - log.info("Delete Query String :" + queryString); - boolean data = dbservice.updateDBData(queryString, argList); - - log.info("Record Deleted"); - - if((payloadObject.get(DesignServiceConstants.TEMPLATE) != null && !payloadObject.get(DesignServiceConstants.TEMPLATE).textValue().isEmpty())) - argList.add(payloadObject.get(DesignServiceConstants.TEMPLATE).textValue()); - else - argList.add("NO"); - - String insertString = "INSERT INTO PROTOCOL_REFERENCE VALUES (?,?,?,?,?,SYSDATE()) "; - - if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && ! payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){ - queryString = queryString + " AND VNFC_TYPE = ? )" ; - } - else{ - queryString = queryString + " ) "; - } - log.info("Query String :" + queryString); - data = dbservice.updateDBData(queryString, argList); - - if(!data) - throw new Exception("Error while updating ProtocolReference"); - - return "{\"update\" : \"success\" } "; - } - private String uploadArtifact(String payload, String requestID) throws Exception { - - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - log.info("Got upload Aritfact with Payload : " + payloadObject.asText()); - try{ - ArtifactHandlerClient ac = new ArtifactHandlerClient(); - String requestString = ac.createArtifactData(payload, requestID); - ac.execute(requestString, "POST"); - int sdc_artifact_id = getSDCArtifactIDbyRequestID(requestID); - int sdc_reference_id = getSDCReferenceID(payload); - createArtifactTrackingRecord(payload, requestID,sdc_artifact_id, sdc_reference_id ); - String status = getDataFromActionStatus(payload, "STATUS"); - if(status == null || status.isEmpty()) - setActionStatus(payload, "Not Tested"); - linkstatusRelationShip(sdc_artifact_id,sdc_reference_id, payload); - - } - catch(Exception e){ - e.printStackTrace(); - throw e; - } - return "{\"update\" : \"success\" } "; - - } - - private void linkstatusRelationShip(int sdc_artifact_id, int sdc_reference_id, String payload) throws Exception { - - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - ArrayList argList = new ArrayList<>(); - argList.add(String.valueOf(sdc_artifact_id)); - argList.add(String.valueOf(sdc_reference_id)); - argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); - argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue()); - argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue()); - - String queryString = "INSERT INTO DT_STATUS_RELATIONSHIP (DT_ARTIFACT_TRACKING_ID,DT_ACTION_STATUS_ID) VALUES " + - "(( SELECT DT_ARTIFACT_TRACKING_ID FROM DT_ARTIFACT_TRACKING WHERE ASDC_ARTIFACTS_ID = ? AND ASDC_REFERENCE_ID = ? ) , " - + "( SELECT DT_ACTION_STATUS_ID FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? " ; - - if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && ! payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){ - queryString = queryString + " AND VNFC_TYPE = ? ) )" ; - } - else{ - queryString = queryString + " ) ) "; - } - log.info("Query String :" + queryString); - boolean data = dbservice.updateDBData(queryString, argList); - - if(!data) - throw new Exception("Error while updating RealtionShip table"); - - } - private int getSDCReferenceID(String payload) throws Exception { - - String vnfc_type = null; - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - ArrayList argList = new ArrayList<>(); - argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); - - argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue()); - argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue()); - - String queryString = " SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE WHERE VNF_TYPE = ? " - + " AND ARTIFACT_TYPE = ? AND ARTIFACT_NAME = ? " ; - - if(payloadObject.get(DesignServiceConstants.ACTION) != null && !payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()){ - argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue()); - queryString = queryString + " AND ACTION = ? "; - } - if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){ - argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue()); - queryString = queryString + " AND VNFC_TYPE = ? "; - - } - - log.info("Query String :" + queryString); - ResultSet data = dbservice.getDBData(queryString, argList); - int sdc_reference_id = 0; - while(data.next()) { - sdc_reference_id = data.getInt("ASDC_REFERENCE_ID"); - } - log.info("Got sdc_reference_id = " + sdc_reference_id ); - return sdc_reference_id; - - } - - private String getDataFromActionStatus(String payload, String dataValue) throws Exception { - String status = null ; - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - ArrayList argList = new ArrayList<>(); - argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); - argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue()); - argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue()); - String queryString = " SELECT " + dataValue + " FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? "; - if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){ - argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue()); - queryString = queryString + " AND VNFC_TYPE = ? "; - } - log.info("Query String :" + queryString); - ResultSet data = dbservice.getDBData(queryString, argList); - while(data.next()) { - status = data.getString("STATUS"); - } - log.info("DT_ACTION_STATUS Status = " + status ); - return status; - } - - private boolean setActionStatus(String payload, String status) throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - ArrayList argList = new ArrayList<>(); - argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue()); - argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue()); - - - String insertQuery = " INSERT INTO DT_ACTION_STATUS (ACTION, VNF_TYPE, VNFC_TYPE, USER, TECHNOLOGY, UPDATED_DATE, STATUS) VALUES (?,?,?,?,?,sysdate() , ?); "; - if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){ - argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue()); - } - else{ - argList.add(null); - } - argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue()); - if(payloadObject.get(DesignServiceConstants.TECHNOLOGY) !=null && !payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()){ - argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue()); - } - else{ - argList.add(null); - } - argList.add(status); - - boolean updateStatus = dbservice.updateDBData(insertQuery, argList); - if(!updateStatus) - throw new Exception("Error while updating Action Status"); - return updateStatus; - } - - private void createArtifactTrackingRecord(String payload, String requestID, int sdc_artifact_id, int sdc_reference_id) throws Exception { - String vnfc_type = null; - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - - ArrayList argList = new ArrayList<>(); - argList.add(String.valueOf(sdc_artifact_id)); - argList.add(String.valueOf(sdc_reference_id)); - argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue()); - if (payloadObject.get(DesignServiceConstants.TECHNOLOGY) != null &&! payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()) - argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue()); - else - argList.add(""); - - if (payloadObject.get(DesignServiceConstants.PROTOCOL) != null &&! payloadObject.get(DesignServiceConstants.PROTOCOL).textValue().isEmpty()) - argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue()); - else - argList.add(""); - - - String queryString = "INSERT INTO DT_ARTIFACT_TRACKING (ASDC_ARTIFACTS_ID, ASDC_REFERENCE_ID, USER, TECHNOLOGY, CREATION_DATE, UPDATED_DATE, ARTIFACT_STATUS, PROTOCOL, IN_CART) VALUES (? , ? , ?, ?, sysdate() , sysdate(), 'Created', ? ,'N' )" ; - - log.info("Query String :" + queryString); - boolean data = dbservice.updateDBData(queryString, argList); - if(!data) - throw new Exception("Error Updating DT_ARTIFACT_TRACKING "); - - - } - - private int getSDCArtifactIDbyRequestID(String requestID) throws Exception { - log.info("Starting getArtifactIDbyRequestID DB Operation"); - int artifact_id = 0; - try{ - ArrayList argList = new ArrayList<>(); - argList.add("TLSUUID" + requestID); - String queryString = " SELECT ASDC_ARTIFACTS_ID FROM ASDC_ARTIFACTS where SERVICE_UUID = ? "; - log.info("Query String :" + queryString); - ResultSet data = dbservice.getDBData(queryString, argList); - while(data.next()){ - artifact_id = data.getInt("ASDC_ARTIFACTS_ID"); - } - } - catch(Exception e){ - e.printStackTrace(); - throw e; - } - log.info("Got SDC_ARTIFACTS_ID As :" + artifact_id); - return artifact_id; - } - - - private String getArtifact(String payload, String requestID) throws Exception { - String fn = "DBService.getStatus "; - log.info("Starting getArtifact DB Operation"); - try{ - String vnfc_type = null; - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - ArrayList argList = new ArrayList<>(); - argList.add(payloadObject.get("artifact-name").textValue()); - argList.add(payloadObject.get("artifact-type").textValue()); - - String queryString = "SELECT INTERNAL_VERSION, ARTIFACT_CONTENT FROM ASDC_ARTIFACTS where " + - " ARTIFACT_NAME = ? AND ARTIFACT_TYPE = ? " ; - - log.info("Query String :" + queryString); - ResultSet data = dbservice.getDBData(queryString, argList); - String artifact_content = null; - int hightestVerion = 0 ; - while(data.next()) { - int version = data.getInt("INTERNAL_VERSION"); - if(hightestVerion < version) - artifact_content = data.getString("ARTIFACT_CONTENT"); - } - - if(artifact_content == null || artifact_content.isEmpty()) - throw new Exception("Sorry !!! I dont have any artifact Named : " + payloadObject.get("artifact-name").textValue()); - DesignResponse designResponse = new DesignResponse(); - designResponse.setUserId(payloadObject.get("userID").textValue()); - List artifactInfoList = new ArrayList(); - ArtifactInfo artifactInfo = new ArtifactInfo(); - artifactInfo.setArtifact_content(artifact_content); - artifactInfoList.add(artifactInfo); - designResponse.setArtifactInfo(artifactInfoList); - - ObjectMapper mapper = new ObjectMapper(); - String jsonString = mapper.writeValueAsString(designResponse); - log.info("Info : " + jsonString); - return jsonString; - } - catch(SQLException e) - { - log.error("Error while DB operation : " + e.getMessage()); - e.printStackTrace(); - throw e; - } - catch(Exception e) - { - log.error("Error while DB operation : " + e.getMessage()); - e.printStackTrace(); - throw e; - } - - } - private String setStatus(String payload, String requestID) throws Exception { - String fn = "DBService.getStatus "; - log.info("Starting getStatus DB Operation"); - try{ - String vnfc_type = null; - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - - - ArrayList argList = new ArrayList<>(); - argList.add(payloadObject.get("artifact_status").textValue()); - argList.add(payloadObject.get("action_status").textValue()); - - argList.add(payloadObject.get("userID").textValue()); - argList.add(payloadObject.get("vnf-type").textValue()); - - String queryString = " UPDATE DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR SET DAT.ARTIFACT_STATUS = ? , DAS.DT_ACTION_STATUS = ? " - + " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID " - + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? " - + " and DAS.VNF_TYPE = ? " ; - - if(payloadObject.get("vnfc-type") !=null && !payloadObject.get("vnfc-type").textValue().isEmpty()){ - argList.add(payloadObject.get("vnfc-type").textValue()); - queryString = queryString + " and DAS.VNFC_TYPE = ? "; - } - - log.info("Query String :" + queryString); - - DesignResponse designResponse = new DesignResponse(); - designResponse.setUserId(payloadObject.get("userID").textValue()); - List statusInfoList = new ArrayList(); - boolean update = dbservice.updateDBData(queryString, argList); - if(!update) - throw new Exception("Sorry .....Something went wrong while updating the Status"); - - ObjectMapper mapper = new ObjectMapper(); - String jsonString = mapper.writeValueAsString(designResponse); - log.info("Info : " + jsonString); - return jsonString; - } - catch(SQLException e) - { - log.error("Error while DB operation : " + e.getMessage()); - e.printStackTrace(); - throw e; - } - catch(Exception e) - { - log.error("Error while DB operation : " + e.getMessage()); - e.printStackTrace(); - throw e; - } - } - private String getStatus(String payload, String requestID) throws Exception { - String fn = "DBService.getStatus "; - log.info("Starting getStatus DB Operation"); - try{ - String vnfc_type = null; - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - String UserID = payloadObject.get("userID").textValue(); - String vnf_type = payloadObject.get("vnf-type").textValue(); - if(payloadObject.get("vnfc-type") != null ) - vnfc_type = payloadObject.get("vnfc-type").textValue(); - ArrayList argList = new ArrayList<>(); - - argList.add(UserID); - argList.add(vnf_type); - - String queryString = "SELECT DAS.VNF_TYPE, DAS.VNFC_TYPE, DAS.STATUS, DAS.ACTION, DAT.ARTIFACT_STATUS " - + "from DT_ACTION_STATUS DAS , DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR " + - " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID " - + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? " - + " and DAS.VNF_TYPE = ? " ; - - if(vnfc_type !=null && ! vnfc_type.isEmpty()){ - argList.add(vnfc_type); - queryString = queryString + " and DAS.VNFC_TYPE = ? "; - } - - log.info("Query String :" + queryString); - - DesignResponse designResponse = new DesignResponse(); - designResponse.setUserId(UserID); - List statusInfoList = new ArrayList(); - ResultSet data = dbservice.getDBData(queryString, argList); - while(data.next()) { - StatusInfo statusInfo = new StatusInfo(); - statusInfo.setAction(data.getString("ACTION")); - statusInfo.setAction_status(data.getString("STATUS")); - statusInfo.setArtifact_status(data.getString("ARTIFACT_STATUS")); - statusInfo.setVnf_type(data.getString("VNF_TYPE")); - statusInfo.setVnfc_type(data.getString("VNFC_TYPE")); - statusInfoList.add(statusInfo); - } - - if(statusInfoList.size() < 1) - throw new Exception("OOPS !!!! No VNF information available for VNF-TYPE : " + vnf_type + " for User : " + UserID); - designResponse.setStatusInfoList(statusInfoList); - ObjectMapper mapper = new ObjectMapper(); - String jsonString = mapper.writeValueAsString(designResponse); - log.info("Info : " + jsonString); - return jsonString; - } - catch(SQLException e) - { - log.error("Error while DB operation : " + e.getMessage()); - e.printStackTrace(); - throw e; - } - catch(Exception e) - { - log.error("Error while DB operation : " + e.getMessage()); - e.printStackTrace(); - throw e; - } - } - private String getGuiReference(String payload, String requestID) { - // TODO Auto-generated method stub - return null; - } - private String getArtifactReference(String payload, String requestID) { - // TODO Auto-generated method stub - return null; - } - private String getAddInCart(String payload, String requestID) { - // TODO Auto-generated method stub - return null; - } - - // private String getDesigns(String payload, String requestID) throws SQLException, JsonProcessingException, IOException, SvcLogicException { - // - // String fn = "DBService.getDesigns "; - // QueryStatus status = null; - // ObjectMapper objectMapper = new ObjectMapper(); - // JsonNode jnode = objectMapper.readTree(payload); - // String UserId = jnode.get("userID").textValue(); - // SvcLogicContext localContext = new SvcLogicContext(); - // localContext.setAttribute("requestID", requestID); - // localContext.setAttribute("userID", UserId); - // if (serviceLogic != null && localContext != null) { - // String queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART from " + - // DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE + - // " AR where DAT.SDC_REFERENCE_ID= AR.SDC_REFERENCE_ID and DAT.USER = $userID" ; - // - // log.info(fn + "Query String : " + queryString); - // try { - // status = serviceLogic.query("SQL", true, null, queryString, null, null, localContext); - // } catch (SvcLogicException e1) { - // // TODO Auto-generated catch block - // e1.printStackTrace(); - // } - // - // if(status.toString().equals("FAILURE")) - // throw new SvcLogicException("Error - while getting FlowReferenceData "); - // - // Properties props = localContext.toProperties(); - // log.info("SvcLogicContext contains the following : " + props.toString()); - // for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) { - // String propName = (String) e.nextElement(); - // log.info(propName+" = "+props.getProperty(propName)); - // - // } - // } - // return requestID; - // - // } - - private String getDesigns(String payload, String requestID) throws Exception { - - String fn = "DBService.getDesigns "; - log.info("Starting getDesgins DB Operation"); - - - try{ - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - String UserID = payloadObject.get("userID").textValue(); - ArrayList argList = new ArrayList<>(); - argList.add(UserID); - - String queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from " + - DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE + - " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? "; - - DesignResponse designResponse = new DesignResponse(); - designResponse.setUserId(UserID); - List designInfoList = new ArrayList(); - ResultSet data = dbservice.getDBData(queryString, argList); - while(data.next()) { - DesignInfo designInfo = new DesignInfo(); - designInfo.setInCart(data.getString("IN_CART")); - designInfo.setProtocol(data.getString("PROTOCOL")); - designInfo.setVnf_type(data.getString("VNF_TYPE")); - designInfo.setVnfc_type(data.getString("VNFC_TYPE")); - designInfo.setAction(data.getString("ACTION")); - designInfo.setArtifact_type(data.getString("ARTIFACT_TYPE")); - designInfo.setArtifact_name(data.getString("ARTIFACT_NAME")); - designInfoList.add(designInfo); - } - if(designInfoList.size() < 1) - throw new Exception(" Welcome to CDT, Looks like you dont have Design Yet... Lets create some...."); - designResponse.setDesignInfoList(designInfoList); - ObjectMapper mapper = new ObjectMapper(); - String jsonString = mapper.writeValueAsString(designResponse); - log.info("Info : " + jsonString); - return jsonString; - } - catch(Exception e) - { - e.printStackTrace(); - throw e; - } - } - -} - - diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/RequestValidator.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/RequestValidator.java deleted file mode 100644 index c0b710deb..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/RequestValidator.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.dbervices; - -import org.onap.appc.design.services.util.ArtifactHandlerClient; -import org.onap.appc.design.services.util.DesignServiceConstants; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class RequestValidator { - - private static final EELFLogger log = EELFManager.getInstance().getLogger(RequestValidator.class); - public static void validate(String action, String payload) throws Exception { - log.info("payload" + payload); - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - log.info("payloadObject" + payloadObject.get(DesignServiceConstants.ARTIFACT_CONTENTS)); - - String errorString = null; - switch (action) { - case DesignServiceConstants.GETDESIGNS: - if(payloadObject.get(DesignServiceConstants.USER_ID) == null || payloadObject.get(DesignServiceConstants.USER_ID).textValue().isEmpty()) - errorString = DesignServiceConstants.USER_ID; - break; - case DesignServiceConstants.GETARTIFACT: - if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) - errorString = DesignServiceConstants.VNF_TYPE; - else if(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue().isEmpty()) - errorString = DesignServiceConstants.ARTIFACT_TYPE; - else if(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue().isEmpty()) - errorString = DesignServiceConstants.ARTIFACT_NAME; - break; - case DesignServiceConstants.GETSTATUS: - if(payloadObject.get(DesignServiceConstants.USER_ID) == null || payloadObject.get(DesignServiceConstants.USER_ID).textValue().isEmpty()) - errorString = DesignServiceConstants.USER_ID; - else if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) - errorString = DesignServiceConstants.VNF_TYPE; - break; - case DesignServiceConstants.SETSTATUS: - if(payloadObject.get(DesignServiceConstants.USER_ID) == null || payloadObject.get(DesignServiceConstants.USER_ID).textValue().isEmpty()) - errorString = DesignServiceConstants.USER_ID; - else if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) - errorString = DesignServiceConstants.VNF_TYPE; - else if(payloadObject.get(DesignServiceConstants.ACTION) == null || payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()) - errorString = DesignServiceConstants.ACTION; - else if(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue().isEmpty()) - errorString = DesignServiceConstants.ARTIFACT_TYPE; - else if(payloadObject.get(DesignServiceConstants.STATUS) == null || payloadObject.get(DesignServiceConstants.STATUS).textValue().isEmpty()) - errorString = DesignServiceConstants.STATUS; - break; - case DesignServiceConstants.UPLOADARTIFACT: - if(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue().isEmpty()) - errorString = DesignServiceConstants.ARTIFACT_NAME; - else if(! payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue().contains("reference")){ - if(payloadObject.get(DesignServiceConstants.ACTION) == null || payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()) - errorString = DesignServiceConstants.ACTION; - } - else if(payloadObject.get(DesignServiceConstants.ARTIFACT_VERSOIN) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_VERSOIN).textValue().isEmpty()) - errorString = DesignServiceConstants.ARTIFACT_VERSOIN; - else if(payloadObject.get(DesignServiceConstants.ARTIFACT_CONTENTS) == null) - errorString = DesignServiceConstants.ARTIFACT_CONTENTS; - else if(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE) == null || payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue().isEmpty()) - errorString = DesignServiceConstants.ARTIFACT_TYPE; - - else if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) - errorString = DesignServiceConstants.VNF_TYPE; - - - break; - case DesignServiceConstants.SETPROTOCOLREFERENCE: - if(payloadObject.get(DesignServiceConstants.ACTION) == null || payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()) - errorString = DesignServiceConstants.ACTION; - else if(payloadObject.get(DesignServiceConstants.ACTION_LEVEL) == null || payloadObject.get(DesignServiceConstants.ACTION_LEVEL).textValue().isEmpty()) - errorString = DesignServiceConstants.ACTION_LEVEL; - else if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) - errorString = DesignServiceConstants.VNF_TYPE; - else if(payloadObject.get(DesignServiceConstants.PROTOCOL) == null || payloadObject.get(DesignServiceConstants.PROTOCOL).textValue().isEmpty()) - errorString = DesignServiceConstants.PROTOCOL; - - case DesignServiceConstants.SETINCART: - if(payloadObject.get(DesignServiceConstants.ACTION) == null || payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()) - errorString = DesignServiceConstants.ACTION; - else if(payloadObject.get(DesignServiceConstants.ACTION_LEVEL) == null || payloadObject.get(DesignServiceConstants.ACTION_LEVEL).textValue().isEmpty()) - errorString = DesignServiceConstants.ACTION_LEVEL; - else if(payloadObject.get(DesignServiceConstants.VNF_TYPE) == null || payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) - errorString = DesignServiceConstants.VNF_TYPE; - else if(payloadObject.get(DesignServiceConstants.PROTOCOL) == null || payloadObject.get(DesignServiceConstants.PROTOCOL).textValue().isEmpty()) - errorString = DesignServiceConstants.PROTOCOL; - break; - default: - throw new Exception(" Action " + action + " not found while processing request "); - - } - if(errorString != null) - throw new Exception(" Missing input parameter :-" + errorString + " -:"); - - } - -} - - diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/propertyServices/PropertyUpdateService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/propertyServices/PropertyUpdateService.java deleted file mode 100644 index 87e84d495..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/propertyServices/PropertyUpdateService.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.propertyServices; - -public class PropertyUpdateService { - - // to set the properties this placeholder will be used. -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/DesignServiceProvider.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/DesignServiceProvider.java deleted file mode 100644 index f41bbac46..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/DesignServiceProvider.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.services; - -import java.util.concurrent.Future; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.DesignServicesService; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.onap.appc.design.services.impl.DesignServicesImpl; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class DesignServiceProvider{ - - private static final EELFLogger log = EELFManager.getInstance().getLogger(DesignServiceProvider.class); - - private final DataBroker dataBroker; - private final RpcProviderRegistry rpcProviderRegistry; - private RpcRegistration serviceRegistration; - - - public DesignServiceProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry) { - this.dataBroker = dataBroker; - this.rpcProviderRegistry = rpcProviderRegistry; - } - - /** - * Method called when the blueprint container is created. - */ - public void init() { - // initialize data broker - this.serviceRegistration = this.rpcProviderRegistry.addRpcImplementation(DesignServicesService.class, new DesignServicesImpl()); - log.info("DesignServicesImpl Session Initiated"); - } - - /** - * Method called when the blueprint container is destroyed. - */ - public void close() { - if(this.serviceRegistration != null){ - this.serviceRegistration.close(); - } - log.info("DesignServicesImpl Closed"); - } - - -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/impl/DesignServicesImpl.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/impl/DesignServicesImpl.java deleted file mode 100644 index 1787618e6..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/impl/DesignServicesImpl.java +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.services.impl; - -import java.util.concurrent.Future; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.DbserviceInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.DbserviceOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.DbserviceOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.DesignServicesService; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.ValidatorInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.ValidatorOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.ValidatorOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.XinterfaceserviceInput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.XinterfaceserviceOutput; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.XinterfaceserviceOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.data.DataBuilder; -import org.opendaylight.yang.gen.v1.org.onap.appc.rev170627.status.StatusBuilder; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.onap.appc.design.dbervices.DbResponseProcessor; -import org.onap.appc.design.dbervices.DesignDBService; -import org.onap.appc.design.services.util.DesignServiceConstants; -import org.onap.appc.design.validator.ValidatorResponseProcessor; -import org.onap.appc.design.validator.ValidatorService; -import org.onap.appc.design.xinterface.XInterfaceService; -import org.onap.appc.design.xinterface.XResponseProcessor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.collect.Lists; -import com.google.common.util.concurrent.Futures; - -public class DesignServicesImpl implements DesignServicesService { - - private static final Logger log = LoggerFactory.getLogger(DesignServicesImpl.class); - - @Override - public Future> dbservice(DbserviceInput input) { - - log.info("Received Request: " + input.getDesignRequest().getRequestId() + " Action : " + - input.getDesignRequest().getAction() + " with Payload :" + input.getDesignRequest().getPayload()); - - - DbserviceOutputBuilder outputBuilder = new DbserviceOutputBuilder(); - DataBuilder databuilder = new DataBuilder(); - StatusBuilder statusBuilder = new StatusBuilder(); - - try{ - DesignDBService dbservices = DesignDBService.initialise(); - DbResponseProcessor responseProcessor = new DbResponseProcessor(); - String response = responseProcessor.parseResponse(dbservices.execute(input.getDesignRequest().getAction(), input.getDesignRequest().getPayload(), input.getDesignRequest().getRequestId()), input.getDesignRequest().getAction()); - log.info("Response in for Design Service : " + response); - databuilder.setBlock(response); - databuilder.setRequestId(input.getDesignRequest().getRequestId()); - statusBuilder.setCode("400"); - statusBuilder.setMessage("success"); - } - catch(Exception e){ - log.error("Error" + e.getMessage()); - e.printStackTrace(); - statusBuilder.setCode("401"); - statusBuilder.setMessage(e.getMessage()); - } - - outputBuilder.setData(databuilder.build()); - outputBuilder.setStatus(statusBuilder.build()); - - RpcResult result = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); - return Futures.immediateFuture(result); - } - - @Override - public Future> xinterfaceservice(XinterfaceserviceInput input) { - log.info("Received Request: " + input.getDesignRequest().getRequestId() + " Action : " + - input.getDesignRequest().getAction() + " with Payload :" + input.getDesignRequest().getPayload()); - XinterfaceserviceOutputBuilder outputBuilder = new XinterfaceserviceOutputBuilder(); - DataBuilder databuilder = new DataBuilder(); - StatusBuilder statusBuilder = new StatusBuilder(); - try { - - XInterfaceService xInterfaceService = new XInterfaceService(); - XResponseProcessor responseProcessor = new XResponseProcessor(); - String response = responseProcessor.parseResponse(xInterfaceService.execute(input.getDesignRequest().getAction(), input.getDesignRequest().getPayload()), input.getDesignRequest().getAction()); - databuilder.setBlock(response); - databuilder.setRequestId(input.getDesignRequest().getRequestId()); - statusBuilder.setCode("400"); - statusBuilder.setMessage("success"); - } catch (Exception e) { - e.printStackTrace(); - statusBuilder.setCode("401"); - statusBuilder.setMessage(e.getMessage()); - } - outputBuilder.setData(databuilder.build()); - outputBuilder.setStatus(statusBuilder.build()); - - RpcResult result = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); - return Futures.immediateFuture(result); - } - - @Override - public Future> validator(ValidatorInput input) { - log.info("Received Request: " + input.getDesignRequest().getRequestId() + " Action : " + - input.getDesignRequest().getAction() + " with Payload :" + input.getDesignRequest().getPayload() + " and Data Type = " + input.getDesignRequest().getDataType()); - ValidatorOutputBuilder outputBuilder = new ValidatorOutputBuilder(); - StatusBuilder statusBuilder = new StatusBuilder(); - - - try { - if(input.getDesignRequest().getDataType() == null || input.getDesignRequest().getDataType().isEmpty()) - throw new Exception ("Data Type required for validate Serivce"); - if(input.getDesignRequest().getAction()== null || input.getDesignRequest().getAction().isEmpty()) - throw new Exception ("Action required for validate Serivce"); - - - if(! input.getDesignRequest().getDataType().equals(DesignServiceConstants.DATA_TYPE_JSON) && - ! input.getDesignRequest().getDataType().equals(DesignServiceConstants.DATA_TYPE_YAML) && - ! input.getDesignRequest().getDataType().equals(DesignServiceConstants.DATA_TYPE_XML) && - ! input.getDesignRequest().getDataType().equals(DesignServiceConstants.DATA_TYPE_VELOCITY)) - throw new Exception ("Request Data format " + input.getDesignRequest().getDataType() - + " is not supported by validate Service : Supported data types are : XML, YAML, VELOCITY, JSON "); - - ValidatorService validatorService = new ValidatorService(); - ValidatorResponseProcessor responseProcessor = new ValidatorResponseProcessor(); - String response = validatorService.execute(input.getDesignRequest().getAction(), input.getDesignRequest().getPayload(), input.getDesignRequest().getDataType()); - statusBuilder.setCode("400"); - statusBuilder.setMessage(response); - } catch (Exception e) { - e.printStackTrace(); - statusBuilder.setCode("401"); - statusBuilder.setMessage(e.getMessage()); - } - - outputBuilder.setStatus(statusBuilder.build()); - - RpcResult result = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); - return Futures.immediateFuture(result); - } -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/ArtifactHandlerClient.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/ArtifactHandlerClient.java deleted file mode 100644 index b250faca9..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/ArtifactHandlerClient.java +++ /dev/null @@ -1,187 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.services.util; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.nio.charset.Charset; -import java.security.SecureRandom; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Properties; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; -import javax.ws.rs.HttpMethod; -import javax.ws.rs.core.MediaType; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - - -public class ArtifactHandlerClient { - - private static final EELFLogger log = EELFManager.getInstance().getLogger(ArtifactHandlerClient.class); - private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR"; - Properties props = new Properties(); - public ArtifactHandlerClient() throws Exception { - String propDir = System.getenv(SDNC_CONFIG_DIR_VAR); - if (propDir == null) - throw new Exception(" Cannot find Property file -" + SDNC_CONFIG_DIR_VAR); - String propFile = propDir + "/" + DesignServiceConstants.DESIGN_SERVICE_PROPERTIES; - InputStream propStream = new FileInputStream(propFile); - try{ - props.load(propStream); - } - catch (Exception e){ - throw new Exception("Could not load properties file " + propFile, e); - } - finally{ - try{ - propStream.close(); - } - catch (Exception e){ - log.warn("Could not close FileInputStream", e); - } - } - } - - public String createArtifactData(String payload, String requestID) throws JsonProcessingException, IOException { - - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode payloadObject = objectMapper.readTree(payload); - - ObjectNode json = objectMapper.createObjectNode(); - - String artifact_name = payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue(); - String artifact_version = payloadObject.get(DesignServiceConstants.ARTIFACT_VERSOIN).textValue(); - String artifact_contents = payloadObject.get(DesignServiceConstants.ARTIFACT_CONTENTS).textValue(); - - ObjectNode requestInfo = objectMapper.createObjectNode(); - - requestInfo.put(DesignServiceConstants.REQUETS_ID, requestID); - requestInfo.put(DesignServiceConstants.REQUEST_ACTION, "StoreSdcDocumentRequest"); - requestInfo.put(DesignServiceConstants.SOURCE, DesignServiceConstants.DESIGN_TOOL); - - String random = getRandom(); - - ObjectNode docParams = objectMapper.createObjectNode(); - - docParams.put(DesignServiceConstants.ARTIFACT_VERSOIN, artifact_version); - docParams.put(DesignServiceConstants.ARTIFACT_NAME, artifact_name); - docParams.put(DesignServiceConstants.ARTIFACT_CONTENTS, artifact_contents); - - - json.put(DesignServiceConstants.REQUEST_INFORMATION, requestInfo); - json.put(DesignServiceConstants.DOCUMENT_PARAMETERS, docParams); - log.info("Final data =" + json.toString()); - return String.format("{\"input\": %s}", json.toString()); - } - - public HashMap execute(String payload, String rpc) throws Exception{ - log.info("Configuring Rest Operation for Payload " + payload + " RPC : " + rpc ); - HashMap outputMessage = new HashMap(); - Client client = null; - WebResource webResource = null; - ClientResponse clientResponse = null; - String responseDataType=MediaType.APPLICATION_JSON; - String requestDataType=MediaType.APPLICATION_JSON; - - try{ - DefaultClientConfig defaultClientConfig = new DefaultClientConfig(); - System.setProperty("jsse.enableSNIExtension", "false"); - SSLContext sslContext = null; - SecureRestClientTrustManager secureRestClientTrustManager = new SecureRestClientTrustManager(); - sslContext = SSLContext.getInstance("SSL"); - sslContext.init(null, new javax.net.ssl.TrustManager[] { secureRestClientTrustManager }, null); - defaultClientConfig.getProperties().put( - com.sun.jersey.client.urlconnection.HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, - new com.sun.jersey.client.urlconnection.HTTPSProperties(getHostnameVerifier(), sslContext)); - client = Client.create(defaultClientConfig); - client.addFilter(new HTTPBasicAuthFilter(props.getProperty("appc.upload.user"), props.getProperty("appc.upload.pass"))); - webResource = client.resource(new URI(props.getProperty("appc.upload.provider.url"))); - webResource.setProperty("Content-Type", "application/json;charset=UTF-8"); - - log.info("Starting Rest Operation....."); - if(HttpMethod.GET.equalsIgnoreCase(rpc)){ - clientResponse = webResource.accept(responseDataType).get(ClientResponse.class); - }else if(HttpMethod.POST.equalsIgnoreCase(rpc)){ - clientResponse = webResource.type(requestDataType).post(ClientResponse.class, payload); - }else if(HttpMethod.PUT.equalsIgnoreCase(rpc)){ - clientResponse = webResource.type(requestDataType).put(ClientResponse.class,payload); - }else if(HttpMethod.DELETE.equalsIgnoreCase(rpc)){ - clientResponse = webResource.delete(ClientResponse.class); - } - - if(!(clientResponse.getStatus() == 200)) - throw new Exception("HTTP error code : " + clientResponse.getStatus()); - - - log.info("Completed Rest Operation....."); - - }catch (Exception e) { - e.printStackTrace(); - log.debug("failed in RESTCONT Action with falut message :"+e.getMessage()); - throw new Exception("Error While Sending Rest Request" + e.getMessage()); - } - finally { - // clean up. - webResource = null; - if(client != null){ - client.destroy(); - client = null; - } - } - - return outputMessage; - } - private String getRandom() { - SecureRandom random = new SecureRandom(); - int num = random.nextInt(100000); - String formatted = String.format("%05d", num); - return formatted; - } - - private HostnameVerifier getHostnameVerifier() { - return new HostnameVerifier() { - @Override - public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) { - return true; - } - }; - } -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/DesignServiceConstants.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/DesignServiceConstants.java deleted file mode 100644 index 9ad5e10ac..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/DesignServiceConstants.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.services.util; - -public class DesignServiceConstants { - - public static String STRING_ENCODING = "utf-8"; - public static String Y = "Y"; - public static String N = "N"; - public static String DATA_TYPE_TEXT = "TEXT"; - public static String DATA_TYPE_JSON = "JSON"; - public static String DATA_TYPE_XML = "XML"; - public static String DATA_TYPE_YAML = "YAML"; - public static String DATA_TYPE_VELOCITY = "VELOCITY"; - public static String DATA_TYPE_SQL = "SQL"; - - public static final String GETDESIGNS = "getDesigns"; - public static final String UPLOADARTIFACTS = "uploadArtifacts"; - public static final String VALIDATETEMPLATE = "validateTemplate"; - public static final String GETSTATUS = "getStatus"; - public static final String SETSTATUS = "setStatus"; - public static final String GETGUIREFERENCE = "getGUIReference"; - public static final String GETARTIFACTREFERENCE = "getArtifactReference"; - public static final String GETAAIDATA = "getAAIData"; - public static final String GETINSTARDATA = "getInstarData"; - public static final String PUBLISHARTIFACTS = "publishdArtifacts"; - public static final String ADDINCART = "addInCart"; - - public static final String SUCCESS = "success"; - public static final String DESINGTIME = "DesignTime"; - public static final String RUNTIME = "RunTime"; - public static final String APPC_FLOW_CONTROLLER = "/appc-flow-controller.properties"; - public static final String VNF_TYPE = "vnf-type"; - public static final String ACTION = "action"; - public static final String VNFC_TYPE = "vnfc-type"; - public static final String VM_INSTANCE = "vm-instance"; - public static final String VM = "vm"; - public static final String VNFC = "vnfc"; - - public static final String DOCUMENT_PARAMETERS = "document-parameters"; - public static final String SERVICE_UUID = "service-uuid"; - public static final String DISTRIBUTION_ID = "distribution-id"; - - public static final String SERVICE_NAME = "service-name"; - public static final String SERVICE_DESCRIPTION ="service-description"; - public static final String SERVICE_ARTIFACTS = "service-artifacts"; - public static final String RESOURCE_UUID ="resource-uuid"; - public static final String RESOURCE_INSTANCE_NAME = "resource-instance-name"; - public static final String REOURCE_NAME = "resource-name"; - public static final String RESOURCE_VERSOIN ="resource-version"; - public static final String RESOURCE_TYPE= "resource-type"; - public static final String ARTIFACT_UUID ="artifact-uuid"; - public static final String ARTIFACT_NAME = "artifact-name"; - - public static final String ARTIFACT_VERSOIN = "artifact-version"; - public static final String ARTIFACT_DESRIPTION = "artifact-description"; - public static final String ARTIFACT_CONTENTS = "artifact-contents"; - public static final String REQUEST_INFORMATION = "request-information"; - public static final String INTERNAL_VERSION = "internal-versoin"; - - - - public static final String DB_DT_ARTIFACT_TRACKING = "DT_ARTIFACT_TRACKING"; - public static final String DB_SDC_REFERENCE = "ASDC_REFERENCE"; - public static final String SCHEMA_SDNCTL = "SDNCTL"; - public static final String GETARTIFACT = "getArtifact"; - public static final String USER_ID = "userID"; - public static final String ARTIFACT_TYPE = "artifact-type"; - public static final String STATUS = "status"; - public static final String UPLOADARTIFACT = "uploadArtifact"; - public static final String REQUETS_ID = "request-id"; - public static final String REQUEST_ACTION = "request-action"; - public static final String SOURCE = "source"; - public static final String DESIGN_SERVICE_PROPERTIES = "designService.properties"; - public static final String DESIGN_TOOL = "Design-tool"; - public static final String TECHNOLOGY = "technology"; - public static final String PROTOCOL = "protocol"; - public static final String SETPROTOCOLREFERENCE = "setProtocolReference"; - public static final String ACTION_LEVEL = "action-level"; - public static final String TEMPLATE = "template"; - public static final String SETINCART = "setInCart"; - public static final String INCART = "inCart"; - public static final String STOREPASSWORD = "storeProperty"; - } diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/EscapeUtils.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/EscapeUtils.java deleted file mode 100644 index 80f756f3a..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/EscapeUtils.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.services.util; - -import org.apache.commons.lang3.StringUtils; - -public class EscapeUtils { - - public EscapeUtils() { - // TODO Auto-generated constructor stub - } - - public static String escapeSql(String str) { - if (str == null) { - return null; - } - String searchList[] = new String[]{"'","\\", "\"" }; - String replacementList[] = new String[]{ "''","\\\\" ,"\\\""}; - return StringUtils.replaceEach(str,searchList, replacementList); - } - -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/SecureRestClientTrustManager.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/SecureRestClientTrustManager.java deleted file mode 100644 index 8e31d9540..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/SecureRestClientTrustManager.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.services.util; - -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -import javax.net.ssl.X509TrustManager; - - -public class SecureRestClientTrustManager implements X509TrustManager { - - @Override - public void checkClientTrusted(X509Certificate[] arg0, String arg1) - throws CertificateException { - } - - @Override - public void checkServerTrusted(X509Certificate[] arg0, String arg1) - throws CertificateException { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - - public boolean isClientTrusted(X509Certificate[] arg0) { - return true; - } - - public boolean isServerTrusted(X509Certificate[] arg0) { - return true; - } - -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/validator/ValidatorResponseProcessor.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/validator/ValidatorResponseProcessor.java deleted file mode 100644 index faea6a5ee..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/validator/ValidatorResponseProcessor.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.validator; - -import org.onap.appc.design.services.impl.DesignServicesImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ValidatorResponseProcessor { - - private static final Logger log = LoggerFactory.getLogger(ValidatorResponseProcessor.class); - public String parseResponse(Object execute, String action) { - return null; - } - -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/validator/ValidatorService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/validator/ValidatorService.java deleted file mode 100644 index 6660dd825..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/validator/ValidatorService.java +++ /dev/null @@ -1,168 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.validator; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringWriter; -import java.nio.charset.StandardCharsets; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.validation.Validator; - -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.app.VelocityEngine; -import org.apache.velocity.exception.MethodInvocationException; -import org.apache.velocity.exception.ParseErrorException; -import org.apache.velocity.exception.ResourceNotFoundException; -import org.apache.velocity.runtime.resource.loader.StringResourceLoader; -import org.apache.velocity.runtime.resource.util.StringResourceRepository; -import org.onap.appc.design.services.util.DesignServiceConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; -import com.fasterxml.jackson.dataformat.yaml.snakeyaml.introspector.BeanAccess; - -public class ValidatorService { - - private static final Logger log = LoggerFactory.getLogger(ValidatorService.class); - public String execute(String action, String payload, String dataType) throws Exception { - - String validateResponse = null; - log.info("Received validation for action= " + action + "Data :" + payload + " dataType = " + dataType); - if(dataType.equals(DesignServiceConstants.DATA_TYPE_XML)) - validateResponse = validateXML(payload); - else if(dataType.equals(DesignServiceConstants.DATA_TYPE_JSON)) - validateResponse = validateJOSN(payload); - else if(dataType.equals(DesignServiceConstants.DATA_TYPE_VELOCITY)) - validateResponse = validateVelocity(payload); - else if(dataType.equals(DesignServiceConstants.DATA_TYPE_YAML)) - validateResponse = validateYAML(payload); - - return validateResponse; - - } - - private String validateYAML(String payload) throws Exception { - ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); - try{ - InputStream is = new ByteArrayInputStream(payload.getBytes()); - - Reader in = new InputStreamReader(is); - Yaml yaml = new Yaml(); - yaml.setBeanAccess(BeanAccess.FIELD); - yaml.load(in); - return DesignServiceConstants.SUCCESS; - } - catch(Exception e){ - log.error("Not a Valid YAML Format "); - throw e; - } - - } - - private String validateVelocity(String payload) { - - try{ - VelocityEngine engine = new VelocityEngine(); - engine.setProperty(Velocity.RESOURCE_LOADER, "string"); - engine.addProperty("string.resource.loader.class", StringResourceLoader.class.getName()); - engine.addProperty("string.resource.loader.repository.static", "false"); - engine.init(); - StringResourceRepository repo = (StringResourceRepository) engine.getApplicationAttribute(StringResourceLoader.REPOSITORY_NAME_DEFAULT); - repo.putStringResource("TestTemplate", payload); - //Template t = ve.getTemplate(payload); - Template t = engine.getTemplate("TestTemplate"); - - return DesignServiceConstants.SUCCESS; - } - catch(ResourceNotFoundException e ){ - log.error("Not a Valid Velocity Template "); - throw e; - } - catch(ParseErrorException pe){ - log.error("Not a Valid Velocity Template "); - throw pe; - } - catch(MethodInvocationException mi){ - log.error("Not a Valid Velocity Template "); - throw mi; - } - } - - private String validateJOSN(String payload) throws Exception { - - try{ - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.readTree(payload); - return DesignServiceConstants.SUCCESS; - } catch(JsonProcessingException e){ - log.error("Not a Valid JOSN file "); - throw e; - } - - } - - private String validateXML(String payload) throws IOException, SAXException, ParserConfigurationException { - - try{ - - DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = dBF.newDocumentBuilder(); - InputSource is = new InputSource(payload); - builder.parse(new InputSource(new ByteArrayInputStream(payload.getBytes("utf-8")))); - return DesignServiceConstants.SUCCESS; - - } catch(ParserConfigurationException e){ - log.info("Error While parsing Payload : " + e.getMessage()); - throw e; - } - catch(SAXException se){ - log.info("Error While parsing Payload : " + se.getMessage()); - throw se; - } - catch(IOException io){ - log.info("Error While parsing Payload : " + io.getMessage()); - throw io; - } - } -} - diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/xinterface/XInterfaceService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/xinterface/XInterfaceService.java deleted file mode 100644 index 157e52937..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/xinterface/XInterfaceService.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.xinterface; - -import java.io.File; -import java.io.IOException; - -import com.google.common.base.Charsets; -import com.google.common.io.Files; - -public class XInterfaceService { - - - public String execute(String action, String payload) throws IOException { - //Remove this once hte interfaces are up and running - File targetFile = new File("/tmp/" + action + "-response.txt" ); - String interfaceResponse = Files.toString(targetFile, Charsets.UTF_8); - return interfaceResponse; - } - -} diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/xinterface/XResponseProcessor.java b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/xinterface/XResponseProcessor.java deleted file mode 100644 index aa72e2f09..000000000 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/xinterface/XResponseProcessor.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.xinterface; - -import java.io.File; -import java.io.IOException; - -import com.google.common.base.Charsets; -import com.google.common.io.Files; - -public class XResponseProcessor { - - public String parseResponse(Object execute, String action) { - return null; - } -} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestArifactHandlerClient.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestArifactHandlerClient.java new file mode 100644 index 000000000..9f6622e36 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestArifactHandlerClient.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.validator; + +import org.junit.Before; +import org.junit.Test; +import org.onap.appc.design.services.util.ArtifactHandlerClient; +import junit.framework.Assert; +import static org.mockito.Mockito.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.Properties; +import org.apache.commons.io.FileUtils; + +public class TestArifactHandlerClient { + + @Test + public void testCreateArtifactData(){ + + try{ + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": " + + content + + " } "; + String requestID ="0000"; + ArtifactHandlerClient ahi = new ArtifactHandlerClient(); + String value = ahi.createArtifactData(payload, requestID); + Assert.assertTrue(!value.isEmpty()); + }catch(Exception e) + { + } + } + + @Test + public void testExecute(){ + + try{ + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": " + + content + + " } "; + String rpc = "Post"; + ArtifactHandlerClient ahi = new ArtifactHandlerClient(); + ahi.execute(payload, rpc); + }catch(Exception e) + { + } + } +} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDBService.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDBService.java new file mode 100644 index 000000000..ffc2cadce --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDBService.java @@ -0,0 +1,242 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.validator; + +import java.io.File; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Properties; +import org.apache.commons.io.FileUtils; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.onap.appc.design.dbervices.DbService; +import org.onap.appc.design.dbervices.DesignDBService; +import org.onap.appc.design.propertyServices.PropertyUpdateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import junit.framework.Assert; +import org.powermock.reflect.Whitebox; + +public class TestDBService { + + private final org.slf4j.Logger logger = LoggerFactory.getLogger(TestDBService.class); + + @Ignore("Test is taking 60 seconds") + @Test + public void testGetDesigns() { + try { + String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\" }"; + DesignDBService dbservice = DesignDBService.initialise(); + dbservice.execute("getDesigns", payload, "1234"); + } catch (Exception e) { + } + } + + @Ignore("Test is taking 120 seconds") + @Test + public void testGetStatus() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } "; + DesignDBService dbservice = DesignDBService.initialise(); + DbService db = new DbService(); + Whitebox.invokeMethod(db, "getDbLibService"); + dbservice.execute("getStatus", payload, "1234"); + } catch (Exception e) { + } + } + + @Ignore("Test is taking 120 seconds") + @Test + public void testUploadArtifact() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } "; + DesignDBService dbservice = DesignDBService.initialise(); + DbService db = new DbService(); + Whitebox.invokeMethod(db, "getDbLibService"); + dbservice.execute("uploadArtifact", payload, "1234"); + } catch (Exception e) { + } + } + + @Ignore("Test is taking 120 seconds") + @Test + public void testGetArtifact() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + DbService db = new DbService(); + Whitebox.invokeMethod(db, "getDbLibService"); + design.execute("getArtifact", payload, "1234"); + } catch (Exception e) { + } + } + + @Ignore("Test is taking 120 seconds") + @Test + public void testSetIncart() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"action-level\":\"VNf\",\"protocol\":\"Test\", \"inCart\":\"Y\",\"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + DbService db = new DbService(); + Whitebox.invokeMethod(db, "getDbLibService"); + design.execute("setInCart", payload, "1234"); + } catch (Exception e) { + } + } + + @Ignore("Test is taking 120 seconds") + @Test + public void testSetProtocolReference() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"action-level\":\"VNf\",\"protocol\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + DbService db = new DbService(); + Whitebox.invokeMethod(db, "getDbLibService"); + design.execute("setProtocolReference", payload, "1234"); + } catch (Exception e) { + } + } + + @Ignore("Test is taking 120 seconds") + @Test + public void testSetStatus() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + DbService db = new DbService(); + Whitebox.invokeMethod(db, "getDbLibService"); + design.execute("setStatus", payload, "1234"); + } catch (Exception e) { + } + } + + @Ignore("Test is taking 120 seconds") + @Test + public void testGetArtifactReference() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + DbService db = new DbService(); + Whitebox.invokeMethod(db, "getDbLibService"); + design.execute("getArtifactReference", payload, "1234"); + } catch (Exception e) { + } + } + + @Ignore("Test is taking 120 seconds") + @Test + public void testGetGuiReference() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + DbService db = new DbService(); + Whitebox.invokeMethod(db, "getDbLibService"); + design.execute("getGuiReference", payload, "1234"); + } catch (Exception e) { + } + } + + @Test + public void testPropertyUpdateService() { + PropertyUpdateService ps = new PropertyUpdateService(); + } + + @Test + public void testLinkstatusRelationShip() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + Whitebox.invokeMethod(design, "linkstatusRelationShip", 1, 1, payload); + } catch (Exception e) { + } + } + + @Test + public void testGetSDCReferenceID() { + + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + Whitebox.invokeMethod(design, "getSDCReferenceID", payload); + } catch (Exception e) { + } + } + + @Test + public void testGetDataFromActionStatus() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + Whitebox.invokeMethod(design, "getDataFromActionStatus", payload, "Test"); + } catch (Exception e) { + } + } + + @Test + public void testSetActionStatus() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + Whitebox.invokeMethod(design, "setActionStatus", payload, "Accepted"); + } catch (Exception e) { + } + } + + @Test + public void testGetSDCArtifactIDbyRequestID() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + Whitebox.invokeMethod(design, "getSDCArtifactIDbyRequestID", "0"); + } catch (Exception e) { + } + } + + @Test + public void testCreateArtifactTrackingRecord() { + try { + String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); + String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; + DesignDBService design = DesignDBService.initialise(); + Whitebox.invokeMethod(design, "createArtifactTrackingRecord",payload,"0",1,1); + } catch (Exception e) { + } + } +} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDbResponse.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDbResponse.java new file mode 100644 index 000000000..73e3dfc99 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDbResponse.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.validator; + +import java.util.ArrayList; +import org.junit.Test; +import org.onap.appc.design.dbervices.DbResponseProcessor; + +public class TestDbResponse { + + @Test + public void testDbResponse() { + DbResponseProcessor dbResponse = new DbResponseProcessor(); + try { + dbResponse.parseResponse("Test", "getDesigns"); + dbResponse.parseResponse("Test", "addInCart"); + dbResponse.parseResponse("Test", "getArtifactReference"); + dbResponse.parseResponse("Test", "getArtifact"); + dbResponse.parseResponse("Test", "getGUIReference"); + dbResponse.parseResponse("Test", "getStatus"); + dbResponse.parseResponse("Test", "uploadArtifact"); + dbResponse.parseResponse("Test", "setProtocolReference"); + dbResponse.parseResponse("Test", "setInCart"); + dbResponse.parseResponse("Test", "getStatus"); + dbResponse.parseResponse("Test", "Test"); + } catch (Exception e) { + } + } +} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDesigndata.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDesigndata.java new file mode 100644 index 000000000..f5c4bfffd --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestDesigndata.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.validator; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.appc.design.data.ArtifactInfo; +import org.onap.appc.design.data.DesignInfo; +import org.onap.appc.design.data.DesignRequest; +import org.onap.appc.design.data.DesignResponse; +import org.onap.appc.design.data.StatusInfo; + +public class TestDesigndata { + + DesignResponse dr = new DesignResponse(); + + @Test + public void testSetUserID() { + dr.setUserId("00000"); + dr.getUserId(); + } + + @Test + public void testSetDesignInfoList() { + DesignInfo di = new DesignInfo(); + List li = new ArrayList(); + di.setAction("TestAction"); + di.setArtifact_name("TestName"); + di.setArtifact_type("TestType"); + di.setInCart("TestCart"); + di.setProtocol("TestProtocol"); + di.setVnf_type("TestVNF"); + di.setVnfc_type("TestVNFC"); + li.add(di); + dr.setDesignInfoList(li); + } + + @Test + public void testSetArtifactInfo() { + ArtifactInfo ai = new ArtifactInfo(); + List li = new ArrayList(); + ai.setArtifact_content("TestContent"); + li.add(ai); + dr.setArtifactInfo(li); + } + + @Test + public void testStatusInfo() { + StatusInfo si = new StatusInfo(); + List li = new ArrayList(); + si.setAction("TestAction"); + si.setAction_status("TestActionStatus"); + si.setArtifact_status("TestArtifactStatus"); + si.setVnf_type("TestVNF"); + si.setVnfc_type("TestVNFC"); + li.add(si); + dr.setStatusInfoList(li); + } + + @Test + public void testDesignRequest() { + DesignRequest dreq = new DesignRequest(); + dreq.setAction("TestAction"); + dreq.setArtifact_contents("TestContent"); + dreq.setArtifact_name("TestName"); + dreq.setProtocol("TestProtocol"); + dreq.setUserId("0000"); + dreq.setVnf_type("testvnf"); + dreq.setVnfc_type("testvnfc"); + dreq.getAction(); + dreq.getArtifact_contents(); + dreq.getArtifact_name(); + dreq.getProtocol(); + dreq.getUserId(); + dreq.getVnf_type(); + dreq.getVnfc_type(); + dreq.toString(); + } +} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestEscapeUtils.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestEscapeUtils.java new file mode 100644 index 000000000..4a99d42e9 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestEscapeUtils.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.validator; + +import java.io.IOException; +import org.junit.Test; +import org.onap.appc.design.services.util.EscapeUtils; +import org.onap.appc.design.xinterface.XInterfaceService; +import org.onap.appc.design.xinterface.XResponseProcessor; +import junit.framework.Assert; + +public class TestEscapeUtils { + + @Test + public void testEscapeUtils() { + + EscapeUtils escapeUtils = new EscapeUtils(); + String str = escapeUtils.escapeSql("\\'Test Data\\'"); + assert (true); + } + + @Test + public void testXResponseProcessor(){ + + XResponseProcessor xr = new XResponseProcessor(); + Object o = new Object(); + xr.parseResponse(o, "Test"); + Assert.assertEquals(null, null); + } +} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestValidatorService.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestValidatorService.java new file mode 100644 index 000000000..622483c66 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/validator/TestValidatorService.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.validator; + +import java.io.InputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Properties; +import org.junit.Before; +import org.junit.Test; +import org.onap.appc.design.services.util.DesignServiceConstants; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import junit.framework.Assert; + +public class TestValidatorService { + +//Onap Migration + + private final Logger logger = LoggerFactory.getLogger(TestValidatorService.class); + @Test + public void testValidXMLValidation(){ + String response = null; + String xmlString = "" + "create" + "" + "" + + "SDN-GP" + "" + "" + "" + ""; + + ValidatorService vs = new ValidatorService(); + try { + response = vs.execute("", xmlString, "XML"); + } catch (Exception e) { + } + Assert.assertEquals("success", response); + + } + @Test + public void testInvalidXMLValidation() { + String response = null; + String xmlString = "" + "create" + "" + "" + + "SDN-GP" + "" + "" + ""; + + ValidatorService vs = new ValidatorService(); + try { + response = vs.execute("", xmlString, "XML"); + } catch (Exception e) { + } + Assert.assertEquals(null, response); + } + @Test + public void testYAMLValidation() { + String response = null; + String YAMLString = "en:"; + ValidatorService vs = new ValidatorService(); + try { + response = vs.execute("", YAMLString, "YAML"); + } catch (Exception e) { + } + Assert.assertEquals("success", response); + } + @Test + public void testInvalidYAMLValidation() { + String response = null; + String YAMLString = "Test \n A:"; + ValidatorService vs = new ValidatorService(); + try { + response = vs.execute("", YAMLString, "YAML"); + } catch (Exception e) { + } + + Assert.assertEquals(null, response); + } + + @Test + public void testJSONValidation(){ + String response = null; + String YAMLString = "{\"Test\": \"Test1\" }"; + + ValidatorService vs = new ValidatorService(); + try { + response = vs.execute("", YAMLString, "JSON"); + } catch (Exception e) { + } + Assert.assertEquals("success", response); + } + @Test + public void testInvalidJSONValidation(){ + String response = null; + String YAMLString = "{\"Test\" \"Test1\" }"; + ValidatorService vs = new ValidatorService(); + try { + response = vs.execute("", YAMLString, "JSON"); + } catch (Exception e) { + } + Assert.assertEquals(null, response); + } + + @Test + public void testInvalidvalidateVelocity(){ + String response = null; + String validateVelocity = "{\"Test\" \"Test1\" }"; + ValidatorService vs = new ValidatorService(); + try { + response = vs.execute("", validateVelocity, "Velocity"); + } catch (Exception e) { + } + Assert.assertEquals(null, response); + + } +} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java deleted file mode 100644 index 9f6622e36..000000000 --- a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.validator; - -import org.junit.Before; -import org.junit.Test; -import org.onap.appc.design.services.util.ArtifactHandlerClient; -import junit.framework.Assert; -import static org.mockito.Mockito.*; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.Properties; -import org.apache.commons.io.FileUtils; - -public class TestArifactHandlerClient { - - @Test - public void testCreateArtifactData(){ - - try{ - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": " - + content + - " } "; - String requestID ="0000"; - ArtifactHandlerClient ahi = new ArtifactHandlerClient(); - String value = ahi.createArtifactData(payload, requestID); - Assert.assertTrue(!value.isEmpty()); - }catch(Exception e) - { - } - } - - @Test - public void testExecute(){ - - try{ - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": " - + content + - " } "; - String rpc = "Post"; - ArtifactHandlerClient ahi = new ArtifactHandlerClient(); - ahi.execute(payload, rpc); - }catch(Exception e) - { - } - } -} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java deleted file mode 100644 index ffc2cadce..000000000 --- a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java +++ /dev/null @@ -1,242 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.validator; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Properties; -import org.apache.commons.io.FileUtils; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.onap.appc.design.dbervices.DbService; -import org.onap.appc.design.dbervices.DesignDBService; -import org.onap.appc.design.propertyServices.PropertyUpdateService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import junit.framework.Assert; -import org.powermock.reflect.Whitebox; - -public class TestDBService { - - private final org.slf4j.Logger logger = LoggerFactory.getLogger(TestDBService.class); - - @Ignore("Test is taking 60 seconds") - @Test - public void testGetDesigns() { - try { - String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\" }"; - DesignDBService dbservice = DesignDBService.initialise(); - dbservice.execute("getDesigns", payload, "1234"); - } catch (Exception e) { - } - } - - @Ignore("Test is taking 120 seconds") - @Test - public void testGetStatus() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } "; - DesignDBService dbservice = DesignDBService.initialise(); - DbService db = new DbService(); - Whitebox.invokeMethod(db, "getDbLibService"); - dbservice.execute("getStatus", payload, "1234"); - } catch (Exception e) { - } - } - - @Ignore("Test is taking 120 seconds") - @Test - public void testUploadArtifact() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } "; - DesignDBService dbservice = DesignDBService.initialise(); - DbService db = new DbService(); - Whitebox.invokeMethod(db, "getDbLibService"); - dbservice.execute("uploadArtifact", payload, "1234"); - } catch (Exception e) { - } - } - - @Ignore("Test is taking 120 seconds") - @Test - public void testGetArtifact() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - DbService db = new DbService(); - Whitebox.invokeMethod(db, "getDbLibService"); - design.execute("getArtifact", payload, "1234"); - } catch (Exception e) { - } - } - - @Ignore("Test is taking 120 seconds") - @Test - public void testSetIncart() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"action-level\":\"VNf\",\"protocol\":\"Test\", \"inCart\":\"Y\",\"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - DbService db = new DbService(); - Whitebox.invokeMethod(db, "getDbLibService"); - design.execute("setInCart", payload, "1234"); - } catch (Exception e) { - } - } - - @Ignore("Test is taking 120 seconds") - @Test - public void testSetProtocolReference() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"action-level\":\"VNf\",\"protocol\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - DbService db = new DbService(); - Whitebox.invokeMethod(db, "getDbLibService"); - design.execute("setProtocolReference", payload, "1234"); - } catch (Exception e) { - } - } - - @Ignore("Test is taking 120 seconds") - @Test - public void testSetStatus() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - DbService db = new DbService(); - Whitebox.invokeMethod(db, "getDbLibService"); - design.execute("setStatus", payload, "1234"); - } catch (Exception e) { - } - } - - @Ignore("Test is taking 120 seconds") - @Test - public void testGetArtifactReference() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - DbService db = new DbService(); - Whitebox.invokeMethod(db, "getDbLibService"); - design.execute("getArtifactReference", payload, "1234"); - } catch (Exception e) { - } - } - - @Ignore("Test is taking 120 seconds") - @Test - public void testGetGuiReference() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - DbService db = new DbService(); - Whitebox.invokeMethod(db, "getDbLibService"); - design.execute("getGuiReference", payload, "1234"); - } catch (Exception e) { - } - } - - @Test - public void testPropertyUpdateService() { - PropertyUpdateService ps = new PropertyUpdateService(); - } - - @Test - public void testLinkstatusRelationShip() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - Whitebox.invokeMethod(design, "linkstatusRelationShip", 1, 1, payload); - } catch (Exception e) { - } - } - - @Test - public void testGetSDCReferenceID() { - - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - Whitebox.invokeMethod(design, "getSDCReferenceID", payload); - } catch (Exception e) { - } - } - - @Test - public void testGetDataFromActionStatus() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - Whitebox.invokeMethod(design, "getDataFromActionStatus", payload, "Test"); - } catch (Exception e) { - } - } - - @Test - public void testSetActionStatus() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - Whitebox.invokeMethod(design, "setActionStatus", payload, "Accepted"); - } catch (Exception e) { - } - } - - @Test - public void testGetSDCArtifactIDbyRequestID() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - Whitebox.invokeMethod(design, "getSDCArtifactIDbyRequestID", "0"); - } catch (Exception e) { - } - } - - @Test - public void testCreateArtifactTrackingRecord() { - try { - String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact")); - String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\": "+ content + " } "; - DesignDBService design = DesignDBService.initialise(); - Whitebox.invokeMethod(design, "createArtifactTrackingRecord",payload,"0",1,1); - } catch (Exception e) { - } - } -} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDbResponse.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDbResponse.java deleted file mode 100644 index 73e3dfc99..000000000 --- a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDbResponse.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.validator; - -import java.util.ArrayList; -import org.junit.Test; -import org.onap.appc.design.dbervices.DbResponseProcessor; - -public class TestDbResponse { - - @Test - public void testDbResponse() { - DbResponseProcessor dbResponse = new DbResponseProcessor(); - try { - dbResponse.parseResponse("Test", "getDesigns"); - dbResponse.parseResponse("Test", "addInCart"); - dbResponse.parseResponse("Test", "getArtifactReference"); - dbResponse.parseResponse("Test", "getArtifact"); - dbResponse.parseResponse("Test", "getGUIReference"); - dbResponse.parseResponse("Test", "getStatus"); - dbResponse.parseResponse("Test", "uploadArtifact"); - dbResponse.parseResponse("Test", "setProtocolReference"); - dbResponse.parseResponse("Test", "setInCart"); - dbResponse.parseResponse("Test", "getStatus"); - dbResponse.parseResponse("Test", "Test"); - } catch (Exception e) { - } - } -} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java deleted file mode 100644 index f5c4bfffd..000000000 --- a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.validator; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.onap.appc.design.data.ArtifactInfo; -import org.onap.appc.design.data.DesignInfo; -import org.onap.appc.design.data.DesignRequest; -import org.onap.appc.design.data.DesignResponse; -import org.onap.appc.design.data.StatusInfo; - -public class TestDesigndata { - - DesignResponse dr = new DesignResponse(); - - @Test - public void testSetUserID() { - dr.setUserId("00000"); - dr.getUserId(); - } - - @Test - public void testSetDesignInfoList() { - DesignInfo di = new DesignInfo(); - List li = new ArrayList(); - di.setAction("TestAction"); - di.setArtifact_name("TestName"); - di.setArtifact_type("TestType"); - di.setInCart("TestCart"); - di.setProtocol("TestProtocol"); - di.setVnf_type("TestVNF"); - di.setVnfc_type("TestVNFC"); - li.add(di); - dr.setDesignInfoList(li); - } - - @Test - public void testSetArtifactInfo() { - ArtifactInfo ai = new ArtifactInfo(); - List li = new ArrayList(); - ai.setArtifact_content("TestContent"); - li.add(ai); - dr.setArtifactInfo(li); - } - - @Test - public void testStatusInfo() { - StatusInfo si = new StatusInfo(); - List li = new ArrayList(); - si.setAction("TestAction"); - si.setAction_status("TestActionStatus"); - si.setArtifact_status("TestArtifactStatus"); - si.setVnf_type("TestVNF"); - si.setVnfc_type("TestVNFC"); - li.add(si); - dr.setStatusInfoList(li); - } - - @Test - public void testDesignRequest() { - DesignRequest dreq = new DesignRequest(); - dreq.setAction("TestAction"); - dreq.setArtifact_contents("TestContent"); - dreq.setArtifact_name("TestName"); - dreq.setProtocol("TestProtocol"); - dreq.setUserId("0000"); - dreq.setVnf_type("testvnf"); - dreq.setVnfc_type("testvnfc"); - dreq.getAction(); - dreq.getArtifact_contents(); - dreq.getArtifact_name(); - dreq.getProtocol(); - dreq.getUserId(); - dreq.getVnf_type(); - dreq.getVnfc_type(); - dreq.toString(); - } -} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java deleted file mode 100644 index 4a99d42e9..000000000 --- a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.validator; - -import java.io.IOException; -import org.junit.Test; -import org.onap.appc.design.services.util.EscapeUtils; -import org.onap.appc.design.xinterface.XInterfaceService; -import org.onap.appc.design.xinterface.XResponseProcessor; -import junit.framework.Assert; - -public class TestEscapeUtils { - - @Test - public void testEscapeUtils() { - - EscapeUtils escapeUtils = new EscapeUtils(); - String str = escapeUtils.escapeSql("\\'Test Data\\'"); - assert (true); - } - - @Test - public void testXResponseProcessor(){ - - XResponseProcessor xr = new XResponseProcessor(); - Object o = new Object(); - xr.parseResponse(o, "Test"); - Assert.assertEquals(null, null); - } -} diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java deleted file mode 100644 index 622483c66..000000000 --- a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.design.validator; - -import java.io.InputStream; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Properties; -import org.junit.Before; -import org.junit.Test; -import org.onap.appc.design.services.util.DesignServiceConstants; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import junit.framework.Assert; - -public class TestValidatorService { - -//Onap Migration - - private final Logger logger = LoggerFactory.getLogger(TestValidatorService.class); - @Test - public void testValidXMLValidation(){ - String response = null; - String xmlString = "" + "create" + "" + "" - + "SDN-GP" + "" + "" + "" + ""; - - ValidatorService vs = new ValidatorService(); - try { - response = vs.execute("", xmlString, "XML"); - } catch (Exception e) { - } - Assert.assertEquals("success", response); - - } - @Test - public void testInvalidXMLValidation() { - String response = null; - String xmlString = "" + "create" + "" + "" - + "SDN-GP" + "" + "" + ""; - - ValidatorService vs = new ValidatorService(); - try { - response = vs.execute("", xmlString, "XML"); - } catch (Exception e) { - } - Assert.assertEquals(null, response); - } - @Test - public void testYAMLValidation() { - String response = null; - String YAMLString = "en:"; - ValidatorService vs = new ValidatorService(); - try { - response = vs.execute("", YAMLString, "YAML"); - } catch (Exception e) { - } - Assert.assertEquals("success", response); - } - @Test - public void testInvalidYAMLValidation() { - String response = null; - String YAMLString = "Test \n A:"; - ValidatorService vs = new ValidatorService(); - try { - response = vs.execute("", YAMLString, "YAML"); - } catch (Exception e) { - } - - Assert.assertEquals(null, response); - } - - @Test - public void testJSONValidation(){ - String response = null; - String YAMLString = "{\"Test\": \"Test1\" }"; - - ValidatorService vs = new ValidatorService(); - try { - response = vs.execute("", YAMLString, "JSON"); - } catch (Exception e) { - } - Assert.assertEquals("success", response); - } - @Test - public void testInvalidJSONValidation(){ - String response = null; - String YAMLString = "{\"Test\" \"Test1\" }"; - ValidatorService vs = new ValidatorService(); - try { - response = vs.execute("", YAMLString, "JSON"); - } catch (Exception e) { - } - Assert.assertEquals(null, response); - } - - @Test - public void testInvalidvalidateVelocity(){ - String response = null; - String validateVelocity = "{\"Test\" \"Test1\" }"; - ValidatorService vs = new ValidatorService(); - try { - response = vs.execute("", validateVelocity, "Velocity"); - } catch (Exception e) { - } - Assert.assertEquals(null, response); - - } -} -- cgit 1.2.3-korg