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.delegate.DelegateExecution
\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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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
731 catch (Exception e) {
\r
732 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
738 public JSONObject getServiceResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) {
\r
739 JSONObject resources = null
\r
740 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
742 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
744 if (catalogDbResponse != null) {
\r
746 resources = parseServiceResourcesJson(catalogDbResponse, "v1")
\r
750 catch (Exception e) {
\r
751 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
757 public String getServiceResourcesByServiceModelInvariantUuidString(DelegateExecution execution, String serviceModelInvariantUuid) {
\r
758 String resources = null
\r
759 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
761 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
763 if (catalogDbResponse != null) {
\r
765 resources = catalogDbResponse
\r
769 catch (Exception e) {
\r
770 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
776 public JSONObject getServiceResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
\r
777 JSONObject resources = null
\r
778 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
\r
780 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
782 if (catalogDbResponse != null) {
\r
783 if (!catalogUtilsVersion.equals("v1")) {
\r
784 resources = new JSONObject(catalogDbResponse)
\r
787 resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
\r
792 catch (Exception e) {
\r
793 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
800 public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
\r
801 JSONObject resources = null
\r
802 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
\r
804 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
806 if (catalogDbResponse != null) {
\r
807 //TODO this is wrong
\r
808 resources = parseServiceResourcesJson(catalogDbResponse)
\r
812 catch (Exception e) {
\r
813 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
819 public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
\r
820 JSONObject resources = null
\r
821 String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
\r
823 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
825 if (catalogDbResponse != null) {
\r
826 if (!catalogUtilsVersion.equals("v1")) {
\r
827 resources = new JSONObject(catalogDbResponse)
\r
830 resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
\r
835 catch (Exception e) {
\r
836 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
844 private JSONArray parseNetworksJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
\r
845 JSONArray modelInfos = null
\r
847 msoLogger.debug("parseNetworksJson - catalogUtilsVersion is " + catalogUtilsVersion)
\r
849 // Create array of jsons
\r
851 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
852 JSONArray networks = responseJson.getJSONArray(arrayName)
\r
853 modelInfos = new JSONArray()
\r
855 for (int i = 0; i < networks.length(); i++) {
\r
857 JSONObject network = networks.getJSONObject(i)
\r
858 JSONObject modelJson = new JSONObject()
\r
859 JSONObject modelInfo = buildModelInfo("network", network, catalogUtilsVersion)
\r
860 modelJson.put("modelInfo", modelInfo)
\r
861 String networkType = jsonUtils.getJsonValueForKey(network, "networkType")
\r
862 modelJson.put("networkType", networkType)
\r
864 switch (catalogUtilsVersion) {
\r
868 String toscaNodeType = jsonUtils.getJsonValueForKey(network, "toscaNodeType")
\r
869 modelJson.put("toscaNodeType", toscaNodeType)
\r
870 String networkTechnology = jsonUtils.getJsonValueForKey(network, "networkTechnology")
\r
871 modelJson.put("networkTechnology", networkTechnology)
\r
872 String networkRole = jsonUtils.getJsonValueForKey(network, "networkRole")
\r
873 modelJson.put("networkRole", networkRole)
\r
874 String networkScope = jsonUtils.getJsonValueForKey(network, "networkScope")
\r
875 modelJson.put("networkScope", networkScope)
\r
878 modelInfos.put(modelJson)
\r
881 String modelInfosString = modelInfos.toString()
\r
882 msoLogger.debug("Returning networks JSON: " + modelInfosString)
\r
884 } catch (Exception e) {
\r
885 utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message)
\r
891 private JSONArray parseVnfsJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
\r
892 JSONArray modelInfos = null
\r
894 msoLogger.debug("parseVnfsJson - catalogUtilsVersion is " + catalogUtilsVersion)
\r
897 // Create array of jsons
\r
899 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
900 JSONArray vnfs = responseJson.getJSONArray(arrayName)
\r
901 modelInfos = new JSONArray()
\r
903 for (int i = 0; i < vnfs.length(); i++) {
\r
904 JSONObject vnf = vnfs.getJSONObject(i)
\r
906 msoLogger.debug(vnf.toString(2))
\r
907 JSONObject modelInfo = buildModelInfo("vnf", vnf, catalogUtilsVersion)
\r
908 JSONObject modelJson = new JSONObject()
\r
909 modelJson.put("modelInfo", modelInfo)
\r
910 switch(catalogUtilsVersion) {
\r
914 String toscaNodeType = jsonUtils.getJsonValueForKey(vnf, "toscaNodeType")
\r
915 modelJson.put("toscaNodeType", toscaNodeType)
\r
916 String nfType = jsonUtils.getJsonValueForKey(vnf, "nfType")
\r
917 modelJson.put("nfType", nfType)
\r
918 String nfRole = jsonUtils.getJsonValueForKey(vnf, "nfRole")
\r
919 modelJson.put("nfRole", nfRole)
\r
920 String nfCode = jsonUtils.getJsonValueForKey(vnf, "nfCode")
\r
921 modelJson.put("nfNamingCode", nfCode)
\r
922 String nfFunction = jsonUtils.getJsonValueForKey(vnf, "nfFunction")
\r
923 modelJson.put("nfFunction", nfFunction)
\r
924 String multiStageDesign = jsonUtils.getJsonValueForKey(vnf, "multiStageDesign")
\r
925 modelJson.put("multiStageDesign", multiStageDesign)
\r
929 JSONArray vfModules = null
\r
931 vfModules = vnf.getJSONArray("vfModules")
\r
932 } catch (Exception e)
\r
934 msoLogger.debug("Cannot find VF MODULE ARRAY: " + i + ", exception is " + e.message)
\r
937 if (vfModules != null) {
\r
938 JSONArray vfModuleInfo = new JSONArray()
\r
939 for (int j = 0; j < vfModules.length(); j++) {
\r
940 JSONObject vfModule = vfModules.getJSONObject(j)
\r
941 JSONObject vfModuleModelInfo = buildModelInfo("vfModule", vfModule, catalogUtilsVersion)
\r
942 JSONObject vfModuleModelJson = new JSONObject()
\r
943 vfModuleModelJson.put("modelInfo", vfModuleModelInfo)
\r
944 String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type")
\r
945 vfModuleModelJson.put("vfModuleType", vfModuleType)
\r
946 switch(catalogUtilsVersion) {
\r
948 //TODO this does not work, isBase is not a integer.
\r
949 Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase")
\r
950 if (isBase.intValue() == 1) {
\r
951 vfModuleModelJson.put("isBase", "true")
\r
954 vfModuleModelJson.put("isBase", "false")
\r
958 boolean isBase = jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase")
\r
959 vfModuleModelJson.put("isBase", isBase)
\r
962 String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label")
\r
963 vfModuleModelJson.put("vfModuleLabel", vfModuleLabel)
\r
964 Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount")
\r
965 vfModuleModelJson.put("initialCount", initialCount.intValue())
\r
966 vfModuleInfo.put(vfModuleModelJson)
\r
968 modelJson.put("vfModules", vfModuleInfo)
\r
970 modelInfos.put(modelJson)
\r
973 String modelInfosString = modelInfos.toString()
\r
974 msoLogger.debug("Returning vnfs JSON: " + modelInfosString)
\r
976 } catch (Exception e) {
\r
977 utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message)
\r
984 * This method parses a Vf Module from the
\r
987 * @param catalogDbResponse
\r
989 * @param catalogUtilsVersion
\r
990 * @return vfModulelJson
\r
992 private JSONObject parseVfModuleJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
\r
993 JSONObject vfModulelJson = new JSONObject()
\r
994 msoLogger.debug("Started Parse Vf Module Json")
\r
996 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
997 JSONArray vfModules = responseJson.getJSONArray(arrayName)
\r
998 if(vfModules != null){
\r
999 JSONObject vfModuleInfo = new JSONObject()
\r
1000 for (int i = 0; i < vfModules.length(); i++) {
\r
1001 JSONObject vfModule = vfModules.getJSONObject(i)
\r
1002 JSONObject vfModuleModelInfo = buildModelInfo("vfModule", vfModule, catalogUtilsVersion)
\r
1003 vfModulelJson.put("modelInfo", vfModuleModelInfo)
\r
1004 String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type")
\r
1005 vfModulelJson.put("vfModuleType", vfModuleType)
\r
1006 switch(catalogUtilsVersion) {
\r
1008 Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase")
\r
1009 if (isBase.intValue() == 1) {
\r
1010 vfModulelJson.put("isBase", "true")
\r
1013 vfModulelJson.put("isBase", "false")
\r
1017 boolean isBase = jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase")
\r
1018 vfModulelJson.put("isBase", isBase)
\r
1021 String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label")
\r
1022 vfModulelJson.put("vfModuleLabel", vfModuleLabel)
\r
1023 Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount")
\r
1024 vfModulelJson.put("initialCount", initialCount.intValue())
\r
1027 msoLogger.debug("Completed Parsing Vf Module: " + vfModulelJson.toString())
\r
1028 }catch (Exception e){
\r
1029 utils.log("DEBUG", "Exception while parsing Vf Modules from Catalog DB Response: " + e.message)
\r
1032 return vfModulelJson
\r
1035 private JSONArray parseAllottedResourcesJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
\r
1036 JSONArray modelInfos = null
\r
1038 msoLogger.debug("parseAllottedResourcesJson - catalogUtilsVersion is " + catalogUtilsVersion)
\r
1041 // Create array of jsons
\r
1043 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
1044 JSONArray allottedResources = responseJson.getJSONArray(arrayName)
\r
1045 modelInfos = new JSONArray()
\r
1047 for (int i = 0; i < allottedResources.length(); i++) {
\r
1048 JSONObject allottedResource = allottedResources.getJSONObject(i)
\r
1049 JSONObject modelInfo = buildModelInfo("allottedResource", allottedResource, catalogUtilsVersion)
\r
1050 JSONObject modelJson = new JSONObject()
\r
1051 modelJson.put("modelInfo", modelInfo)
\r
1052 switch(catalogUtilsVersion) {
\r
1056 String toscaNodeType = jsonUtils.getJsonValueForKey(allottedResource, "toscaNodeType")
\r
1057 modelJson.put("toscaNodeType", toscaNodeType)
\r
1058 String nfType = jsonUtils.getJsonValueForKey(allottedResource, "nfType")
\r
1059 modelJson.put("nfType", nfType)
\r
1060 String nfRole = jsonUtils.getJsonValueForKey(allottedResource, "nfRole")
\r
1061 modelJson.put("nfRole", nfRole)
\r
1062 String nfCode = jsonUtils.getJsonValueForKey(allottedResource, "nfCode")
\r
1063 modelJson.put("nfNamingCode", nfCode)
\r
1064 String nfFunction = jsonUtils.getJsonValueForKey(allottedResource, "nfFunction")
\r
1065 modelJson.put("nfFunction", nfFunction)
\r
1066 String providingServiceModelName = jsonUtils.getJsonValueForKey(allottedResource, "providingServiceModelName")
\r
1067 modelJson.put("providingServiceModelName", providingServiceModelName)
\r
1068 String providingServiceModelUuid = jsonUtils.getJsonValueForKey(allottedResource, "providingServiceModelUuid")
\r
1069 modelJson.put("providingServiceModelUuid", providingServiceModelUuid)
\r
1074 modelInfos.put(modelJson)
\r
1077 String modelInfosString = modelInfos.toString()
\r
1078 msoLogger.debug("Returning allottedResources JSON: " + modelInfosString)
\r
1080 } catch (Exception e) {
\r
1081 utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message)
\r
1087 //TODO this is wrong
\r
1088 private JSONObject parseServiceResourcesJson (String catalogDbResponse) {
\r
1089 JSONObject serviceResources = new JSONObject()
\r
1090 String catalogUtilsVersion = "v1"
\r
1093 // Create array of jsons
\r
1095 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
1096 JSONObject serviceResourcesRoot = responseJson.getJSONObject("serviceResources")
\r
1097 JSONArray vnfsArray = parseVnfsJson(serviceResourcesRoot.toString(), "vnfResources", catalogUtilsVersion)
\r
1098 serviceResources.put("vnfs", vnfsArray)
\r
1099 JSONArray networksArray = parseNetworksJson(serviceResourcesRoot.toString(), "networkResourceCustomization", catalogUtilsVersion)
\r
1100 serviceResources.put("networks", networksArray)
\r
1101 JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "allottedResourceCustomization", catalogUtilsVersion)
\r
1102 serviceResources.put("allottedResources", allottedResourcesArray)
\r
1104 String serviceResourcesString = serviceResources.toString()
\r
1105 msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesString)
\r
1107 } catch (Exception e) {
\r
1108 utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message)
\r
1111 return serviceResources
\r
1114 private JSONObject parseServiceResourcesJson (String catalogDbResponse, String catalogUtilsVersion) {
\r
1115 JSONObject serviceResources = new JSONObject()
\r
1116 JSONObject serviceResourcesObject = new JSONObject()
\r
1117 String serviceResourcesString = ""
\r
1120 // Create array of jsons
\r
1122 JSONObject responseJson = new JSONObject(catalogDbResponse)
\r
1123 JSONObject serviceResourcesRoot = responseJson.getJSONObject("serviceResources")
\r
1124 JSONObject modelInfo = buildModelInfo("", serviceResourcesRoot, catalogUtilsVersion)
\r
1125 serviceResources.put("modelInfo", modelInfo)
\r
1126 JSONArray vnfsArray = parseVnfsJson(serviceResourcesRoot.toString(), "serviceVnfs", catalogUtilsVersion)
\r
1127 serviceResources.put("serviceVnfs", vnfsArray)
\r
1128 JSONArray networksArray = parseNetworksJson(serviceResourcesRoot.toString(), "serviceNetworks", catalogUtilsVersion)
\r
1129 serviceResources.put("serviceNetworks", networksArray)
\r
1130 JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "serviceAllottedResources", catalogUtilsVersion)
\r
1131 serviceResources.put("serviceAllottedResources", allottedResourcesArray)
\r
1132 serviceResourcesObject.put("serviceResources", serviceResources)
\r
1134 serviceResourcesString = serviceResourcesObject.toString()
\r
1135 msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesString)
\r
1137 } catch (Exception e) {
\r
1138 utils.log("ERROR", "Exception in parsing Catalog DB Response: " + e.message)
\r
1141 return serviceResourcesObject
\r
1144 private JSONObject buildModelInfo(String modelType, JSONObject modelFromDb, String catalogUtilsVersion) {
\r
1145 JSONObject modelInfo = null
\r
1147 modelInfo = new JSONObject()
\r
1148 modelInfo.put("modelType", modelType)
\r
1149 String modelInvariantId = jsonUtils.getJsonValueForKey(modelFromDb, "modelInvariantUuid")
\r
1150 modelInfo.put("modelInvariantId", modelInvariantId)
\r
1151 if(modelType.equalsIgnoreCase("allottedResource") || modelType.equalsIgnoreCase("vnf")){
\r
1152 String modelInstanceName = jsonUtils.getJsonValueForKey(modelFromDb, "modelInstanceName")
\r
1153 modelInfo.put("modelInstanceName", modelInstanceName)
\r
1155 if ((!"vfModule".equals(modelType) && !"vnf".equals(modelType)) || !catalogUtilsVersion.equals("v1")) {
\r
1156 String modelVersionId = jsonUtils.getJsonValueForKey(modelFromDb, "modelUuid")
\r
1157 modelInfo.put("modelVersionId", modelVersionId)
\r
1160 String modelVersionId = jsonUtils.getJsonValueForKey(modelFromDb, "asdcUuid")
\r
1161 modelInfo.put("modelVersionId", modelVersionId)
\r
1163 String modelName = jsonUtils.getJsonValueForKey(modelFromDb, "modelName")
\r
1164 modelInfo.put("modelName", modelName)
\r
1165 String modelVersion = jsonUtils.getJsonValueForKey(modelFromDb, "modelVersion")
\r
1166 modelInfo.put("modelVersion", modelVersion)
\r
1167 if (!"vfModule".equals(modelType)) {
\r
1168 String modelCustomizationName = jsonUtils.getJsonValueForKey(modelFromDb, "modelCustomizationName")
\r
1169 modelInfo.put("modelCustomizationName", modelCustomizationName)
\r
1171 String modelCustomizationId = jsonUtils.getJsonValueForKey(modelFromDb, "modelCustomizationUuid")
\r
1172 switch (catalogUtilsVersion) {
\r
1174 modelInfo.put("modelCustomizationId", modelCustomizationId)
\r
1177 modelInfo.put("modelCustomizationUuid", modelCustomizationId)
\r
1180 JSONObject modelJson = new JSONObject()
\r
1181 modelJson.put("modelInfo", modelInfo)
\r
1183 catch (Exception e) {
\r
1184 utils.log("ERROR", "Exception while parsing model information: " + e.message)
\r
1189 private String getResponseFromCatalogDb (DelegateExecution execution, String endPoint) {
\r
1191 String catalogDbEndpoint = execution.getVariable("URN_mso_catalog_db_endpoint")
\r
1192 String queryEndpoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + endPoint
\r
1193 RESTConfig config = new RESTConfig(queryEndpoint);
\r
1194 def responseData = ''
\r
1195 def bpmnRequestId = UUID.randomUUID().toString()
\r
1196 RESTClient client = new RESTClient(config).
\r
1197 addHeader('X-TransactionId', bpmnRequestId).
\r
1198 addHeader('X-FromAppId', 'BPMN').
\r
1199 addHeader('Content-Type', 'application/json').
\r
1200 addHeader('Accept','application/json');
\r
1202 String basicAuthCred = execution.getVariable("BasicAuthHeaderValueDB")
\r
1203 if (basicAuthCred != null && !"".equals(basicAuthCred)) {
\r
1204 client.addAuthorizationHeader(basicAuthCred)
\r
1206 msoLogger.debug('sending GET to Catalog DB endpoint: ' + endPoint)
\r
1207 APIResponse response = client.httpGet()
\r
1209 responseData = response.getResponseBodyAsString()
\r
1210 if (responseData != null) {
\r
1211 msoLogger.debug("Received data from Catalog DB: " + responseData)
\r
1214 msoLogger.debug('Response code:' + response.getStatusCode())
\r
1215 msoLogger.debug('Response:' + System.lineSeparator() + responseData)
\r
1216 if (response.getStatusCode() == 200) {
\r
1217 // parse response as needed
\r
1218 return responseData
\r
1224 catch (Exception e) {
\r
1225 msoLogger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message)
\r
1232 * get resource recipe by resource model uuid and action
\r
1234 public JSONObject getResourceRecipe(DelegateExecution execution, String resourceModelUuid, String action) {
\r
1235 String endPoint = "/resourceRecipe?resourceModelUuid=" + UriUtils.encode(resourceModelUuid, "UTF-8")+ "&action=" + UriUtils.encode(action, "UTF-8")
\r
1236 JSONObject responseJson = null
\r
1238 msoLogger.debug("ENDPOINT: " + endPoint)
\r
1239 String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
\r
1241 if (catalogDbResponse != null) {
\r
1242 responseJson = new JSONObject(catalogDbResponse)
\r
1245 catch (Exception e) {
\r
1246 utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
\r
1249 return responseJson
\r