2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.bpmn.infrastructure.scripts
23 import org.camunda.bpm.engine.delegate.BpmnError
24 import org.camunda.bpm.engine.delegate.DelegateExecution
25 import org.onap.aai.domain.yang.AllottedResources
26 import org.onap.aai.domain.yang.LogicalLink
27 import org.onap.aai.domain.yang.NetworkPolicy
28 import org.onap.aai.domain.yang.Relationship
29 import org.onap.aai.domain.yang.ServiceInstance
30 import org.onap.aaiclient.client.aai.AAIResourcesClient
31 import org.onap.aaiclient.client.aai.AAIVersion
32 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
33 import org.onap.aaiclient.client.aai.entities.Relationships
34 import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri
35 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
36 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
37 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
38 import org.onap.so.bpmn.common.scripts.ExceptionUtil
39 import org.onap.so.bpmn.common.scripts.MsoUtils
40 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
41 import org.onap.so.bpmn.core.RollbackData
42 import org.onap.so.bpmn.core.UrnPropertiesReader
43 import org.onap.so.bpmn.core.WorkflowException
44 import org.onap.so.bpmn.core.json.JsonUtils
45 import org.onap.so.db.request.beans.ResourceOperationStatus
46 import org.slf4j.Logger
47 import org.slf4j.LoggerFactory
49 import static org.apache.commons.lang3.StringUtils.isBlank
50 import static org.apache.commons.lang3.StringUtils.isNotBlank
52 class ServiceIntentUtils {
53 static final String AAI_VERSION = AAIVersion.LATEST
54 private static final Logger logger = LoggerFactory.getLogger(ServiceIntentUtils.class);
57 ExceptionUtil exceptionUtil = new ExceptionUtil()
58 JsonUtils jsonUtil = new JsonUtils()
59 MsoUtils msoUtils = new MsoUtils()
60 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
62 ServiceIntentUtils() {
66 void setCommonExecutionVars(DelegateExecution execution) {
67 setCommonExecutionVars(execution, true)
70 void setCommonExecutionVars(DelegateExecution execution, boolean exceptionOnErr) {
74 String bpmnRequestStr = execution.getVariable("bpmnRequest")
75 logger.debug("Input Request: " + bpmnRequestStr)
77 String requestId = execution.getVariable("mso-request-id")
78 execution.setVariable("msoRequestId", requestId)
79 logger.debug("requestId: " + requestId)
82 String globalSubscriberId = jsonUtil.getJsonValue(bpmnRequestStr, "globalSubscriberId")
83 if (isBlank(globalSubscriberId) && exceptionOnErr) {
84 msg = "Input globalSubscriberId' is null"
85 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
87 execution.setVariable("globalSubscriberId", globalSubscriberId)
90 String serviceType = jsonUtil.getJsonValue(bpmnRequestStr, "serviceType")
91 if (isBlank(serviceType) && exceptionOnErr) {
92 msg = "Input serviceType is null"
94 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
96 execution.setVariable("serviceType", serviceType)
99 String servicename = jsonUtil.getJsonValue(bpmnRequestStr, "name")
100 if (isNotBlank(servicename)) {
101 execution.setVariable("servicename", servicename)
103 logger.debug("erviceIntentUtils.setCommonExecutionVars: servicename is NOT set")
106 //requestParameters, subscriptionServiceType is 5G
107 String subscriptionServiceType = jsonUtil.getJsonValue(bpmnRequestStr, "subscriptionServiceType")
108 if (isBlank(subscriptionServiceType)) {
109 msg = "Input subscriptionServiceType is null"
111 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
113 execution.setVariable("subscriptionServiceType", subscriptionServiceType)
116 String jobId = UUID.randomUUID().toString()
117 execution.setVariable("jobId", jobId)
119 String sliceParams = jsonUtil.getJsonValue(bpmnRequestStr, "additionalProperties")
120 execution.setVariable("serviceIntentParams", sliceParams)
122 } catch (BpmnError e) {
124 } catch (Exception ex) {
125 msg = "Exception in ServiceIntentUtils.setCommonExecutionVars: " + ex.getMessage()
127 if (exceptionOnErr) {
128 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
133 void setSdncCallbackUrl(DelegateExecution execution, boolean exceptionOnErr) {
134 setSdncCallbackUrl(execution, "sdncCallbackUrl", exceptionOnErr)
137 void setSdncCallbackUrl(DelegateExecution execution, String variableName, boolean exceptionOnErr) {
138 String sdncCallbackUrl = UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback', execution)
140 if (isBlank(sdncCallbackUrl) && exceptionOnErr) {
141 String msg = "mso.workflow.sdncadapter.callback is null"
143 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
145 execution.setVariable(variableName, sdncCallbackUrl)
149 String buildSDNCRequest(DelegateExecution execution, String svcInstId, String svcAction) {
153 reqAction = "CreateCloudLeasedLineInstanceByEline"
156 reqAction = "DeleteCloudLeasedLineInstanceByEline"
159 reqAction = "ActivateCloudLeasedLineInstanceByEline"
162 reqAction = "DeactivateCloudLeasedLineInstanceByEline"
165 reqAction = "ModifyCloudLeasedLineInstanceByEline"
168 reqAction = svcAction
171 buildSDNCRequest(execution, svcInstId, svcAction, reqAction)
174 String buildSDNCRequest(DelegateExecution execution, String svcInstId, String svcAction, String reqAction) {
176 String uuid = execution.getVariable('testReqId') // for junits
178 uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis()
181 def callbackURL = execution.getVariable("sdncCallbackUrl")
182 def requestId = execution.getVariable("msoRequestId")
183 def serviceId = execution.getVariable("sliceServiceInstanceId")
184 def subServiceType = execution.getVariable("subscriptionServiceType")
185 def vnfType = execution.getVariable("serviceType")
186 def vnfName = execution.getVariable("sliceServiceInstanceName")
187 def tenantId = execution.getVariable("sliceServiceInstanceId")
188 def source = execution.getVariable("sliceServiceInstanceId")
189 def vnfId = execution.getVariable("sliceServiceInstanceId")
190 def cloudSiteId = execution.getVariable("sliceServiceInstanceId")
191 def serviceModelInfo = execution.getVariable("serviceModelInfo")
192 def vnfModelInfo = execution.getVariable("serviceModelInfo")
193 def globalSubscriberId = execution.getVariable("globalSubscriberId")
195 String vnfNameString = """<vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>"""
196 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
197 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
199 String sdncVNFParamsXml = ""
201 if (execution.getVariable("vnfParamsExistFlag") == true) {
202 sdncVNFParamsXml = buildSDNCParamsXml(execution)
204 sdncVNFParamsXml = buildDefaultVnfInputParams(vnfId)
208 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
209 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
210 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
211 <sdncadapter:RequestHeader>
212 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
213 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
214 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(svcAction)}</sdncadapter:SvcAction>
215 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
216 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
217 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
218 </sdncadapter:RequestHeader>
219 <sdncadapterworkflow:SDNCRequestData>
220 <request-information>
221 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
222 <request-action>${MsoUtils.xmlEscape(reqAction)}</request-action>
223 <source>${MsoUtils.xmlEscape(source)}</source>
227 </request-information>
228 <service-information>
229 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
230 <subscription-service-type>${MsoUtils.xmlEscape(subServiceType)}</subscription-service-type>
231 ${serviceEcompModelInformation}
232 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
233 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
234 </service-information>
236 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
237 <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
238 ${vnfEcompModelInformation}
242 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
243 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
246 </sdncadapterworkflow:SDNCRequestData>
247 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
249 logger.debug("sdncRequest: " + sdncRequest)
254 String buildDefaultVnfInputParams(String vnfName) {
256 """<vnf-input-parameters>
258 <name>${MsoUtils.xmlEscape(vnfName)}</name>
260 </vnf-input-parameters>"""
265 String buildSDNCParamsXml(DelegateExecution execution) {
267 StringBuilder sb = new StringBuilder()
268 Map<String, String> paramsMap = execution.getVariable("TNNSSMF_vnfParamsMap")
270 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
272 String key = entry.getKey();
273 String value = entry.getValue()
274 paramsXml = """<${key}>$value</$key>"""
275 params = sb.append(paramsXml)
280 void validateSDNCResponse(DelegateExecution execution, String response, String method) {
281 validateSDNCResponse(execution, response, method, true)
284 void validateSDNCResponse(DelegateExecution execution, String response, String method, boolean exceptionOnErr) {
285 logger.debug("STARTED ValidateSDNCResponse Process")
289 String prefix = execution.getVariable("prefix")
290 if (isBlank(prefix)) {
291 if (exceptionOnErr) {
292 msg = "validateSDNCResponse: prefix is null"
294 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
299 WorkflowException workflowException = execution.getVariable("WorkflowException")
300 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
302 logger.debug("ServiceIntentUtils.validateSDNCResponse: SDNCResponse: " + response)
303 logger.debug("ServiceIntentUtils.validateSDNCResponse: workflowException: " + workflowException)
305 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
307 String sdncResponse = response
308 if (execution.getVariable(prefix + 'sdncResponseSuccess') == true) {
309 logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
310 RollbackData rollbackData = execution.getVariable("rollbackData")
311 if (rollbackData == null) {
312 rollbackData = new RollbackData()
315 if (method.equals("allocate")) {
316 rollbackData.put("VNFMODULE", "rollbackSDNCRequestAllocate", "true")
317 } else if (method.equals("deallocate")) {
318 rollbackData.put("VNFMODULE", "rollbackSDNCRequestDeallocate", "true")
319 } else if (method.equals("activate")) {
320 rollbackData.put("VNFMODULE", "rollbackSDNCRequestActivate", "true")
321 } else if (method.equals("deactivate")) {
322 rollbackData.put("VNFMODULE", "rollbackSDNCRequestDeactivate", "true")
323 } else if (method.equals("modify")) {
324 rollbackData.put("VNFMODULE", "rollbackSDNCRequestModify", "true")
326 execution.setVariable("rollbackData", rollbackData)
328 if (exceptionOnErr) {
329 msg = "ServiceIntentUtils.validateSDNCResponse: bad Response from SDNC Adapter for " + method + " SDNC Call."
331 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
335 logger.debug("COMPLETED ValidateSDNCResponse Process")
338 String getExecutionInputParams(DelegateExecution execution) {
339 String res = "\n msoRequestId=" + execution.getVariable("msoRequestId") +
340 "\n modelInvariantUuid=" + execution.getVariable("modelInvariantUuid") +
341 "\n modelUuid=" + execution.getVariable("modelUuid") +
342 "\n serviceInstanceID=" + execution.getVariable("serviceInstanceID") +
343 "\n operationType=" + execution.getVariable("operationType") +
344 "\n globalSubscriberId=" + execution.getVariable("globalSubscriberId") +
345 "\n dummyServiceId=" + execution.getVariable("dummyServiceId") +
346 "\n nsiId=" + execution.getVariable("nsiId") +
347 "\n serviceType=" + execution.getVariable("serviceType") +
348 "\n subscriptionServiceType=" + execution.getVariable("subscriptionServiceType") +
349 "\n jobId=" + execution.getVariable("jobId") +
350 "\n serviceIntentParams=" + execution.getVariable("serviceIntentParams") +
351 "\n servicename=" + execution.getVariable("servicename")
356 String getFirstSnssaiFromSliceProfile(String sliceProfileStr) {
357 String snssaiListStr = jsonUtil.getJsonValue(sliceProfileStr, "snssaiList")
358 String snssai = jsonUtil.StringArrayToList(snssaiListStr).get(0)
363 String getFirstPlmnIdFromSliceProfile(String sliceProfileStr) {
364 String plmnListStr = jsonUtil.getJsonValue(sliceProfileStr, "pLMNIdList")
365 String res = jsonUtil.StringArrayToList(plmnListStr).get(0)
370 void createRelationShipInAAI(DelegateExecution execution, AAIResourceUri uri, Relationship relationship) {
371 logger.debug("createRelationShipInAAI Start")
373 AAIResourcesClient client = new AAIResourcesClient()
375 if (!client.exists(uri)) {
376 logger.info("ERROR: createRelationShipInAAI: not exist: uri={}", uri)
379 AAIResourceUri from = ((AAIResourceUri) (uri.clone())).relationshipAPI()
380 client.create(from, relationship)
382 } catch (BpmnError e) {
384 } catch (Exception ex) {
385 msg = "Exception in createRelationShipInAAI. " + ex.getMessage()
387 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
389 logger.debug("createRelationShipInAAI Exit")
392 void attachLogicalLinkToAllottedResource(DelegateExecution execution, String aaiVersion, AAIResourceUri arUri,
393 String logicalLinkId) {
395 String toLink = "aai/${aaiVersion}/network/logical-links/logical-link/${logicalLinkId}"
397 Relationship relationship = new Relationship()
398 relationship.setRelatedLink(toLink)
399 relationship.setRelatedTo("logical-link")
400 relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
402 createRelationShipInAAI(execution, arUri, relationship)
405 void attachNetworkPolicyToAllottedResource(DelegateExecution execution, String aaiVersion,
406 AAIResourceUri aaiResourceUri, String networkPolicyId) {
408 String toLink = "aai/${aaiVersion}/network/network-policies/network-policy/${networkPolicyId}"
410 Relationship relationship = new Relationship()
411 relationship.setRelatedLink(toLink)
412 relationship.setRelatedTo("network-policy")
413 relationship.setRelationshipLabel("org.onap.relationships.inventory.Uses")
415 createRelationShipInAAI(execution, aaiResourceUri, relationship)
419 ResourceOperationStatus buildRoStatus(String nsstId,
426 String statusDescription) {
427 ResourceOperationStatus roStatus = new ResourceOperationStatus()
428 roStatus.setResourceTemplateUUID(nsstId)
429 roStatus.setResourceInstanceID(nssiId)
430 roStatus.setServiceId(nsiId)
431 roStatus.setOperationId(jobId)
432 roStatus.setOperType(action)
433 roStatus.setProgress(progress)
434 roStatus.setStatus(status)
435 roStatus.setStatusDescription(statusDescription)
441 void setEnableSdncConfig(DelegateExecution execution) {
442 String enableSdnc = UrnPropertiesReader.getVariable(
443 "mso.workflow.TnNssmf.enableSDNCNetworkConfig")
444 if (isBlank(enableSdnc)) {
445 logger.debug("mso.workflow.TnNssmf.enableSDNCNetworkConfig is undefined, so use default value (true)")
449 logger.debug("setEnableSdncConfig: enableSdnc=" + enableSdnc)
451 execution.setVariable("enableSdnc", enableSdnc)
454 String setExecVarFromJsonIfExists(DelegateExecution execution,
455 String jsonStr, String jsonKey, String varName) {
456 return setExecVarFromJsonStr(execution, jsonStr, jsonKey, varName, false)
459 String setExecVarFromJsonStr(DelegateExecution execution,
460 String jsonStr, String jsonKey, String varName,
461 boolean exceptionOnErr) {
463 String valueStr = jsonUtil.getJsonValue(jsonStr, jsonKey)
464 if (isBlank(valueStr)) {
465 if (exceptionOnErr) {
466 msg = "cannot find " + jsonKey + " in " + jsonStr
468 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
471 execution.setVariable(varName, valueStr)
477 ServiceInstance getServiceInstanceFromAai(String serviceInstanceId) {
478 if (isBlank(serviceInstanceId)) {
479 logger.error("ERROR: getServiceInstanceFromAai: serviceInstanceId is blank")
483 ServiceInstance nssi = null
484 AAIResourcesClient client = new AAIResourcesClient()
485 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.Types.SERVICE_INSTANCE
486 .getFragment(serviceInstanceId))
487 Optional<ServiceInstance> nssiOpt = client.get(ServiceInstance.class, uri)
489 if (nssiOpt.isPresent()) {
493 String msg = String.format("ERROR: getServiceInstanceFromAai: NSSI %s not found in AAI", serviceInstanceId)
500 String getModelUuidFromServiceInstance(String serviceInstanceId) {
501 ServiceInstance si = getServiceInstanceFromAai(serviceInstanceId)
503 String msg = String.format("ERROR: getModelUuidFromServiceInstance: getServiceInstanceFromAai() failed. " +
504 "serviceInstanceId=%s", serviceInstanceId)
509 return si.getModelVersionId()
512 AAIResourceUri buildNetworkPolicyUri(String networkPolicyId) {
513 AAIResourceUri networkPolicyUri =
514 AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId))
516 return networkPolicyUri
519 AAIResourceUri buildAllottedResourceUri(DelegateExecution execution, String serviceInstanceId,
520 String allottedResourceId) {
522 AAIResourceUri allottedResourceUri =
523 AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
524 .customer(execution.getVariable("globalSubscriberId"))
525 .serviceSubscription(execution.getVariable("subscriptionServiceType"))
526 .serviceInstance(serviceInstanceId)
527 .allottedResource(allottedResourceId))
529 return allottedResourceUri
532 AAIPluralResourceUri buildAllottedResourcesUri(DelegateExecution execution, String serviceInstanceId) {
534 AAIPluralResourceUri arsUri =
535 AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
536 .customer(execution.getVariable("globalSubscriberId"))
537 .serviceSubscription(execution.getVariable("subscriptionServiceType"))
538 .serviceInstance(serviceInstanceId)
539 .allottedResources())
544 AllottedResources getAllottedResourcesFromAai(DelegateExecution execution, String serviceInstanceId, boolean exceptionOnErr) {
545 AllottedResources res
547 AAIResourcesClient client = new AAIResourcesClient()
549 AAIPluralResourceUri arsUri = buildAllottedResourcesUri(execution, serviceInstanceId)
551 //AAIResultWrapper wrapperAllotted = client.get(arsUri, NotFoundException.class)
552 //Optional<AllottedResources> allAllotted = wrapperAllotted.asBean(AllottedResources.class)
553 //AllottedResources allottedResources = allAllotted.get()
555 Optional<AllottedResources> arsOpt = client.get(AllottedResources.class, arsUri)
556 if (arsOpt.isPresent()) {
560 String msg = String.format("ERROR: getAllottedResourcesFromAai: ars not found. nssiId=%s", serviceInstanceId)
562 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
564 } catch (BpmnError e) {
565 if (exceptionOnErr) {
568 } catch (Exception ex) {
569 if (exceptionOnErr) {
570 String msg = String.format("ERROR: getAllottedResourcesFromAai: %s", ex.getMessage())
572 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
579 String getPolicyIdFromAr(DelegateExecution execution, String serviceInstanceId,
580 String arId, boolean exceptionOnErr) {
583 AAIResourcesClient client = new AAIResourcesClient()
585 AAIResourceUri arUri = buildAllottedResourceUri(execution, serviceInstanceId, arId)
586 List<AAIResourceUri> policyUriList = getRelationshipUriListInAai(execution, arUri,
587 AAIFluentTypeBuilder.Types.NETWORK_POLICY, exceptionOnErr)
588 for (AAIResourceUri policyUri : policyUriList) {
589 Optional<NetworkPolicy> policyOpt = client.get(NetworkPolicy.class, policyUri)
590 if (policyOpt.isPresent()) {
591 NetworkPolicy policy = policyOpt.get()
592 return policy.getNetworkPolicyId()
594 String msg = String.format("ERROR: getPolicyIdFromAr: arUri=%s", policyUri)
596 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
599 } catch (BpmnError e) {
600 if (exceptionOnErr) {
603 } catch (Exception ex) {
604 if (exceptionOnErr) {
605 String msg = String.format("ERROR: getPolicyIdFromAr: %s", ex.getMessage())
607 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
615 List<AAIResourceUri> getRelationshipUriListInAai(DelegateExecution execution,
618 boolean exceptionOnErr) {
619 AAIResourcesClient client = new AAIResourcesClient()
620 AAIResultWrapper wrapper = client.get(uri);
621 Optional<Relationships> relationships = wrapper.getRelationships()
622 if (relationships.isPresent()) {
623 return relationships.get().getRelatedUris(info)
625 if (exceptionOnErr) {
626 String msg = "ERROR: getRelationshipUriListInAai: No relationship found"
628 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
635 List<String> getLogicalLinkNamesFromAr(DelegateExecution execution, String serviceInstanceId,
636 String arId, boolean exceptionOnErr) {
637 List<String> res = new ArrayList<>()
639 AAIResourcesClient client = new AAIResourcesClient()
641 AAIResourceUri arUri = buildAllottedResourceUri(execution, serviceInstanceId, arId)
642 List<AAIResourceUri> logicalLinkUriList = getRelationshipUriListInAai(execution, arUri,
643 AAIFluentTypeBuilder.Types.LOGICAL_LINK, exceptionOnErr)
644 for (AAIResourceUri logicalLinkUri : logicalLinkUriList) {
645 Optional<LogicalLink> logicalLinkOpt = client.get(LogicalLink.class, logicalLinkUri)
646 if (logicalLinkOpt.isPresent()) {
647 LogicalLink logicalLink = logicalLinkOpt.get()
648 res.add(logicalLink.getLinkName())
650 String msg = String.format("ERROR: getLogicalLinkNamesFromAr: logicalLinkUri=%s", logicalLinkUri)
652 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
655 } catch (BpmnError e) {
656 if (exceptionOnErr) {
659 } catch (Exception ex) {
660 if (exceptionOnErr) {
661 String msg = String.format("ERROR: getLogicalLinkNamesFromAr: %s", ex.getMessage())
663 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)