2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.bpmn.common.scripts
\r
23 import org.json.JSONObject;
\r
24 import org.json.JSONArray;
\r
25 import org.json.XML;
\r
26 import org.springframework.web.util.UriUtils;
\r
28 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
31 import groovy.json.JsonBuilder
\r
32 import groovy.json.JsonSlurper
\r
33 import groovy.util.slurpersupport.GPathResult
\r
34 import groovy.xml.QName;
\r
36 import org.camunda.bpm.engine.runtime.Execution
\r
38 import org.openecomp.mso.logger.MsoLogger;
\r
39 import org.openecomp.mso.rest.APIResponse;
\r
40 import org.openecomp.mso.rest.RESTClient
\r
41 import org.openecomp.mso.rest.RESTConfig
\r
45 * Utilities for accessing Catalog DB Adapter to retrieve Networks, VNF/VFModules, AllottedResources and complete ServiceResources information
\r
49 class CatalogDbUtils {
\r
51 MsoUtils utils = new MsoUtils()
\r
52 JsonUtils jsonUtils = new JsonUtils()
\r
53 MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
\r
54 static private String defaultDbAdapterVersion = "v2"
\r
56 public JSONArray getAllNetworksByServiceModelUuid(Execution execution, String serviceModelUuid) {
\r
57 JSONArray networksList = null
\r
58 String endPoint = "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
\r
60 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
62 if (catalogDbResponse != null) {
\r
63 networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
\r
67 catch (Exception e) {
\r
68 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
74 public JSONArray getAllNetworksByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) {
\r
75 JSONArray networksList = null
\r
76 String endPoint = "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
\r
78 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
80 if (catalogDbResponse != null) {
\r
81 if (!catalogUtilsVersion.equals("v1")) {
\r
82 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
83 networksList = responseJson.getJSONArray("serviceNetworks")
\r
86 networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
\r
91 catch (Exception e) {
\r
92 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
98 public JSONArray getAllNetworksByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) {
\r
99 JSONArray networksList = null
\r
100 String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
102 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
104 if (catalogDbResponse != null) {
\r
105 networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
\r
109 catch (Exception e) {
\r
110 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
113 return networksList
\r
116 public JSONArray getAllNetworksByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
\r
117 JSONArray networksList = null
\r
118 String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
120 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
122 if (catalogDbResponse != null) {
\r
123 if (!catalogUtilsVersion.equals("v1")) {
\r
124 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
125 networksList = responseJson.getJSONArray("serviceNetworks")
\r
128 networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
\r
133 catch (Exception e) {
\r
134 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
137 return networksList
\r
140 public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
\r
141 JSONArray networksList = null
\r
142 String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
\r
144 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
146 if (catalogDbResponse != null) {
\r
147 networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
\r
151 catch (Exception e) {
\r
152 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
155 return networksList
\r
158 public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
\r
159 JSONArray networksList = null
\r
160 String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
\r
162 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
164 if (catalogDbResponse != null) {
\r
165 if (!catalogUtilsVersion.equals("v1")) {
\r
166 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
167 networksList = responseJson.getJSONArray("serviceNetworks")
\r
170 networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
\r
175 catch (Exception e) {
\r
176 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
179 return networksList
\r
182 public JSONArray getAllNetworksByNetworkModelCustomizationUuid(Execution execution, String networkModelCustomizationUuid) {
\r
183 JSONArray networksList = null
\r
184 String endPoint = "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8")
\r
186 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
188 if (catalogDbResponse != null) {
\r
189 networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
\r
193 catch (Exception e) {
\r
194 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
197 return networksList
\r
200 public JSONArray getAllNetworksByNetworkModelCustomizationUuid(Execution execution, String networkModelCustomizationUuid, String catalogUtilsVersion) {
\r
201 JSONArray networksList = null
\r
202 String endPoint = "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8")
\r
204 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
206 if (catalogDbResponse != null) {
\r
207 if (!catalogUtilsVersion.equals("v1")) {
\r
208 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
209 networksList = responseJson.getJSONArray("serviceNetworks")
\r
212 networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
\r
217 catch (Exception e) {
\r
218 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
221 return networksList
\r
224 public JSONArray getAllNetworksByNetworkType(Execution execution, String networkType) {
\r
225 JSONArray networksList = null
\r
226 String endPoint = "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8")
\r
228 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
230 if (catalogDbResponse != null) {
\r
231 networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
\r
235 catch (Exception e) {
\r
236 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
239 return networksList
\r
242 public JSONArray getAllNetworksByNetworkType(Execution execution, String networkType, String catalogUtilsVersion) {
\r
243 JSONArray networksList = null
\r
244 String endPoint = "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8")
\r
246 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
248 if (catalogDbResponse != null) {
\r
249 if (!catalogUtilsVersion.equals("v1")) {
\r
250 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
251 networksList = responseJson.getJSONArray("serviceNetworks")
\r
254 networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
\r
259 catch (Exception e) {
\r
260 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
263 return networksList
\r
267 public JSONArray getAllVnfsByServiceModelUuid(Execution execution, String serviceModelUuid) {
\r
268 JSONArray vnfsList = null
\r
269 String endPoint = "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
\r
271 msoLogger.debug("ENDPOINT: " + endPoint)
\r
272 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
274 if (catalogDbResponse != null) {
\r
275 vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
\r
279 catch (Exception e) {
\r
280 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
286 public JSONArray getAllVnfsByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) {
\r
287 JSONArray vnfsList = null
\r
288 String endPoint = "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
\r
290 msoLogger.debug("ENDPOINT: " + endPoint)
\r
291 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
293 if (catalogDbResponse != null) {
\r
294 if (!catalogUtilsVersion.equals("v1")) {
\r
295 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
296 vnfsList = responseJson.getJSONArray("serviceVnfs")
\r
299 vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
\r
304 catch (Exception e) {
\r
305 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
311 public JSONArray getAllVnfsByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) {
\r
312 JSONArray vnfsList = null
\r
313 String endPoint ="/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
315 msoLogger.debug("ENDPOINT: " + endPoint)
\r
316 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
318 if (catalogDbResponse != null) {
\r
319 vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
\r
323 catch (Exception e) {
\r
324 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
330 public JSONArray getAllVnfsByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
\r
331 JSONArray vnfsList = null
\r
332 String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
334 msoLogger.debug("ENDPOINT: " + endPoint)
\r
335 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
337 if (catalogDbResponse != null) {
\r
338 if (!catalogUtilsVersion.equals("v1")) {
\r
339 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
340 vnfsList = responseJson.getJSONArray("serviceVnfs")
\r
343 vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
\r
348 catch (Exception e) {
\r
349 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
355 public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
\r
356 JSONArray vnfsList = null
\r
357 String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
\r
359 msoLogger.debug("ENDPOINT: " + endPoint)
\r
360 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
362 if (catalogDbResponse != null) {
\r
363 vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
\r
367 catch (Exception e) {
\r
368 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
374 public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
\r
375 JSONArray vnfsList = null
\r
376 String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
\r
378 msoLogger.debug("ENDPOINT: " + endPoint)
\r
379 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
381 if (catalogDbResponse != null) {
\r
382 if (!catalogUtilsVersion.equals("v1")) {
\r
383 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
384 vnfsList = responseJson.getJSONArray("serviceVnfs")
\r
387 vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
\r
392 catch (Exception e) {
\r
393 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
399 public JSONArray getAllVnfsByVnfModelCustomizationUuid(Execution execution, String vnfModelCustomizationUuid) {
\r
400 JSONArray vnfsList = null
\r
401 String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8")
\r
403 msoLogger.debug("ENDPOINT: " + endPoint)
\r
404 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
406 if (catalogDbResponse != null) {
\r
407 vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
\r
411 catch (Exception e) {
\r
412 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
419 * This method gets a all vnfs for a particular
\r
420 * service from the catalog database using the
\r
421 * service model's model name.
\r
423 * @param catalogDbEndpoint
\r
424 * @param serviceModelModelName
\r
425 * @return vnfsList *
\r
428 public JSONArray getAllVnfsByServiceModelModelName(Execution execution, String serviceModelModelName) {
\r
429 JSONArray vnfsList = null
\r
430 String endPoint = "/serviceVnfs?serviceModelName=" + UriUtils.encode(serviceModelModelName, "UTF-8")
\r
432 msoLogger.debug("ENDPOINT: " + endPoint)
\r
433 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
435 if (catalogDbResponse != null) {
\r
436 vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", defaultDbAdapterVersion)
\r
438 }catch (Exception e) {
\r
439 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
444 public JSONArray getAllVnfsByVnfModelCustomizationUuid(Execution execution, String vnfModelCustomizationUuid, String catalogUtilsVersion) {
\r
445 JSONArray vnfsList = null
\r
446 String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8")
\r
448 msoLogger.debug("ENDPOINT: " + endPoint)
\r
449 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
451 if (catalogDbResponse != null) {
\r
452 if (!catalogUtilsVersion.equals("v1")) {
\r
453 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
454 vnfsList = responseJson.getJSONArray("serviceVnfs")
\r
457 vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
\r
462 catch (Exception e) {
\r
463 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
470 * This method gets a single vf module from
\r
471 * the catalog database using the vf module's
\r
472 * model name. It returns that vf module as
\r
475 * @param catalogDbEndpoint
\r
476 * @param vfModuleModelName
\r
479 public JSONObject getVfModuleByVfModuleModelName(Execution execution, String vfModuleModelName) {
\r
480 JSONObject vfModule = null
\r
481 String endPoint = "/vfModules?vfModuleModelName=" + UriUtils.encode(vfModuleModelName, "UTF-8")
\r
483 msoLogger.debug("Get VfModule By VfModule ModelName Endpoint is: " + endPoint)
\r
484 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
486 if (catalogDbResponse != null) {
\r
487 vfModule = parseVfModuleJson(catalogDbResponse, "vfModules", "v1")
\r
490 catch(Exception e){
\r
491 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
498 * This method gets a single vf module from
\r
499 * the catalog database using the vf module's
\r
500 * model name. It returns that vf module as
\r
503 * @param catalogDbEndpoint
\r
504 * @param vfModuleModelName
\r
505 * @param catalogUtilsVersion
\r
506 * @return vfModules
\r
508 public JSONObject getVfModuleByVfModuleModelName(Execution execution, String vfModuleModelName, String catalogUtilsVersion) {
\r
509 JSONObject vfModule = null
\r
510 String endPoint = "/vfModules?vfModuleModelName=" + UriUtils.encode(vfModuleModelName, "UTF-8")
\r
512 msoLogger.debug("Get VfModule By VfModule ModelName Endpoint is: " + endPoint)
\r
513 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
515 if (catalogDbResponse != null) {
\r
516 vfModule = parseVfModuleJson(catalogDbResponse, "vfModules", "v1")
\r
519 catch(Exception e){
\r
520 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
527 public JSONArray getAllottedResourcesByServiceModelUuid(Execution execution, String serviceModelUuid) {
\r
528 JSONArray vnfsList = null
\r
529 String endPoint = "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
\r
531 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
533 if (catalogDbResponse != null) {
\r
534 vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
\r
538 catch (Exception e) {
\r
539 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
545 public JSONArray getAllottedResourcesByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) {
\r
546 JSONArray vnfsList = null
\r
547 String endPoint = "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
\r
549 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
551 if (catalogDbResponse != null) {
\r
552 if (!catalogUtilsVersion.equals("v1")) {
\r
553 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
554 vnfsList = responseJson.getJSONArray("serviceAllottedResources")
\r
557 vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
\r
562 catch (Exception e) {
\r
563 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
569 public JSONArray getAllottedResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) {
\r
570 JSONArray vnfsList = null
\r
571 String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
573 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
575 if (catalogDbResponse != null) {
\r
576 vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
\r
580 catch (Exception e) {
\r
581 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
587 public JSONArray getAllottedResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
\r
588 JSONArray vnfsList = null
\r
589 String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
591 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
593 if (catalogDbResponse != null) {
\r
594 if (!catalogUtilsVersion.equals("v1")) {
\r
595 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
596 vnfsList = responseJson.getJSONArray()
\r
599 vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
\r
604 catch (Exception e) {
\r
605 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
606 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.getStackTrace())
\r
612 public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
\r
613 JSONArray vnfsList = null
\r
614 String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
\r
616 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
618 if (catalogDbResponse != null) {
\r
619 vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
\r
623 catch (Exception e) {
\r
624 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
630 public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
\r
631 JSONArray vnfsList = null
\r
632 String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
\r
634 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
636 if (catalogDbResponse != null) {
\r
637 if (!catalogUtilsVersion.equals("v1")) {
\r
638 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
639 vnfsList = responseJson.getJSONArray("serviceAllottedResources")
\r
642 vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
\r
647 catch (Exception e) {
\r
648 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
655 public JSONArray getAllottedResourcesByArModelCustomizationUuid(Execution execution, String arModelCustomizationUuid) {
\r
656 JSONArray vnfsList = null
\r
657 String endPoint = "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8")
\r
659 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
661 if (catalogDbResponse != null) {
\r
662 vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
\r
666 catch (Exception e) {
\r
667 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
673 public JSONArray getAllottedResourcesByArModelCustomizationUuid(Execution execution, String arModelCustomizationUuid, String catalogUtilsVersion) {
\r
674 JSONArray vnfsList = null
\r
675 String endPoint = "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8")
\r
677 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
679 if (catalogDbResponse != null) {
\r
680 if (!catalogUtilsVersion.equals("v1")) {
\r
681 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
682 vnfsList = responseJson.getJSONArray("serviceAllottedResources")
\r
685 vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
\r
690 catch (Exception e) {
\r
691 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
697 public JSONObject getServiceResourcesByServiceModelUuid(Execution execution, String serviceModelUuid) {
\r
698 JSONObject resources = null
\r
699 String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
\r
701 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
703 if (catalogDbResponse != null) {
\r
705 resources = parseServiceResourcesJson(catalogDbResponse, "v1")
\r
709 catch (Exception e) {
\r
710 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
716 public JSONObject getServiceResourcesByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) {
\r
717 JSONObject resources = null
\r
718 String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
\r
720 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
722 if (catalogDbResponse != null) {
\r
723 if (!catalogUtilsVersion.equals("v1")) {
\r
724 resources = new JSONObject(catalogDbResponse)
\r
727 resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
\r
732 catch (Exception e) {
\r
733 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
740 public JSONObject getServiceResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) {
\r
741 JSONObject resources = null
\r
742 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
744 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
746 if (catalogDbResponse != null) {
\r
748 resources = parseServiceResourcesJson(catalogDbResponse, "v1")
\r
752 catch (Exception e) {
\r
753 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
759 public JSONObject getServiceResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
\r
760 JSONObject resources = null
\r
761 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
763 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
765 if (catalogDbResponse != null) {
\r
766 if (!catalogUtilsVersion.equals("v1")) {
\r
767 resources = new JSONObject(catalogDbResponse)
\r
770 resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
\r
775 catch (Exception e) {
\r
776 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
783 public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
\r
784 JSONObject resources = null
\r
785 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
\r
787 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
789 if (catalogDbResponse != null) {
\r
790 resources = parseServiceResourcesJson(catalogDbResponse)
\r
794 catch (Exception e) {
\r
795 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
801 public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
\r
802 JSONObject resources = null
\r
803 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
\r
805 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
807 if (catalogDbResponse != null) {
\r
808 if (!catalogUtilsVersion.equals("v1")) {
\r
809 resources = new JSONObject(catalogDbResponse)
\r
812 resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
\r
817 catch (Exception e) {
\r
818 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
826 private JSONArray parseNetworksJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
\r
827 JSONArray modelInfos = null
\r
829 msoLogger.debug("parseNetworksJson - catalogUtilsVersion is " + catalogUtilsVersion)
\r
831 // Create array of jsons
\r
833 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
834 JSONArray networks = responseJson.getJSONArray(arrayName)
\r
835 modelInfos = new JSONArray()
\r
837 for (int i = 0; i < networks.length(); i++) {
\r
839 JSONObject network = networks.getJSONObject(i)
\r
840 JSONObject modelJson = new JSONObject()
\r
841 JSONObject modelInfo = buildModelInfo("network", network, catalogUtilsVersion)
\r
842 modelJson.put("modelInfo", modelInfo)
\r
843 String networkType = jsonUtils.getJsonValueForKey(network, "networkType")
\r
844 modelJson.put("networkType", networkType)
\r
846 switch (catalogUtilsVersion) {
\r
850 String toscaNodeType = jsonUtils.getJsonValueForKey(network, "toscaNodeType")
\r
851 modelJson.put("toscaNodeType", toscaNodeType)
\r
852 String networkTechnology = jsonUtils.getJsonValueForKey(network, "networkTechnology")
\r
853 modelJson.put("networkTechnology", networkTechnology)
\r
854 String networkRole = jsonUtils.getJsonValueForKey(network, "networkRole")
\r
855 modelJson.put("networkRole", networkRole)
\r
856 String networkScope = jsonUtils.getJsonValueForKey(network, "networkScope")
\r
857 modelJson.put("networkScope", networkScope)
\r
860 modelInfos.put(modelJson)
\r
863 String modelInfosString = modelInfos.toString()
\r
864 msoLogger.debug("Returning networks JSON: " + modelInfosString)
\r
866 } catch (Exception e) {
\r
867 utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message)
\r
873 private JSONArray parseVnfsJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
\r
874 JSONArray modelInfos = null
\r
876 msoLogger.debug("parseVnfsJson - catalogUtilsVersion is " + catalogUtilsVersion)
\r
879 // Create array of jsons
\r
881 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
882 JSONArray vnfs = responseJson.getJSONArray(arrayName)
\r
883 modelInfos = new JSONArray()
\r
885 for (int i = 0; i < vnfs.length(); i++) {
\r
886 JSONObject vnf = vnfs.getJSONObject(i)
\r
888 msoLogger.debug(vnf.toString(2))
\r
889 JSONObject modelInfo = buildModelInfo("vnf", vnf, catalogUtilsVersion)
\r
890 JSONObject modelJson = new JSONObject()
\r
891 modelJson.put("modelInfo", modelInfo)
\r
892 switch(catalogUtilsVersion) {
\r
896 String toscaNodeType = jsonUtils.getJsonValueForKey(vnf, "toscaNodeType")
\r
897 modelJson.put("toscaNodeType", toscaNodeType)
\r
898 String nfType = jsonUtils.getJsonValueForKey(vnf, "nfType")
\r
899 modelJson.put("nfType", nfType)
\r
900 String nfRole = jsonUtils.getJsonValueForKey(vnf, "nfRole")
\r
901 modelJson.put("nfRole", nfRole)
\r
902 String nfCode = jsonUtils.getJsonValueForKey(vnf, "nfCode")
\r
903 modelJson.put("nfNamingCode", nfCode)
\r
904 String nfFunction = jsonUtils.getJsonValueForKey(vnf, "nfFunction")
\r
905 modelJson.put("nfFunction", nfFunction)
\r
909 JSONArray vfModules = null
\r
911 vfModules = vnf.getJSONArray("vfModules")
\r
912 } catch (Exception e)
\r
914 msoLogger.debug("Cannot find VF MODULE ARRAY: " + i + ", exception is " + e.message)
\r
917 if (vfModules != null) {
\r
918 JSONArray vfModuleInfo = new JSONArray()
\r
919 for (int j = 0; j < vfModules.length(); j++) {
\r
920 JSONObject vfModule = vfModules.getJSONObject(j)
\r
921 JSONObject vfModuleModelInfo = buildModelInfo("vfModule", vfModule, catalogUtilsVersion)
\r
922 JSONObject vfModuleModelJson = new JSONObject()
\r
923 vfModuleModelJson.put("modelInfo", vfModuleModelInfo)
\r
924 String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type")
\r
925 vfModuleModelJson.put("vfModuleType", vfModuleType)
\r
926 switch(catalogUtilsVersion) {
\r
928 Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase")
\r
929 if (isBase.intValue() == 1) {
\r
930 vfModuleModelJson.put("isBase", "true")
\r
933 vfModuleModelJson.put("isBase", "false")
\r
937 boolean isBase = jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase")
\r
938 vfModuleModelJson.put("isBase", isBase)
\r
941 String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label")
\r
942 vfModuleModelJson.put("vfModuleLabel", vfModuleLabel)
\r
943 Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount")
\r
944 vfModuleModelJson.put("initialCount", initialCount.intValue())
\r
945 vfModuleInfo.put(vfModuleModelJson)
\r
947 modelJson.put("vfModules", vfModuleInfo)
\r
949 modelInfos.put(modelJson)
\r
952 String modelInfosString = modelInfos.toString()
\r
953 msoLogger.debug("Returning vnfs JSON: " + modelInfosString)
\r
955 } catch (Exception e) {
\r
956 utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message)
\r
963 * This method parses a Vf Module from the
\r
966 * @param catalogDbResponse
\r
968 * @param catalogUtilsVersion
\r
969 * @return vfModulelJson
\r
971 private JSONObject parseVfModuleJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
\r
972 JSONObject vfModulelJson = new JSONObject()
\r
973 msoLogger.debug("Started Parse Vf Module Json")
\r
975 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
976 JSONArray vfModules = responseJson.getJSONArray(arrayName)
\r
977 if(vfModules != null){
\r
978 JSONObject vfModuleInfo = new JSONObject()
\r
979 for (int i = 0; i < vfModules.length(); i++) {
\r
980 JSONObject vfModule = vfModules.getJSONObject(i)
\r
981 JSONObject vfModuleModelInfo = buildModelInfo("vfModule", vfModule, catalogUtilsVersion)
\r
982 vfModulelJson.put("modelInfo", vfModuleModelInfo)
\r
983 String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type")
\r
984 vfModulelJson.put("vfModuleType", vfModuleType)
\r
985 switch(catalogUtilsVersion) {
\r
987 Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase")
\r
988 if (isBase.intValue() == 1) {
\r
989 vfModulelJson.put("isBase", "true")
\r
992 vfModulelJson.put("isBase", "false")
\r
996 boolean isBase = jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase")
\r
997 vfModulelJson.put("isBase", isBase)
\r
1000 String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label")
\r
1001 vfModulelJson.put("vfModuleLabel", vfModuleLabel)
\r
1002 Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount")
\r
1003 vfModulelJson.put("initialCount", initialCount.intValue())
\r
1006 msoLogger.debug("Completed Parsing Vf Module: " + vfModulelJson.toString())
\r
1007 }catch (Exception e){
\r
1008 utils.log("DEBUG", "Exception while parsing Vf Modules from Catalog DB Response: " + e.message)
\r
1011 return vfModulelJson
\r
1014 private JSONArray parseAllottedResourcesJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
\r
1015 JSONArray modelInfos = null
\r
1017 msoLogger.debug("parseAllottedResourcesJson - catalogUtilsVersion is " + catalogUtilsVersion)
\r
1020 // Create array of jsons
\r
1022 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
1023 JSONArray allottedResources = responseJson.getJSONArray(arrayName)
\r
1024 modelInfos = new JSONArray()
\r
1026 for (int i = 0; i < allottedResources.length(); i++) {
\r
1027 JSONObject allottedResource = allottedResources.getJSONObject(i)
\r
1028 JSONObject modelInfo = buildModelInfo("allottedResource", allottedResource, catalogUtilsVersion)
\r
1029 JSONObject modelJson = new JSONObject()
\r
1030 modelJson.put("modelInfo", modelInfo)
\r
1031 switch(catalogUtilsVersion) {
\r
1035 String toscaNodeType = jsonUtils.getJsonValueForKey(allottedResource, "toscaNodeType")
\r
1036 modelJson.put("toscaNodeType", toscaNodeType)
\r
1037 String nfType = jsonUtils.getJsonValueForKey(allottedResource, "nfType")
\r
1038 modelJson.put("nfType", nfType)
\r
1039 String nfRole = jsonUtils.getJsonValueForKey(allottedResource, "nfRole")
\r
1040 modelJson.put("nfRole", nfRole)
\r
1041 String nfCode = jsonUtils.getJsonValueForKey(allottedResource, "nfCode")
\r
1042 modelJson.put("nfNamingCode", nfCode)
\r
1043 String nfFunction = jsonUtils.getJsonValueForKey(allottedResource, "nfFunction")
\r
1044 modelJson.put("nfFunction", nfFunction)
\r
1045 String parentServiceModelUuid = jsonUtils.getJsonValueForKey(allottedResource, "parentServiceModelUuid")
\r
1046 modelJson.put("parentServiceModelUuid", parentServiceModelUuid)
\r
1051 modelInfos.put(modelJson)
\r
1054 String modelInfosString = modelInfos.toString()
\r
1055 msoLogger.debug("Returning allottedResources JSON: " + modelInfosString)
\r
1057 } catch (Exception e) {
\r
1058 utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message)
\r
1064 private JSONObject parseServiceResourcesJson (String catalogDbResponse) {
\r
1065 JSONObject serviceResources = new JSONObject()
\r
1066 String catalogUtilsVersion = "v1"
\r
1069 // Create array of jsons
\r
1071 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
1072 JSONObject serviceResourcesRoot = responseJson.getJSONObject("serviceResources")
\r
1073 JSONArray vnfsArray = parseVnfsJson(serviceResourcesRoot.toString(), "vnfResources", catalogUtilsVersion)
\r
1074 serviceResources.put("vnfs", vnfsArray)
\r
1075 JSONArray networksArray = parseNetworksJson(serviceResourcesRoot.toString(), "networkResourceCustomization", catalogUtilsVersion)
\r
1076 serviceResources.put("networks", networksArray)
\r
1077 JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "allottedResourceCustomization", catalogUtilsVersion)
\r
1078 serviceResources.put("allottedResources", allottedResourcesArray)
\r
1080 String serviceResourcesString = serviceResources.toString()
\r
1081 msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesString)
\r
1083 } catch (Exception e) {
\r
1084 utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message)
\r
1087 return serviceResources
\r
1090 private JSONObject parseServiceResourcesJson (String catalogDbResponse, String catalogUtilsVersion) {
\r
1091 JSONObject serviceResources = new JSONObject()
\r
1092 JSONObject serviceResourcesObject = new JSONObject()
\r
1093 String serviceResourcesString = ""
\r
1096 // Create array of jsons
\r
1098 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
1099 JSONObject serviceResourcesRoot = responseJson.getJSONObject("serviceResources")
\r
1100 JSONObject modelInfo = buildModelInfo("", serviceResourcesRoot, catalogUtilsVersion)
\r
1101 serviceResources.put("modelInfo", modelInfo)
\r
1102 JSONArray vnfsArray = parseVnfsJson(serviceResourcesRoot.toString(), "serviceVnfs", catalogUtilsVersion)
\r
1103 serviceResources.put("serviceVnfs", vnfsArray)
\r
1104 JSONArray networksArray = parseNetworksJson(serviceResourcesRoot.toString(), "serviceNetworks", catalogUtilsVersion)
\r
1105 serviceResources.put("serviceNetworks", networksArray)
\r
1106 JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "serviceAllottedResources", catalogUtilsVersion)
\r
1107 serviceResources.put("serviceAllottedResources", allottedResourcesArray)
\r
1108 serviceResourcesObject.put("serviceResources", serviceResources)
\r
1110 serviceResourcesString = serviceResourcesObject.toString()
\r
1111 msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesString)
\r
1113 } catch (Exception e) {
\r
1114 utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message)
\r
1117 return serviceResourcesObject
\r
1120 private JSONObject buildModelInfo(String modelType, JSONObject modelFromDb, String catalogUtilsVersion) {
\r
1121 JSONObject modelInfo = null
\r
1123 modelInfo = new JSONObject()
\r
1124 modelInfo.put("modelType", modelType)
\r
1125 String modelInvariantId = jsonUtils.getJsonValueForKey(modelFromDb, "modelInvariantUuid")
\r
1126 modelInfo.put("modelInvariantId", modelInvariantId)
\r
1127 if(modelType.equalsIgnoreCase("allottedResource")){
\r
1128 String modelInstanceName = jsonUtils.getJsonValueForKey(modelFromDb, "modelInstanceName")
\r
1129 modelInfo.put("modelInstanceName", modelInstanceName)
\r
1131 if ((!"vfModule".equals(modelType) && !"vnf".equals(modelType)) || !catalogUtilsVersion.equals("v1")) {
\r
1132 String modelVersionId = jsonUtils.getJsonValueForKey(modelFromDb, "modelUuid")
\r
1133 modelInfo.put("modelVersionId", modelVersionId)
\r
1136 String modelVersionId = jsonUtils.getJsonValueForKey(modelFromDb, "asdcUuid")
\r
1137 modelInfo.put("modelVersionId", modelVersionId)
\r
1139 String modelName = jsonUtils.getJsonValueForKey(modelFromDb, "modelName")
\r
1140 modelInfo.put("modelName", modelName)
\r
1141 String modelVersion = jsonUtils.getJsonValueForKey(modelFromDb, "modelVersion")
\r
1142 modelInfo.put("modelVersion", modelVersion)
\r
1143 if (!"vfModule".equals(modelType)) {
\r
1144 String modelCustomizationName = jsonUtils.getJsonValueForKey(modelFromDb, "modelCustomizationName")
\r
1145 modelInfo.put("modelCustomizationName", modelCustomizationName)
\r
1147 String modelCustomizationId = jsonUtils.getJsonValueForKey(modelFromDb, "modelCustomizationUuid")
\r
1148 switch (catalogUtilsVersion) {
\r
1150 modelInfo.put("modelCustomizationId", modelCustomizationId)
\r
1153 modelInfo.put("modelCustomizationUuid", modelCustomizationId)
\r
1156 JSONObject modelJson = new JSONObject()
\r
1157 modelJson.put("modelInfo", modelInfo)
\r
1159 catch (Exception e) {
\r
1160 utils.log("ERROR", "Exception while parsing model information: " + e.message)
\r
1165 private String getResponseFromCatalogDb (Execution execution, String endPoint) {
\r
1167 String catalogDbEndpoint = execution.getVariable("URN_mso_catalog_db_endpoint")
\r
1168 String queryEndpoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + endPoint
\r
1169 RESTConfig config = new RESTConfig(queryEndpoint);
\r
1170 def responseData = ''
\r
1171 def bpmnRequestId = UUID.randomUUID().toString()
\r
1172 RESTClient client = new RESTClient(config).
\r
1173 addHeader('X-TransactionId', bpmnRequestId).
\r
1174 addHeader('X-FromAppId', 'BPMN').
\r
1175 addHeader('Content-Type', 'application/json').
\r
1176 addHeader('Accept','application/json');
\r
1178 String basicAuthCred = execution.getVariable("BasicAuthHeaderValueDB")
\r
1179 if (basicAuthCred != null && !"".equals(basicAuthCred)) {
\r
1180 client.addAuthorizationHeader(basicAuthCred)
\r
1182 msoLogger.debug('sending GET to Catalog DB endpoint: ' + endPoint)
\r
1183 APIResponse response = client.httpGet()
\r
1185 responseData = response.getResponseBodyAsString()
\r
1186 if (responseData != null) {
\r
1187 msoLogger.debug("Received data from Catalog DB: " + responseData)
\r
1190 msoLogger.debug('Response code:' + response.getStatusCode())
\r
1191 msoLogger.debug('Response:' + System.lineSeparator() + responseData)
\r
1192 if (response.getStatusCode() == 200) {
\r
1193 // parse response as needed
\r
1194 return responseData
\r
1200 catch (Exception e) {
\r
1201 msoLogger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message)
\r
1208 * get resource recipe by resource model uuid and action
\r
1210 public JSONObject getResourceRecipe(Execution execution, String resourceModelUuid, String action) {
\r
1211 String endPoint = "/resourceRecipe?resourceModelUuid=" + UriUtils.encode(resourceModelUuid, "UTF-8")+ "&action=" + UriUtils.encode(action, "UTF-8")
\r
1212 JSONObject responseJson = null
\r
1214 msoLogger.debug("ENDPOINT: " + endPoint)
\r
1215 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
1217 if (catalogDbResponse != null) {
\r
1218 responseJson = new JSONObject(catalogDbResponse)
\r
1221 catch (Exception e) {
\r
1222 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
1225 return responseJson
\r