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