Junit Cases for Artifact Handler. 33/10933/4
authorRamya Balaji <rb111y@att.com>
Mon, 11 Sep 2017 19:50:25 +0000 (15:50 -0400)
committerSkip Wonnell <skip@att.com>
Tue, 12 Sep 2017 12:50:28 +0000 (12:50 +0000)
Issue-ID : APPC-168
Change-Id: Id2b211d5656ffa8d5f326c30d745bc497e76f4d0
Signed-off-by: Ramya Balaji <rb111y@att.com>
14 files changed:
appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/FlowControlDBServiceTest.java
appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/FlowControlNodeTest.java
appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/RestExecutorTest.java
appc-inbound/appc-artifact-handler/provider/pom.xml
appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java
appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java
appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/DBServiceTest.java [new file with mode: 0644]
appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/MockDBService.java [moved from appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/TestArtifactHandlerNode.java with 60% similarity]
appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/MockSvcLogicResource.java [new file with mode: 0644]
appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNodeTest.java [new file with mode: 0644]
appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/MockArtifactHandlerNode.java [new file with mode: 0644]
appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/utils/ArtifactHandlerProviderUtilTest.java [new file with mode: 0644]
appc-inbound/appc-artifact-handler/provider/src/test/resources/templates/reference_template
appc-inbound/appc-artifact-handler/provider/src/test/resources/templates/reference_template.json [new file with mode: 0755]

index 9b86243..fa29773 100644 (file)
@@ -1,3 +1,27 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Amdocs\r
+ * =============================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
 package org.openecomp.appc.flow.executor.node;\r
 \r
 import static org.mockito.Matchers.any;\r
index 8f66fd9..6bb1cb2 100644 (file)
@@ -1,6 +1,29 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Amdocs\r
+ * =============================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
 package org.openecomp.appc.flow.executor.node;\r
 \r
-import static org.junit.Assert.*;\r
 import static org.mockito.Mockito.doReturn;\r
 import static org.mockito.Mockito.verify;\r
 \r
index b2c4559..e943c9b 100644 (file)
@@ -1,6 +1,29 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Amdocs\r
+ * =============================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
 package org.openecomp.appc.flow.executor.node;\r
 \r
-import static org.junit.Assert.*;\r
 import static org.mockito.Matchers.any;\r
 import static org.mockito.Matchers.anyString;\r
 import static org.mockito.Mockito.doReturn;\r
index 0e7f76f..35aea7e 100755 (executable)
@@ -144,7 +144,6 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>sal-common-util</artifactId>
                        </dependency>
-
                <dependency>
                        <groupId>org.onap.ccsdk.sli.core</groupId>
                        <artifactId>sli-common</artifactId>
@@ -204,5 +203,15 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
                        <version>${ccsdk.sli.adaptors.version}</version>
                        <scope>compile</scope>
                </dependency>
+               <dependency>
+                       <groupId>org.powermock</groupId>
+                       <artifactId>powermock-api-mockito</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.mockito</groupId>
+                       <artifactId>mockito-core</artifactId>
+                       <scope>test</scope>
+               </dependency>
        </dependencies>
 </project>
index fea4a27..470f068 100644 (file)
@@ -42,27 +42,37 @@ public class DBService {
     private static final EELFLogger log = EELFManager.getInstance().getLogger(DBService.class);
     private SvcLogicResource serviceLogic;
     private static DBService dgGeneralDBService = null;
+
     public static DBService initialise() {
         if (dgGeneralDBService == null) {
             dgGeneralDBService = new DBService();
         }
         return dgGeneralDBService;
     }
+
     private DBService() {
         if (serviceLogic == null) {
             serviceLogic = new SqlResource();
         }
     }
 
-    public String getInternalVersionNumber(SvcLogicContext ctx, String artifactName, String prefix) throws SvcLogicException {
+    protected DBService(SqlResource svcLogic) {
+        if (serviceLogic == null) {
+            serviceLogic = svcLogic;
+        }
+    }
+
+    public String getInternalVersionNumber(SvcLogicContext ctx, String artifactName, String prefix)
+            throws SvcLogicException {
         String fn = "DBService.getInternalVersionNumber";
-        QueryStatus status = null;    
-        String  artifactInternalVersion = null;
-        if (serviceLogic != null && ctx != null) {    
-            String key = "select max(internal_version) as maximum from ASDC_ARTIFACTS  WHERE ARTIFACT_NAME = '" + artifactName + "'";    
+        QueryStatus status = null;
+        String artifactInternalVersion = null;
+        if (serviceLogic != null && ctx != null) {
+            String key = "select max(internal_version) as maximum from ASDC_ARTIFACTS  WHERE ARTIFACT_NAME = '"
+                    + artifactName + "'";
             log.info("Getting internal Versoin :" + key);
             status = serviceLogic.query("SQL", false, null, key, prefix, null, ctx);
-            if(status.toString().equals("FAILURE"))
+            if (status.toString().equals("FAILURE"))
                 throw new SvcLogicException("Error - getting internal Artifact Number");
             artifactInternalVersion = ctx.getAttribute("maximum");
             log.info("Internal Version received as : " + artifactInternalVersion);
@@ -73,59 +83,55 @@ public class DBService {
         }
         return artifactInternalVersion;
     }
+
     public String getArtifactID(SvcLogicContext ctx, String artifactName) throws SvcLogicException {
         String fn = "DBService.getArtifactID";
-        QueryStatus status = null;    
-        String  artifactID = null;
-        if (serviceLogic != null && ctx != null) {    
-            String key = "select max(ASDC_ARTIFACTS_ID) as id from ASDC_ARTIFACTS  WHERE ARTIFACT_NAME = '" + artifactName + "'";    
+        QueryStatus status = null;
+        String artifactID = null;
+        if (serviceLogic != null && ctx != null) {
+            String key = "select max(ASDC_ARTIFACTS_ID) as id from ASDC_ARTIFACTS  WHERE ARTIFACT_NAME = '"
+                    + artifactName + "'";
             log.info("Getting Artifact ID String :" + key);
             status = serviceLogic.query("SQL", false, null, key, null, null, ctx);
-            if(status.toString().equals("FAILURE"))
+            if (status.toString().equals("FAILURE"))
                 throw new SvcLogicException("Error - getting  Artifact ID from database");
             artifactID = ctx.getAttribute("id");
             log.info("SDC_ARTIFACTS_ID received as : " + ctx.getAttribute("id"));
         }
         return artifactID;
     }
+
     public QueryStatus saveArtifacts(SvcLogicContext ctx, int intversion) throws SvcLogicException {
         String fn = "DBService.saveArtifacts";
         QueryStatus status = null;
         if (serviceLogic != null && ctx != null) {
-            String key = "INSERT INTO ASDC_ARTIFACTS " +
-                    "SET SERVICE_UUID    =  $service-uuid , " + 
-                    " DISTRIBUTION_ID    =  $distribution-id ," + 
-                    " SERVICE_NAME    =  $service-name ," + 
-                    " SERVICE_DESCRIPTION    =  $service-description ," + 
-                    " RESOURCE_UUID    = $resource-uuid ," + 
-                    " RESOURCE_INSTANCE_NAME    = $resource-instance-name ," + 
-                    " RESOURCE_NAME    = $resource-name ," + 
-                    " RESOURCE_VERSION    = $resource-version ," + 
-                    " RESOURCE_TYPE    = $resource-type ," + 
-                    " ARTIFACT_UUID    = $artifact-uuid ," + 
-                    " ARTIFACT_TYPE    = $artifact-type ," + 
-                    " ARTIFACT_VERSION    = $artifact-version ," + 
-                    " ARTIFACT_DESCRIPTION    = $artifact-description ," + 
-                    " INTERNAL_VERSION    = " + intversion + "," + 
-                    " ARTIFACT_NAME       =  $artifact-name ," + 
-                    " ARTIFACT_CONTENT    =  $artifact-contents "  ;
+            String key = "INSERT INTO ASDC_ARTIFACTS " + "SET SERVICE_UUID    =  $service-uuid , "
+                    + " DISTRIBUTION_ID    =  $distribution-id ," + " SERVICE_NAME    =  $service-name ,"
+                    + " SERVICE_DESCRIPTION    =  $service-description ," + " RESOURCE_UUID    = $resource-uuid ,"
+                    + " RESOURCE_INSTANCE_NAME    = $resource-instance-name ," + " RESOURCE_NAME    = $resource-name ,"
+                    + " RESOURCE_VERSION    = $resource-version ," + " RESOURCE_TYPE    = $resource-type ,"
+                    + " ARTIFACT_UUID    = $artifact-uuid ," + " ARTIFACT_TYPE    = $artifact-type ,"
+                    + " ARTIFACT_VERSION    = $artifact-version ," + " ARTIFACT_DESCRIPTION    = $artifact-description ,"
+                    + " INTERNAL_VERSION    = " + intversion + "," + " ARTIFACT_NAME       =  $artifact-name ,"
+                    + " ARTIFACT_CONTENT    =  $artifact-contents ";
 
             status = serviceLogic.save("SQL", false, false, key, null, null, ctx);
-            if(status.toString().equals("FAILURE"))
-                throw new SvcLogicException("Error While processing storing Artifact: " +ctx.getAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME));
+            if (status.toString().equals("FAILURE"))
+                throw new SvcLogicException("Error While processing storing Artifact: "
+                        + ctx.getAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME));
         }
         return status;
 
     }
+
     public QueryStatus logData(SvcLogicContext ctx, String prefix) throws SvcLogicException {
         String fn = "DBService.saveReferenceData";
         QueryStatus status = null;
         if (serviceLogic != null && ctx != null) {
             String key = "INSERT INTO CONFIG_TRANSACTION_LOG " + " SET request_id = $request-id , "
-                    + " message_type = $log-message-type , "
-                    + " message = $log-message ;";
+                    + " message_type = $log-message-type , " + " message = $log-message ;";
             status = serviceLogic.save("SQL", false, false, key, null, prefix, ctx);
-            if(status.toString().equals("FAILURE"))
+            if (status.toString().equals("FAILURE"))
                 throw new SvcLogicException("Error while loging data");
 
         }
@@ -134,61 +140,56 @@ public class DBService {
 
     public void processConfigureActionDg(SvcLogicContext context, boolean isUpdate) {
         String fn = "DBService.processConfigureActionDg";
-        log.info("Update Parameter for SDC Reference " + isUpdate );
+        log.info("Update Parameter for SDC Reference " + isUpdate);
         String key = "";
         QueryStatus status = null;
-        if(isUpdate);
-
+        if (isUpdate)
+            ;
     }
 
     public void processSdcReferences(SvcLogicContext context, boolean isUpdate) throws SvcLogicException {
         String fn = "DBService.processSdcReferences";
         String key = "";
         QueryStatus status = null;
-        
-        if (isUpdate && SdcArtifactHandlerConstants.FILE_CATEGORY.equals(SdcArtifactHandlerConstants.CAPABILITY)) {
-            key = "update " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + "  set ARTIFACT_NAME = $" + SdcArtifactHandlerConstants.ARTIFACT_NAME +
-            " where VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE +
-            " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY +
-            " and ACTION = null";
-        }
-        else if(isUpdate)
-            key = "update " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + "  set ARTIFACT_NAME = $" + SdcArtifactHandlerConstants.ARTIFACT_NAME +
-            " where VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE +
-            " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY +
-            " and ACTION = $" + SdcArtifactHandlerConstants.ACTION ;
 
-        else { 
+        if (isUpdate && SdcArtifactHandlerConstants.FILE_CATEGORY.equals(SdcArtifactHandlerConstants.CAPABILITY)) {
+            key = "update " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + "  set ARTIFACT_NAME = $"
+                    + SdcArtifactHandlerConstants.ARTIFACT_NAME + " where VNFC_TYPE = $"
+                    + SdcArtifactHandlerConstants.VNFC_TYPE + " and FILE_CATEGORY = $"
+                    + SdcArtifactHandlerConstants.FILE_CATEGORY + " and ACTION = null";
+        } else if (isUpdate)
+            key = "update " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + "  set ARTIFACT_NAME = $"
+                    + SdcArtifactHandlerConstants.ARTIFACT_NAME + " where VNFC_TYPE = $"
+                    + SdcArtifactHandlerConstants.VNFC_TYPE + " and FILE_CATEGORY = $"
+                    + SdcArtifactHandlerConstants.FILE_CATEGORY + " and ACTION = $"
+                    + SdcArtifactHandlerConstants.ACTION;
+
+        else {
             if (SdcArtifactHandlerConstants.FILE_CATEGORY.equals(SdcArtifactHandlerConstants.CAPABILITY)) {
-                key = "insert into " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE +
-                " set VNFC_TYPE = null "  +
-                " , FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY +
-                " , VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE +
-                " , ACTION = null "  +
-                " , ARTIFACT_TYPE = null " +
-                " , ARTIFACT_NAME = $" + SdcArtifactHandlerConstants.ARTIFACT_NAME ;
-            }
-            else {
-                key = "insert into " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE +
-                " set VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE +
-                " , FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY +
-                " , VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE +
-                " , ACTION = $" + SdcArtifactHandlerConstants.ACTION +
-                " , ARTIFACT_TYPE = $" + SdcArtifactHandlerConstants.ARTIFACT_TYPE +
-                " , ARTIFACT_NAME = $" + SdcArtifactHandlerConstants.ARTIFACT_NAME ;
+                key = "insert into " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + " set VNFC_TYPE = null "
+                        + " , FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY + " , VNF_TYPE = $"
+                        + SdcArtifactHandlerConstants.VNF_TYPE + " , ACTION = null " + " , ARTIFACT_TYPE = null "
+                        + " , ARTIFACT_NAME = $" + SdcArtifactHandlerConstants.ARTIFACT_NAME;
+            } else {
+                key = "insert into " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + " set VNFC_TYPE = $"
+                        + SdcArtifactHandlerConstants.VNFC_TYPE + " , FILE_CATEGORY = $"
+                        + SdcArtifactHandlerConstants.FILE_CATEGORY + " , VNF_TYPE = $"
+                        + SdcArtifactHandlerConstants.VNF_TYPE + " , ACTION = $" + SdcArtifactHandlerConstants.ACTION
+                        + " , ARTIFACT_TYPE = $" + SdcArtifactHandlerConstants.ARTIFACT_TYPE + " , ARTIFACT_NAME = $"
+                        + SdcArtifactHandlerConstants.ARTIFACT_NAME;
             }
         }
-        if (serviceLogic != null && context != null) {    
+        if (serviceLogic != null && context != null) {
             log.info("Insert Key: " + key);
             status = serviceLogic.save("SQL", false, false, key, null, null, context);
-            if(status.toString().equals("FAILURE"))
+            if (status.toString().equals("FAILURE"))
                 throw new SvcLogicException("Error While processing sdc_reference table ");
         }
     }
 
-    public boolean isArtifactUpdateRequired(SvcLogicContext context, String db) throws SvcLogicException, SQLException  {
+    public boolean isArtifactUpdateRequired(SvcLogicContext context, String db) throws SvcLogicException, SQLException {
         String fn = "DBService.isArtifactUpdateRequired";
-        log.info("Checking if Update required for this data" );
+        log.info("Checking if Update required for this data");
 
         log.info("db" + db);
         log.info("ACTION=" + context.getAttribute(SdcArtifactHandlerConstants.ACTION));
@@ -196,61 +197,54 @@ public class DBService {
         log.info("VNFC_INSTANCE=" + context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE));
         log.info("VM_INSTANCE=" + context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE));
         log.info("VNF_TYPE=" + context.getAttribute(SdcArtifactHandlerConstants.VNF_TYPE));
-        String whereClause =  "";
-
-        QueryStatus status = null;    
-    /*    if(context.getAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME) !=null &&
-                context.getAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME).toLowerCase().startsWith(SdcArtifactHandlerConstants.PD))
-            whereClause = " where artifact_name = $" + SdcArtifactHandlerConstants.ARTIFACT_NAME
-            + " and vnf_type = 'DummyVnf' ";
-        else*/
-            whereClause = " where VNF_TYPE = $" +  SdcArtifactHandlerConstants.VNF_TYPE;
-        
-        if (db !=null && db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE) &&
-            context.getAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY).equals(SdcArtifactHandlerConstants.CAPABILITY) &&
-            context.getAttribute(SdcArtifactHandlerConstants.ACTION) ==null) {
-                whereClause = whereClause + " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY ;
+        String whereClause = "";
+
+        QueryStatus status = null;
+        whereClause = " where VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE;
+
+        if (db != null && db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE)
+                && context.getAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY)
+                        .equals(SdcArtifactHandlerConstants.CAPABILITY)
+                && context.getAttribute(SdcArtifactHandlerConstants.ACTION) == null) {
+            whereClause = whereClause + " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY;
         }
-            
-        else if(db !=null && db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE)) {
+
+        else if (db != null && db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE)) {
             whereClause = whereClause + " and VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE
-                    + " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY
-                    + " and ACTION = $" + SdcArtifactHandlerConstants.ACTION;
+                    + " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY + " and ACTION = $"
+                    + SdcArtifactHandlerConstants.ACTION;
         }
 
-        else if(db.equals(SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE)) {
+        else if (db.equals(SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE)) {
             whereClause = " where PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL;
-        }
-        else if(db.equals(SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG)) {
+        } else if (db.equals(SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG)) {
             whereClause = whereClause + " and ACTION = $" + SdcArtifactHandlerConstants.ACTION;
-        }
-        else if(db.equals(SdcArtifactHandlerConstants.DB_VNFC_REFERENCE)){
-            int vm_instance = -1  ;
-            if(context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE) !=null)
+        } else if (db.equals(SdcArtifactHandlerConstants.DB_VNFC_REFERENCE)) {
+            int vm_instance = -1;
+            if (context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE) != null)
                 vm_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE));
-            int vnfc_instance = -1  ;
-            if(context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE) !=null)
+            int vnfc_instance = -1;
+            if (context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE) != null)
                 vnfc_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE));
