Junit Cases for Artifact Handler.
[appc.git] / appc-inbound / appc-artifact-handler / provider / src / main / java / org / openecomp / appc / artifact / handler / dbservices / DBService.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.openecomp.appc.artifact.handler.dbservices;
26
27 import java.sql.SQLException;
28 import java.util.HashMap;
29
30 import org.openecomp.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
32 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
34 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
35 import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
36
37 import com.att.eelf.configuration.EELFLogger;
38 import com.att.eelf.configuration.EELFManager;
39
40 public class DBService {
41
42     private static final EELFLogger log = EELFManager.getInstance().getLogger(DBService.class);
43     private SvcLogicResource serviceLogic;
44     private static DBService dgGeneralDBService = null;
45
46     public static DBService initialise() {
47         if (dgGeneralDBService == null) {
48             dgGeneralDBService = new DBService();
49         }
50         return dgGeneralDBService;
51     }
52
53     private DBService() {
54         if (serviceLogic == null) {
55             serviceLogic = new SqlResource();
56         }
57     }
58
59     protected DBService(SqlResource svcLogic) {
60         if (serviceLogic == null) {
61             serviceLogic = svcLogic;
62         }
63     }
64
65     public String getInternalVersionNumber(SvcLogicContext ctx, String artifactName, String prefix)
66             throws SvcLogicException {
67         String fn = "DBService.getInternalVersionNumber";
68         QueryStatus status = null;
69         String artifactInternalVersion = null;
70         if (serviceLogic != null && ctx != null) {
71             String key = "select max(internal_version) as maximum from ASDC_ARTIFACTS  WHERE ARTIFACT_NAME = '"
72                     + artifactName + "'";
73             log.info("Getting internal Versoin :" + key);
74             status = serviceLogic.query("SQL", false, null, key, prefix, null, ctx);
75             if (status.toString().equals("FAILURE"))
76                 throw new SvcLogicException("Error - getting internal Artifact Number");
77             artifactInternalVersion = ctx.getAttribute("maximum");
78             log.info("Internal Version received as : " + artifactInternalVersion);
79             log.info("Internal Version received as1 : " + ctx.getAttribute("max(internal_version)"));
80             log.info("Internal Version received as1 : " + ctx.getAttribute("max"));
81             log.info("Internal Version received as1 : " + ctx.getAttribute("internal_version"));
82             log.info("Internal Version received as1 : " + ctx.getAttributeKeySet().toString());
83         }
84         return artifactInternalVersion;
85     }
86
87     public String getArtifactID(SvcLogicContext ctx, String artifactName) throws SvcLogicException {
88         String fn = "DBService.getArtifactID";
89         QueryStatus status = null;
90         String artifactID = null;
91         if (serviceLogic != null && ctx != null) {
92             String key = "select max(ASDC_ARTIFACTS_ID) as id from ASDC_ARTIFACTS  WHERE ARTIFACT_NAME = '"
93                     + artifactName + "'";
94             log.info("Getting Artifact ID String :" + key);
95             status = serviceLogic.query("SQL", false, null, key, null, null, ctx);
96             if (status.toString().equals("FAILURE"))
97                 throw new SvcLogicException("Error - getting  Artifact ID from database");
98             artifactID = ctx.getAttribute("id");
99             log.info("SDC_ARTIFACTS_ID received as : " + ctx.getAttribute("id"));
100         }
101         return artifactID;
102     }
103
104     public QueryStatus saveArtifacts(SvcLogicContext ctx, int intversion) throws SvcLogicException {
105         String fn = "DBService.saveArtifacts";
106         QueryStatus status = null;
107         if (serviceLogic != null && ctx != null) {
108             String key = "INSERT INTO ASDC_ARTIFACTS " + "SET SERVICE_UUID    =  $service-uuid , "
109                     + " DISTRIBUTION_ID    =  $distribution-id ," + " SERVICE_NAME    =  $service-name ,"
110                     + " SERVICE_DESCRIPTION    =  $service-description ," + " RESOURCE_UUID    = $resource-uuid ,"
111                     + " RESOURCE_INSTANCE_NAME    = $resource-instance-name ," + " RESOURCE_NAME    = $resource-name ,"
112                     + " RESOURCE_VERSION    = $resource-version ," + " RESOURCE_TYPE    = $resource-type ,"
113                     + " ARTIFACT_UUID    = $artifact-uuid ," + " ARTIFACT_TYPE    = $artifact-type ,"
114                     + " ARTIFACT_VERSION    = $artifact-version ," + " ARTIFACT_DESCRIPTION    = $artifact-description ,"
115                     + " INTERNAL_VERSION    = " + intversion + "," + " ARTIFACT_NAME       =  $artifact-name ,"
116                     + " ARTIFACT_CONTENT    =  $artifact-contents ";
117
118             status = serviceLogic.save("SQL", false, false, key, null, null, ctx);
119             if (status.toString().equals("FAILURE"))
120                 throw new SvcLogicException("Error While processing storing Artifact: "
121                         + ctx.getAttribute(SdcArtifactHandlerConstants.ARTIFACT_NAME));
122         }
123         return status;
124
125     }
126
127     public QueryStatus logData(SvcLogicContext ctx, String prefix) throws SvcLogicException {
128         String fn = "DBService.saveReferenceData";
129         QueryStatus status = null;
130         if (serviceLogic != null && ctx != null) {
131             String key = "INSERT INTO CONFIG_TRANSACTION_LOG " + " SET request_id = $request-id , "
132                     + " message_type = $log-message-type , " + " message = $log-message ;";
133             status = serviceLogic.save("SQL", false, false, key, null, prefix, ctx);
134             if (status.toString().equals("FAILURE"))
135                 throw new SvcLogicException("Error while loging data");
136
137         }
138         return status;
139     }
140
141     public void processConfigureActionDg(SvcLogicContext context, boolean isUpdate) {
142         String fn = "DBService.processConfigureActionDg";
143         log.info("Update Parameter for SDC Reference " + isUpdate);
144         String key = "";
145         QueryStatus status = null;
146         if (isUpdate)
147             ;
148     }
149
150     public void processSdcReferences(SvcLogicContext context, boolean isUpdate) throws SvcLogicException {
151         String fn = "DBService.processSdcReferences";
152         String key = "";
153         QueryStatus status = null;
154
155         if (isUpdate && SdcArtifactHandlerConstants.FILE_CATEGORY.equals(SdcArtifactHandlerConstants.CAPABILITY)) {
156             key = "update " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + "  set ARTIFACT_NAME = $"
157                     + SdcArtifactHandlerConstants.ARTIFACT_NAME + " where VNFC_TYPE = $"
158                     + SdcArtifactHandlerConstants.VNFC_TYPE + " and FILE_CATEGORY = $"
159                     + SdcArtifactHandlerConstants.FILE_CATEGORY + " and ACTION = null";
160         } else if (isUpdate)
161             key = "update " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + "  set ARTIFACT_NAME = $"
162                     + SdcArtifactHandlerConstants.ARTIFACT_NAME + " where VNFC_TYPE = $"
163                     + SdcArtifactHandlerConstants.VNFC_TYPE + " and FILE_CATEGORY = $"
164                     + SdcArtifactHandlerConstants.FILE_CATEGORY + " and ACTION = $"
165                     + SdcArtifactHandlerConstants.ACTION;
166
167         else {
168             if (SdcArtifactHandlerConstants.FILE_CATEGORY.equals(SdcArtifactHandlerConstants.CAPABILITY)) {
169                 key = "insert into " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + " set VNFC_TYPE = null "
170                         + " , FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY + " , VNF_TYPE = $"
171                         + SdcArtifactHandlerConstants.VNF_TYPE + " , ACTION = null " + " , ARTIFACT_TYPE = null "
172                         + " , ARTIFACT_NAME = $" + SdcArtifactHandlerConstants.ARTIFACT_NAME;
173             } else {
174                 key = "insert into " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + " set VNFC_TYPE = $"
175                         + SdcArtifactHandlerConstants.VNFC_TYPE + " , FILE_CATEGORY = $"
176                         + SdcArtifactHandlerConstants.FILE_CATEGORY + " , VNF_TYPE = $"
177                         + SdcArtifactHandlerConstants.VNF_TYPE + " , ACTION = $" + SdcArtifactHandlerConstants.ACTION
178                         + " , ARTIFACT_TYPE = $" + SdcArtifactHandlerConstants.ARTIFACT_TYPE + " , ARTIFACT_NAME = $"
179                         + SdcArtifactHandlerConstants.ARTIFACT_NAME;
180             }
181         }
182         if (serviceLogic != null && context != null) {
183             log.info("Insert Key: " + key);
184             status = serviceLogic.save("SQL", false, false, key, null, null, context);
185             if (status.toString().equals("FAILURE"))
186                 throw new SvcLogicException("Error While processing sdc_reference table ");
187         }
188     }
189
190     public boolean isArtifactUpdateRequired(SvcLogicContext context, String db) throws SvcLogicException, SQLException {
191         String fn = "DBService.isArtifactUpdateRequired";
192         log.info("Checking if Update required for this data");
193
194         log.info("db" + db);
195         log.info("ACTION=" + context.getAttribute(SdcArtifactHandlerConstants.ACTION));
196         log.info("VNFC_TYPE=" + context.getAttribute(SdcArtifactHandlerConstants.VNFC_TYPE));
197         log.info("VNFC_INSTANCE=" + context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE));
198         log.info("VM_INSTANCE=" + context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE));
199         log.info("VNF_TYPE=" + context.getAttribute(SdcArtifactHandlerConstants.VNF_TYPE));
200         String whereClause = "";
201
202         QueryStatus status = null;
203         whereClause = " where VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE;
204
205         if (db != null && db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE)
206                 && context.getAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY)
207                         .equals(SdcArtifactHandlerConstants.CAPABILITY)
208                 && context.getAttribute(SdcArtifactHandlerConstants.ACTION) == null) {
209             whereClause = whereClause + " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY;
210         }
211
212         else if (db != null && db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE)) {
213             whereClause = whereClause + " and VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE
214                     + " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY + " and ACTION = $"
215                     + SdcArtifactHandlerConstants.ACTION;
216         }
217
218         else if (db.equals(SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE)) {
219             whereClause = " where PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL;
220         } else if (db.equals(SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG)) {
221             whereClause = whereClause + " and ACTION = $" + SdcArtifactHandlerConstants.ACTION;
222         } else if (db.equals(SdcArtifactHandlerConstants.DB_VNFC_REFERENCE)) {
223             int vm_instance = -1;
224             if (context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE) != null)
225                 vm_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE));
226             int vnfc_instance = -1;
227             if (context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE) != null)
228                 vnfc_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE));
229             whereClause = whereClause + " and ACTION = $" + SdcArtifactHandlerConstants.ACTION + " and VNFC_TYPE = $"
230                     + SdcArtifactHandlerConstants.VNFC_TYPE + " and VNFC_INSTANCE = $"
231                     + SdcArtifactHandlerConstants.VNFC_INSTANCE + " and VM_INSTANCE = $"
232                     + SdcArtifactHandlerConstants.VM_INSTANCE;
233
234         }
235         if (serviceLogic != null && context != null) {
236             String key = "select COUNT(*) from " + db + whereClause;
237             log.info("SELECT String : " + key);
238             status = serviceLogic.query("SQL", false, null, key, null, null, context);
239             if (status.toString().equals("FAILURE")) {
240                 throw new SvcLogicException("Error while reading data from " + db);
241             }
242             String count = context.getAttribute("COUNT(*)");
243             log.info("Number of row Returned : " + count + ": " + status + ":");
244             if (count != null && Integer.parseInt(count) > 0) {
245                 context.setAttribute(count, null);
246                 return true;
247             } else
248                 return false;
249         }
250         return false;
251     }
252
253     public void processDeviceInterfaceProtocol(SvcLogicContext context, boolean isUpdate) throws SvcLogicException {
254         String fn = "DBService.processDeviceInterfaceProtocol";
255         log.info("Starting DB operation for Device Interface Protocol " + isUpdate);
256         String key = "";
257         QueryStatus status = null;
258         if (isUpdate)
259             key = "update " + SdcArtifactHandlerConstants.DB_DEVICE_INTERFACE_PROTOCOL + " set PROTOCOL = $"
260                     + SdcArtifactHandlerConstants.DEVICE_PROTOCOL + " , DG_RPC = 'getDeviceRunningConfig' "
261                     + " , MODULE = 'APPC' " + " where VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE;
262         else
263             key = "insert into " + SdcArtifactHandlerConstants.DB_DEVICE_INTERFACE_PROTOCOL + " set  VNF_TYPE = $"
264                     + SdcArtifactHandlerConstants.VNF_TYPE + " , PROTOCOL = $"
265                     + SdcArtifactHandlerConstants.DEVICE_PROTOCOL + " , DG_RPC = 'getDeviceRunningConfig' "
266                     + " , MODULE = 'APPC' ";
267
268         if (serviceLogic != null && context != null) {
269
270             status = serviceLogic.save("SQL", false, false, key, null, null, context);
271             if (status.toString().equals("FAILURE"))
272                 throw new SvcLogicException("Error While processing DEVICE_INTERFACE_PROTOCOL table ");
273         }
274
275     }
276
277     public void processDeviceAuthentication(SvcLogicContext context, boolean isUpdate) throws SvcLogicException {
278         String fn = "DBService.processDeviceAuthentication";
279         log.info(fn + "Starting DB operation for Device Authentication " + isUpdate);
280         String key = "";
281         QueryStatus status = null;
282         if (isUpdate)
283             key = "update " + SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION + " set USER_NAME = $"
284                     + SdcArtifactHandlerConstants.USER_NAME + " , PASSWORD = 'dummy' " + " , PORT_NUMBER = $"
285                     + SdcArtifactHandlerConstants.PORT_NUMBER + " where VNF_TYPE = $"
286                     + SdcArtifactHandlerConstants.VNF_TYPE;
287         else
288             key = "insert into " + SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION + " set  VNF_TYPE = $"
289                     + SdcArtifactHandlerConstants.VNF_TYPE + " , USER_NAME = $" + SdcArtifactHandlerConstants.USER_NAME
290                     + " , PASSWORD = 'dummy' " + " , PORT_NUMBER = $" + SdcArtifactHandlerConstants.PORT_NUMBER;
291
292         if (serviceLogic != null && context != null) {
293             status = serviceLogic.save("SQL", false, false, key, null, null, context);
294             if (status.toString().equals("FAILURE"))
295                 throw new SvcLogicException("Error While processing DEVICE_AUTHENTICATION table ");
296         }
297     }
298
299     public void processVnfcReference(SvcLogicContext context, boolean isUpdate) throws SvcLogicException {
300         String fn = "DBService.processVnfcReference";
301         log.info(fn + "Starting DB operation for Vnfc Reference " + isUpdate);
302         String key = "";
303         int vm_instance = -1;
304         if (context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE) != null)
305             vm_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE));
306         int vnfc_instance = -1;
307         if (context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE) != null)
308             vnfc_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE));
309         QueryStatus status = null;
310         if (isUpdate)
311             key = "update " + SdcArtifactHandlerConstants.DB_VNFC_REFERENCE + " set VM_INSTANCE = " + vm_instance
312                     + " , VNFC_INSTANCE = " + vnfc_instance + " , VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE
313                     + " , VNFC_FUNCTION_CODE = $" + SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE
314                     + " , GROUP_NOTATION_TYPE = $" + SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE
315                     + " , GROUP_NOTATION_VALUE = $" + SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE
316                     + " , IPADDRESS_V4_OAM_VIP = $" + SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP
317                     + " where VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE + " and ACTION = $"
318                     + SdcArtifactHandlerConstants.ACTION + " and VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE
319                     + " and VNFC_INSTANCE = $" + SdcArtifactHandlerConstants.VNFC_INSTANCE + " and VM_INSTANCE = $"
320                     + SdcArtifactHandlerConstants.VM_INSTANCE;
321         else
322             key = "insert into " + SdcArtifactHandlerConstants.DB_VNFC_REFERENCE + " set  VNF_TYPE = $"
323                     + SdcArtifactHandlerConstants.VNF_TYPE + " , ACTION = $" + SdcArtifactHandlerConstants.ACTION
324                     + " , VM_INSTANCE = $" + SdcArtifactHandlerConstants.VM_INSTANCE + " , VNFC_INSTANCE = $"
325                     + SdcArtifactHandlerConstants.VNFC_INSTANCE + " , VNFC_TYPE = $"
326                     + SdcArtifactHandlerConstants.VNFC_TYPE + " , VNFC_FUNCTION_CODE = $"
327                     + SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE + " , GROUP_NOTATION_TYPE = $"
328                     + SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE + " , IPADDRESS_V4_OAM_VIP = $"
329                     + SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP + " , GROUP_NOTATION_VALUE = $"
330                     + SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE;
331
332         if (serviceLogic != null && context != null) {
333             status = serviceLogic.save("SQL", false, false, key, null, null, context);
334             if (status.toString().equals("FAILURE"))
335                 throw new SvcLogicException("Error While processing VNFC_REFERENCE table ");
336         }
337     }
338
339     public void processDownloadDgReference(SvcLogicContext context, boolean isUpdate)
340             throws SvcLogicException, SQLException {
341         String fn = "DBService.processDownloadDgReference";
342         log.info(fn + "Starting DB operation for Download DG Reference " + isUpdate);
343         String key = "";
344         QueryStatus status = null;
345
346         if (isUpdate)
347             key = "update " + SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE + " set DOWNLOAD_CONFIG_DG = $"
348                     + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE + " where PROTOCOL = $"
349                     + SdcArtifactHandlerConstants.DEVICE_PROTOCOL;
350         else
351             key = "insert into " + SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE + " set DOWNLOAD_CONFIG_DG = $"
352                     + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE + " , PROTOCOL = $"
353                     + SdcArtifactHandlerConstants.DEVICE_PROTOCOL;
354
355         if (serviceLogic != null && context != null)
356             status = serviceLogic.save("SQL", false, false, key, null, null, context);
357         if (status.toString().equals("FAILURE"))
358             throw new SvcLogicException("Error While processing DOWNLOAD_DG_REFERENCE table ");
359     }
360
361     public void processConfigActionDg(SvcLogicContext context, boolean isUpdate) throws SvcLogicException {
362         String fn = "DBService.processConfigActionDg";
363         log.info(fn + "Starting DB operation for Config DG Action " + isUpdate);
364         String key = "";
365         QueryStatus status = null;
366
367         if (context.getAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE) != null
368                 && context.getAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE).length() > 0) {
369             if (isUpdate)
370                 key = "update " + SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG + " set DOWNLOAD_CONFIG_DG = $"
371                         + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE + " where ACTION = $"
372                         + SdcArtifactHandlerConstants.ACTION + " and VNF_TYPE = $"
373                         + SdcArtifactHandlerConstants.VNF_TYPE;
374             else
375                 key = "insert into " + SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG + " set DOWNLOAD_CONFIG_DG = $"
376                         + SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE + " , ACTION = $"
377                         + SdcArtifactHandlerConstants.ACTION + " , VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE;
378
379             if (serviceLogic != null && context != null)
380                 status = serviceLogic.save("SQL", false, false, key, null, null, context);
381             if (status.toString().equals("FAILURE"))
382                 throw new SvcLogicException("Error While processing Configure DG Action table ");
383         } else
384             log.info("No Update required for Config DG Action");
385
386     }
387
388     public String getModelDataInformationbyArtifactName(String artifact_name) throws SvcLogicException {
389         String fn = "DBService.getVnfData";
390         String key = "";
391         SvcLogicContext con = new SvcLogicContext();
392         HashMap<String, String> modelData = new HashMap<String, String>();
393         QueryStatus status = null;
394         key = "select VNF_TYPE, VNFC_TYPE, ACTION, FILE_CATEGORY, ARTIFACT_TYPE from ASDC_REFERENCE where  ARTIFACT_NAME = "
395                 + artifact_name;
396
397         if (serviceLogic != null && con != null) {
398             log.info(fn + "select Key: " + key);
399             status = serviceLogic.query("SQL", false, null, key, null, null, con);
400             if (status.toString().equals("FAILURE"))
401                 throw new SvcLogicException("Error While processing is ArtifactUpdateRequiredforPD table ");
402
403         }
404
405         log.info(fn + "Vnf_received :" + con.getAttribute("VNF_TYPE"));
406
407         return con.getAttribute("VNF_TYPE");
408
409     }
410
411     public void updateYangContents(SvcLogicContext context, String artifactId, String yangContents)
412             throws SvcLogicException {
413         String fn = "DBService.updateYangContents";
414         log.info(fn + "Starting DB operation for  updateYangContents");
415         String key = "";
416         QueryStatus status = null;
417
418         key = "update ASDC_ARTIFACTS " + " set ARTIFACT_CONTENT = '" + yangContents + "'"
419                 + " where ASDC_ARTIFACTS_ID = " + artifactId;
420
421         if (serviceLogic != null && context != null)
422             status = serviceLogic.save("SQL", false, false, key, null, null, context);
423         if (status.toString().equals("FAILURE"))
424             throw new SvcLogicException("Error While processing Configure DG Action table ");
425
426     }
427
428
429     public void insertProtocolReference(SvcLogicContext context, String vnfType, String protocol, String action,
430             String action_level, String template) throws SvcLogicException {
431         String fn = "DBService.insertProtocolReference";
432         log.info(fn + "Starting DB operation for  insertProtocolReference");
433         String key = "";
434         QueryStatus status = null;
435
436         key = "insert into PROTOCOL_REFERENCE (ACTION, VNF_TYPE, PROTOCOL, UPDATED_DATE, TEMPLATE, ACTION_LEVEL)"
437                 + " values  (" + "'" + action + "', '" + vnfType + "', '" + protocol + "', now(),'" + template + "', '"
438                 + action_level + "')";
439
440         if (serviceLogic != null && context != null)
441             status = serviceLogic.save("SQL", false, false, key, null, null, context);
442         if (status.toString().equals("FAILURE"))
443             throw new SvcLogicException("Error While processing insertProtocolReference ");
444
445     }
446
447
448 }