2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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.json.JSONArray
24 import org.json.JSONObject
26 import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
28 import static org.apache.commons.lang3.StringUtils.*
29 import groovy.xml.XmlUtil
30 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
31 import org.onap.so.bpmn.common.scripts.ExceptionUtil
32 import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
33 import org.onap.so.bpmn.common.scripts.MsoUtils
34 import org.onap.aai.domain.yang.SpPartner
35 import org.onap.so.bpmn.common.recipe.ResourceInput
36 import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
37 import org.onap.so.bpmn.core.WorkflowException
38 import org.onap.so.bpmn.core.json.JsonUtils
39 import org.onap.so.bpmn.core.UrnPropertiesReader
40 import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
41 import org.onap.so.client.aai.AAIObjectType
42 import org.onap.so.client.aai.AAIResourcesClient
43 import org.onap.so.client.aai.entities.uri.AAIResourceUri
44 import org.onap.so.client.aai.entities.uri.AAIUriFactory
45 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
46 import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
49 import javax.ws.rs.core.Response
50 import org.onap.so.logger.MsoLogger
52 import org.camunda.bpm.engine.runtime.Execution
53 import org.camunda.bpm.engine.delegate.BpmnError
54 import org.camunda.bpm.engine.delegate.DelegateExecution
55 import org.apache.commons.lang3.*
56 import org.apache.commons.codec.binary.Base64
60 * This groovy class supports the <class>Create3rdONAPE2EServiceInstance.bpmn</class> process.
61 * flow for Create E2EServiceInstance in 3rdONAP
63 public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcessor {
65 String Prefix = "CRE3rdONAPESI_"
67 ExceptionUtil exceptionUtil = new ExceptionUtil()
69 JsonUtils jsonUtil = new JsonUtils()
71 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, Create3rdONAPE2EServiceInstance.class)
73 public void checkSPPartnerInfo (DelegateExecution execution) {
74 msoLogger.info(" ***** Started checkSPPartnerInfo *****")
76 //get bpmn inputs from resource request.
77 String requestId = execution.getVariable("mso-request-id")
78 String requestAction = execution.getVariable("requestAction")
79 msoLogger.info("The requestAction is: " + requestAction)
80 String recipeParamsFromRequest = execution.getVariable("recipeParams")
81 msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
82 String resourceInput = execution.getVariable("resourceInput")
83 msoLogger.info("The resourceInput is: " + resourceInput)
84 //Get ResourceInput Object
85 ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
86 String resourceInputPrameters = resourceInputObj.getResourceParameters()
87 String inputParametersJson = JsonUtils.getJsonValue(resourceInputPrameters, "requestInputs")
88 JSONObject inputParameters = new JSONObject(inputParametersJson)
90 // set local resourceInput
91 execution.setVariable(Prefix + "ResourceInput", resourceInputObj)
93 boolean is3rdONAPExist = false
95 if(inputParameters.has("sppartner_url"))
97 String sppartnerUrl = inputParameters.get("sppartner_url")
98 if(!isBlank(sppartnerUrl)) {
99 execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl)
100 is3rdONAPExist = true
103 is3rdONAPExist = false
104 String msg = "sppartner Url is blank."
108 if(inputParameters.has("sppartner_providingServiceUuid"))
110 String sppartnerUUID= inputParameters.get("sppartner_providingServiceUuid")
111 execution.setVariable(Prefix + "SppartnerUUID", sppartnerUUID)
112 is3rdONAPExist = true
115 is3rdONAPExist = false
116 String msg = "sppartner providingServiceUuid is blank."
119 if(inputParameters.has("sppartner_providingServiceInvariantUuid"))
121 String sppartnerInvarianteUUID = inputParameters.get("sppartner_providingServiceInvariantUuid")
122 execution.setVariable(Prefix + "SppartnerInvarianteUUID", sppartnerInvarianteUUID)
123 is3rdONAPExist = true
126 is3rdONAPExist = false
127 String msg = "sppartner providingServiceInvarianteUuid is blank."
131 if(inputParameters.has("sppartner_handoverMode"))
133 String handoverMode = inputParameters.get("sppartner_handoverMode")
134 execution.setVariable(Prefix + "HandoverMode", handoverMode)
135 is3rdONAPExist = true
138 is3rdONAPExist = false
139 String msg = "sppartner handoverMode is blank."
143 execution.setVariable("Is3rdONAPExist", is3rdONAPExist)
144 execution.setVariable(Prefix + "ServiceInstanceId", resourceInputObj.getServiceInstanceId())
145 execution.setVariable("mso-request-id", requestId)
146 execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId())
148 } catch (Exception ex){
149 String msg = "Exception in checkSPPartnerInfo " + ex.getMessage()
151 // exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
155 public void checkLocallCall (DelegateExecution execution) {
156 msoLogger.info(" ***** Started checkLocallCall *****")
159 //Get ResourceInput Object
160 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
163 String incomingRequest = resourceInputObj.getRequestsInputs()
164 String serviceParameters = JsonUtils.getJsonValue(incomingRequest, "service.parameters")
165 String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs")
166 JSONObject inputParameters = new JSONObject(requestInputs)
167 execution.setVariable(Prefix + "ServiceParameters", inputParameters)
169 // CallSource is added only when ONAP SO calling 3rdONAP(External API) SO(Remote call)
170 boolean isLocalCall = true
171 String callSource = "UUI"
172 if(inputParameters.has("CallSource"))
174 callSource = inputParameters.get("CallSource")
175 if("ExternalAPI".equalsIgnoreCase(callSource)) {
176 String sppartnerId = inputParameters.get("SppartnerServiceId")
177 execution.setVariable(Prefix + "SppartnerServiceId", sppartnerId)
181 execution.setVariable(Prefix + "CallSource", callSource)
182 msoLogger.debug("callSource is: " + callSource )
184 execution.setVariable("IsLocalCall", isLocalCall)
186 } catch (Exception ex){
187 String msg = "Exception in checkLocallCall " + ex.getMessage()
189 // exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
193 public void preProcessRequest(DelegateExecution execution){
194 msoLogger.info(" ***** Started preProcessRequest *****")
198 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
200 String globalSubscriberId = resourceInputObj.getGlobalSubscriberId()
201 if (isBlank(globalSubscriberId)) {
202 msg = "Input globalSubscriberId is null"
206 execution.setVariable("globalSubscriberId", globalSubscriberId)
207 msoLogger.info("globalSubscriberId:" + globalSubscriberId)
209 String serviceType = resourceInputObj.getServiceType()
210 if (isBlank(serviceType)) {
211 msg = "Input serviceType is null"
214 execution.setVariable("serviceType", serviceType)
215 msoLogger.info("serviceType:" + serviceType)
217 String resourceName = resourceInputObj.getResourceInstanceName()
218 if (isBlank(resourceName)) {
219 msg = "Input resourceName is null"
222 execution.setVariable("resourceName", resourceName)
223 msoLogger.info("resourceName:" + resourceName)
225 int beginIndex = resourceName.indexOf("_") + 1
226 String serviceInstanceName = resourceName.substring(beginIndex)
227 execution.setVariable("serviceInstanceName", serviceInstanceName)
229 String serviceInstanceId = resourceInputObj.getServiceInstanceId()
230 if (isBlank(serviceInstanceId)) {
231 msg = "Input serviceInstanceId is null"
234 execution.setVariable(Prefix + "ServiceInstanceId", serviceInstanceId)
235 msoLogger.info("serviceInstanceId:" + serviceInstanceId)
237 String resourceModelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid()
238 if (isBlank(resourceModelInvariantUuid)) {
239 msg = "Input resourceModelInvariantUuid is null"
242 execution.setVariable(Prefix + "ResourceModelInvariantUuid", resourceModelInvariantUuid)
243 msoLogger.info("resourceModelInvariantUuid:" + resourceModelInvariantUuid)
245 String resourceModelUuid = resourceInputObj.getResourceModelInfo().getModelUuid()
246 if (isBlank(resourceModelUuid)) {
247 msg = "Input resourceModelUuid is null"
250 execution.setVariable(Prefix + "ResourceModelUuid", resourceModelUuid)
251 msoLogger.info("resourceModelUuid:" + resourceModelUuid)
253 String resourceModelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
254 if (isBlank(resourceModelCustomizationUuid)) {
255 msg = "Input resourceModelCustomizationUuid is null"
258 execution.setVariable(Prefix + "ResourceModelCustomizationUuid", resourceModelCustomizationUuid)
259 msoLogger.info("resourceModelCustomizationUuid:" + resourceModelCustomizationUuid)
261 } catch (Exception ex){
262 msg = "Exception in preProcessRequest " + ex.getMessage()
264 // exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
268 public void prepareUpdateProgress(DelegateExecution execution) {
269 msoLogger.info(" ***** Started prepareUpdateProgress *****")
270 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
271 String operType = resourceInputObj.getOperationType()
272 String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
273 String ServiceInstanceId = resourceInputObj.getServiceInstanceId()
274 String modelName = resourceInputObj.getResourceModelInfo().getModelName()
275 String operationId = resourceInputObj.getOperationId()
276 String progress = execution.getVariable("progress")
277 String status = execution.getVariable("status")
278 String statusDescription = execution.getVariable("statusDescription")
281 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
282 xmlns:ns="http://org.onap.so/requestsdb">
285 <ns:updateResourceOperationStatus>
286 <operType>${operType}</operType>
287 <operationId>${operationId}</operationId>
288 <progress>${progress}</progress>
289 <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID>
290 <serviceId>${ServiceInstanceId}</serviceId>
291 <status>${status}</status>
292 <statusDescription>${statusDescription}</statusDescription>
293 </ns:updateResourceOperationStatus>
295 </soapenv:Envelope>"""
297 setProgressUpdateVariables(execution, body)
298 msoLogger.info(" ***** Exit prepareUpdateProgress *****")
301 public void allocateCrossONAPResource(DelegateExecution execution) {
302 msoLogger.info(" ***** Started allocateCrossONAPResource *****")
304 //get TP links from AAI for SOTN handoverMode only
305 String handoverMode = execution.getVariable(Prefix + "HandoverMode")
306 if("SOTN".equalsIgnoreCase(handoverMode)) {
307 // Put TP Link info into serviceParameters
308 JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
309 if(inputParameters.has("remote-access-provider-id")) {
310 Map<String, Object> crossTPs = new HashMap<String, Object>();
311 crossTPs.put("local-access-provider-id", inputParameters.get("remote-access-provider-id"));
312 crossTPs.put("local-access-client-id", inputParameters.get("remote-access-client-id"));
313 crossTPs.put("local-access-topology-id", inputParameters.get("remote-access-topology-id"));
314 crossTPs.put("local-access-node-id", inputParameters.get("remote-access-node-id"));
315 crossTPs.put("local-access-ltp-id", inputParameters.get("remote-access-ltp-id"));
316 crossTPs.put("remote-access-provider-id", inputParameters.get("local-access-provider-id"));
317 crossTPs.put("remote-access-client-id", inputParameters.get("local-access-client-id"));
318 crossTPs.put("remote-access-topology-id", inputParameters.get("local-access-topology-id"));
319 crossTPs.put("remote-access-node-id", inputParameters.get("local-access-node-id"));
320 crossTPs.put("remote-access-ltp-id", inputParameters.get("local-access-ltp-id"));
322 inputParameters.put("local-access-provider-id", crossTPs.get("local-access-provider-id"));
323 inputParameters.put("local-access-client-id", crossTPs.get("local-access-client-id"));
324 inputParameters.put("local-access-topology-id", crossTPs.get("local-access-topology-id"));
325 inputParameters.put("local-access-node-id", crossTPs.get("local-access-node-id"));
326 inputParameters.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id"));
327 inputParameters.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id"));
328 inputParameters.put("remote-access-client-id", crossTPs.get("remote-access-client-id"));
329 inputParameters.put("remote-access-topology-id", crossTPs.get("remote-access-topology-id"));
330 inputParameters.put("remote-access-node-id", crossTPs.get("remote-access-node-id"));
331 inputParameters.put("remote-access-ltp-id", crossTPs.get("remote-access-ltp-id"));
333 execution.setVariable(Prefix + "ServiceParameters", inputParameters)
336 msoLogger.error("No allocated CrossONAPResource found in ServiceParameters")
340 msoLogger.info("Exit " + allocateCrossONAPResource)
343 public void prepare3rdONAPRequest(DelegateExecution execution) {
344 msoLogger.info(" ***** Started prepare3rdONAPRequest *****")
346 String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
347 String extAPIPath = sppartnerUrl + '/serviceOrder'
348 execution.setVariable("ExternalAPIURL", extAPIPath)
350 // ExternalAPI message format
351 String externalId = execution.getVariable("resourceName")
352 String category = "E2E Service"
353 String description = "Service Order from SPPartner"
354 String requestedStartDate = utils.generateCurrentTimeInUtc()
355 String requestedCompletionDate = utils.generateCurrentTimeInUtc()
356 String priority = "1" // 0-4 0:highest
357 String subscriberId = execution.getVariable("globalSubscriberId")
358 String customerRole = "ONAPcustomer"
359 String subscriberName = subscriberId
360 String referredType = "Consumer"
361 String orderItemId = "1"
362 String action = "add" //for create
363 String serviceState = "active"
364 String serviceName = execution.getVariable("serviceInstanceName")
365 String serviceUuId = execution.getVariable(Prefix + "SppartnerUUID")
367 Map<String, String> valueMap = new HashMap<>()
368 valueMap.put("externalId", '"' + externalId + '"')
369 valueMap.put("category", '"' + category + '"')
370 valueMap.put("description", '"' + description + '"')
371 valueMap.put("requestedStartDate", '"' + requestedStartDate + '"')
372 valueMap.put("requestedCompletionDate", '"' + requestedCompletionDate + '"')
373 valueMap.put("priority", '"'+ priority + '"')
374 valueMap.put("subscriberId", '"' + subscriberId + '"')
375 valueMap.put("customerRole", '"' + customerRole + '"')
376 valueMap.put("subscriberName", '"' + subscriberName + '"')
377 valueMap.put("referredType", '"' + referredType + '"')
378 valueMap.put("orderItemId", '"' + orderItemId + '"')
379 valueMap.put("action", '"' + action + '"')
380 valueMap.put("serviceState", '"' + serviceState + '"')
381 valueMap.put("serviceId", "null") //null for add
382 valueMap.put("serviceName", '"' + serviceName + '"')
383 valueMap.put("serviceUuId", '"' + serviceUuId + '"')
385 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create()
387 // insert CallSource='ExternalAPI' to uuiRequest
388 Map<String, String> requestInputsMap = new HashMap<>()
389 requestInputsMap.put("inputName", '"CallSource"')
390 requestInputsMap.put("inputValue", '"ExternalAPI"')
391 String _requestInputs_ = externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
393 requestInputsMap.clear()
394 String serviceInstanceId = execution.getVariable(Prefix + "ServiceInstanceId")
395 requestInputsMap.put("inputName", '"SppartnerServiceId"')
396 requestInputsMap.put("inputValue", '"' + serviceInstanceId + '"')
397 _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
399 requestInputsMap.clear()
400 String serviceType = execution.getVariable("serviceType")
401 requestInputsMap.put("inputName", '"serviceType"')
402 requestInputsMap.put("inputValue", '"' + serviceType + '"')
403 _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
405 // Transfer all uuiRequest incomeParameters to ExternalAPI format
406 JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
407 for(String key : inputParameters.keySet()) {
408 String inputName = key
409 String inputValue = inputParameters.opt(key)
410 requestInputsMap.clear()
411 requestInputsMap.put("inputName", '"' + inputName+ '"')
412 requestInputsMap.put("inputValue", '"' + inputValue + '"')
413 _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
415 valueMap.put("_requestInputs_", _requestInputs_)
417 String payload = externalAPIUtil.setTemplate(ExternalAPIUtil.PostServiceOrderRequestsTemplate, valueMap)
418 execution.setVariable(Prefix + "Payload", payload)
419 msoLogger.info("Exit " + prepare3rdONAPRequest)
422 public void doCreateE2ESIin3rdONAP(DelegateExecution execution) {
423 msoLogger.info(" ***** Started doCreateE2ESIin3rdONAP *****")
425 String extAPIPath = execution.getVariable("ExternalAPIURL")
426 String payload = execution.getVariable(Prefix + "Payload")
427 msoLogger.debug("doCreateE2ESIin3rdONAP externalAPIURL is: " + extAPIPath)
428 msoLogger.debug("doCreateE2ESIin3rdONAP payload is: " + payload)
430 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create()
431 execution.setVariable("ServiceOrderId", "")
433 Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
435 int responseCode = response.getStatus()
436 execution.setVariable(Prefix + "PostServiceOrderResponseCode", responseCode)
437 msoLogger.debug("Post ServiceOrder response code is: " + responseCode)
439 String extApiResponse = response.readEntity(String.class)
440 JSONObject responseObj = new JSONObject(extApiResponse)
441 execution.setVariable(Prefix + "PostServiceOrderResponse", extApiResponse)
443 msoLogger.debug("doCreateE2ESIin3rdONAP response body is: " + extApiResponse)
446 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
447 //200 OK 201 CREATED 202 ACCEPTED
449 msoLogger.debug("Post ServiceOrder Received a Good Response")
450 String serviceOrderId = responseObj.get("id")
451 execution.setVariable(Prefix + "SuccessIndicator", true)
452 execution.setVariable("ServiceOrderId", serviceOrderId)
453 msoLogger.info("Post ServiceOrderid is: " + serviceOrderId)
456 msoLogger.error("Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
457 // exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Post ServiceOrder Received a bad response from 3rdONAP External API")
460 msoLogger.error("doCreateE2ESIin3rdONAP exception:" + e.getMessage())
463 msoLogger.info("Exit " + doCreateE2ESIin3rdONAP)
467 public void getE2ESIProgressin3rdONAP(DelegateExecution execution) {
468 msoLogger.info(" ***** Started getE2ESIProgressin3rdONAP *****")
471 String extAPIPath = execution.getVariable("ExternalAPIURL")
472 extAPIPath += "/" + execution.getVariable("ServiceOrderId")
473 msoLogger.debug("getE2ESIProgressin3rdONAP create externalAPIURL is: " + extAPIPath)
475 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create()
477 Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
479 int responseCode = response.getStatus()
480 execution.setVariable(Prefix + "GetServiceOrderResponseCode", responseCode)
481 msoLogger.debug("Get ServiceOrder response code is: " + responseCode)
483 String extApiResponse = response.readEntity(String.class)
484 JSONObject responseObj = new JSONObject(extApiResponse)
485 execution.setVariable(Prefix + "GetServiceOrderResponse", extApiResponse)
487 msoLogger.debug("getE2ESIProgressin3rdONAP create response body is: " + extApiResponse)
489 //Process Response //200 OK 201 CREATED 202 ACCEPTED
490 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
492 msoLogger.debug("Get Create ServiceOrder Received a Good Response")
494 String orderState = responseObj.get("state")
495 if("REJECTED".equalsIgnoreCase(orderState)) {
496 execution.setVariable("progress", 100)
497 execution.setVariable("status", "error")
498 execution.setVariable("statusDescription", "Create Service Order Status is REJECTED")
502 JSONArray items = responseObj.getJSONArray("orderItem")
503 JSONObject item = items[0]
504 JSONObject service = item.get("service")
505 String sppartnerServiceId = service.get("id")
506 if(sppartnerServiceId == null || sppartnerServiceId.equals("null")) {
507 execution.setVariable("progress", 100)
508 execution.setVariable("status", "error")
509 execution.setVariable("statusDescription", "Create Service Order Status get null sppartnerServiceId")
510 msoLogger.error("null sppartnerServiceId while getting progress from externalAPI")
514 execution.setVariable(Prefix + "SppartnerServiceId", sppartnerServiceId)
516 String serviceOrderState = item.get("state")
517 execution.setVariable(Prefix + "SuccessIndicator", true)
518 execution.setVariable("ServiceOrderState", serviceOrderState)
520 // Get serviceOrder State and process progress
521 if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) {
522 execution.setVariable("progress", 15)
523 execution.setVariable("status", "processing")
524 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
526 else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
527 execution.setVariable("progress", 40)
528 execution.setVariable("status", "processing")
529 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
531 else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
532 execution.setVariable("progress", 100)
533 execution.setVariable("status", "finished")
534 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
536 else if("FAILED".equalsIgnoreCase(serviceOrderState)) {
537 execution.setVariable("progress", 100)
538 execution.setVariable("status", "error")
539 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
542 execution.setVariable("progress", 100)
543 execution.setVariable("status", "error")
544 execution.setVariable("statusDescription", "Create Service Order Status is unknown")
548 msoLogger.debug("Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
549 execution.setVariable("progress", 100)
550 execution.setVariable("status", "error")
551 execution.setVariable("statusDescription", "Get Create ServiceOrder Received a bad response")
552 // exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get Create ServiceOrder Received a bad response from 3rdONAP External API")
556 execution.setVariable("progress", 100)
557 execution.setVariable("status", "error")
558 execution.setVariable("statusDescription", "Get Create ServiceOrder Exception")
559 msoLogger.error("getE2ESIProgressin3rdONAP exception:" + e.getMessage())
561 msoLogger.info("Exit " + getE2ESIProgressin3rdONAP)
567 public void timeDelay(DelegateExecution execution) {
570 } catch(InterruptedException e) {
571 msoLogger.error("Time Delay exception" + e)
575 public void saveSPPartnerInAAI(DelegateExecution execution) {
576 msoLogger.info(" ***** Started saveSPPartnerInAAI *****")
578 String sppartnerId = execution.getVariable(Prefix + "SppartnerServiceId")
579 String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
580 String callSource = execution.getVariable(Prefix + "CallSource")
581 String serviceInstanceId = execution.getVariable(Prefix + "ServiceInstanceId")
582 String globalSubscriberId = execution.getVariable("globalSubscriberId")
583 String serviceType = execution.getVariable("serviceType")
584 String resourceModelInvariantUuid = execution.getVariable(Prefix + "ResourceModelInvariantUuid")
585 String resourceModelUuid = execution.getVariable(Prefix + "ResourceModelUuid")
586 String resourceModelCustomizationUuid = execution.getVariable(Prefix + "ResourceModelCustomizationUuid")
588 SpPartner partner = new SpPartner()
589 partner.setSpPartnerId(sppartnerId)
590 partner.setUrl(sppartnerUrl)
591 partner.setCallsource(callSource)
592 partner.setModelInvariantId(resourceModelInvariantUuid)
593 partner.setModelVersionId(resourceModelUuid)
594 partner.setModelCustomizationId(resourceModelCustomizationUuid)
596 AAIResourcesClient client = new AAIResourcesClient()
597 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId)
598 client.create(uri, partner)
600 AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
601 client.connect(uri, siUri)
602 } catch (Exception ex) {
603 String msg = "Exception in Create3rdONAPE2EServiceInstance.saveSPPartnerInAAI. " + ex.getMessage()
605 // throw new BpmnError("MSOWorkflowException")
607 msoLogger.info("Exit " + saveSPPartnerInAAI)
610 private void setProgressUpdateVariables(DelegateExecution execution, String body) {
611 def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
612 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
613 execution.setVariable("CVFMI_updateResOperStatusRequest", body)
616 public void postProcess(DelegateExecution execution){
617 msoLogger.info(" ***** Started postProcess *****")
618 String responseCode = execution.getVariable(Prefix + "PutSppartnerResponseCode")
619 String responseObj = execution.getVariable(Prefix + "PutSppartnerResponse")
621 msoLogger.info("response from AAI for put sppartner, response code :" + responseCode + " response object :" + responseObj)
622 msoLogger.info(" ***** Exit postProcess *****")
625 public void sendSyncResponse (DelegateExecution execution) {
626 msoLogger.debug(" *** sendSyncResponse *** ")
629 String operationStatus = "finished"
630 // RESTResponse for main flow
631 String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
632 msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
633 sendWorkflowResponse(execution, 202, resourceOperationResp)
634 execution.setVariable("sentSyncResponse", true)
636 } catch (Exception ex) {
637 String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
639 // exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
641 msoLogger.debug(" ***** Exit sendSyncResopnse *****")