-            whereClause = whereClause + " and ACTION = $" + SdcArtifactHandlerConstants.ACTION
-                    + " and VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE
-                    + " and VNFC_INSTANCE = $" + SdcArtifactHandlerConstants.VNFC_INSTANCE
-                    + " and VM_INSTANCE = $" + SdcArtifactHandlerConstants.VM_INSTANCE ;
+            whereClause = whereClause + " and ACTION = $" + SdcArtifactHandlerConstants.ACTION + " and VNFC_TYPE = $"
+                    + SdcArtifactHandlerConstants.VNFC_TYPE + " and VNFC_INSTANCE = $"
+                    + SdcArtifactHandlerConstants.VNFC_INSTANCE + " and VM_INSTANCE = $"
+                    + SdcArtifactHandlerConstants.VM_INSTANCE;
 
         }
-        if (serviceLogic != null && context != null) {    
-            String key = "select COUNT(*) from " + db + whereClause ;        
+        if (serviceLogic != null && context != null) {
+            String key = "select COUNT(*) from " + db + whereClause;
             log.info("SELECT String : " + key);
             status = serviceLogic.query("SQL", false, null, key, null, null, context);
-            if(status.toString().equals("FAILURE")){
-                throw new SvcLogicException("Error while reading data from " + db );
+            if (status.toString().equals("FAILURE")) {
+                throw new SvcLogicException("Error while reading data from " + db);
             }
             String count = context.getAttribute("COUNT(*)");
-            log.info("Number of row Returned : " + count + ": " +  status + ":");
-            if(count !=null && Integer.parseInt(count) > 0){                
+            log.info("Number of row Returned : " + count + ": " + status + ":");
+            if (count != null && Integer.parseInt(count) > 0) {
                 context.setAttribute(count, null);
                 return true;
-            }
-            else
+            } else
                 return false;
         }
         return false;
@@ -258,26 +252,23 @@ public class DBService {
 
     public void processDeviceInterfaceProtocol(SvcLogicContext context, boolean isUpdate) throws SvcLogicException {
         String fn = "DBService.processDeviceInterfaceProtocol";
-        log.info("Starting DB operation for Device Interface Protocol " + isUpdate );
+        log.info("Starting DB operation for Device Interface Protocol " + isUpdate);
         String key = "";
         QueryStatus status = null;
-        if(isUpdate)
-            key = "update " + SdcArtifactHandlerConstants.DB_DEVICE_INTERFACE_PROTOCOL +
-            " set PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL +
-            " , DG_RPC = 'getDeviceRunningConfig' " +  
-            " , MODULE = 'APPC' " + 
-            " where VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE ;
+        if (isUpdate)
+            key = "update " + SdcArtifactHandlerConstants.DB_DEVICE_INTERFACE_PROTOCOL + " set PROTOCOL = $"
+                    + SdcArtifactHandlerConstants.DEVICE_PROTOCOL + " , DG_RPC = 'getDeviceRunningConfig' "
+                    + " , MODULE = 'APPC' " + " where VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE;
         else
-            key = "insert into " + SdcArtifactHandlerConstants.DB_DEVICE_INTERFACE_PROTOCOL+
-            " set  VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE +
-            " , PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL +
-            " , DG_RPC = 'getDeviceRunningConfig' " +  
-            " , MODULE = 'APPC' " ; 
+            key = "insert into " + SdcArtifactHandlerConstants.DB_DEVICE_INTERFACE_PROTOCOL + " set  VNF_TYPE = $"
+                    + SdcArtifactHandlerConstants.VNF_TYPE + " , PROTOCOL = $"
+                    + SdcArtifactHandlerConstants.DEVICE_PROTOCOL + " , DG_RPC = 'getDeviceRunningConfig' "
+                    + " , MODULE = 'APPC' ";
 
-        if (serviceLogic != null && context != null) {    
+        if (serviceLogic != null && context != null) {
 
             status = serviceLogic.save("SQL", false, false, key, null, null, context);
-            if(status.toString().equals("FAILURE"))
+            if (status.toString().equals("FAILURE"))
                 throw new SvcLogicException("Error While processing DEVICE_INTERFACE_PROTOCOL table ");
         }
 
@@ -285,178 +276,173 @@ public class DBService {
 
     public void processDeviceAuthentication(SvcLogicContext context, boolean isUpdate) throws SvcLogicException {
         String fn = "DBService.processDeviceAuthentication";
-        log.info(fn + "Starting DB operation for Device Authentication " + isUpdate );
+        log.info(fn + "Starting DB operation for Device Authentication " + isUpdate);
         String key = "";
         QueryStatus status = null;
-        if(isUpdate)
-            key = "update " + SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION +
-            " set USER_NAME = $" + SdcArtifactHandlerConstants.USER_NAME +
-            " , PASSWORD = 'dummy' " +
-            " , PORT_NUMBER = $" + SdcArtifactHandlerConstants.PORT_NUMBER +
-            " where VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE ;
+        if (isUpdate)
+            key = "update " + SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION + " set USER_NAME = $"
+                    + SdcArtifactHandlerConstants.USER_NAME + " , PASSWORD = 'dummy' " + " , PORT_NUMBER = $"
+                    + SdcArtifactHandlerConstants.PORT_NUMBER + " where VNF_TYPE = $"
+                    + SdcArtifactHandlerConstants.VNF_TYPE;
         else
-            key = "insert into " + SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION+
-            " set  VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE +
-            " , USER_NAME = $" + SdcArtifactHandlerConstants.USER_NAME +
-            " , PASSWORD = 'dummy' " +
-            " , PORT_NUMBER = $" + SdcArtifactHandlerConstants.PORT_NUMBER;
+            key = "insert into " + SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION + " set  VNF_TYPE = $"
+                    + SdcArtifactHandlerConstants.VNF_TYPE + " , USER_NAME = $" + SdcArtifactHandlerConstants.USER_NAME
+                    + " , PASSWORD = 'dummy' " + " , PORT_NUMBER = $" + SdcArtifactHandlerConstants.PORT_NUMBER;
 
-        if (serviceLogic != null && context != null) {    
+        if (serviceLogic != null && context != null) {
             status = serviceLogic.save("SQL", false, false, key, null, null, context);
-            if(status.toString().equals("FAILURE"))
+            if (status.toString().equals("FAILURE"))
                 throw new SvcLogicException("Error While processing DEVICE_AUTHENTICATION table ");
-        }    
+        }
     }
 
     public void processVnfcReference(SvcLogicContext context, boolean isUpdate) throws SvcLogicException {
         String fn = "DBService.processVnfcReference";
-        log.info(fn + "Starting DB operation for Vnfc Reference " + isUpdate );
+        log.info(fn + "Starting DB operation for Vnfc Reference " + isUpdate);
         String key = "";
-        int vm_instance = -1  ;
-        if(context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE) !=null)
+        int vm_instance = -1;
+        if (context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE) != null)
             vm_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE));
-        int vnfc_instance = -1  ;
-        if(context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE) !=null)
+        int vnfc_instance = -1;
+        if (context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE) != null)
             vnfc_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE));
         QueryStatus status = null;
