aboutsummaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp
diff options
context:
space:
mode:
Diffstat (limited to 'appc-inbound/appc-design-services/provider/src/main/java/org/openecomp')
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/ArtifactInfo.java42
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignInfo.java115
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignRequest.java132
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/DesignResponse.java77
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/data/StatusInfo.java86
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DbResponseProcessor.java110
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DbService.java146
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/DesignDBService.java645
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/dbervices/RequestValidator.java126
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/propertyServices/PropertyUpdateService.java30
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/DesignServiceProvider.java72
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/impl/DesignServicesImpl.java160
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/ArtifactHandlerClient.java187
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/DesignServiceConstants.java106
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/EscapeUtils.java44
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/services/util/SecureRestClientTrustManager.java58
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/validator/ValidatorResponseProcessor.java38
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/validator/ValidatorService.java168
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/xinterface/XInterfaceService.java43
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/appc/design/xinterface/XResponseProcessor.java38
20 files changed, 2423 insertions, 0 deletions
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
new file mode 100644
index 000000000..41c02eac9
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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
new file mode 100644
index 000000000..96e429f02
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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
new file mode 100644
index 000000000..3c980b44f
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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.openecomp.appc.design.services.util.DesignServiceConstants;
+import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager;
+import org.openecomp.sdnc.sli.resource.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
new file mode 100644
index 000000000..65fac2554
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.appc.design.data;
+
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class DesignResponse{
+
+
+ @JsonProperty("userID")
+ String userId ;
+
+ @JsonProperty("designInfo")
+ List<DesignInfo> designInfoList;
+
+ @JsonProperty("statusInfo")
+ List<StatusInfo> statusInfoList;
+
+ @JsonProperty("artifactInfo")
+ List<ArtifactInfo> artifactInfo;
+
+
+ public List<ArtifactInfo> getArtifactInfo() {
+ return artifactInfo;
+ }
+
+ public void setArtifactInfo(List<ArtifactInfo> artifactInfo) {
+ this.artifactInfo = artifactInfo;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public List<DesignInfo> getDesignInfoList() {
+ return designInfoList;
+ }
+
+ public void setDesignInfoList(List<DesignInfo> designInfoList) {
+ this.designInfoList = designInfoList;
+ }
+
+ public List<StatusInfo> getStatusInfoList() {
+ return statusInfoList;
+ }
+
+ public void setStatusInfoList(List<StatusInfo> 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
new file mode 100644
index 000000000..32a3e79e5
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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
new file mode 100644
index 000000000..b6f6510a7
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.appc.design.dbervices;
+
+import org.openecomp.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
new file mode 100644
index 000000000..3c5ac740b
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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.openecomp.sdnc.sli.provider.SvcLogicService;
+import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager;
+import org.openecomp.sdnc.sli.resource.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.openecomp.sdnc.sli.resource.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 = DBResourceManager.create(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<String> 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<String> 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
new file mode 100644
index 000000000..ba126aff2
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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.openecomp.appc.design.data.ArtifactInfo;
+import org.openecomp.appc.design.data.DesignInfo;
+import org.openecomp.appc.design.data.DesignResponse;
+import org.openecomp.appc.design.data.StatusInfo;
+import org.openecomp.appc.design.services.util.ArtifactHandlerClient;
+import org.openecomp.appc.design.services.util.DesignServiceConstants;
+import org.openecomp.sdnc.sli.SvcLogicResource;
+import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager;
+import org.openecomp.sdnc.sli.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<String> 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<String> 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 asdc_artifact_id = getASDCArtifactIDbyRequestID(requestID);
+ int asdc_reference_id = getASDCReferenceID(payload);
+ createArtifactTrackingRecord(payload, requestID,asdc_artifact_id, asdc_reference_id );
+ String status = getDataFromActionStatus(payload, "STATUS");
+ if(status == null || status.isEmpty())
+ setActionStatus(payload, "Not Tested");
+ linkstatusRelationShip(asdc_artifact_id,asdc_reference_id, payload);
+
+ }
+ catch(Exception e){
+ e.printStackTrace();
+ throw e;
+ }
+ return "{\"update\" : \"success\" } ";
+
+ }
+
+ private void linkstatusRelationShip(int asdc_artifact_id, int asdc_reference_id, String payload) throws Exception {
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ JsonNode payloadObject = objectMapper.readTree(payload);
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(String.valueOf(asdc_artifact_id));
+ argList.add(String.valueOf(asdc_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 getASDCReferenceID(String payload) throws Exception {
+
+ String vnfc_type = null;
+ ObjectMapper objectMapper = new ObjectMapper();
+ JsonNode payloadObject = objectMapper.readTree(payload);
+ ArrayList<String> 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 asdc_reference_id = 0;
+ while(data.next()) {
+ asdc_reference_id = data.getInt("ASDC_REFERENCE_ID");
+ }
+ log.info("Got asdc_reference_id = " + asdc_reference_id );
+ return asdc_reference_id;
+
+ }
+
+ private String getDataFromActionStatus(String payload, String dataValue) throws Exception {
+ String status = null ;
+ ObjectMapper objectMapper = new ObjectMapper();
+ JsonNode payloadObject = objectMapper.readTree(payload);
+ ArrayList<String> 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<String> 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 asdc_artifact_id, int asdc_reference_id) throws Exception {
+ String vnfc_type = null;
+ ObjectMapper objectMapper = new ObjectMapper();
+ JsonNode payloadObject = objectMapper.readTree(payload);
+
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(String.valueOf(asdc_artifact_id));
+ argList.add(String.valueOf(asdc_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 getASDCArtifactIDbyRequestID(String requestID) throws Exception {
+ log.info("Starting getArtifactIDbyRequestID DB Operation");
+ int artifact_id = 0;
+ try{
+ ArrayList<String> 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 ASDC_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<String> 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<ArtifactInfo> artifactInfoList = new ArrayList<ArtifactInfo>();
+ 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<String> 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<StatusInfo> statusInfoList = new ArrayList<StatusInfo>();
+ 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<String> 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<StatusInfo> statusInfoList = new ArrayList<StatusInfo>();
+ 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_ASDC_REFERENCE +
+ // " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_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<String> 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_ASDC_REFERENCE +
+ " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? ";
+
+ DesignResponse designResponse = new DesignResponse();
+ designResponse.setUserId(UserID);
+ List<DesignInfo> designInfoList = new ArrayList<DesignInfo>();
+ 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
new file mode 100644
index 000000000..0a9dd670a
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.appc.design.dbervices;
+
+import org.openecomp.appc.design.services.util.ArtifactHandlerClient;
+import org.openecomp.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
new file mode 100644
index 000000000..79746ebc1
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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
new file mode 100644
index 000000000..641041979
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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.openecomp.appc.rev170627.DesignServicesService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.openecomp.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 <DesignServicesService> 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
new file mode 100644
index 000000000..e800b8704
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.appc.design.services.impl;
+
+import java.util.concurrent.Future;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.DbserviceInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.DbserviceOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.DbserviceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.DesignServicesService;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.ValidatorInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.ValidatorOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.ValidatorOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.XinterfaceserviceInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.XinterfaceserviceOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.XinterfaceserviceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.data.DataBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.status.StatusBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.openecomp.appc.design.dbervices.DbResponseProcessor;
+import org.openecomp.appc.design.dbervices.DesignDBService;
+import org.openecomp.appc.design.services.util.DesignServiceConstants;
+import org.openecomp.appc.design.validator.ValidatorResponseProcessor;
+import org.openecomp.appc.design.validator.ValidatorService;
+import org.openecomp.appc.design.xinterface.XInterfaceService;
+import org.openecomp.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<RpcResult<DbserviceOutput>> 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<DbserviceOutput> result = RpcResultBuilder.<DbserviceOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<XinterfaceserviceOutput>> 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<XinterfaceserviceOutput> result = RpcResultBuilder.<XinterfaceserviceOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<ValidatorOutput>> 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<ValidatorOutput> result = RpcResultBuilder.<ValidatorOutput>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
new file mode 100644
index 000000000..6254728ee
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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.openecomp.sdnc.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, "StoreAsdcDocumentRequest");
+ 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<String, String> execute(String payload, String rpc) throws Exception{
+ log.info("Configuring Rest Operation for Payload " + payload + " RPC : " + rpc );
+ HashMap<String, String> outputMessage = new HashMap<String, String>();
+ 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
new file mode 100644
index 000000000..702d1d1fa
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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_ASDC_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
new file mode 100644
index 000000000..ae0f7f77b
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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
new file mode 100644
index 000000000..69014b5e4
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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
new file mode 100644
index 000000000..1af4a97a0
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.appc.design.validator;
+
+import org.openecomp.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
new file mode 100644
index 000000000..2ab327530
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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.openecomp.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
new file mode 100644
index 000000000..16a4b40da
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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
new file mode 100644
index 000000000..33e8438f0
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/openecomp/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.openecomp.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;
+ }
+}