7511a855a4fd3f3f2abf0c9c10bf09553d8d46da
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / onap / so / bpmn / common / scripts / CatalogDbUtils.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2019 Samsung
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  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.bpmn.common.scripts
24
25 import org.apache.commons.lang3.StringUtils
26 import org.camunda.bpm.engine.delegate.DelegateExecution
27 import org.json.JSONArray
28 import org.json.JSONObject
29 import org.onap.logging.ref.slf4j.ONAPLogConstants
30 import org.onap.so.bpmn.core.UrnPropertiesReader
31 import org.onap.so.bpmn.core.json.JsonUtils
32 import org.onap.so.client.HttpClient
33 import org.onap.so.client.HttpClientFactory
34 import org.onap.so.logger.MessageEnum
35 import org.onap.so.logger.MsoLogger
36 import org.slf4j.Logger
37 import org.slf4j.LoggerFactory
38 import org.onap.so.utils.TargetEntity
39 import org.springframework.web.util.UriUtils
40
41 import javax.ws.rs.core.MediaType
42 import javax.ws.rs.core.Response
43
44 /***
45  * Utilities for accessing Catalog DB Adapter to retrieve Networks, VNF/VFModules, AllottedResources and complete ServiceResources information
46  *
47  */
48
49 class CatalogDbUtils {
50     private static final Logger logger = LoggerFactory.getLogger( CatalogDbUtils.class);
51
52         private HttpClientFactory httpClientFactory
53         private MsoUtils msoUtils
54         private  JsonUtils jsonUtils
55         static private String defaultDbAdapterVersion = "v2"
56
57         CatalogDbUtils(HttpClientFactory httpClientFactory, MsoUtils msoUtils, JsonUtils jsonUtils) {
58                 this.httpClientFactory = httpClientFactory
59                 this.msoUtils = msoUtils
60                 this.jsonUtils = jsonUtils
61         }
62
63         public JSONArray getAllVnfsByVnfModelCustomizationUuid(DelegateExecution execution, String vnfModelCustomizationUuid, String catalogUtilsVersion) {
64                 JSONArray vnfsList = null
65                 String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8")
66                 try {
67                         logger.debug("ENDPOINT: " + endPoint)
68                         String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
69
70                         if (catalogDbResponse != null) {
71                                 if (!catalogUtilsVersion.equals("v1")) {
72                                         JSONObject responseJson = new JSONObject(catalogDbResponse)
73                                         vnfsList = responseJson.getJSONArray("serviceVnfs")
74                                 }
75                                 else {
76                                         vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
77                                 }
78                         }
79
80                 }
81                 catch (Exception e) {
82                         logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
83                                         "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(),
84                                         MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
85                         throw e
86                 }
87
88                 return vnfsList
89         }
90
91         public JSONObject getServiceResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) {
92                 JSONObject resources = null
93                 String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
94                 try {
95                         String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
96
97                         if (catalogDbResponse != null) {
98                                 if (!catalogUtilsVersion.equals("v1")) {
99                                         resources = new JSONObject(catalogDbResponse)
100                                 }
101                                 else {
102                                         resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
103                                 }
104                         }
105                 }
106                 catch (Exception e) {
107                         msoUtils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
108                         throw e
109                 }
110
111                 return resources
112         }
113
114         public String getServiceResourcesByServiceModelInvariantUuidString(DelegateExecution execution, String serviceModelInvariantUuid) {
115                 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
116                 try {
117                         return getResponseFromCatalogDb(execution, endPoint)
118                 }
119                 catch (Exception e) {
120                         logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
121                                         "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(),
122                                         MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
123                         throw e
124                 }
125         }
126
127         public JSONObject getServiceResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
128                 JSONObject resources = null
129                 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
130                 try {
131                         String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
132
133                         if (catalogDbResponse != null) {
134                                 if (!catalogUtilsVersion.equals("v1")) {
135                                         resources = new JSONObject(catalogDbResponse)
136                                 }
137                                 else {
138                                         resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
139                                 }
140                         }
141
142                 }
143                 catch (Exception e) {
144                         logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
145                                         "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(),
146                                         MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
147                         throw e
148                 }
149
150                 return resources
151         }
152
153         public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
154                 JSONObject resources = null
155                 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
156                 try {
157                         String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
158
159                         if (catalogDbResponse != null) {
160                                 if (!catalogUtilsVersion.equals("v1")) {
161                                         resources = new JSONObject(catalogDbResponse)
162                                 }
163                                 else {
164                                         resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
165                                 }
166                         }
167
168                 }
169                 catch (Exception e) {
170                         logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
171                                         "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(),
172                                         MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
173                         throw e
174                 }
175
176                 return resources
177         }
178
179         private JSONArray parseNetworksJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
180                 JSONArray modelInfos = null
181
182                 logger.debug("parseNetworksJson - catalogUtilsVersion is " + catalogUtilsVersion)
183                 try {
184                         // Create array of jsons
185
186                         JSONObject responseJson = new JSONObject(catalogDbResponse)
187                         JSONArray networks = responseJson.getJSONArray(arrayName)
188                         modelInfos = new JSONArray()
189
190                         for (int i = 0; i < networks.length(); i++) {
191
192                                 JSONObject network = networks.getJSONObject(i)
193                                 JSONObject modelJson = new JSONObject()
194                                 JSONObject modelInfo = buildModelInfo("network", network, catalogUtilsVersion)
195                                 modelJson.put("modelInfo", modelInfo)
196                                 String networkType = jsonUtils.getJsonValueForKey(network, "networkType")
197                                 modelJson.put("networkType", networkType)
198
199                                 switch (catalogUtilsVersion) {
200                                         case "v1":
201                                                 break
202                                         default:
203                                                 String toscaNodeType = jsonUtils.getJsonValueForKey(network, "toscaNodeType")
204                                                 modelJson.put("toscaNodeType", toscaNodeType)
205                                                 String networkTechnology = jsonUtils.getJsonValueForKey(network, "networkTechnology")
206                                                 modelJson.put("networkTechnology", networkTechnology)
207                                                 String networkRole = jsonUtils.getJsonValueForKey(network, "networkRole")
208                                                 modelJson.put("networkRole", networkRole)
209                                                 String networkScope = jsonUtils.getJsonValueForKey(network, "networkScope")
210                                                 modelJson.put("networkScope", networkScope)
211                                                 break
212                                 }
213                                 modelInfos.put(modelJson)
214                         }
215
216                         String modelInfosString = modelInfos.toString()
217                         logger.debug("Returning networks JSON: " + modelInfosString)
218
219                 } catch (Exception e) {
220                         logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
221                                         "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(),
222                                         MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
223                 }
224
225                 return modelInfos
226         }
227
228         private JSONArray parseVnfsJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
229                 JSONArray modelInfos = null
230
231                 logger.debug("parseVnfsJson - catalogUtilsVersion is " + catalogUtilsVersion)
232
233                 try {
234                         // Create array of jsons
235
236                         JSONObject responseJson = new JSONObject(catalogDbResponse)
237                         JSONArray vnfs = responseJson.getJSONArray(arrayName)
238                         modelInfos = new JSONArray()
239
240                         for (int i = 0; i < vnfs.length(); i++) {
241                                 JSONObject vnf = vnfs.getJSONObject(i)
242
243                                 logger.debug(vnf.toString(2))
244                                 JSONObject modelInfo = buildModelInfo("vnf", vnf, catalogUtilsVersion)
245                                 JSONObject modelJson = new JSONObject()
246                                 modelJson.put("modelInfo", modelInfo)
247                                 switch(catalogUtilsVersion) {
248                                         case "v1":
249                                                 break
250                                         default:
251                                                 String toscaNodeType = jsonUtils.getJsonValueForKey(vnf, "toscaNodeType")
252                                                 modelJson.put("toscaNodeType", toscaNodeType)
253                                                 String nfType = jsonUtils.getJsonValueForKey(vnf, "nfType")
254                                                 modelJson.put("nfType", nfType)
255                                                 String nfRole = jsonUtils.getJsonValueForKey(vnf, "nfRole")
256                                                 modelJson.put("nfRole", nfRole)
257                                                 String nfCode = jsonUtils.getJsonValueForKey(vnf, "nfCode")
258                                                 modelJson.put("nfNamingCode", nfCode)
259                                                 String nfFunction = jsonUtils.getJsonValueForKey(vnf, "nfFunction")
260                                                 modelJson.put("nfFunction", nfFunction)
261                                                 String multiStageDesign = jsonUtils.getJsonValueForKey(vnf, "multiStageDesign")
262                                                 modelJson.put("multiStageDesign", multiStageDesign)
263                                                 break
264                                 }
265
266                                 JSONArray vfModules = null
267                                 try {
268                                         vfModules = vnf.getJSONArray("vfModules")
269                                 } catch (Exception e)
270                                 {
271                                         logger.debug("Cannot find VF MODULE ARRAY: " + i + ", exception is " + e.message)
272                                 }
273
274                                 if (vfModules != null) {
275                                         JSONArray vfModuleInfo = new JSONArray()
276                                         for (int j = 0; j < vfModules.length(); j++) {
277                                                 JSONObject vfModule = vfModules.getJSONObject(j)
278                                                 JSONObject vfModuleModelInfo = buildModelInfo("vfModule", vfModule, catalogUtilsVersion)
279                                                 JSONObject vfModuleModelJson = new JSONObject()
280                                                 vfModuleModelJson.put("modelInfo", vfModuleModelInfo)
281                                                 String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type")
282                                                 vfModuleModelJson.put("vfModuleType", vfModuleType)
283                                                 vfModuleModelJson.put("isBase", jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase"))
284                                                 String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label")
285                                                 vfModuleModelJson.put("vfModuleLabel", vfModuleLabel)
286                                                 Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount")
287                                                 vfModuleModelJson.put("initialCount", initialCount.intValue())
288                                                 vfModuleInfo.put(vfModuleModelJson)
289                                         }
290                                         modelJson.put("vfModules", vfModuleInfo)
291                                 }
292                                 modelInfos.put(modelJson)
293                         }
294
295                         String modelInfosString = modelInfos.toString()
296                         logger.debug("Returning vnfs JSON: " + modelInfosString)
297
298                 } catch (Exception e) {
299                         logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
300                                         "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(),
301                                         MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
302                 }
303
304                 return modelInfos
305         }
306
307         private JSONArray parseAllottedResourcesJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
308                 JSONArray modelInfos = null
309
310                 logger.debug("parseAllottedResourcesJson - catalogUtilsVersion is " + catalogUtilsVersion)
311
312                 try {
313                         // Create array of jsons
314
315                         JSONObject responseJson = new JSONObject(catalogDbResponse)
316                         JSONArray allottedResources = responseJson.getJSONArray(arrayName)
317                         modelInfos = new JSONArray()
318
319                         for (int i = 0; i < allottedResources.length(); i++) {
320                                 JSONObject allottedResource = allottedResources.getJSONObject(i)
321                                 JSONObject modelInfo = buildModelInfo("allottedResource", allottedResource, catalogUtilsVersion)
322                                 JSONObject modelJson = new JSONObject()
323                                 modelJson.put("modelInfo", modelInfo)
324                                 switch(catalogUtilsVersion) {
325                                         case "v1":
326                                                 break
327                                         default:
328                                                 String toscaNodeType = jsonUtils.getJsonValueForKey(allottedResource, "toscaNodeType")
329                                                 modelJson.put("toscaNodeType", toscaNodeType)
330                                                 String nfType = jsonUtils.getJsonValueForKey(allottedResource, "nfType")
331                                                 modelJson.put("nfType", nfType)
332                                                 String nfRole = jsonUtils.getJsonValueForKey(allottedResource, "nfRole")
333                                                 modelJson.put("nfRole", nfRole)
334                                                 String nfCode = jsonUtils.getJsonValueForKey(allottedResource, "nfCode")
335                                                 modelJson.put("nfNamingCode", nfCode)
336                                                 String nfFunction = jsonUtils.getJsonValueForKey(allottedResource, "nfFunction")
337                                                 modelJson.put("nfFunction", nfFunction)
338                                                 String providingServiceModelName = jsonUtils.getJsonValueForKey(allottedResource, "providingServiceModelName")
339                                                 modelJson.put("providingServiceModelName", providingServiceModelName)
340                                                 String providingServiceModelUuid = jsonUtils.getJsonValueForKey(allottedResource, "providingServiceModelUuid")
341                                                 modelJson.put("providingServiceModelUuid", providingServiceModelUuid)
342                                                 break
343                                 }
344
345
346                                 modelInfos.put(modelJson)
347                         }
348
349                         String modelInfosString = modelInfos.toString()
350                         logger.debug("Returning allottedResources JSON: " + modelInfosString)
351
352                 } catch (Exception e) {
353                         logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
354                                         "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(),
355                                         MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
356                 }
357
358                 return modelInfos
359         }
360
361         private JSONObject parseServiceResourcesJson (String catalogDbResponse, String catalogUtilsVersion) {
362                 JSONObject serviceResources = new JSONObject()
363                 JSONObject serviceResourcesObject = new JSONObject()
364
365                 try {
366                         // Create array of jsons
367
368                         JSONObject responseJson = new JSONObject(catalogDbResponse)
369                         JSONObject serviceResourcesRoot = responseJson.getJSONObject("serviceResources")
370                         JSONObject modelInfo = buildModelInfo("", serviceResourcesRoot, catalogUtilsVersion)
371                         serviceResources.put("modelInfo", modelInfo)
372                         JSONArray vnfsArray = parseVnfsJson(serviceResourcesRoot.toString(), "serviceVnfs", catalogUtilsVersion)
373                         serviceResources.put("serviceVnfs", vnfsArray)
374                         JSONArray networksArray = parseNetworksJson(serviceResourcesRoot.toString(), "serviceNetworks", catalogUtilsVersion)
375                         serviceResources.put("serviceNetworks", networksArray)
376                         JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "serviceAllottedResources", catalogUtilsVersion)
377                         serviceResources.put("serviceAllottedResources", allottedResourcesArray)
378                         serviceResourcesObject.put("serviceResources", serviceResources)
379                         logger.debug("Returning serviceResources JSON: " + serviceResourcesObject.toString())
380
381                 } catch (Exception e) {
382                         logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
383                                         "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(),
384                                         MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
385                 }
386
387                 return serviceResourcesObject
388         }
389
390         private JSONObject buildModelInfo(String modelType, JSONObject modelFromDb, String catalogUtilsVersion) {
391                 JSONObject modelInfo = null
392                 try {
393                         modelInfo = new JSONObject()
394                         modelInfo.put("modelType", modelType)
395                         String modelInvariantId = jsonUtils.getJsonValueForKey(modelFromDb, "modelInvariantUuid")
396                         modelInfo.put("modelInvariantId", modelInvariantId)
397                         if(modelType.equalsIgnoreCase("allottedResource") || modelType.equalsIgnoreCase("vnf")){
398                                 String modelInstanceName = jsonUtils.getJsonValueForKey(modelFromDb, "modelInstanceName")
399                                 modelInfo.put("modelInstanceName", modelInstanceName)
400                         }
401                         if ((!"vfModule".equals(modelType) && !"vnf".equals(modelType)) || !catalogUtilsVersion.equals("v1")) {
402                                 String modelVersionId = jsonUtils.getJsonValueForKey(modelFromDb, "modelUuid")
403                                 modelInfo.put("modelVersionId", modelVersionId)
404                         }
405                         else {
406                                 String modelVersionId = jsonUtils.getJsonValueForKey(modelFromDb, "asdcUuid")
407                                 modelInfo.put("modelVersionId", modelVersionId)
408                         }
409                         String modelName = jsonUtils.getJsonValueForKey(modelFromDb, "modelName")
410                         modelInfo.put("modelName", modelName)
411                         String modelVersion = jsonUtils.getJsonValueForKey(modelFromDb, "modelVersion")
412                         modelInfo.put("modelVersion", modelVersion)
413                         if (!"vfModule".equals(modelType)) {
414                                 String modelCustomizationName = jsonUtils.getJsonValueForKey(modelFromDb, "modelCustomizationName")
415                                 modelInfo.put("modelCustomizationName", modelCustomizationName)
416                         }
417                         String modelCustomizationId = jsonUtils.getJsonValueForKey(modelFromDb, "modelCustomizationUuid")
418                         switch (catalogUtilsVersion) {
419                                 case "v1":
420                                         modelInfo.put("modelCustomizationId", modelCustomizationId)
421                                         break
422                                 default:
423                                         modelInfo.put("modelCustomizationUuid", modelCustomizationId)
424                                         break
425                         }
426                         JSONObject modelJson = new JSONObject()
427                         modelJson.put("modelInfo", modelInfo)
428                 }
429                 catch (Exception e) {
430                         logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
431                                         "Exception while parsing model information", "BPMN", MsoLogger.getServiceName(),
432                                         MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
433                 }
434                 return modelInfo
435         }
436
437         private String getResponseFromCatalogDb (DelegateExecution execution, String endPoint) {
438                 try {
439
440                         String catalogDbEndpoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint",execution)
441                         String queryEndpoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + endPoint
442                         def responseData = ''
443                         HttpClient client = httpClientFactory.newJsonClient(new URL(queryEndpoint), TargetEntity.CATALOG_DB)
444                         client.addAdditionalHeader(ONAPLogConstants.Headers.REQUEST_ID, UUID.randomUUID().toString())
445                         client.addAdditionalHeader('X-FromAppId', "BPMN")
446                         client.addAdditionalHeader('Accept', MediaType.APPLICATION_JSON)
447                         String basicAuthCred = execution.getVariable("BasicAuthHeaderValueDB")
448                         client.addAdditionalHeader("Authorization", StringUtils.defaultIfEmpty(basicAuthCred, getBasicDBAuthHeader(execution)))
449
450                         logger.debug('sending GET to Catalog DB endpoint: ' + endPoint)
451                         Response response = client.get()
452
453                         responseData = response.readEntity(String.class)
454                         if (responseData != null) {
455                                 logger.debug("Received data from Catalog DB: " + responseData)
456                         }
457
458                         logger.debug('Response code:' + response.getStatus())
459                         logger.debug('Response:' + System.lineSeparator() + responseData)
460                         if (response.getStatus() == 200) {
461                                 // parse response as needed
462                                 return responseData
463                         }
464                         else {
465                                 return null
466                         }
467                 }
468                 catch (Exception e) {
469                         logger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message)
470                         throw e
471                 }
472
473         }
474
475         /**
476          * get resource recipe by resource model uuid and action
477          */
478         public JSONObject getResourceRecipe(DelegateExecution execution, String resourceModelUuid, String action) {
479                 String endPoint = "/resourceRecipe?resourceModelUuid=" + UriUtils.encode(resourceModelUuid, "UTF-8")+ "&action=" + UriUtils.encode(action, "UTF-8")
480                 JSONObject responseJson = null
481                 try {
482                         logger.debug("ENDPOINT: " + endPoint)
483                         String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
484
485                         if (catalogDbResponse != null) {
486                                 responseJson = new JSONObject(catalogDbResponse)
487                         }
488                 }
489                 catch (Exception e) {
490                         msoUtils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
491                         throw e
492                 }
493
494                 return responseJson
495         }
496
497         private String getBasicDBAuthHeader(DelegateExecution execution) {
498
499                 String encodedString = null
500                 try {
501                         String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution)
502                         msoUtils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB)
503
504                         encodedString = msoUtils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution))
505                         execution.setVariable("BasicAuthHeaderValueDB",encodedString)
506                 } catch (IOException ex) {
507                         String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
508                         msoUtils.log("ERROR", dataErrorMessage)
509                 }
510                 return encodedString
511         }
512
513 }