-        if(isUpdate)
-            key = "update " + SdcArtifactHandlerConstants.DB_VNFC_REFERENCE +
-            " set VM_INSTANCE = " + vm_instance   + 
-            " , VNFC_INSTANCE = " + vnfc_instance + 
-            " , VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE +
-            " , VNFC_FUNCTION_CODE = $" + SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE +
-            " , GROUP_NOTATION_TYPE = $" + SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE +
-            " , GROUP_NOTATION_VALUE = $" + SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE  +
-            " , IPADDRESS_V4_OAM_VIP = $" + SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP  +
-            " where VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE +
-            " and ACTION = $" + SdcArtifactHandlerConstants.ACTION +
-            " and VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE  +
-            " and VNFC_INSTANCE = $" + SdcArtifactHandlerConstants.VNFC_INSTANCE
-            + " and VM_INSTANCE = $" + SdcArtifactHandlerConstants.VM_INSTANCE ;
+        if (isUpdate)
+            key = "update " + SdcArtifactHandlerConstants.DB_VNFC_REFERENCE + " set VM_INSTANCE = " + vm_instance
+                    + " , VNFC_INSTANCE = " + vnfc_instance + " , VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE
+                    + " , VNFC_FUNCTION_CODE = $" + SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE
+                    + " , GROUP_NOTATION_TYPE = $" + SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE
+                    + " , GROUP_NOTATION_VALUE = $" + SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE
+                    + " , IPADDRESS_V4_OAM_VIP = $" + SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP
+                    + " where VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE + " and ACTION = $"
+                    + SdcArtifactHandlerConstants.ACTION + " and VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE
+                    + " and VNFC_INSTANCE = $" + SdcArtifactHandlerConstants.VNFC_INSTANCE + " and VM_INSTANCE = $"
+                    + SdcArtifactHandlerConstants.VM_INSTANCE;
         else
-            key = "insert into " + SdcArtifactHandlerConstants.DB_VNFC_REFERENCE+
-            " set  VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE +
-            " , ACTION = $" + SdcArtifactHandlerConstants.ACTION +
-            " , VM_INSTANCE = $" + SdcArtifactHandlerConstants.VM_INSTANCE +
-            " , VNFC_INSTANCE = $" + SdcArtifactHandlerConstants.VNFC_INSTANCE +
-            " , VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE +
-            " , VNFC_FUNCTION_CODE = $" + SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE +
-            " , GROUP_NOTATION_TYPE = $" + SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE +
-            " , IPADDRESS_V4_OAM_VIP = $" + SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP  +
-            " , GROUP_NOTATION_VALUE = $" + SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE ;
-
-        if (serviceLogic != null && context != null) {    
+            key = "insert into " + SdcArtifactHandlerConstants.DB_VNFC_REFERENCE + " set  VNF_TYPE = $"
+                    + SdcArtifactHandlerConstants.VNF_TYPE + " , ACTION = $" + SdcArtifactHandlerConstants.ACTION
+                    + " , VM_INSTANCE = $" + SdcArtifactHandlerConstants.VM_INSTANCE + " , VNFC_INSTANCE = $"
+                    + SdcArtifactHandlerConstants.VNFC_INSTANCE + " , VNFC_TYPE = $"
+                    + SdcArtifactHandlerConstants.VNFC_TYPE + " , VNFC_FUNCTION_CODE = $"
+                    + SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE + " , GROUP_NOTATION_TYPE = $"
+                    + SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE + " , IPADDRESS_V4_OAM_VIP = $"
+                    + SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP + " , GROUP_NOTATION_VALUE = $"
+                    + SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE;
+
+        if (serviceLogic != null && context != null) {
             status = serviceLogic.save("SQL", false, false, key, null, null, context);
-            if(status.toString().equals("FAILURE"))
+            if (status.toString().equals("FAILURE"))
                 throw new SvcLogicException("Error While processing VNFC_REFERENCE table ");
         }
     }
 
-    public void processDownloadDgReference(SvcLogicContext context, boolean isUpdate) throws SvcLogicException, SQLException {
+    public void processDownloadDgReference(SvcLogicContext context, boolean isUpdate)
+            throws SvcLogicException, SQLException {
         String fn = "DBService.processDownloadDgReference";
-        log.info(fn + "Starting DB operation for Download DG Reference " + isUpdate );
+        log.info(fn + "Starting DB operation for Download DG Reference " + isUpdate);
         String key = "";
         QueryStatus status = null;
 
-        if(isUpdate)
-            key = "update " + SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE +
-            " set DOWNLOAD_CONFIG_DG = $" + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE +
-            " where PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL ;
-        else 
-            key = "insert into " + SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE+
-            " set DOWNLOAD_CONFIG_DG = $" + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE +
-            " , PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL ;
+        if (isUpdate)
+            key = "update " + SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE + " set DOWNLOAD_CONFIG_DG = $"
+                    + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE + " where PROTOCOL = $"
+                    + SdcArtifactHandlerConstants.DEVICE_PROTOCOL;
+        else
+            key = "insert into " + SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE + " set DOWNLOAD_CONFIG_DG = $"
+                    + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE + " , PROTOCOL = $"
+                    + SdcArtifactHandlerConstants.DEVICE_PROTOCOL;
 
         if (serviceLogic != null && context != null)
             status = serviceLogic.save("SQL", false, false, key, null, null, context);
-        if(status.toString().equals("FAILURE"))
+        if (status.toString().equals("FAILURE"))
             throw new SvcLogicException("Error While processing DOWNLOAD_DG_REFERENCE table ");
     }
-    public void processConfigActionDg(SvcLogicContext context, boolean isUpdate) throws SvcLogicException
-    {
+
+    public void processConfigActionDg(SvcLogicContext context, boolean isUpdate) throws SvcLogicException {
         String fn = "DBService.processConfigActionDg";
-        log.info(fn + "Starting DB operation for Config DG Action " + isUpdate );
+        log.info(fn + "Starting DB operation for Config DG Action " + isUpdate);
         String key = "";
         QueryStatus status = null;
 
-        if(context.getAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE) != null &&
-                context.getAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE).length() > 0){
-            if(isUpdate)
-                key = "update " + SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG +
-                " set DOWNLOAD_CONFIG_DG = $" + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE +
-                " where ACTION = $" + SdcArtifactHandlerConstants.ACTION  +
-                " and VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE ;
-            else 
-                key = "insert into " + SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG+
-                " set DOWNLOAD_CONFIG_DG = $" + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE +
-                " , ACTION = $" + SdcArtifactHandlerConstants.ACTION  +
-                " , VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE ;
+        if (context.getAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE) != null
+                && context.getAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE).length() > 0) {
+            if (isUpdate)
+                key = "update " + SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG + " set DOWNLOAD_CONFIG_DG = $"
+                        + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE + " where ACTION = $"
+                        + SdcArtifactHandlerConstants.ACTION + " and VNF_TYPE = $"
+                        + SdcArtifactHandlerConstants.VNF_TYPE;
+            else
+                key = "insert into " + SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG + " set DOWNLOAD_CONFIG_DG = $"
+                        + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE + " , ACTION = $"
+                        + SdcArtifactHandlerConstants.ACTION + " , VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE;
 
             if (serviceLogic != null && context != null)
                 status = serviceLogic.save("SQL", false, false, key, null, null, context);
-            if(status.toString().equals("FAILURE"))
+            if (status.toString().equals("FAILURE"))
                 throw new SvcLogicException("Error While processing Configure DG Action table ");
-        }
-        else
+        } else
             log.info("No Update required for Config DG Action");
 
     }
 
