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.AaiUtil
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.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
56 import org.springframework.web.util.UriUtils
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 (BpmnError e) {
149 } catch (Exception ex){
150 String msg = "Exception in checkSPPartnerInfo " + ex.getMessage()
152 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
156 public void checkLocallCall (DelegateExecution execution) {
157 msoLogger.info(" ***** Started checkLocallCall *****")
160 //Get ResourceInput Object
161 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
164 String incomingRequest = resourceInputObj.getRequestsInputs()
165 String serviceParameters = JsonUtils.getJsonValue(incomingRequest, "service.parameters")
166 String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs")
167 JSONObject inputParameters = new JSONObject(requestInputs)
168 execution.setVariable(Prefix + "ServiceParameters", inputParameters)
170 // CallSource is added only when ONAP SO calling 3rdONAP(External API) SO(Remote call)
171 boolean isLocalCall = true
172 String callSource = "UUI"
173 if(inputParameters.has("CallSource"))
175 callSource = inputParameters.get("CallSource")
176 if("ExternalAPI".equalsIgnoreCase(callSource)) {
177 String sppartnerId = inputParameters.get("SppartnerServiceId")
178 execution.setVariable(Prefix + "SppartnerServiceId", sppartnerId)
182 execution.setVariable(Prefix + "CallSource", callSource)
183 msoLogger.debug("callSource is: " + callSource )
185 execution.setVariable("IsLocalCall", isLocalCall)
187 } catch (Exception ex){
188 String msg = "Exception in checkLocallCall " + ex.getMessage()
190 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
194 public void preProcessRequest(DelegateExecution execution){
195 msoLogger.info(" ***** Started preProcessRequest *****")
199 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
201 String globalSubscriberId = resourceInputObj.getGlobalSubscriberId()
202 if (isBlank(globalSubscriberId)) {
203 msg = "Input globalSubscriberId is null"
207 execution.setVariable("globalSubscriberId", globalSubscriberId)
208 msoLogger.info("globalSubscriberId:" + globalSubscriberId)
210 String serviceType = resourceInputObj.getServiceType()
211 if (isBlank(serviceType)) {
212 msg = "Input serviceType is null"
215 execution.setVariable("serviceType", serviceType)
216 msoLogger.info("serviceType:" + serviceType)
218 String resourceName = resourceInputObj.getResourceInstanceName()
219 if (isBlank(resourceName)) {
220 msg = "Input resourceName is null"
223 execution.setVariable("resourceName", resourceName)
224 msoLogger.info("resourceName:" + resourceName)
226 int beginIndex = resourceName.indexOf("_") + 1
227 String serviceInstanceName = resourceName.substring(beginIndex)
228 execution.setVariable("serviceInstanceName", serviceInstanceName)
230 String serviceInstanceId = resourceInputObj.getServiceInstanceId()
231 if (isBlank(serviceInstanceId)) {
232 msg = "Input serviceInstanceId is null"
235 execution.setVariable(Prefix + "ServiceInstanceId", serviceInstanceId)
236 msoLogger.info("serviceInstanceId:" + serviceInstanceId)
238 String resourceModelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid()
239 if (isBlank(resourceModelInvariantUuid)) {
240 msg = "Input resourceModelInvariantUuid is null"
243 execution.setVariable(Prefix + "ResourceModelInvariantUuid", resourceModelInvariantUuid)
244 msoLogger.info("resourceModelInvariantUuid:" + resourceModelInvariantUuid)
246 String resourceModelUuid = resourceInputObj.getResourceModelInfo().getModelUuid()
247 if (isBlank(resourceModelUuid)) {
248 msg = "Input resourceModelUuid is null"
251 execution.setVariable(Prefix + "ResourceModelUuid", resourceModelUuid)
252 msoLogger.info("resourceModelUuid:" + resourceModelUuid)
254 String resourceModelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
255 if (isBlank(resourceModelCustomizationUuid)) {
256 msg = "Input resourceModelCustomizationUuid is null"
259 execution.setVariable(Prefix + "ResourceModelCustomizationUuid", resourceModelCustomizationUuid)
260 msoLogger.info("resourceModelCustomizationUuid:" + resourceModelCustomizationUuid)
262 } catch (BpmnError e) {
264 } catch (Exception ex){
265 msg = "Exception in preProcessRequest " + ex.getMessage()
267 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
271 public void prepareUpdateProgress(DelegateExecution execution) {
272 msoLogger.info(" ***** Started prepareUpdateProgress *****")
273 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
274 String operType = resourceInputObj.getOperationType()
275 String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
276 String ServiceInstanceId = resourceInputObj.getServiceInstanceId()
277 String modelName = resourceInputObj.getResourceModelInfo().getModelName()
278 String operationId = resourceInputObj.getOperationId()
279 String progress = execution.getVariable("progress")
280 String status = execution.getVariable("status")
281 String statusDescription = execution.getVariable("statusDescription")
284 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
285 xmlns:ns="http://org.openecomp.mso/requestsdb">
288 <ns:updateResourceOperationStatus>
289 <operType>${operType}</operType>
290 <operationId>${operationId}</operationId>
291 <progress>${progress}</progress>
292 <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID>
293 <serviceId>${ServiceInstanceId}</serviceId>
294 <status>${status}</status>
295 <statusDescription>${statusDescription}</statusDescription>
296 </ns:updateResourceOperationStatus>
298 </soapenv:Envelope>"""
300 setProgressUpdateVariables(execution, body)
301 msoLogger.info(" ***** Exit prepareUpdateProgress *****")
304 public void allocateCrossONAPResource(DelegateExecution execution) {
305 msoLogger.info(" ***** Started allocateCrossONAPResource *****")
307 //get TP links from AAI for SOTN handoverMode only
308 String handoverMode = execution.getVariable(Prefix + "HandoverMode")
309 if("SOTN".equalsIgnoreCase(handoverMode)) {
310 // Put TP Link info into serviceParameters
311 JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
312 if(inputParameters.has("remote-access-provider-id")) {
313 Map<String, Object> crossTPs = new HashMap<String, Object>();
314 crossTPs.put("local-access-provider-id", inputParameters.get("remote-access-provider-id"));
315 crossTPs.put("local-access-client-id", inputParameters.get("remote-access-client-id"));
316 crossTPs.put("local-access-topology-id", inputParameters.get("remote-access-topology-id"));
317 crossTPs.put("local-access-node-id", inputParameters.get("remote-access-node-id"));
318 crossTPs.put("local-access-ltp-id", inputParameters.get("remote-access-ltp-id"));
319 crossTPs.put("remote-access-provider-id", inputParameters.get("local-access-provider-id"));
320 crossTPs.put("remote-access-client-id", inputParameters.get("local-access-client-id"));
321 crossTPs.put("remote-access-topology-id", inputParameters.get("local-access-topology-id"));
322 crossTPs.put("remote-access-node-id", inputParameters.get("local-access-node-id"));
323 crossTPs.put("remote-access-ltp-id", inputParameters.get("local-access-ltp-id"));
325 inputParameters.put("local-access-provider-id", crossTPs.get("local-access-provider-id"));
326 inputParameters.put("local-access-client-id", crossTPs.get("local-access-client-id"));
327 inputParameters.put("local-access-topology-id", crossTPs.get("local-access-topology-id"));
328 inputParameters.put("local-access-node-id", crossTPs.get("local-access-node-id"));
329 inputParameters.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id"));
330 inputParameters.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id"));
331 inputParameters.put("remote-access-client-id", crossTPs.get("remote-access-client-id"));
332 inputParameters.put("remote-access-topology-id", crossTPs.get("remote-access-topology-id"));
333 inputParameters.put("remote-access-node-id", crossTPs.get("remote-access-node-id"));
334 inputParameters.put("remote-access-ltp-id", crossTPs.get("remote-access-ltp-id"));
336 execution.setVariable(Prefix + "ServiceParameters", inputParameters)
339 msoLogger.error("No allocated CrossONAPResource found in ServiceParameters")
343 msoLogger.info("Exit " + allocateCrossONAPResource)
346 public void prepare3rdONAPRequest(DelegateExecution execution) {
347 msoLogger.info(" ***** Started prepare3rdONAPRequest *****")
349 String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
350 String extAPIPath = sppartnerUrl + '/serviceOrder'
351 execution.setVariable("ExternalAPIURL", extAPIPath)
353 // ExternalAPI message format
354 String externalId = execution.getVariable("resourceName")
355 String category = "E2E Service"
356 String description = "Service Order from SPPartner"
357 String requestedStartDate = utils.generateCurrentTimeInUtc()
358 String requestedCompletionDate = utils.generateCurrentTimeInUtc()
359 String priority = "1" // 0-4 0:highest
360 String subscriberId = execution.getVariable("globalSubscriberId")
361 String customerRole = "ONAPcustomer"
362 String subscriberName = subscriberId
363 String referredType = "Consumer"
364 String orderItemId = "1"
365 String action = "add" //for create
366 String serviceState = "active"
367 String serviceName = execution.getVariable("serviceInstanceName")
368 String serviceUuId = execution.getVariable(Prefix + "SppartnerUUID")
370 Map<String, String> valueMap = new HashMap<>()
371 valueMap.put("externalId", '"' + externalId + '"')
372 valueMap.put("category", '"' + category + '"')
373 valueMap.put("description", '"' + description + '"')
374 valueMap.put("requestedStartDate", '"' + requestedStartDate + '"')
375 valueMap.put("requestedCompletionDate", '"' + requestedCompletionDate + '"')
376 valueMap.put("priority", '"'+ priority + '"')
377 valueMap.put("subscriberId", '"' + subscriberId + '"')
378 valueMap.put("customerRole", '"' + customerRole + '"')
379 valueMap.put("subscriberName", '"' + subscriberName + '"')
380 valueMap.put("referredType", '"' + referredType + '"')
381 valueMap.put("orderItemId", '"' + orderItemId + '"')
382 valueMap.put("action", '"' + action + '"')
383 valueMap.put("serviceState", '"' + serviceState + '"')
384 valueMap.put("serviceId", "null") //null for add
385 valueMap.put("serviceName", '"' + serviceName + '"')
386 valueMap.put("serviceUuId", '"' + serviceUuId + '"')
388 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
390 // insert CallSource='ExternalAPI' to uuiRequest
391 Map<String, String> requestInputsMap = new HashMap<>()
392 requestInputsMap.put("inputName", '"CallSource"')
393 requestInputsMap.put("inputValue", '"ExternalAPI"')
394 String _requestInputs_ = externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
396 requestInputsMap.clear()
397 String serviceInstanceId = execution.getVariable(Prefix + "ServiceInstanceId")
398 requestInputsMap.put("inputName", '"SppartnerServiceId"')
399 requestInputsMap.put("inputValue", '"' + serviceInstanceId + '"')
400 _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
402 requestInputsMap.clear()
403 String serviceType = execution.getVariable("serviceType")
404 requestInputsMap.put("inputName", '"serviceType"')
405 requestInputsMap.put("inputValue", '"' + serviceType + '"')
406 _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
408 // Transfer all uuiRequest incomeParameters to ExternalAPI format
409 JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
410 for(String key : inputParameters.keySet()) {
411 String inputName = key
412 String inputValue = inputParameters.opt(key)
413 requestInputsMap.clear()
414 requestInputsMap.put("inputName", '"' + inputName+ '"')
415 requestInputsMap.put("inputValue", '"' + inputValue + '"')
416 _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
418 valueMap.put("_requestInputs_", _requestInputs_)
420 String payload = externalAPIUtil.setTemplate(ExternalAPIUtil.PostServiceOrderRequestsTemplate, valueMap)
421 execution.setVariable(Prefix + "Payload", payload)
422 msoLogger.info("Exit " + prepare3rdONAPRequest)
425 public void doCreateE2ESIin3rdONAP(DelegateExecution execution) {
426 msoLogger.info(" ***** Started doCreateE2ESIin3rdONAP *****")
428 String extAPIPath = execution.getVariable("ExternalAPIURL")
429 String payload = execution.getVariable(Prefix + "Payload")
430 msoLogger.debug("doCreateE2ESIin3rdONAP externalAPIURL is: " + extAPIPath)
431 msoLogger.debug("doCreateE2ESIin3rdONAP payload is: " + payload)
433 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
435 Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
437 int responseCode = response.getStatus()
438 execution.setVariable(Prefix + "PostServiceOrderResponseCode", responseCode)
439 msoLogger.debug("Post ServiceOrder response code is: " + responseCode)
441 String extApiResponse = response.readEntity(String.class)
442 JSONObject responseObj = new JSONObject(extApiResponse)
443 execution.setVariable(Prefix + "PostServiceOrderResponse", extApiResponse)
445 msoLogger.debug("doCreateE2ESIin3rdONAP response body is: " + extApiResponse)
448 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
449 //200 OK 201 CREATED 202 ACCEPTED
451 msoLogger.debug("Post ServiceOrder Received a Good Response")
452 String serviceOrderId = responseObj.get("id")
453 execution.setVariable(Prefix + "SuccessIndicator", true)
454 execution.setVariable("ServiceOrderId", serviceOrderId)
455 msoLogger.info("Post ServiceOrderid is: " + serviceOrderId)
458 msoLogger.error("Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
459 // exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Post ServiceOrder Received a bad response from 3rdONAP External API")
462 msoLogger.info("Exit " + doCreateE2ESIin3rdONAP)
466 public void getE2ESIProgressin3rdONAP(DelegateExecution execution) {
467 msoLogger.info(" ***** Started getE2ESIProgressin3rdONAP *****")
469 String extAPIPath = execution.getVariable("ExternalAPIURL")
470 extAPIPath += "/" + execution.getVariable("ServiceOrderId")
471 utils.log("DEBUG", "getE2ESIProgressin3rdONAP create externalAPIURL is: " + extAPIPath, isDebugEnabled)
473 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
475 Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
477 int responseCode = response.getStatus()
478 execution.setVariable(Prefix + "GetServiceOrderResponseCode", responseCode)
479 msoLogger.debug("Get ServiceOrder response code is: " + responseCode)
481 String extApiResponse = response.readEntity(String.class)
482 JSONObject responseObj = new JSONObject(extApiResponse)
483 execution.setVariable(Prefix + "GetServiceOrderResponse", extApiResponse)
485 msoLogger.debug("getE2ESIProgressin3rdONAP create response body is: " + extApiResponse)
487 //Process Response //200 OK 201 CREATED 202 ACCEPTED
488 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
490 msoLogger.debug("Get Create ServiceOrder Received a Good Response")
492 String orderState = responseObj.get("state")
493 if("REJECTED".equalsIgnoreCase(orderState)) {
494 execution.setVariable("progress", 100)
495 execution.setVariable("status", "error")
496 execution.setVariable("statusDescription", "Create Service Order Status is REJECTED")
500 JSONArray items = responseObj.getJSONArray("orderItem")
501 JSONObject item = items[0]
502 JSONObject service = item.get("service")
503 String sppartnerServiceId = service.get("id")
504 if(sppartnerServiceId == null || sppartnerServiceId.equals("null")) {
505 execution.setVariable("progress", 100)
506 execution.setVariable("status", "error")
507 execution.setVariable("statusDescription", "Create Service Order Status get null sppartnerServiceId")
508 msoLogger.error("null sppartnerServiceId while getting progress from externalAPI")
512 execution.setVariable(Prefix + "SppartnerServiceId", sppartnerServiceId)
514 String serviceOrderState = item.get("state")
515 execution.setVariable(Prefix + "SuccessIndicator", true)
516 execution.setVariable("ServiceOrderState", serviceOrderState)
518 // Get serviceOrder State and process progress
519 if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) {
520 execution.setVariable("progress", 15)
521 execution.setVariable("status", "processing")
522 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
524 else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
525 execution.setVariable("progress", 40)
526 execution.setVariable("status", "processing")
527 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
529 else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
530 execution.setVariable("progress", 100)
531 execution.setVariable("status", "finished")
532 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
534 else if("FAILED".equalsIgnoreCase(serviceOrderState)) {
535 execution.setVariable("progress", 100)
536 execution.setVariable("status", "error")
537 execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
540 execution.setVariable("progress", 100)
541 execution.setVariable("status", "error")
542 execution.setVariable("statusDescription", "Create Service Order Status is unknown")
546 msoLogger.debug("Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
547 execution.setVariable("progress", 100)
548 execution.setVariable("status", "error")
549 execution.setVariable("statusDescription", "Get Create ServiceOrder Received a bad response")
550 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get Create ServiceOrder Received a bad response from 3rdONAP External API")
553 msoLogger.info("Exit " + getE2ESIProgressin3rdONAP)
559 public void timeDelay(DelegateExecution execution) {
562 } catch(InterruptedException e) {
563 msoLogger.error("Time Delay exception" + e)
567 public void saveSPPartnerInAAI(DelegateExecution execution) {
568 msoLogger.info(" ***** Started saveSPPartnerInAAI *****")
570 String sppartnerId = execution.getVariable(Prefix + "SppartnerServiceId")
571 String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
572 String callSource = execution.getVariable(Prefix + "CallSource")
573 String serviceInstanceId = execution.getVariable(Prefix + "ServiceInstanceId")
574 String globalSubscriberId = execution.getVariable("globalSubscriberId")
575 String serviceType = execution.getVariable("serviceType")
576 String resourceModelInvariantUuid = execution.getVariable(Prefix + "ResourceModelInvariantUuid")
577 String resourceModelUuid = execution.getVariable(Prefix + "ResourceModelUuid")
578 String resourceModelCustomizationUuid = execution.getVariable(Prefix + "ResourceModelCustomizationUuid")
580 SpPartner partner = new SpPartner()
581 partner.setSpPartnerId(sppartnerId)
582 partner.setUrl(sppartnerUrl)
583 partner.setCallsource(callSource)
584 partner.setModelInvariantId(resourceModelInvariantUuid)
585 partner.setModelVersionId(resourceModelUuid)
586 partner.setModelCustomizationId(resourceModelCustomizationUuid)
588 AAIResourcesClient client = new AAIResourcesClient()
589 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId)
590 client.create(uri, partner)
592 AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
593 client.connect(uri, siUri)
595 msoLogger.info("Exit " + saveSPPartnerInAAI)
598 private void setProgressUpdateVariables(DelegateExecution execution, String body) {
599 def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
600 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
601 execution.setVariable("CVFMI_updateResOperStatusRequest", body)
604 public void postProcess(DelegateExecution execution){
605 msoLogger.info(" ***** Started postProcess *****")
606 String responseCode = execution.getVariable(Prefix + "PutSppartnerResponseCode")
607 String responseObj = execution.getVariable(Prefix + "PutSppartnerResponse")
609 msoLogger.info("response from AAI for put sppartner, response code :" + responseCode + " response object :" + responseObj)
610 msoLogger.info(" ***** Exit postProcess *****")
613 public void sendSyncResponse (DelegateExecution execution) {
614 msoLogger.debug(" *** sendSyncResponse *** ")
617 String operationStatus = "finished"
618 // RESTResponse for main flow
619 String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
620 msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
621 sendWorkflowResponse(execution, 202, resourceOperationResp)
622 execution.setVariable("sentSyncResponse", true)
624 } catch (Exception ex) {
625 String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
627 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
629 msoLogger.debug(" ***** Exit sendSyncResopnse *****")