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
27 import static org.apache.commons.lang3.StringUtils.*
28 import groovy.xml.XmlUtil
29 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
30 import org.onap.so.bpmn.common.scripts.ExceptionUtil
31 import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
32 import org.onap.so.bpmn.common.scripts.MsoUtils
33 import org.onap.aai.domain.yang.SpPartner
34 import org.onap.so.bpmn.common.recipe.ResourceInput
35 import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
36 import org.onap.so.bpmn.core.WorkflowException
37 import org.onap.so.bpmn.core.json.JsonUtils
38 import org.onap.so.bpmn.core.UrnPropertiesReader
39 import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
40 import org.onap.so.client.aai.AAIObjectType
41 import org.onap.so.client.aai.AAIResourcesClient
42 import org.onap.so.client.aai.entities.uri.AAIResourceUri
43 import org.onap.so.client.aai.entities.uri.AAIUriFactory
44 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
45 import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
48 import javax.ws.rs.core.Response
49 import org.onap.so.logger.MsoLogger
51 import org.camunda.bpm.engine.runtime.Execution
52 import org.camunda.bpm.engine.delegate.BpmnError
53 import org.camunda.bpm.engine.delegate.DelegateExecution
54 import org.apache.commons.lang3.*
55 import org.apache.commons.codec.binary.Base64
59 * This groovy class supports the <class>Create3rdONAPE2EServiceInstance.bpmn</class> process.
60 * flow for Create E2EServiceInstance in 3rdONAP
62 public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcessor {
64 String Prefix = "CRE3rdONAPESI_"
66 ExceptionUtil exceptionUtil = new ExceptionUtil()
68 JsonUtils jsonUtil = new JsonUtils()
70 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, Create3rdONAPE2EServiceInstance.class)
72 public void checkSPPartnerInfo (DelegateExecution execution) {
73 msoLogger.info(" ***** Started checkSPPartnerInfo *****")
75 //get bpmn inputs from resource request.
76 String requestId = execution.getVariable("mso-request-id")
77 String requestAction = execution.getVariable("requestAction")
78 msoLogger.info("The requestAction is: " + requestAction)
79 String recipeParamsFromRequest = execution.getVariable("recipeParams")
80 msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
81 String resourceInput = execution.getVariable("resourceInput")
82 msoLogger.info("The resourceInput is: " + resourceInput)
83 //Get ResourceInput Object
84 ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
85 String resourceInputPrameters = resourceInputObj.getResourceParameters()
86 String inputParametersJson = JsonUtils.getJsonValue(resourceInputPrameters, "requestInputs")
87 JSONObject inputParameters = new JSONObject(inputParametersJson)
89 // set local resourceInput
90 execution.setVariable(Prefix + "ResourceInput", resourceInputObj)
92 boolean is3rdONAPExist = false
94 if(inputParameters.has("sppartner_url"))
96 String sppartnerUrl = inputParameters.get("sppartner_url")
97 if(!isBlank(sppartnerUrl)) {
98 execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl)
102 is3rdONAPExist = false
103 String msg = "sppartner Url is blank."
107 if(inputParameters.has("sppartner_providingServiceUuid"))
109 String sppartnerUUID= inputParameters.get("sppartner_providingServiceUuid")
110 execution.setVariable(Prefix + "SppartnerUUID", sppartnerUUID)
111 is3rdONAPExist = true
114 is3rdONAPExist = false
115 String msg = "sppartner providingServiceUuid is blank."
118 if(inputParameters.has("sppartner_providingServiceInvariantUuid"))
120 String sppartnerInvarianteUUID = inputParameters.get("sppartner_providingServiceInvariantUuid")
121 execution.setVariable(Prefix + "SppartnerInvarianteUUID", sppartnerInvarianteUUID)
122 is3rdONAPExist = true
125 is3rdONAPExist = false
126 String msg = "sppartner providingServiceInvarianteUuid is blank."
130 if(inputParameters.has("sppartner_handoverMode"))
132 String handoverMode = inputParameters.get("sppartner_handoverMode")
133 execution.setVariable(Prefix + "HandoverMode", handoverMode)
134 is3rdONAPExist = true
137 is3rdONAPExist = false
138 String msg = "sppartner handoverMode is blank."
142 execution.setVariable("Is3rdONAPExist", is3rdONAPExist)
143 execution.setVariable(Prefix + "ServiceInstanceId", resourceInputObj.getServiceInstanceId())
144 execution.setVariable("mso-request-id", requestId)
145 execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId())
147 } catch (Exception ex){
148 String msg = "Exception in checkSPPartnerInfo " + ex.getMessage()
150 // exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
154 public void checkLocallCall (DelegateExecution execution) {
155 msoLogger.info(" ***** Started checkLocallCall *****")
158 //Get ResourceInput Object
159 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
162 String incomingRequest = resourceInputObj.getRequestsInputs()
163 String serviceParameters = JsonUtils.getJsonValue(incomingRequest, "service.parameters")
164 String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs")
165 JSONObject inputParameters = new JSONObject(requestInputs)
166 execution.setVariable(Prefix + "ServiceParameters", inputParameters)
168 // CallSource is added only when ONAP SO calling 3rdONAP(External API) SO(Remote call)
169 boolean isLocalCall = true
170 String callSource = "UUI"
171 if(inputParameters.has("CallSource"))
173 callSource = inputParameters.get("CallSource")
174 if("ExternalAPI".equalsIgnoreCase(callSource)) {
175 String sppartnerId = inputParameters.get("SppartnerServiceId")
176 execution.setVariable(Prefix + "SppartnerServiceId", sppartnerId)
180 execution.setVariable(Prefix + "CallSource", callSource)
181 msoLogger.debug("callSource is: " + callSource )
183 execution.setVariable("IsLocalCall", isLocalCall)
185 } catch (Exception ex){
186 String msg = "Exception in checkLocallCall " + ex.getMessage()
188 // exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
192 public void preProcessRequest(DelegateExecution execution){
193 msoLogger.info(" ***** Started preProcessRequest *****")
197 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
199 String globalSubscriberId = resourceInputObj.getGlobalSubscriberId()
200 if (isBlank(globalSubscriberId)) {
201 msg = "Input globalSubscriberId is null"
205 execution.setVariable("globalSubscriberId", globalSubscriberId)
206 msoLogger.info("globalSubscriberId:" + globalSubscriberId)
208 String serviceType = resourceInputObj.getServiceType()
209 if (isBlank(serviceType)) {
210 msg = "Input serviceType is null"
213 execution.setVariable("serviceType", serviceType)
214 msoLogger.info("serviceType:" + serviceType)
216 String resourceName = resourceInputObj.getResourceInstanceName()
217 if (isBlank(resourceName)) {
218 msg = "Input resourceName is null"
221 execution.setVariable("resourceName", resourceName)
222 msoLogger.info("resourceName:" + resourceName)
224 int beginIndex = resourceName.indexOf("_") + 1
225 String serviceInstanceName = resourceName.substring(beginIndex)
226 execution.setVariable("serviceInstanceName", serviceInstanceName)
228 String serviceInstanceId = resourceInputObj.getServiceInstanceId()
229 if (isBlank(serviceInstanceId)) {
230 msg = "Input serviceInstanceId is null"
233 execution.setVariable(Prefix + "ServiceInstanceId", serviceInstanceId)
234 msoLogger.info("serviceInstanceId:" + serviceInstanceId)
236 String resourceModelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid()
237 if (isBlank(resourceModelInvariantUuid)) {
238 msg = "Input resourceModelInvariantUuid is null"
241 execution.setVariable(Prefix + "ResourceModelInvariantUuid", resourceModelInvariantUuid)
242 msoLogger.info("resourceModelInvariantUuid:" + resourceModelInvariantUuid)
244 String resourceModelUuid = resourceInputObj.getResourceModelInfo().getModelUuid()
245 if (isBlank(resourceModelUuid)) {
246 msg = "Input resourceModelUuid is null"
249 execution.setVariable(Prefix + "ResourceModelUuid", resourceModelUuid)
250 msoLogger.info("resourceModelUuid:" + resourceModelUuid)
252 String resourceModelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
253 if (isBlank(resourceModelCustomizationUuid)) {
254 msg = "Input resourceModelCustomizationUuid is null"
257 execution.setVariable(Prefix + "ResourceModelCustomizationUuid", resourceModelCustomizationUuid)
258 msoLogger.info("resourceModelCustomizationUuid:" + resourceModelCustomizationUuid)
260 } catch (Exception ex){
261 msg = "Exception in preProcessRequest " + ex.getMessage()
263 // exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
267 public void prepareUpdateProgress(DelegateExecution execution) {
268 msoLogger.info(" ***** Started prepareUpdateProgress *****")
269 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
270 String operType = resourceInputObj.getOperationType()
271 String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
272 String ServiceInstanceId = resourceInputObj.getServiceInstanceId()
273 String modelName = resourceInputObj.getResourceModelInfo().getModelName()
274 String operationId = resourceInputObj.getOperationId()
275 String progress = execution.getVariable("progress")
276 String status = execution.getVariable("status")
277 String statusDescription = execution.getVariable("statusDescription")
280 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
281 xmlns:ns="http://org.openecomp.mso/requestsdb">
284 <ns:updateResourceOperationStatus>
285 <operType>${operType}</operType>
286 <operationId>${operationId}</operationId>
287 <progress>${progress}</progress>
288 <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID>
289 <serviceId>${ServiceInstanceId}</serviceId>
290 <status>${status}</status>
291 <statusDescription>${statusDescription}</statusDescription>
292 </ns:updateResourceOperationStatus>
294 </soapenv:Envelope>"""
296 setProgressUpdateVariables(execution, body)
297 msoLogger.info(" ***** Exit prepareUpdateProgress *****")
300 public void allocateCrossONAPResource(DelegateExecution execution) {
301 msoLogger.info(" ***** Started allocateCrossONAPResource *****")
303 //get TP links from AAI for SOTN handoverMode only
304 String handoverMode = execution.getVariable(Prefix + "HandoverMode")
305 if("SOTN".equalsIgnoreCase(handoverMode)) {
306 // Put TP Link info into serviceParameters
307 JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
308 if(inputParameters.has("remote-access-provider-id")) {
309 Map<String, Object> crossTPs = new HashMap<String, Object>();
310 crossTPs.put("local-access-provider-id", inputParameters.get("remote-access-provider-id"));
311 crossTPs.put("local-access-client-id", inputParameters.get("remote-access-client-id"));
312 crossTPs.put("local-access-topology-id", inputParameters.get("remote-access-topology-id"));
313 crossTPs.put("local-access-node-id", inputParameters.get("remote-access-node-id"));
314 crossTPs.put("local-access-ltp-id", inputParameters.get("remote-access-ltp-id"));
315 crossTPs.put("remote-access-provider-id", inputParameters.get("local-access-provider-id"));
316 crossTPs.put("remote-access-client-id", inputParameters.get("local-access-client-id"));
317 crossTPs.put("remote-access-topology-id", inputParameters.get("local-access-topology-id"));
318 crossTPs.put("remote-access-node-id", inputParameters.get("local-access-node-id"));
319 crossTPs.put("remote-access-ltp-id", inputParameters.get("local-access-ltp-id"));
321 inputParameters.put("local-access-provider-id", crossTPs.get("local-access-provider-id"));
322 inputParameters.put("local-access-client-id", crossTPs.get("local-access-client-id"));
323 inputParameters.put("local-access-topology-id", crossTPs.get("local-access-topology-id"));
324 inputParameters.put("local-access-node-id", crossTPs.get("local-access-node-id"));
325 inputParameters.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id"));
326 inputParameters.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id"));
327 inputParameters.put("remote-access-client-id", crossTPs.get("remote-access-client-id"));
328 inputParameters.put("remote-access-topology-id", crossTPs.get("remote-access-topology-id"));
329 inputParameters.put("remote-access-node-id", crossTPs.get("remote-access-node-id"));
330 inputParameters.put("remote-access-ltp-id", crossTPs.get("remote-access-ltp-id"));
332 execution.setVariable(Prefix + "ServiceParameters", inputParameters)
335 msoLogger.error("No allocated CrossONAPResource found in ServiceParameters")
339 msoLogger.info("Exit " + allocateCrossONAPResource)
342 public void prepare3rdONAPRequest(DelegateExecution execution) {
343 msoLogger.info(" ***** Started prepare3rdONAPRequest *****")
345 String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
346 String extAPIPath = sppartnerUrl + '/serviceOrder'
347 execution.setVariable("ExternalAPIURL", extAPIPath)
349 // ExternalAPI message format
350 String externalId = execution.getVariable("resourceName")
351 String category = "E2E Service"
352 String description = "Service Order from SPPartner"
353 String requestedStartDate = utils.generateCurrentTimeInUtc()
354 String requestedCompletionDate = utils.generateCurrentTimeInUtc()
355 String priority = "1" // 0-4 0:highest
356 String subscriberId = execution.getVariable("globalSubscriberId")
357 String customerRole = "ONAPcustomer"
358 String subscriberName = subscriberId
359 String referredType = "Consumer"
360 String orderItemId = "1"
361 String action = "add" //for create
362 String serviceState = "active"
363 String serviceName = execution.getVariable("serviceInstanceName")
364 String serviceUuId = execution.getVariable(Prefix + "SppartnerUUID")
366 Map<String, String> valueMap = new HashMap<>()
367 valueMap.put("externalId", '"' + externalId + '"')
368 valueMap.put("category", '"' + category + '"')
369 valueMap.put("description", '"' + description + '"')
370 valueMap.put("requestedStartDate", '"' + requestedStartDate + '"')
371 valueMap.put("requestedCompletionDate", '"' + requestedCompletionDate + '"')
372 valueMap.put("priority", '"'+ priority + '"')
373 valueMap.put("subscriberId", '"' + subscriberId + '"')
374 valueMap.put("customerRole", '"' + customerRole + '"')
375 valueMap.put("subscriberName", '"' + subscriberName + '"')
376 valueMap.put("referredType", '"' + referredType + '"')
377 valueMap.put("orderItemId", '"' + orderItemId + '"')
378 valueMap.put("action", '"' + action + '"')
379 valueMap.put("serviceState", '"' + serviceState + '"')
380 valueMap.put("serviceId", "null") //null for add
381 valueMap.put("serviceName", '"' + serviceName + '"')
382 valueMap.put("serviceUuId", '"' + serviceUuId + '"')
384 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
386 // insert CallSource='ExternalAPI' to uuiRequest
387 Map<String, String> requestInputsMap = new HashMap<>()
388 requestInputsMap.put("inputName", '"CallSource"')
389 requestInputsMap.put("inputValue", '"ExternalAPI"')
390 String _requestInputs_ = externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
392 requestInputsMap.clear()
393 String serviceInstanceId = execution.getVariable(Prefix + "ServiceInstanceId")
394 requestInputsMap.put("inputName", '"SppartnerServiceId"')
395 requestInputsMap.put("inputValue", '"' + serviceInstanceId + '"')
396 _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
398 requestInputsMap.clear()
399 String serviceType = execution.getVariable("serviceType")
400 requestInputsMap.put("inputName", '"serviceType"')
401 requestInputsMap.put("inputValue", '"' + serviceType + '"')
402 _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
404 // Transfer all uuiRequest incomeParameters to ExternalAPI format
405 JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
406 for(String key : inputParameters.keySet()) {
407 String inputName = key
408 String inputValue = inputParameters.opt(key)
409 requestInputsMap.clear()
410 requestInputsMap.put("inputName", '"' + inputName+ '"')
411 requestInputsMap.put("inputValue", '"' + inputValue + '"')
412 _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
414 valueMap.put("_requestInputs_", _requestInputs_)
416 String payload = externalAPIUtil.setTemplate(ExternalAPIUtil.PostServiceOrderRequestsTemplate, valueMap)
417 execution.setVariable(Prefix + "Payload", payload)
418 msoLogger.info("Exit " + prepare3rdONAPRequest)
421 public void doCreateE2ESIin3rdONAP(DelegateExecution execution) {
422 msoLogger.info(" ***** Started doCreateE2ESIin3rdONAP *****")
424 String extAPIPath = execution.getVariable("ExternalAPIURL")
425 String payload = execution.getVariable(Prefix + "Payload")
426 msoLogger.debug("doCreateE2ESIin3rdONAP externalAPIURL is: " + extAPIPath)
427 msoLogger.debug("doCreateE2ESIin3rdONAP payload is: " + payload)
429 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
430 execution.setVariable("ServiceOrderId", "")
432 Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
434 int responseCode = response.getStatus()
435 execution.setVariable(Prefix + "PostServiceOrderResponseCode", responseCode)
436 msoLogger.debug("Post ServiceOrder response code is: " + responseCode)
438 String extApiResponse = response.readEntity(String.class)
439 JSONObject responseObj = new JSONObject(extApiResponse)
440 execution.setVariable(Prefix + "PostServiceOrderResponse", extApiResponse)
442 msoLogger.debug("doCreateE2ESIin3rdONAP response body is: " + extApiResponse)
445 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
446 //200 OK 201 CREATED 202 ACCEPTED
448 msoLogger.debug("Post ServiceOrder Received a Good Response")
449 String serviceOrderId = responseObj.get("id")
450 execution.setVariable(Prefix + "SuccessIndicator", true)
451 execution.setVariable("ServiceOrderId", serviceOrderId)
452 msoLogger.info("Post ServiceOrderid is: " + serviceOrderId)
455 msoLogger.error("Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
456 // exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Post ServiceOrder Received a bad response from 3rdONAP External API")
459 msoLogger.error("doCreateE2ESIin3rdONAP exception:" + e.getMessage())
462 msoLogger.info("Exit " + doCreateE2ESIin3rdONAP)
466 public void getE2ESIProgressin3rdONAP(DelegateExecution execution) {
467 msoLogger.info(" ***** Started getE2ESIProgressin3rdONAP *****")
470 String extAPIPath = execution.getVariable("ExternalAPIURL")
471 extAPIPath += "/" + execution.getVariable("ServiceOrderId")
472 msoLogger.debug("getE2ESIProgressin3rdONAP create externalAPIURL is: " + extAPIPath)
474 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
476 Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
478 int responseCode = response.getStatus()
479 execution.setVariable(Prefix + "GetServiceOrderResponseCode", responseCode)
480 msoLogger.debug("Get ServiceOrder response code is: " + responseCode)
482 String extApiResponse = response.readEntity(String.class)
483 JSONObject responseObj = new JSONObject(extApiResponse)
484 execution.setVariable(Prefix + "GetServiceOrderResponse", extApiResponse)
486 msoLogger.debug("getE2ESIProgressin3rdONAP create response body is: " + extApiResponse)
488 //Process Response //200 OK 201 CREATED 202 ACCEPTED
489 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
491 msoLogger.debug("Get Create ServiceOrder Received a Good Response")
493 String orderState = responseObj.get("state")
494 if("REJECTED".equalsIgnoreCase(orderState)) {
495 execution.setVariable("progress", 100)
496 execution.setVariable("status", "error")
497 execution.setVariable("statusDescription", "Create Service Order Status is REJECTED")
501 JSONArray items = responseObj.getJSONArray("orderItem")
502 JSONObject item = items[0]
503 JSONObject service = item.get("service")
504 String sppartnerServiceId = service.get("id")
505 if(sppartnerServiceId == null || sppartnerServiceId.equals("null")) {
506 execution.setVariable("progress", 100)
507 execution.setVariable("status", "error")
508 execution.setVariable("statusDescription", "Create Service Order Status get null sppartnerServiceId")
509 msoLogger.error("null sppartnerServiceId while getting progress from externalAPI")
513 execution.setVariable(Prefix + "SppartnerServiceId", sppartnerServiceId)
515 String serviceOrderState = item.get("state")
516 execution.setVariable(Prefix + "SuccessIndicator", true)
517 execution.setVariable("ServiceOrderState", serviceOrderState)
519 // Get serviceOrder State and process progress
520 if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) {
521 execution.setVariable("progress", 15)
522 execution.setVariable("status", "processing")
523 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
525 else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
526 execution.setVariable("progress", 40)
527 execution.setVariable("status", "processing")
528 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
530 else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
531 execution.setVariable("progress", 100)
532 execution.setVariable("status", "finished")
533 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
535 else if("FAILED".equalsIgnoreCase(serviceOrderState)) {
536 execution.setVariable("progress", 100)
537 execution.setVariable("status", "error")
538 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
541 execution.setVariable("progress", 100)
542 execution.setVariable("status", "error")
543 execution.setVariable("statusDescription", "Create Service Order Status is unknown")
547 msoLogger.debug("Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
548 execution.setVariable("progress", 100)
549 execution.setVariable("status", "error")
550 execution.setVariable("statusDescription", "Get Create ServiceOrder Received a bad response")
551 // exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get Create ServiceOrder Received a bad response from 3rdONAP External API")
555 execution.setVariable("progress", 100)
556 execution.setVariable("status", "error")
557 execution.setVariable("statusDescription", "Get Create ServiceOrder Exception")
558 msoLogger.error("getE2ESIProgressin3rdONAP exception:" + e.getMessage())
560 msoLogger.info("Exit " + getE2ESIProgressin3rdONAP)
566 public void timeDelay(DelegateExecution execution) {
569 } catch(InterruptedException e) {
570 msoLogger.error("Time Delay exception" + e)
574 public void saveSPPartnerInAAI(DelegateExecution execution) {
575 msoLogger.info(" ***** Started saveSPPartnerInAAI *****")
577 String sppartnerId = execution.getVariable(Prefix + "SppartnerServiceId")
578 String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
579 String callSource = execution.getVariable(Prefix + "CallSource")
580 String serviceInstanceId = execution.getVariable(Prefix + "ServiceInstanceId")
581 String globalSubscriberId = execution.getVariable("globalSubscriberId")
582 String serviceType = execution.getVariable("serviceType")
583 String resourceModelInvariantUuid = execution.getVariable(Prefix + "ResourceModelInvariantUuid")
584 String resourceModelUuid = execution.getVariable(Prefix + "ResourceModelUuid")
585 String resourceModelCustomizationUuid = execution.getVariable(Prefix + "ResourceModelCustomizationUuid")
587 SpPartner partner = new SpPartner()
588 partner.setSpPartnerId(sppartnerId)
589 partner.setUrl(sppartnerUrl)
590 partner.setCallsource(callSource)
591 partner.setModelInvariantId(resourceModelInvariantUuid)
592 partner.setModelVersionId(resourceModelUuid)
593 partner.setModelCustomizationId(resourceModelCustomizationUuid)
595 AAIResourcesClient client = new AAIResourcesClient()
596 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId)
597 client.create(uri, partner)
599 AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
600 client.connect(uri, siUri)
601 } catch (Exception ex) {
602 String msg = "Exception in Create3rdONAPE2EServiceInstance.saveSPPartnerInAAI. " + ex.getMessage()
604 // throw new BpmnError("MSOWorkflowException")
606 msoLogger.info("Exit " + saveSPPartnerInAAI)
609 private void setProgressUpdateVariables(DelegateExecution execution, String body) {
610 def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
611 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
612 execution.setVariable("CVFMI_updateResOperStatusRequest", body)
615 public void postProcess(DelegateExecution execution){
616 msoLogger.info(" ***** Started postProcess *****")
617 String responseCode = execution.getVariable(Prefix + "PutSppartnerResponseCode")
618 String responseObj = execution.getVariable(Prefix + "PutSppartnerResponse")
620 msoLogger.info("response from AAI for put sppartner, response code :" + responseCode + " response object :" + responseObj)
621 msoLogger.info(" ***** Exit postProcess *****")
624 public void sendSyncResponse (DelegateExecution execution) {
625 msoLogger.debug(" *** sendSyncResponse *** ")
628 String operationStatus = "finished"
629 // RESTResponse for main flow
630 String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
631 msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
632 sendWorkflowResponse(execution, 202, resourceOperationResp)
633 execution.setVariable("sentSyncResponse", true)
635 } catch (Exception ex) {
636 String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
638 // exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
640 msoLogger.debug(" ***** Exit sendSyncResopnse *****")