-    public String  getModelDataInformationbyArtifactName(String artifact_name) throws SvcLogicException 
-    {
+    public String getModelDataInformationbyArtifactName(String artifact_name) throws SvcLogicException {
         String fn = "DBService.getVnfData";
         String key = "";
         SvcLogicContext con = new SvcLogicContext();
         HashMap<String, String> modelData = new HashMap<String, String>();
         QueryStatus status = null;
-        key = "select VNF_TYPE, VNFC_TYPE, ACTION, FILE_CATEGORY, ARTIFACT_TYPE from ASDC_REFERENCE where  ARTIFACT_NAME = " + artifact_name ;
+        key = "select VNF_TYPE, VNFC_TYPE, ACTION, FILE_CATEGORY, ARTIFACT_TYPE from ASDC_REFERENCE where  ARTIFACT_NAME = "
+                + artifact_name;
 
-        if (serviceLogic != null && con != null) {    
+        if (serviceLogic != null && con != null) {
             log.info(fn + "select Key: " + key);
             status = serviceLogic.query("SQL", false, null, key, null, null, con);
-            if(status.toString().equals("FAILURE"))
-                throw new SvcLogicException("Error While processing is ArtifactUpdateRequiredforPD table ");        
+            if (status.toString().equals("FAILURE"))
+                throw new SvcLogicException("Error While processing is ArtifactUpdateRequiredforPD table ");
 
         }
 
-        log.info(fn + "Vnf_received :" + con.getAttribute("VNF_TYPE"));            
+        log.info(fn + "Vnf_received :" + con.getAttribute("VNF_TYPE"));
 
         return con.getAttribute("VNF_TYPE");
 
     }
-    public void updateYangContents(SvcLogicContext context, String artifactId, String yangContents) throws SvcLogicException {
+
+    public void updateYangContents(SvcLogicContext context, String artifactId, String yangContents)
+            throws SvcLogicException {
         String fn = "DBService.updateYangContents";
         log.info(fn + "Starting DB operation for  updateYangContents");
         String key = "";
         QueryStatus status = null;
 
-            key = "update ASDC_ARTIFACTS " + 
-                " set ARTIFACT_CONTENT = '" + yangContents  +  "'" + 
-                " where ASDC_ARTIFACTS_ID = " + artifactId ;
-                
-            if (serviceLogic != null && context != null)
-                status = serviceLogic.save("SQL", false, false, key, null, null, context);
-            if(status.toString().equals("FAILURE"))
-                throw new SvcLogicException("Error While processing Configure DG Action table ");        
+        key = "update ASDC_ARTIFACTS " + " set ARTIFACT_CONTENT = '" + yangContents + "'"
+                + " where ASDC_ARTIFACTS_ID = " + artifactId;
+
+        if (serviceLogic != null && context != null)
+            status = serviceLogic.save("SQL", false, false, key, null, null, context);
+        if (status.toString().equals("FAILURE"))
+            throw new SvcLogicException("Error While processing Configure DG Action table ");
 
     }
-    
-    
-    public void insertProtocolReference(SvcLogicContext context, String vnfType, String protocol, String action, String action_level,
-            String template) throws SvcLogicException {
+
+
+    public void insertProtocolReference(SvcLogicContext context, String vnfType, String protocol, String action,
+            String action_level, String template) throws SvcLogicException {
         String fn = "DBService.insertProtocolReference";
         log.info(fn + "Starting DB operation for  insertProtocolReference");
         String key = "";
         QueryStatus status = null;
 
-            key = "insert into PROTOCOL_REFERENCE (ACTION, VNF_TYPE, PROTOCOL, UPDATED_DATE, TEMPLATE, ACTION_LEVEL)" + 
-                " values  (" +  
-                 "'"+action +"', '"+ vnfType+"', '"+protocol+"', now(),'"+template+"', '"+action_level+"')";
-                
-            if (serviceLogic != null && context != null)
-                status = serviceLogic.save("SQL", false, false, key, null, null, context);
-            if(status.toString().equals("FAILURE"))
-                throw new SvcLogicException("Error While processing insertProtocolReference ");    
-        
+        key = "insert into PROTOCOL_REFERENCE (ACTION, VNF_TYPE, PROTOCOL, UPDATED_DATE, TEMPLATE, ACTION_LEVEL)"
+                + " values  (" + "'" + action + "', '" + vnfType + "', '" + protocol + "', now(),'" + template + "', '"
+                + action_level + "')";
+
+        if (serviceLogic != null && context != null)
+            status = serviceLogic.save("SQL", false, false, key, null, null, context);
+        if (status.toString().equals("FAILURE"))
+            throw new SvcLogicException("Error While processing insertProtocolReference ");
+
     }
+
+
 }
index 35ab463..fec7fbb 100644 (file)
@@ -49,19 +49,18 @@ import com.att.eelf.configuration.EELFManager;
 public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
 
     private static final EELFLogger log = EELFManager.getInstance().getLogger(ArtifactHandlerNode.class);
-    public void processArtifact(Map<String, String> inParams, SvcLogicContext ctx) throws Exception 
-    {
-        String responsePrefix = inParams.get("response_prefix");        
-        try{
-            if(inParams != null && !inParams.isEmpty() && inParams.get("postData") !=null ){
-                log.info("Received request for process Artifact with params: " + inParams.toString());                        
+
+    public void processArtifact(Map<String, String> inParams, SvcLogicContext ctx) throws Exception {
+        String responsePrefix = inParams.get("response_prefix");
+        try {
+            if (inParams != null && !inParams.isEmpty() && inParams.get("postData") != null) {
+                log.info("Received request for process Artifact with params: " + inParams.toString());
                 String postData = inParams.get("postData");
                 JSONObject input = new JSONObject(postData).getJSONObject("input");
-                responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
+                responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
                 storeUpdateSdcArtifacts(input);
             }
-        }
-        catch(Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
             throw e;
         }
@@ -69,33 +68,39 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
 
     private boolean storeUpdateSdcArtifacts(JSONObject postDataJson) throws Exception {
         log.info("Starting processing of SDC Artifacs into Handler with Data : " + postDataJson.toString());
-        try{
-            JSONObject request_information = (JSONObject)postDataJson.get(SdcArtifactHandlerConstants.REQUEST_INFORMATION);
-            JSONObject document_information =(JSONObject)postDataJson.get(SdcArtifactHandlerConstants.DOCUMENT_PARAMETERS);
+        try {
+            JSONObject request_information =
+                    (JSONObject) postDataJson.get(SdcArtifactHandlerConstants.REQUEST_INFORMATION);
+            JSONObject document_information =
+                    (JSONObject) postDataJson.get(SdcArtifactHandlerConstants.DOCUMENT_PARAMETERS);
             String artifact_name = document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME);
-            if(artifact_name !=null){
-                updateStoreArtifacts(request_information, document_information );
-                if(artifact_name.toLowerCase().startsWith(SdcArtifactHandlerConstants.REFERENCE))
-                    return storeReferenceData(request_information, document_information );
+            if (artifact_name != null) {
+                updateStoreArtifacts(request_information, document_information);
+                if (artifact_name.toLowerCase().startsWith(SdcArtifactHandlerConstants.REFERENCE))
+                    return storeReferenceData(request_information, document_information);
                 else if (artifact_name.toLowerCase().startsWith(SdcArtifactHandlerConstants.PD))
-                    return createDataForPD(request_information, document_information );
+                    return createDataForPD(request_information, document_information);
 
-            }
-            else
-                throw new Exception("Missing Artifact Name for Request : "  + request_information.getString(SdcArtifactHandlerConstants.REQUETS_ID));
-        }
-        catch(Exception e){
+            } else
+                throw new Exception("Missing Artifact Name for Request : "
+                        + request_information.getString(SdcArtifactHandlerConstants.REQUETS_ID));
+        } catch (Exception e) {
             e.printStackTrace();
-            throw new Exception("Error while processing Request ID : " + ((JSONObject)postDataJson.get(SdcArtifactHandlerConstants.REQUEST_INFORMATION)).getString(SdcArtifactHandlerConstants.REQUETS_ID) + e.getMessage());
+            throw new Exception("Error while processing Request ID : "
+                    + ((JSONObject) postDataJson.get(SdcArtifactHandlerConstants.REQUEST_INFORMATION))
+                            .getString(SdcArtifactHandlerConstants.REQUETS_ID)
+                    + e.getMessage());
         }
-        return false;        
+        return false;
 
     }
+
     private boolean createDataForPD(JSONObject request_information, JSONObject document_information) throws Exception {
 
         String fn = "ArtifactHandlerNode.createReferenceDataForPD";
         String artifact_name = document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME);
-        log.info(fn + "Received PD File Name: " + artifact_name + " and suffix lenght " + SdcArtifactHandlerConstants.PD.length());
+        log.info(fn + "Received PD File Name: " + artifact_name + " and suffix lenght "
+                + SdcArtifactHandlerConstants.PD.length());
         try {
 
             String suffix = artifact_name.substring(SdcArtifactHandlerConstants.PD.length());
@@ -103,52 +108,52 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
         } catch (Exception e) {
             e.printStackTrace();
             throw new Exception("Error while createing PD data records " + e.getMessage());
-        }        
+        }
         return true;
     }
 
-    private void createArtifactRecords(JSONObject request_information, JSONObject document_information, String suffix) throws Exception {
+    private void createArtifactRecords(JSONObject request_information, JSONObject document_information, String suffix)
+            throws Exception {
 
         log.info("Creating Tosca Records and storing into SDC Artifacs");
-        String [] docs = {"Tosca", "Yang"};    
+        String[] docs = {"Tosca", "Yang"};
         ArtifactHandlerProviderUtil ahpUtil = new ArtifactHandlerProviderUtil();
         String PDFileContents = document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS);
 
-        //Tosca generation
+        // Tosca generation
         OutputStream toscaStream = new ByteArrayOutputStream();
         String toscaContents = null;
         ArtifactProcessorImpl toscaGenerator = new ArtifactProcessorImpl();
-        toscaGenerator.generateArtifact(PDFileContents,toscaStream);
-        if(toscaStream != null)
+        toscaGenerator.generateArtifact(PDFileContents, toscaStream);
+        if (toscaStream != null)
             toscaContents = toscaStream.toString();
         log.info("Generated Tosca File : " + toscaContents);
 
-        //Yang generation
-        //String yangContents = "Dummay Yang, Yang contents will be available after IST Integration";
-
         String yangContents = "YANG generation is in Progress";
         String yangName = null;
 
-        for(String doc : docs){
+        for (String doc : docs) {
             document_information.put(SdcArtifactHandlerConstants.ARTIFACT_TYPE, doc.concat("Type"));
             document_information.put(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION, doc.concat("Model"));
-            if(doc.equals("Tosca"))
-                document_information.put(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS, ahpUtil.escapeSql(toscaContents));
+            if (doc.equals("Tosca"))
+                document_information.put(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS,
+                        ahpUtil.escapeSql(toscaContents));
             else if (doc.equals("Yang"))
-                document_information.put(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS, ahpUtil.escapeSql(yangContents));
+                document_information.put(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS,
+                        ahpUtil.escapeSql(yangContents));
             document_information.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, doc.concat(suffix));
             yangName = doc.concat(suffix);
             updateStoreArtifacts(request_information, document_information);
-        }    
+        }
 
         String artifactId = getArtifactID(yangName);
         OutputStream yangStream = new ByteArrayOutputStream();
         YANGGenerator yangGenerator = YANGGeneratorFactory.getYANGGenerator();
-        yangGenerator.generateYANG(artifactId , toscaContents, yangStream);
-        if(yangStream != null)
+        yangGenerator.generateYANG(artifactId, toscaContents, yangStream);
+        if (yangStream != null)
             yangContents = yangStream.toString();
 
-        if(yangContents !=null ){
+        if (yangContents != null) {
             updateYangContents(artifactId, ahpUtil.escapeSql(yangContents));
         }
 
@@ -157,84 +162,111 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
     private void updateYangContents(String artifactId, String yangContents) throws SvcLogicException {
         SvcLogicContext context = new SvcLogicContext();
         DBService dbservice = DBService.initialise();
-        dbservice.updateYangContents(context, artifactId, yangContents);    
+        dbservice.updateYangContents(context, artifactId, yangContents);
     }
 
-    private String getArtifactID(String yangName) throws SvcLogicException {        
+    private String getArtifactID(String yangName) throws SvcLogicException {
         SvcLogicContext context = new SvcLogicContext();
         DBService dbservice = DBService.initialise();
-        return dbservice.getArtifactID(context, yangName);    
+        return dbservice.getArtifactID(context, yangName);
     }
 
-    private boolean updateStoreArtifacts(JSONObject request_information, JSONObject document_information ) throws Exception {
+    protected boolean updateStoreArtifacts(JSONObject request_information, JSONObject document_information)
+            throws Exception {
         log.info("UpdateStoreArtifactsStarted storing of SDC Artifacs ");
 
         SvcLogicContext context = new SvcLogicContext();
         DBService dbservice = DBService.initialise();
         ArtifactHandlerProviderUtil ahpUtil = new ArtifactHandlerProviderUtil();
         int intversion = 0;
-        context.setAttribute("artifact_name",document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
-        String internal_version = dbservice.getInternalVersionNumber(context, document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME), null);
+        context.setAttribute("artifact_name",
+                document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
+        String internal_version = dbservice.getInternalVersionNumber(context,
+                document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME), null);
         log.info("Internal Version number received from Database : " + internal_version);
-        if(internal_version != null){
+        if (internal_version != null) {
             intversion = Integer.parseInt(internal_version);
-            intversion++ ;
-        }        
-        context.setAttribute(SdcArtifactHandlerConstants.SERVICE_UUID, document_information.getString(SdcArtifactHandlerConstants.SERVICE_UUID));
-        context.setAttribute(SdcArtifactHandlerConstants.DISTRIBUTION_ID, document_information.getString(SdcArtifactHandlerConstants.DISTRIBUTION_ID));
-        context.setAttribute(SdcArtifactHandlerConstants.SERVICE_NAME, document_information.getString(SdcArtifactHandlerConstants.SERVICE_NAME));
-        context.setAttribute(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION, document_information.getString(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION));
-        context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_UUID, document_information.getString(SdcArtifactHandlerConstants.RESOURCE_UUID));
-        context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME,document_information.getString(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME));
-        context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_VERSOIN, document_information.getString(SdcArtifactHandlerConstants.RESOURCE_VERSOIN));
-        context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_TYPE, document_information.getString(SdcArtifactHandlerConstants.RESOURCE_TYPE));
-        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_UUID, document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_UUID));
-        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_TYPE,document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_TYPE));
-        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_VERSOIN,document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_VERSOIN));
-        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION,document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION));
-        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS,ahpUtil.escapeSql(document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS)));
-        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME,document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
+            intversion++;
+        }
+        context.setAttribute(SdcArtifactHandlerConstants.SERVICE_UUID,
+                document_information.getString(SdcArtifactHandlerConstants.SERVICE_UUID));
+        context.setAttribute(SdcArtifactHandlerConstants.DISTRIBUTION_ID,
+                document_information.getString(SdcArtifactHandlerConstants.DISTRIBUTION_ID));
+        context.setAttribute(SdcArtifactHandlerConstants.SERVICE_NAME,
+                document_information.getString(SdcArtifactHandlerConstants.SERVICE_NAME));
+        context.setAttribute(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION,
+                document_information.getString(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION));
+        context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_UUID,
+                document_information.getString(SdcArtifactHandlerConstants.RESOURCE_UUID));
+        context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME,
+                document_information.getString(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME));
+        context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_VERSOIN,
+                document_information.getString(SdcArtifactHandlerConstants.RESOURCE_VERSOIN));
+        context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_TYPE,
+                document_information.getString(SdcArtifactHandlerConstants.RESOURCE_TYPE));
+        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_UUID,
+                document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_UUID));
+        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_TYPE,
+                document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_TYPE));
+        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_VERSOIN,
+                document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_VERSOIN));
+        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION,
+                document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION));
+        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS,
+                ahpUtil.escapeSql(document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS)));
+        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME,
+                document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
         dbservice.saveArtifacts(context, intversion);
-        return true;            
+        return true;
 
     }
 
-    public boolean storeReferenceData(JSONObject request_information, JSONObject document_information) throws Exception {    
-        log.info("Started storing of SDC Artifacs into Handler" );
-        try{
+    public boolean storeReferenceData(JSONObject request_information, JSONObject document_information)
+            throws Exception {
+        log.info("Started storing of SDC Artifacs into Handler");
+        try {
             boolean updateRequired = false;
             boolean pdFile = false;
             String suffix = null;
             String categorySuffix = null;
             DBService dbservice = DBService.initialise();
             ArtifactHandlerProviderUtil ahpUtil = new ArtifactHandlerProviderUtil();
-            String contentString =  ahpUtil.escapeSql(document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS))    ;
-            String artifactName=ahpUtil.escapeSql(document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
-            String capabilityArtifactName=StringUtils.replace(artifactName, SdcArtifactHandlerConstants.ARTIFACT_NAME_REFERENCE, SdcArtifactHandlerConstants.ARTIFACT_NAME_CAPABILITY);
+            String contentString =
+                    ahpUtil.escapeSql(document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS));
+            String artifactName =
+                    ahpUtil.escapeSql(document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
+            String capabilityArtifactName =
+                    StringUtils.replace(artifactName, SdcArtifactHandlerConstants.ARTIFACT_NAME_REFERENCE,
+                            SdcArtifactHandlerConstants.ARTIFACT_NAME_CAPABILITY);
             JSONObject capabilities = new JSONObject();
             JSONArray vnfActionList = new JSONArray();
             JSONArray vfModuleActionList = new JSONArray();
             JSONArray vnfcActionList = new JSONArray();
             JSONArray vmActionList = new JSONArray();
-            String vnfType=null;
+            String vnfType = null;
             JSONObject contentObject = new JSONObject(contentString);
-            JSONArray contentArray= contentObject.getJSONArray("reference_data");
-            for(int a=0; a<contentArray.length() ; a++){
-                
+            JSONArray contentArray = contentObject.getJSONArray("reference_data");
+            for (int a = 0; a < contentArray.length(); a++) {
+
                 JSONObject content = (JSONObject) contentArray.get(a);
                 log.info("contentString =" + content.toString());
                 JSONObject scope = content.getJSONObject("scope");
                 log.info("scope :" + scope);
                 SvcLogicContext context = new SvcLogicContext();
-                vnfType=scope.getString(SdcArtifactHandlerConstants.VNF_TYPE);
-                context.setAttribute(SdcArtifactHandlerConstants.VNF_TYPE, scope.getString(SdcArtifactHandlerConstants.VNF_TYPE));
-                context.setAttribute(SdcArtifactHandlerConstants.ACTION, content.getString(SdcArtifactHandlerConstants.ACTION));
-                String actionLevel=content.getString(SdcArtifactHandlerConstants.ACTION_LEVEL);
-                context.setAttribute(SdcArtifactHandlerConstants.ACTION_LEVEL, content.getString(SdcArtifactHandlerConstants.ACTION_LEVEL));
-                if ((null != actionLevel) && actionLevel.equalsIgnoreCase(SdcArtifactHandlerConstants.ACTION_LEVEL_VNFC)) {
+                vnfType = scope.getString(SdcArtifactHandlerConstants.VNF_TYPE);
+                context.setAttribute(SdcArtifactHandlerConstants.VNF_TYPE,
+                        scope.getString(SdcArtifactHandlerConstants.VNF_TYPE));
+                context.setAttribute(SdcArtifactHandlerConstants.ACTION,
+                        content.getString(SdcArtifactHandlerConstants.ACTION));
+                String actionLevel = content.getString(SdcArtifactHandlerConstants.ACTION_LEVEL);
+                context.setAttribute(SdcArtifactHandlerConstants.ACTION_LEVEL,
+                        content.getString(SdcArtifactHandlerConstants.ACTION_LEVEL));
+                if ((null != actionLevel)
+                        && actionLevel.equalsIgnoreCase(SdcArtifactHandlerConstants.ACTION_LEVEL_VNFC)) {
                     vnfcActionList.put(content.getString(SdcArtifactHandlerConstants.ACTION));
                 }
-                if (null != actionLevel && actionLevel.equalsIgnoreCase(SdcArtifactHandlerConstants.ACTION_LEVEL_VF_MODULE)) {
+                if (null != actionLevel
+                        && actionLevel.equalsIgnoreCase(SdcArtifactHandlerConstants.ACTION_LEVEL_VF_MODULE)) {
                     vfModuleActionList.put(content.getString(SdcArtifactHandlerConstants.ACTION));
                 }
                 if (null != actionLevel && actionLevel.equalsIgnoreCase(SdcArtifactHandlerConstants.ACTION_LEVEL_VNF)) {
@@ -243,208 +275,239 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
                 if (null != actionLevel && actionLevel.equalsIgnoreCase(SdcArtifactHandlerConstants.ACTION_LEVEL_VM)) {
                     vmActionList.put(content.getString(SdcArtifactHandlerConstants.ACTION));
                 }
-                if(scope.has(SdcArtifactHandlerConstants.VNFC_TYPE) && !scope.isNull(SdcArtifactHandlerConstants.VNFC_TYPE) )
-                    context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE, scope.getString(SdcArtifactHandlerConstants.VNFC_TYPE));
+                if (scope.has(SdcArtifactHandlerConstants.VNFC_TYPE)
+                        && !scope.isNull(SdcArtifactHandlerConstants.VNFC_TYPE))
+                    context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE,
+                            scope.getString(SdcArtifactHandlerConstants.VNFC_TYPE));
                 else
-                    context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE,null);
+                    context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE, null);
                 if (content.has(SdcArtifactHandlerConstants.DEVICE_PROTOCOL))
-                    context.setAttribute(SdcArtifactHandlerConstants.DEVICE_PROTOCOL, content.getString(SdcArtifactHandlerConstants.DEVICE_PROTOCOL));
+                    context.setAttribute(SdcArtifactHandlerConstants.DEVICE_PROTOCOL,
+                            content.getString(SdcArtifactHandlerConstants.DEVICE_PROTOCOL));
                 if (content.has(SdcArtifactHandlerConstants.USER_NAME))
-                    context.setAttribute(SdcArtifactHandlerConstants.USER_NAME, content.getString(SdcArtifactHandlerConstants.USER_NAME));
+                    context.setAttribute(SdcArtifactHandlerConstants.USER_NAME,
+                            content.getString(SdcArtifactHandlerConstants.USER_NAME));
                 if (content.has(SdcArtifactHandlerConstants.PORT_NUMBER))
-                    context.setAttribute(SdcArtifactHandlerConstants.PORT_NUMBER, content.getString(SdcArtifactHandlerConstants.PORT_NUMBER));
+                    context.setAttribute(SdcArtifactHandlerConstants.PORT_NUMBER,
+                            content.getString(SdcArtifactHandlerConstants.PORT_NUMBER));
                 context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_TYPE, "");
-                if(content.has("artifact-list") && content.get("artifact-list") instanceof JSONArray){                
-                    JSONArray artifactLists = (JSONArray)content.get("artifact-list"); 
-                    for(int i=0;i<artifactLists.length();i++){
-                        JSONObject artifact=(JSONObject)artifactLists.get(i);
+                if (content.has("artifact-list") && content.get("artifact-list") instanceof JSONArray) {
+                    JSONArray artifactLists = (JSONArray) content.get("artifact-list");
+                    for (int i = 0; i < artifactLists.length(); i++) {
+                        JSONObject artifact = (JSONObject) artifactLists.get(i);
                         log.info("artifact is " + artifact);
-                        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME, artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
-                        context.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY, artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_TYPE));
-
-                        if(artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME) !=null &&
-                                artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME).toLowerCase().startsWith(SdcArtifactHandlerConstants.PD))
-                        {
-                            suffix = artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME).substring(SdcArtifactHandlerConstants.PD.length());
-                            categorySuffix = artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_TYPE).substring(SdcArtifactHandlerConstants.PD.length());
+                        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME,
+                                artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
+                        context.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY,
+                                artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_TYPE));
+
+                        if (artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME) != null
+                                && artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME).toLowerCase()
+                                        .startsWith(SdcArtifactHandlerConstants.PD)) {
+                            suffix = artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME)
+                                    .substring(SdcArtifactHandlerConstants.PD.length());
+                            categorySuffix = artifact.getString(SdcArtifactHandlerConstants.ARTIFACT_TYPE)
+                                    .substring(SdcArtifactHandlerConstants.PD.length());
                             pdFile = true;
                         }
 
-                        dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context, SdcArtifactHandlerConstants.DB_SDC_REFERENCE));
+                        dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context,
+                                SdcArtifactHandlerConstants.DB_SDC_REFERENCE));
 
                         cleanArtifactInstanceData(context);
                     }
 
-                    if(pdFile)
-                    {
+                    if (pdFile) {
                         context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME, "Tosca".concat(suffix));
-                        context.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY, SdcArtifactHandlerConstants.TOSCA_MODEL);
-                        dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context, SdcArtifactHandlerConstants.DB_SDC_REFERENCE));
+                        context.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY,
+                                SdcArtifactHandlerConstants.TOSCA_MODEL);
+                        dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context,
+                                SdcArtifactHandlerConstants.DB_SDC_REFERENCE));
                         context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME, "Yang".concat(suffix));
-                        context.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY, SdcArtifactHandlerConstants.PARAMETER_YANG);
-                        dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context, SdcArtifactHandlerConstants.DB_SDC_REFERENCE));
+                        context.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY,
+                                SdcArtifactHandlerConstants.PARAMETER_YANG);
+                        dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context,
+                                SdcArtifactHandlerConstants.DB_SDC_REFERENCE));
                     }
                 }
                 if (content.getString(SdcArtifactHandlerConstants.ACTION).equals("Configure")) {
-                    if(content.has(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE) && content.getString(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE).length() > 0){
-                        context.setAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE, content.getString(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE));
-                        dbservice.processDownloadDgReference(context, dbservice.isArtifactUpdateRequired(context, SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE));
+                    if (content.has(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE)
+                            && content.getString(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE).length() > 0) {
+                        context.setAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE,
+                                content.getString(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE));
+                        dbservice.processDownloadDgReference(context, dbservice.isArtifactUpdateRequired(context,
+                                SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE));
                     }
-    
-                    dbservice.processConfigActionDg(context, dbservice.isArtifactUpdateRequired(context, SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG));
-                    dbservice.processDeviceInterfaceProtocol(context, dbservice.isArtifactUpdateRequired(context, SdcArtifactHandlerConstants.DB_DEVICE_INTERFACE_PROTOCOL));
-                    dbservice.processDeviceAuthentication(context, dbservice.isArtifactUpdateRequired(context, SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION));
-                    
+
+                    dbservice.processConfigActionDg(context, dbservice.isArtifactUpdateRequired(context,
+                            SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG));
+                    dbservice.processDeviceInterfaceProtocol(context, dbservice.isArtifactUpdateRequired(context,
+                            SdcArtifactHandlerConstants.DB_DEVICE_INTERFACE_PROTOCOL));
+                    dbservice.processDeviceAuthentication(context, dbservice.isArtifactUpdateRequired(context,
+                            SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION));
+
                 }
-                
-                
+
+
                 populateProtocolReference(dbservice, content);
-                
+
                 context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE, null);
-                
-                if( content.has(SdcArtifactHandlerConstants.VM)  && content.get(SdcArtifactHandlerConstants.VM) instanceof JSONArray){
-                    JSONArray vmList = (JSONArray)content.get(SdcArtifactHandlerConstants.VM);
-                    for(int i=0;i<vmList.length();i++){
-                        JSONObject vmInstance=(JSONObject)vmList.get(i);    
-                        context.setAttribute(SdcArtifactHandlerConstants.VM_INSTANCE, String.valueOf(vmInstance.getInt(SdcArtifactHandlerConstants.VM_INSTANCE)));
+
+                if (content.has(SdcArtifactHandlerConstants.VM)
+                        && content.get(SdcArtifactHandlerConstants.VM) instanceof JSONArray) {
+                    JSONArray vmList = (JSONArray) content.get(SdcArtifactHandlerConstants.VM);
+                    for (int i = 0; i < vmList.length(); i++) {
+                        JSONObject vmInstance = (JSONObject) vmList.get(i);
+                        context.setAttribute(SdcArtifactHandlerConstants.VM_INSTANCE,
+                                String.valueOf(vmInstance.getInt(SdcArtifactHandlerConstants.VM_INSTANCE)));
                         log.info("VALUE = " + context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE));
-                        if(vmInstance.get(SdcArtifactHandlerConstants.VNFC) instanceof JSONArray){
-                            JSONArray vnfcInstanceList = (JSONArray)vmInstance.get(SdcArtifactHandlerConstants.VNFC);
-                            for(int k=0;k<vnfcInstanceList.length();k++){
-                                JSONObject vnfcInstance = (JSONObject)vnfcInstanceList.get(k);
-                                context.setAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE, String.valueOf(vnfcInstance.getInt(SdcArtifactHandlerConstants.VNFC_INSTANCE)));
-                                context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE, vnfcInstance.getString(SdcArtifactHandlerConstants.VNFC_TYPE));
-                                context.setAttribute(SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE, vnfcInstance.getString(SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE));
-                                if(vnfcInstance.has(SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP))
-                                    context.setAttribute(SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP, vnfcInstance.getString(SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP));
-                                if(vnfcInstance.has(SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE))
-                                    context.setAttribute(SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE, vnfcInstance.getString(SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE));
-                                if(vnfcInstance.has(SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE))
-                                    context.setAttribute(SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE, vnfcInstance.getString(SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE));
-                                dbservice.processVnfcReference(context, dbservice.isArtifactUpdateRequired(context, SdcArtifactHandlerConstants.DB_VNFC_REFERENCE));
+                        if (vmInstance.get(SdcArtifactHandlerConstants.VNFC) instanceof JSONArray) {
+                            JSONArray vnfcInstanceList = (JSONArray) vmInstance.get(SdcArtifactHandlerConstants.VNFC);
+                            for (int k = 0; k < vnfcInstanceList.length(); k++) {
+                                JSONObject vnfcInstance = (JSONObject) vnfcInstanceList.get(k);
+                                context.setAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE,
+                                        String.valueOf(vnfcInstance.getInt(SdcArtifactHandlerConstants.VNFC_INSTANCE)));
+                                context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE,
+                                        vnfcInstance.getString(SdcArtifactHandlerConstants.VNFC_TYPE));
+                                context.setAttribute(SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE,
+                                        vnfcInstance.getString(SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE));
+                                if (vnfcInstance.has(SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP))
+                                    context.setAttribute(SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP,
+                                            vnfcInstance.getString(SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP));
+                                if (vnfcInstance.has(SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE))
+                                    context.setAttribute(SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE,
+                                            vnfcInstance.getString(SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE));
+                                if (vnfcInstance.has(SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE))
+                                    context.setAttribute(SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE,
+                                            vnfcInstance.getString(SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE));
+                                dbservice.processVnfcReference(context, dbservice.isArtifactUpdateRequired(context,
+                                        SdcArtifactHandlerConstants.DB_VNFC_REFERENCE));
                                 cleanVnfcInstance(context);
                             }
-                            context.setAttribute(SdcArtifactHandlerConstants.VM_INSTANCE,null);
+                            context.setAttribute(SdcArtifactHandlerConstants.VM_INSTANCE, null);
                         }
-                    }        
-                } 
-                
-                                
+                    }
+                }
+
+
             }
-            capabilities.put("vnf",vnfActionList );     
+            capabilities.put("vnf", vnfActionList);
             capabilities.put("vf-module", vfModuleActionList);
             capabilities.put("vnfc", vnfcActionList);
             capabilities.put("vm", vmActionList);
-            processAndStoreCapablitiesArtifact(dbservice, document_information, capabilities,capabilityArtifactName,vnfType );
-            
-        }
-            catch(Exception e)
-            {
-                e.printStackTrace();
-                throw new Exception("Error While Storing :  " + e.getMessage());            
-            }
-        
-            return true;            
+            processAndStoreCapablitiesArtifact(dbservice, document_information, capabilities, capabilityArtifactName,
+                    vnfType);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new Exception("Error While Storing :  " + e.getMessage());
         }
 
-        
-        
+        return true;
+    }
 
+    private void cleanArtifactInstanceData(SvcLogicContext context) {
+        context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME, null);
+        context.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY, null);
+    }
 
-        private void cleanArtifactInstanceData(SvcLogicContext context)
-        {
-            context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME, null);
-            context.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY, null);
-        }
+    private void cleanVnfcInstance(SvcLogicContext context) {
 
-        private void cleanVnfcInstance(SvcLogicContext context) {
+        context.setAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE, null);
+        context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE, null);
+        context.setAttribute(SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE, null);
+        context.setAttribute(SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP, null);
+        context.setAttribute(SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE, null);
+        context.setAttribute(SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE, null);
 
-            context.setAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE, null);
-            context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE, null);
-            context.setAttribute(SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE, null);
-            context.setAttribute(SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP, null);
-            context.setAttribute(SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE, null);
-            context.setAttribute(SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE, null);
+    }
 
-        }
+    private void processAndStoreCapablitiesArtifact(DBService dbservice, JSONObject document_information,
+            JSONObject capabilities, String capabilityArtifactName, String vnfType) throws Exception {
+        log.info("Begin-->processAndStoreCapablitiesArtifact ");
 
-        private void processAndStoreCapablitiesArtifact (DBService dbservice , JSONObject document_information, 
-        JSONObject capabilities, String capabilityArtifactName, String vnfType) throws Exception {
-            log.info("Begin-->processAndStoreCapablitiesArtifact ");
+        try {
 
-            try {
-                
-                JSONObject newCapabilitiesObject=new JSONObject();
-                newCapabilitiesObject.put("capabilities", capabilities);
-                SvcLogicContext context = new SvcLogicContext();
-                context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME,capabilityArtifactName);
-                context.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY, SdcArtifactHandlerConstants.CAPABILITY);
-                context.setAttribute(SdcArtifactHandlerConstants.ACTION, null);
-                context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE, null);
-                context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_TYPE, null);
-                context.setAttribute(SdcArtifactHandlerConstants.VNF_TYPE,vnfType);
-                context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS,newCapabilitiesObject.toString());
-                dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context, SdcArtifactHandlerConstants.DB_SDC_REFERENCE));
-                int intversion = 0;
-                
-                String internal_version = dbservice.getInternalVersionNumber(context, context.getAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME), null);
-                log.info("Internal Version number received from Database : " + internal_version);
-                if(internal_version != null){
-                    intversion = Integer.parseInt(internal_version);
-                    intversion++ ;
-                }        
-                context.setAttribute(SdcArtifactHandlerConstants.SERVICE_UUID, document_information.getString(SdcArtifactHandlerConstants.SERVICE_UUID));
-                context.setAttribute(SdcArtifactHandlerConstants.DISTRIBUTION_ID, document_information.getString(SdcArtifactHandlerConstants.DISTRIBUTION_ID));
-                context.setAttribute(SdcArtifactHandlerConstants.SERVICE_NAME, document_information.getString(SdcArtifactHandlerConstants.SERVICE_NAME));
-                context.setAttribute(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION, document_information.getString(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION));
-                context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_UUID, document_information.getString(SdcArtifactHandlerConstants.RESOURCE_UUID));
-                context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME,document_information.getString(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME));
-                context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_VERSOIN, document_information.getString(SdcArtifactHandlerConstants.RESOURCE_VERSOIN));
-                context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_TYPE, document_information.getString(SdcArtifactHandlerConstants.RESOURCE_TYPE));
-                context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_UUID, document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_UUID));
-                context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_VERSOIN,document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_VERSOIN));
-                context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION,document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION));
-                
-                
-                dbservice.saveArtifacts(context, intversion);
-                return ;            
-            }
-            catch (Exception e) {
-                log.error("Error saving capabilities artifact to DB: "+ e.toString());
-                throw e;
-            }
-            finally {
-                log.info("End-->processAndStoreCapablitiesArtifact ");
-            }
-        
-            }
-        
-
-            private void populateProtocolReference(DBService dbservice, JSONObject content)  throws Exception{
-                log.info("Begin-->populateProtocolReference ");
-                try {
-                    SvcLogicContext context = new SvcLogicContext();
-                    JSONObject scope = content.getJSONObject("scope");
-                    String vnfType=null,protocol=null,action=null,actionLevel=null,template=null;
-                    if(scope.has(SdcArtifactHandlerConstants.VNF_TYPE) && !scope.isNull(SdcArtifactHandlerConstants.VNF_TYPE))
-                        vnfType=scope.getString(SdcArtifactHandlerConstants.VNF_TYPE);
-                    if (content.has(SdcArtifactHandlerConstants.DEVICE_PROTOCOL))
-                        protocol=content.getString(SdcArtifactHandlerConstants.DEVICE_PROTOCOL);
-                    if (content.has(SdcArtifactHandlerConstants.ACTION))
-                        action= content.getString(SdcArtifactHandlerConstants.ACTION);
-                    if (content.has(SdcArtifactHandlerConstants.ACTION_LEVEL))
-                        actionLevel=content.getString(SdcArtifactHandlerConstants.ACTION_LEVEL);
-                    if (content.has(SdcArtifactHandlerConstants.TEMPLATE) && !content.isNull(SdcArtifactHandlerConstants.TEMPLATE))
-                        template=content.getString(SdcArtifactHandlerConstants.TEMPLATE);
-                    dbservice.insertProtocolReference(context, vnfType,protocol,action,actionLevel,template);
-                }
-                catch (Exception e) {
-                    log.error("Error inserting record into protocolReference: "+e.toString());
-                    throw e;
-                }
-                finally {
-                    log.info("End-->populateProtocolReference ");
-                }
+            JSONObject newCapabilitiesObject = new JSONObject();
+            newCapabilitiesObject.put("capabilities", capabilities);
+            SvcLogicContext context = new SvcLogicContext();
+            context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME, capabilityArtifactName);
+            context.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY, SdcArtifactHandlerConstants.CAPABILITY);
+            context.setAttribute(SdcArtifactHandlerConstants.ACTION, null);
+            context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE, null);
+            context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_TYPE, null);
+            context.setAttribute(SdcArtifactHandlerConstants.VNF_TYPE, vnfType);
+            context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS, newCapabilitiesObject.toString());
+            dbservice.processSdcReferences(context,
+                    dbservice.isArtifactUpdateRequired(context, SdcArtifactHandlerConstants.DB_SDC_REFERENCE));
+            int intversion = 0;
+
+            String internal_version = dbservice.getInternalVersionNumber(context,
+                    context.getAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME), null);
+            log.info("Internal Version number received from Database : " + internal_version);
+            if (internal_version != null) {
+                intversion = Integer.parseInt(internal_version);
+                intversion++;
             }
+            context.setAttribute(SdcArtifactHandlerConstants.SERVICE_UUID,
+                    document_information.getString(SdcArtifactHandlerConstants.SERVICE_UUID));
+            context.setAttribute(SdcArtifactHandlerConstants.DISTRIBUTION_ID,
+                    document_information.getString(SdcArtifactHandlerConstants.DISTRIBUTION_ID));
+            context.setAttribute(SdcArtifactHandlerConstants.SERVICE_NAME,
+                    document_information.getString(SdcArtifactHandlerConstants.SERVICE_NAME));
+            context.setAttribute(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION,
+                    document_information.getString(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION));
+            context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_UUID,
+                    document_information.getString(SdcArtifactHandlerConstants.RESOURCE_UUID));
+            context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME,
+                    document_information.getString(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME));
+            context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_VERSOIN,
+                    document_information.getString(SdcArtifactHandlerConstants.RESOURCE_VERSOIN));
+            context.setAttribute(SdcArtifactHandlerConstants.RESOURCE_TYPE,
+                    document_information.getString(SdcArtifactHandlerConstants.RESOURCE_TYPE));
+            context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_UUID,
+                    document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_UUID));
+            context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_VERSOIN,
+                    document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_VERSOIN));
+            context.setAttribute(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION,
+                    document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION));
+
+
+            dbservice.saveArtifacts(context, intversion);
+            return;
+        } catch (Exception e) {
+            log.error("Error saving capabilities artifact to DB: " + e.toString());
+            throw e;
+        } finally {
+            log.info("End-->processAndStoreCapablitiesArtifact ");
+        }
 
     }
+
+    private void populateProtocolReference(DBService dbservice, JSONObject content) throws Exception {
+        log.info("Begin-->populateProtocolReference ");
+        try {
+            SvcLogicContext context = new SvcLogicContext();
+            JSONObject scope = content.getJSONObject("scope");
+            String vnfType = null, protocol = null, action = null, actionLevel = null, template = null;
+            if (scope.has(SdcArtifactHandlerConstants.VNF_TYPE) && !scope.isNull(SdcArtifactHandlerConstants.VNF_TYPE))
+                vnfType = scope.getString(SdcArtifactHandlerConstants.VNF_TYPE);
+            if (content.has(SdcArtifactHandlerConstants.DEVICE_PROTOCOL))
+                protocol = content.getString(SdcArtifactHandlerConstants.DEVICE_PROTOCOL);
+            if (content.has(SdcArtifactHandlerConstants.ACTION))
+                action = content.getString(SdcArtifactHandlerConstants.ACTION);
+            if (content.has(SdcArtifactHandlerConstants.ACTION_LEVEL))
+                actionLevel = content.getString(SdcArtifactHandlerConstants.ACTION_LEVEL);
+            if (content.has(SdcArtifactHandlerConstants.TEMPLATE)
+                    && !content.isNull(SdcArtifactHandlerConstants.TEMPLATE))
+                template = content.getString(SdcArtifactHandlerConstants.TEMPLATE);
+            dbservice.insertProtocolReference(context, vnfType, protocol, action, actionLevel, template);
+        } catch (Exception e) {
+            log.error("Error inserting record into protocolReference: " + e.toString());
+            throw e;
+        } finally {
+            log.info("End-->populateProtocolReference ");
+        }
+    }
+
+}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/DBServiceTest.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/DBServiceTest.java
new file mode 100644 (file)
index 0000000..043283f
--- /dev/null
@@ -0,0 +1,287 @@
+/*-
+ * ============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.artifact.handler.dbservices;
+
+import java.nio.charset.Charset;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.openecomp.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.powermock.reflect.Whitebox;
+
+public class DBServiceTest {
+
+    @Test
+    public void testSaveArtifacts() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        int internalVersion = 1;
+        dbService.saveArtifacts(ctx, internalVersion);
+    }
+
+    @Test(expected = Exception.class)
+    public void testSaveArtifactsException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        int internalVersion = 1;
+        dbService.saveArtifacts(ctx, internalVersion);
+    }
+
+    @Test
+    public void testLogData() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String prefix = "test";
+        dbService.logData(ctx, prefix);
+    }
+
+
+    @Test(expected = Exception.class)
+    public void testLogDataException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String prefix = "test";
+        dbService.logData(ctx, prefix);
+    }
+
+    @Test
+    public void testProcessConfigActionDg() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        ctx.setAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE, "Reference");
+        dbService.processConfigActionDg(ctx, isUpdate);
+    }
+
+    @Test(expected = Exception.class)
+    public void testProcessConfigActionDgException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        ctx.setAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE, "Reference");
+        dbService.processConfigActionDg(ctx, isUpdate);
+    }
+
+    @Test
+    public void testGetModelDataInformationbyArtifactName() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String artifactName = "test";
+        dbService.getModelDataInformationbyArtifactName(artifactName);
+    }
+
+    @Test(expected = Exception.class)
+    public void testGetModelDataInformationbyArtifactNameException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String artifactName = "test";
+        dbService.getModelDataInformationbyArtifactName(artifactName);
+    }
+
+    @Test
+    public void testUpdateYangContents() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String artifactName = "test";
+        String artifactId = "TestArtifact";
+        String yangContents = "TestYangContents";
+        dbService.updateYangContents(ctx, artifactId, yangContents);
+    }
+
+    @Test(expected = Exception.class)
+    public void testUpdateYangContentsException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String artifactName = "test";
+        String artifactId = "TestArtifact";
+        String yangContents = "TestYangContents";
+        dbService.updateYangContents(ctx, artifactId, yangContents);
+    }
+
+    @Test
+    public void testInsertProtocolReference() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String vnfType = "testVnf";
+        String protocol = "testProtocol";
+        String action = "testAction";
+        String actionLevel = "testActionLevel";
+        String template = "testTemplateData";
+        dbService.insertProtocolReference(ctx, vnfType, protocol, action, actionLevel, template);
+    }
+
+
+    @Test(expected = Exception.class)
+    public void testInsertProtocolReferenceException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String vnfType = "testVnf";
+        String protocol = "testProtocol";
+        String action = "testAction";
+        String actionLevel = "testActionLevel";
+        String template = "testTemplateData";
+        dbService.insertProtocolReference(ctx, vnfType, protocol, action, actionLevel, template);
+    }
+
+    @Test
+    public void testprocessDpwnloadDGReference() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        dbService.processDownloadDgReference(ctx, isUpdate);
+    }
+
+    @Test(expected = Exception.class)
+    public void testprocessDpwnloadDGReferenceException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        dbService.processDownloadDgReference(ctx, isUpdate);
+    }
+
+    @Test
+    public void testProcessVnfcReference() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        dbService.processVnfcReference(ctx, isUpdate);
+    }
+
+    @Test(expected = Exception.class)
+    public void testProcessVnfcReferenceException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        dbService.processVnfcReference(ctx, isUpdate);
+    }
+
+    @Test
+    public void testProcessDeviceAuthentication() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        dbService.processDeviceAuthentication(ctx, isUpdate);
+    }
+
+    @Test(expected = Exception.class)
+    public void testProcessDeviceAuthenticationException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        dbService.processDeviceAuthentication(ctx, isUpdate);
+    }
+
+    @Test
+    public void testProcessDeviceInterfaceProtocol() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        dbService.processDeviceInterfaceProtocol(ctx, isUpdate);
+    }
+
+    @Test(expected = Exception.class)
+    public void testProcessDeviceInterfaceProtocolException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        dbService.processDeviceInterfaceProtocol(ctx, isUpdate);
+    }
+
+    @Test
+    public void testProcessSdcReferences() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        dbService.processSdcReferences(ctx, isUpdate);
+    }
+
+    @Test(expected = Exception.class)
+    public void testProcessSdcReferencesException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        boolean isUpdate = true;
+        dbService.processSdcReferences(ctx, isUpdate);
+    }
+
+    @Test
+    public void testIsArtifactUpdateRequired() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String db = "db";
+        dbService.isArtifactUpdateRequired(ctx, db);
+    }
+
+    @Test(expected = Exception.class)
+    public void testIsArtifactUpdateRequiredExcetion() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String db = "db";
+        dbService.isArtifactUpdateRequired(ctx, db);
+    }
+
+
+    @Test
+    public void testgetArtifactID() throws Exception {
+        MockDBService dbService = MockDBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String db = "db";
+        dbService.getArtifactID(ctx, db);
+    }
+
+    @Test(expected = Exception.class)
+    public void testgetArtifactIDException() throws Exception {
+        DBService dbService = DBService.initialise();
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        String db = "db";
+        dbService.getArtifactID(ctx, db);
+    }
+}
+
  * ============LICENSE_END=========================================================
  */
 
-package org.openecomp.appc.artifact.handler.node;
+package org.openecomp.appc.artifact.handler.dbservices;
 
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.Enumeration;
-import java.util.Properties;
+public class MockDBService extends DBService {
+    private static MockDBService mockDgGeneralDBService = null;
+    private static MockSvcLogicResource serviceLogic = new MockSvcLogicResource();;
 
-import org.apache.commons.io.IOUtils;
-import org.json.JSONObject;
+    public MockDBService() {
+        super(serviceLogic);
+        if (mockDgGeneralDBService != null) {
+            mockDgGeneralDBService = new MockDBService(serviceLogic);
+        }
+
+    }
+
+    public MockDBService(MockSvcLogicResource serviceLogic2) {
+        super(serviceLogic);
+    }
+
+    public static MockDBService initialise() {
+        if (mockDgGeneralDBService == null) {
+            mockDgGeneralDBService = new MockDBService(serviceLogic);
+        }
+        return mockDgGeneralDBService;
+    }
 
-public class TestArtifactHandlerNode {
 }
+
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/MockSvcLogicResource.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/MockSvcLogicResource.java
new file mode 100644 (file)
index 0000000..ae09e45
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * ============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.artifact.handler.dbservices;
+
+import java.util.Map;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
+
+public class MockSvcLogicResource extends SqlResource {
+
+    @Override
+    public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix,
+            String orderBy, SvcLogicContext ctx) throws SvcLogicException {
+        QueryStatus status = QueryStatus.SUCCESS;
+        ctx.setAttribute("id", "testId");
+        ctx.setAttribute("VNF_TYPE", "testvnf");
+        ctx.setAttribute("maximum", "1");
+        ctx.setAttribute("COUNT(*)", "1");
+        return status;
+    }
+
+
+    @Override
+    public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map<String, String> parms,
+            String prefix, SvcLogicContext ctx) throws SvcLogicException {
+        return QueryStatus.SUCCESS;
+    }
+
+
+}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNodeTest.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNodeTest.java
new file mode 100644 (file)
index 0000000..895aabe
--- /dev/null
@@ -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.artifact.handler.node;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.json.JSONObject;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.powermock.reflect.Whitebox;
+import static org.junit.Assert.assertTrue;
+import org.openecomp.appc.artifact.handler.dbservices.DBService;
+import org.openecomp.appc.artifact.handler.dbservices.MockDBService;
+import org.openecomp.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
+import org.openecomp.appc.artifact.handler.utils.ArtifactHandlerProviderUtilTest;
+
+import java.util.Map;
+import java.util.HashMap;
+
+public class ArtifactHandlerNodeTest {
+
+    @Test
+    public void testProcessArtifact() throws Exception {
+        SvcLogicContext ctx = new SvcLogicContext();
+        ctx.setAttribute("test", "test");
+        MockArtifactHandlerNode ah = new MockArtifactHandlerNode();
+        Map<String, String> inParams = new HashMap<String, String>();
+        JSONObject postData = new JSONObject();
+        JSONObject input = new JSONObject();
+        inParams.put("response_prefix", "prefix");
+        JSONObject requestInfo = new JSONObject();
+        JSONObject documentInfo = new JSONObject();
+        String artifactContent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
+                .getResourceAsStream("templates/reference_template"), Charset.defaultCharset());
+        documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS, artifactContent);
+        documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, "reference_Junit.json");
+        requestInfo.put("RequestInfo", "testValue");
+        input.put(SdcArtifactHandlerConstants.DOCUMENT_PARAMETERS, documentInfo);
+        input.put(SdcArtifactHandlerConstants.REQUEST_INFORMATION, requestInfo);
+        postData.put("input", input);
+        inParams.put("postData", postData.toString());
+        ah.processArtifact(inParams, ctx);
+    }
+
+    @Test(expected = Exception.class)
+    public void testStoreReferenceData() throws Exception {
+        MockArtifactHandlerNode ah = new MockArtifactHandlerNode();
+        JSONObject documentInfo = new JSONObject();
+        String artifactContent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
+                .getResourceAsStream("templates/reference_template"), Charset.defaultCharset());
+        documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS, artifactContent);
+        documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, "reference_Junit.json");
+        JSONObject requestInfo = new JSONObject();
+        requestInfo.put("RequestInfo", "testStoreReferenceData");
+        ah.storeReferenceData(requestInfo, documentInfo);
+    }
+
+    @Test
+    public void testPopulateProtocolReference() throws Exception {
+        ArtifactHandlerNode ah = new ArtifactHandlerNode();
+        String contentStr =
+                "{\"action\": \"TestAction\",\"action-level\": \"vnf\",\"scope\": {\"vnf-type\": \"vDBE-I\",\"vnfc-type\": null},\"template\": \"N\",\"device-protocol\": \"REST\"}";
+        JSONObject content = new JSONObject(contentStr);
+        MockDBService dbService = MockDBService.initialise();
+        Whitebox.invokeMethod(ah, "populateProtocolReference", dbService, content);
+    }
+
+    @Test
+    public void testProcessAndStoreCapablitiesArtifact() throws Exception {
+        ArtifactHandlerNode ah = new ArtifactHandlerNode();
+        JSONObject capabilities = new JSONObject();
+        JSONObject documentInfo = new JSONObject();
+        MockDBService dbService = MockDBService.initialise();
+        documentInfo.put(SdcArtifactHandlerConstants.SERVICE_UUID, "testuid");
+        documentInfo.put(SdcArtifactHandlerConstants.DISTRIBUTION_ID, "testDist");
+        documentInfo.put(SdcArtifactHandlerConstants.SERVICE_NAME, "testName");
+        documentInfo.put(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION, "testDesc");
+        documentInfo.put(SdcArtifactHandlerConstants.RESOURCE_UUID, "testRes");
+        documentInfo.put(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME, "testResIns");
+        documentInfo.put(SdcArtifactHandlerConstants.RESOURCE_VERSOIN, "testVers");
+        documentInfo.put(SdcArtifactHandlerConstants.RESOURCE_TYPE, "testResType");
+        documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_UUID, "testArtifactUuid");
+        documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_VERSOIN, "testArtifactVers");
+        documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION, "testArtifactDesc");
+        Whitebox.invokeMethod(ah, "processAndStoreCapablitiesArtifact", dbService, documentInfo, capabilities,
+                "artifactName", "someVnf");
+    }
+
+    @Test
+    public void testCleanVnfcInstance() throws Exception {
+        ArtifactHandlerNode ah = new ArtifactHandlerNode();
+        SvcLogicContext ctx = new SvcLogicContext();
+        Whitebox.invokeMethod(ah, "cleanVnfcInstance", ctx);
+        assertTrue(true);
+    }
+
+    @Test(expected = Exception.class)
+    public void testGetArtifactIDException() throws Exception {
+        ArtifactHandlerNode ah = new ArtifactHandlerNode();
+        String yFileName = "yFileName";
+        Whitebox.invokeMethod(ah, "getArtifactID", yFileName);
+    }
+
+    @Test(expected = Exception.class)
+    public void testStoreUpdateSdcArtifacts() throws Exception {
+        ArtifactHandlerNode ah = new ArtifactHandlerNode();
+        String postDataStr =
+                "{\"request-information\":{},\"document-parameters\":{\"artifact-name\":\"testArtifact\",\"artifact-contents\":{\"content\":\"TestContent\"}}}";
+        JSONObject postData = new JSONObject(postDataStr);
+        Whitebox.invokeMethod(ah, "storeUpdateSdcArtifacts", postData);
+    }
+
+    @Test(expected = Exception.class)
+    public void testUpdateStoreArtifacts() throws Exception {
+        MockArtifactHandlerNode ah = new MockArtifactHandlerNode();
+        JSONObject documentInfo = new JSONObject();
+        String artifactContent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
+                .getResourceAsStream("templates/reference_template"), Charset.defaultCharset());
+        documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_CONTENTS, artifactContent);
+        documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, "reference_Junit.json");
+        JSONObject requestInfo = new JSONObject();
+        requestInfo.put("RequestInfo", "testupdateStoreArtifacts");
+        ah.updateStoreArtifacts(requestInfo, documentInfo);
+    }
+
+    @Test
+    public void testCleanArtifactInstanceData() throws Exception {
+        MockArtifactHandlerNode ah = new MockArtifactHandlerNode();
+        SvcLogicContext ctx = new SvcLogicContext();
+        Whitebox.invokeMethod(ah, "cleanArtifactInstanceData", ctx);
+    }
+
+    @Test(expected = Exception.class)
+    public void testUpdateYangContents() throws Exception {
+        MockArtifactHandlerNode ah = new MockArtifactHandlerNode();
+        String artifactId = "1";
+        String yangContents = "SomeContent";
+        Whitebox.invokeMethod(ah, "updateYangContents", artifactId, yangContents);
+    }
+    
+}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/MockArtifactHandlerNode.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/node/MockArtifactHandlerNode.java
new file mode 100644 (file)
index 0000000..437fa26
--- /dev/null
@@ -0,0 +1,65 @@
+/*-
+ * ============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.artifact.handler.node;
+
+import org.json.JSONObject;
+import org.openecomp.appc.artifact.handler.dbservices.MockDBService;
+import org.openecomp.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+public class MockArtifactHandlerNode extends ArtifactHandlerNode {
+
+    @Override
+    public boolean updateStoreArtifacts(JSONObject request_information, JSONObject document_information)
+            throws Exception {
+        if (request_information != null && request_information.get("RequestInfo").equals("testupdateStoreArtifacts")) {
+            super.updateStoreArtifacts(request_information, document_information);
+        }
+        SvcLogicContext context = new SvcLogicContext();
+        MockDBService dbservice = MockDBService.initialise();
+        int intversion = 0;
+        context.setAttribute("artifact_name",
+                document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
+        String internal_version = dbservice.getInternalVersionNumber(context,
+                document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME), null);
+        if (internal_version != null) {
+            intversion = Integer.parseInt(internal_version);
+            intversion++;
+        }
+
+        return true;
+
+    }
+
+    @Override
+    public boolean storeReferenceData(JSONObject request_information, JSONObject document_information)
+            throws Exception {
+        if (request_information != null && request_information.get("RequestInfo").equals("testStoreReferenceData")) {
+            super.storeReferenceData(request_information, document_information);
+        }
+        return true;
+    }
+
+}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/utils/ArtifactHandlerProviderUtilTest.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/utils/ArtifactHandlerProviderUtilTest.java
new file mode 100644 (file)
index 0000000..be7e3cf
--- /dev/null
@@ -0,0 +1,82 @@
+/*-
+ * ============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.artifact.handler.utils;
+
+import static org.junit.Assert.assertTrue;
+import java.nio.charset.Charset;
+import org.apache.commons.io.IOUtils;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+public class ArtifactHandlerProviderUtilTest {
+
+    @Test(expected = Exception.class)
+    public void testProcessTemplate() throws Exception {
+        String artifact_conetent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
+                .getResourceAsStream("templates/reference_template.json"), Charset.defaultCharset());
+        JSONObject obj = new JSONObject();
+        obj.put("artifact-name", "reference_JunitTestArtifact");
+        obj.put("artifact-version", "0.01");
+        obj.put("artifact-contents", artifact_conetent);
+        ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
+        ahprovider.processTemplate(obj.toString());
+    }
+
+    @Test(expected = Exception.class)
+    public void testcreateDummyRequestData() throws Exception {
+        String artifact_conetent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
+                .getResourceAsStream("templates/reference_template.json"), Charset.defaultCharset());
+        JSONObject obj = new JSONObject();
+        obj.put("artifact-name", "reference_JunitTestArtifact");
+        obj.put("artifact-version", "0.01");
+        obj.put("artifact-contents", artifact_conetent);
+        ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
+        String requestInfo = ahprovider.createDummyRequestData();
+    }
+
+    @Test
+    public void testEscapeSql() throws Exception {
+        String testStr = "Test String is 'test'";
+        ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
+        ahprovider.escapeSql(testStr);
+        assertTrue(true);
+    }
+
+    @Test
+    public void testGetRandom() throws Exception {
+        ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
+        Whitebox.invokeMethod(ahprovider, "getRandom");
+        assertTrue(true);
+    }
+
+    @Test
+    public void testEscapeUtils() throws Exception {
+        String str = "The Test string is 'test'";
+        EscapeUtils.escapeSql(str);
+        assertTrue(true);
+    }
+}
+
index e69de29..ef4772d 100755 (executable)
@@ -0,0 +1,100 @@
+{
+"reference_data" : [
+{
+"action": "ConfigureTest",
+"action-level":"VNF",
+"scope": {
+"vnf-type": "TestvUSP - vDBE-IPX HUB",
+"vnfc-type": "TestDBE-VM #1"
+},
+"template": "Y",
+"vm": [
+{
+"vm-instance": 1,
+"vnfc": [
+{
+"vnfc-instance": 1,
+"vnfc-type": "TestDBE-VM #1",
+"vnfc-function-code": "Testdbg",
+"group-notation-type": "GNType",
+"ipaddress-v4-oam-vip": "N",
+"group-notation-value": "GNValue"
+},
+{
+"vnfc-instance": 2,
+"vnfc-type": "TestDBE-VM #1",
+"vnfc-function-code": "Testdbg",
+"group-notation-type": "GNType",
+"ipaddress-v4-oam-vip": "Y",
+"group-notation-value": "GNValue"
+}
+]
+},
+{
+"vm-instance": 2,
+"vnfc": [{
+"vnfc-instance": 1,
+"vnfc-type": "TestDBE-VM #1",
+"vnfc-function-code": "Testdbg",
+"group-notation-type": "GNType",
+"ipaddress-v4-oam-vip": "Y",
+"group-notation-value": "GNValue"
+}
+]
+}
+],
+"device-protocol": "TestNETCONF-XML",
+"user-name": "Testnetconf",
+"port-number": "22",
+"download-dg-reference" : "TestDownloadDGReference",
+"artifact-list": [
+{
+"artifact-name": "TestvDBE-I_template.json",
+"artifact-type": "Testconfig_template"
+},
+{
+"artifact-name": "TESTvDBE-I_parameter_definitions.json",
+"artifact-type": "Testparameter_definitions"
+},
+{
+"artifact-name": "PD_JunitTESTvDBE-I_parameter_yang.json",
+"artifact-type": "PD_definations"
+}
+]
+},
+{
+       "action": "ConfigModify",
+       "action-level": "VNF",
+       "scope": {
+               "vnf-type": "vDBE-I",
+               "vnfc-type": null
+       },
+       "template": "Y",
+       "device-protocol": "NETCONF-XML",
+       "user-name": "Testnetconf",
+       "port-number": "22",
+       "artifact-list": [
+               {
+                       "artifact-name": "template_ConfigModify_vDBE-I_0.0.1V.xml",
+                       "artifact-type": "config_template"
+               },
+               {
+                       "artifact-name": "pd_ConfigModify_vDBE-I_0.0.1V.yaml",
+                       "artifact-type": "parameter_definitions"
+               }
+       ]
+},
+
+{
+       "action": "HealthCheck",
+       "action-level": "VM",
+       "scope": {
+               "vnf-type": "vDBE-I",
+               "vnfc-type": null
+       },
+       "template": "N",
+       "device-protocol": "REST",
+       "vnfc-function-code": ["SSC","MMSC"]
+}
+]
+}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/resources/templates/reference_template.json b/appc-inbound/appc-artifact-handler/provider/src/test/resources/templates/reference_template.json
new file mode 100755 (executable)
index 0000000..ef4772d
--- /dev/null
@@ -0,0 +1,100 @@
+{
+"reference_data" : [
+{
+"action": "ConfigureTest",
+"action-level":"VNF",
+"scope": {
+"vnf-type": "TestvUSP - vDBE-IPX HUB",
+"vnfc-type": "TestDBE-VM #1"
+},
+"template": "Y",
+"vm": [
+{
+"vm-instance": 1,
+"vnfc": [
+{
+"vnfc-instance": 1,
+"vnfc-type": "TestDBE-VM #1",
+"vnfc-function-code": "Testdbg",
+"group-notation-type": "GNType",
+"ipaddress-v4-oam-vip": "N",
+"group-notation-value": "GNValue"
+},
+{
+"vnfc-instance": 2,
+"vnfc-type": "TestDBE-VM #1",
+"vnfc-function-code": "Testdbg",
+"group-notation-type": "GNType",
+"ipaddress-v4-oam-vip": "Y",
+"group-notation-value": "GNValue"
+}
+]
+},
+{
+"vm-instance": 2,
+"vnfc": [{
+"vnfc-instance": 1,
+"vnfc-type": "TestDBE-VM #1",
+"vnfc-function-code": "Testdbg",
+"group-notation-type": "GNType",
+"ipaddress-v4-oam-vip": "Y",
+"group-notation-value": "GNValue"
+}
+]
+}
+],
+"device-protocol": "TestNETCONF-XML",
+"user-name": "Testnetconf",
+"port-number": "22",
+"download-dg-reference" : "TestDownloadDGReference",
+"artifact-list": [
+{
+"artifact-name": "TestvDBE-I_template.json",
+"artifact-type": "Testconfig_template"
+},
+{
+"artifact-name": "TESTvDBE-I_parameter_definitions.json",
+"artifact-type": "Testparameter_definitions"
+},
+{
+"artifact-name": "PD_JunitTESTvDBE-I_parameter_yang.json",
+"artifact-type": "PD_definations"
+}
+]
+},
+{
+       "action": "ConfigModify",
+       "action-level": "VNF",
+       "scope": {
+               "vnf-type": "vDBE-I",
+               "vnfc-type": null
+       },
+       "template": "Y",
+       "device-protocol": "NETCONF-XML",
+       "user-name": "Testnetconf",
+       "port-number": "22",
+       "artifact-list": [
+               {
+                       "artifact-name": "template_ConfigModify_vDBE-I_0.0.1V.xml",
+                       "artifact-type": "config_template"
+               },
+               {
+                       "artifact-name": "pd_ConfigModify_vDBE-I_0.0.1V.yaml",
+                       "artifact-type": "parameter_definitions"
+               }
+       ]
+},
+
+{
+       "action": "HealthCheck",
+       "action-level": "VM",
+       "scope": {
+               "vnf-type": "vDBE-I",
+               "vnfc-type": null
+       },
+       "template": "N",
+       "device-protocol": "REST",
+       "vnfc-function-code": ["SSC","MMSC"]
+}
+]
+}