diff options
Diffstat (limited to 'bpmn')
5 files changed, 831 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 606b97bec2..34cbb00735 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import com.fasterxml.jackson.databind.ObjectMapper import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -529,4 +530,24 @@ class OofUtils { return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString() } + + public String buildSelectNSTRequest(String requestId, Map<String, Object> profileInfo) { + def transactionId = requestId + logger.debug( "transactionId is: " + transactionId) + ObjectMapper objectMapper = new ObjectMapper() + String json = objectMapper.writeValueAsString(profileInfo) + StringBuilder response = new StringBuilder() + response.append( + "{\n" + + " \"requestInfo\": {\n" + + " \"transactionId\": \"${transactionId}\",\n" + + " \"requestId\": \"${requestId}\",\n" + + " \"sourceId\": \"so\",\n" + + " \"timeout\": 600\n" + + " },\n") + response.append(",\n \"serviceInfo\": \n") + response.append(json); + response.append("\n }\n") + return response.toString() + } } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInfo.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInfo.java new file mode 100644 index 0000000000..542fa2d463 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInfo.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.core.domain; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.*; + + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"id", "serviceInput", "serviceProperties", "serviceArtifact"}) +@JsonRootName("serviceInfo") +public class ServiceInfo extends JsonWrapper implements Serializable { + private static final long serialVersionUID = 1L; + @JsonProperty("id") + private Integer id; + @JsonProperty("serviceInput") + private String serviceInput; + @JsonProperty("serviceProperties") + private String serviceProperties; + @JsonProperty("serviceArtifact") + private List<ServiceArtifact> serviceArtifact = null; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + + @JsonProperty("id") + public Integer getId() { + return id; + } + + @JsonProperty("id") + public void setId(Integer id) { + this.id = id; + } + + @JsonProperty("serviceInput") + public String getServiceInput() { + return serviceInput; + } + + @JsonProperty("serviceInput") + public void setServiceInput(String serviceInput) { + this.serviceInput = serviceInput; + } + + @JsonProperty("serviceProperties") + public String getServiceProperties() { + return serviceProperties; + } + + @JsonProperty("serviceProperties") + public void setServiceProperties(String serviceProperties) { + this.serviceProperties = serviceProperties; + } + + @JsonProperty("serviceArtifact") + public List<ServiceArtifact> getServiceArtifact() { + return serviceArtifact; + } + + @JsonProperty("serviceArtifact") + public void setServiceArtifact(List<ServiceArtifact> serviceArtifact) { + this.serviceArtifact = serviceArtifact; + } + + @JsonAnyGetter + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} + + diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceProxy.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceProxy.java new file mode 100644 index 0000000000..6903d34987 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceProxy.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.core.domain; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.*; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"modelInfo", "toscaNodeType", "description", "sourceModelUuid"}) +@JsonRootName("serviceProxy") +public class ServiceProxy extends JsonWrapper implements Serializable { + private static final long serialVersionUID = 1L; + @JsonProperty("modelInfo") + private ModelInfo modelInfo; + @JsonProperty("toscaNodeType") + private String toscaNodeType; + @JsonProperty("description") + private String description; + @JsonProperty("sourceModelUuid") + private String sourceModelUuid; + + @JsonProperty("modelInfo") + public ModelInfo getModelInfo() { + return modelInfo; + } + + @JsonProperty("modelInfo") + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + @JsonProperty("toscaNodeType") + public String getToscaNodeType() { + return toscaNodeType; + } + + @JsonProperty("toscaNodeType") + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + @JsonProperty("sourceModelUuid") + public String getSourceModelUuid() { + return sourceModelUuid; + } + + @JsonProperty("sourceModelUuid") + public void setSourceModelUuid(String sourceModelUuid) { + this.sourceModelUuid = sourceModelUuid; + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy new file mode 100644 index 0000000000..7cc1a559c3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -0,0 +1,520 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.core.Response + +import static org.apache.commons.lang3.StringUtils.* +import org.springframework.web.util.UriUtils +import groovy.json.JsonSlurper +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.SliceTaskParams +import org.onap.so.db.request.beans.OrchestrationTask +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.OofUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.ErrorCode +import org.onap.so.logger.LoggingAnchor +import org.onap.so.logger.MessageEnum +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +public class CreateSliceService extends AbstractServiceTaskProcessor { + String Prefix = "CRESS_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + JsonSlurper jsonSlurper = new JsonSlurper() + ObjectMapper objectMapper = new ObjectMapper() + OofUtils oofUtils = new OofUtils() + private static final Logger logger = LoggerFactory.getLogger(CreateSliceService.class) + + + public void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + execution.setVariable("prefix", Prefix) + String msg = "" + + try { + String ssRequest = execution.getVariable("bpmnRequest") + logger.debug(ssRequest) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + ssRequest + " reqId:" + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)) { + serviceInstanceId = UUID.randomUUID().toString() + } + + String operationId = UUID.randomUUID().toString() + execution.setVariable("operationId", operationId) + + logger.debug("Generated new Service Instance:" + serviceInstanceId) + serviceInstanceId = UriUtils.encode(serviceInstanceId, "UTF-8") + execution.setVariable("serviceInstanceId", serviceInstanceId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(ssRequest, "requestDetails.subscriberInfo.globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //requestInfo + execution.setVariable("source", jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.source")) + execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.instanceName")) + execution.setVariable("disableRollback", jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.suppressRollback")) + String productFamilyId = jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.productFamilyId") + if (isBlank(productFamilyId)) { + msg = "Input productFamilyId is null" + logger.debug(msg) + //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("productFamilyId", productFamilyId) + } + + //modelInfo + String serviceModelInfo = jsonUtil.getJsonValue(ssRequest, "requestDetails.modelInfo") + if (isBlank(serviceModelInfo)) { + msg = "Input serviceModelInfo is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("serviceModelInfo", serviceModelInfo) + } + + logger.debug("modelInfo: " + serviceModelInfo) + + //requestParameters + String subscriptionServiceType = jsonUtil.getJsonValue(ssRequest, "requestDetails.requestParameters.subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + logger.debug("subscriptionServiceType: " + subscriptionServiceType) + + /* + * Extracting User Parameters from incoming Request and converting into a Map + */ + Map reqMap = jsonSlurper.parseText(ssRequest) + + //InputParams + def userParamsList = reqMap.requestDetails?.requestParameters?.userParams + + Map<String, String> inputMap = [:] + if (userParamsList) { + for (def i = 0; i < userParamsList.size(); i++) { + def userParams1 = userParamsList.get(i) + userParams1.each { param -> inputMap.put(param.key, param.value) } + } + } + + logger.debug("User Input Parameters map: " + inputMap.toString()) + String uuiRequest = inputMap.get("UUIRequest") + Map uuiReqMap = jsonSlurper.parseText(uuiRequest) + Map<String, Object> serviceObject = (Map<String, Object>) uuiReqMap.get("service") + Map<String, Object> parameterObject = (Map<String, Object>) serviceObject.get("parameters") + Map<String, Object> requestInputs = (Map<String, Object>) parameterObject.get("requestInputs") + + execution.setVariable("serviceInputParams", inputMap) + execution.setVariable("uuiRequest", uuiRequest) + execution.setVariable("serviceProfile", requestInputs) + + //TODO + //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams")) + //execution.setVariable("failExists", true) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("Finish preProcessRequest") + } + + public void getNSTSelection(DelegateExecution execution) { + logger.debug("Start getNSTSelection") + String requestId = execution.getVariable("msoRequestId") + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") + String oofUrl = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + + def authHeader = "" + String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) + String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + + String basicAuthValue = utils.encrypt(basicAuth, msokey) + if (basicAuthValue != null) { + logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) + try { + authHeader = utils.getBasicAuth(basicAuthValue, msokey) + execution.setVariable("BasicAuthHeaderValue", authHeader) + } catch (Exception ex) { + logger.debug( "Unable to encode username and password string: " + ex) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + + "encode username and password string") + } + } else { + logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + + "value null") + } + + URL requestUrl = new URL(oofUrl + "/api/oof/v1/selection/nst") + String oofRequest = oofUtils.buildSelectNSTRequest(requestId, serviceProfile) + HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.OOF) + httpClient.addAdditionalHeader("Authorization", authHeader) + Response httpResponse = httpClient.post(oofRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + + if(responseCode != 200){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + } + + Map<String, Object> nstSolution + try { + Map<String, Object> resMap = httpResponse.readEntity(Map.class) + List<Map<String, Object>> nstSolutions = (List<Map<String, Object>>) resMap.get("solutions") + nstSolution = nstSolutions.get(0) + execution.setVariable("nstSolution", nstSolution) + } catch (Exception ex) { + logger.debug( "Failed to get NST solution suggested by OOF.") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get NST solution suggested by OOF.") + } + + logger.debug("Finish getNSTSelection") + + } + + public void prepareDecomposeService(DelegateExecution execution) { + logger.debug("Start prepareDecomposeService") + String uuiRequest = execution.getVariable("uuiRequest") + String ssModelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid") + String ssModelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid") + String ssServiceModelInfo = """{ + "modelInvariantUuid":"${ssModelInvariantUuid}", + "modelUuid":"${ssModelUuid}", + "modelVersion":"" + }""" + execution.setVariable("ssServiceModelInfo", ssServiceModelInfo) + + logger.debug("Finish prepareDecomposeService") + } + + public void processDecomposition(DelegateExecution execution) { + logger.debug("Start processDecomposition") + String uuiRequest = execution.getVariable("uuiRequest") + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") + Map<String, Object> nstSolution = execution.getVariable("nstSolution") + + Map uuiReqMap = jsonSlurper.parseText(uuiRequest) + Map<String, Object> serviceObject = (Map<String, Object>) uuiReqMap.get("service") + String subscriptionServiceType = serviceObject.get("serviceType") + + String serviceType = (String) serviceProfile.get("sST") + String resourceSharingLevel = (String) serviceProfile.get("resourceSharingLevel") + String nstModelUuid = (String) nstSolution.get("UUID") + String nstModelInvariantUuid = (String) nstSolution.get("invariantUUID") + + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + execution.setVariable("serviceType", serviceType) + execution.setVariable("resourceSharingLevel", resourceSharingLevel) + execution.setVariable("nstModelUuid", nstModelUuid) + execution.setVariable("nstModelInvariantUuid", nstModelInvariantUuid) + + logger.debug("Finish processDecomposition") + } + + public void prepareCreateOrchestrationTask(DelegateExecution execution) { + logger.debug("Start createOrchestrationTask") + String taskId = execution.getBusinessKey() + execution.setVariable("orchestrationTaskId", taskId) + logger.debug("BusinessKey: " + taskId) + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String taskName = "SliceServiceTask" + String taskStatus = "Planning" + String isManual = "false" + String requestMethod = "POST" + execution.setVariable("CSSOT_taskId", taskId) + execution.setVariable("CSSOT_name", taskName) + execution.setVariable("CSSOT_status", taskStatus) + execution.setVariable("CSSOT_isManual", isManual) + execution.setVariable("CSSOT_requestMethod", requestMethod) + + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") + Map<String, Object> sliceProfileTn = execution.getVariable("sliceProfileTn") + Map<String, Object> sliceProfileCn = execution.getVariable("sliceProfileCn") + Map<String, Object> sliceProfileAn = execution.getVariable("sliceProfileAn") + + SliceTaskParams sliceTaskParams = new SliceTaskParams() + sliceTaskParams.setServiceId(serviceInstanceId) + sliceTaskParams.setServiceName(serviceInstanceName) + sliceTaskParams.setServiceProfile(serviceProfile) + sliceTaskParams.setSliceProfileTn(sliceProfileTn) + sliceTaskParams.setSliceProfileCn(sliceProfileCn) + sliceTaskParams.setSliceProfileAn(sliceProfileAn) + execution.setVariable("sliceTaskParams", sliceTaskParams) + + String paramJson = sliceTaskParams.convertToJson() + execution.setVariable("CSSOT_paramJson", paramJson) + logger.debug("CSSOT_paramJson: " + paramJson) + + logger.debug("Finish createOrchestrationTask") + } + + public void prepareUpdateOrchestrationTask(DelegateExecution execution) { + logger.debug("Start prepareUpdateOrchestrationTask") + String requestMethod = "PUT" + String taskStatus = execution.getVariable("taskStatus") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + String paramJson = sliceTaskParams.convertToJson() + execution.setVariable("CSSOT_status", taskStatus) + execution.setVariable("CSSOT_paramJson", paramJson) + execution.setVariable("CSSOT_requestMethod", requestMethod) + logger.debug("Finish prepareUpdateOrchestrationTask") + } + + public void prepareGetUserOptions(DelegateExecution execution) { + logger.debug("Start prepareGetUserOptions") + String requestMethod = "GET" + execution.setVariable("taskAction", "commit") + String taskAction = execution.getVariable("taskAction") + logger.debug("task action is: " + taskAction) + if (!"commit".equals(taskAction) && !"abort".equals(taskAction)) { + String msg = "Unknown task action: " + taskAction + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("CSSOT_requestMethod", requestMethod) + logger.debug("Finish prepareGetUserOptions") + } + + public void processUserOptions(DelegateExecution execution) { + logger.debug("Start processUserOptions") + String response = execution.getVariable("CSSOT_dbResponse") + OrchestrationTask orchestrationTask = objectMapper.readValue(response, OrchestrationTask.class) + String paramJson = orchestrationTask.getParams() + logger.debug("paramJson: " + paramJson) + SliceTaskParams sliceTaskParams = new SliceTaskParams() + sliceTaskParams.convertFromJson(paramJson) + execution.setVariable("sliceTaskParams", sliceTaskParams) + logger.debug("Finish processUserOptions") + } + + public void updateAAIOrchStatus(DelegateExecution execution) { + logger.debug("Start updateAAIOrchStatus") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String orchStatus = execution.getVariable("orchestrationStatus") + + try { + ServiceInstance si = execution.getVariable("serviceInstanceData") + si.setOrchestrationStatus(orchStatus) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + client.update(uri, si) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in CreateSliceService.updateAAIOrchStatus " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug("Finish updateAAIOrchStatus") + } + + public void prepareInitServiceOperationStatus(DelegateExecution execution) { + logger.debug("Start prepareInitServiceOperationStatus") + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = "CREATE" + String userId = execution.getVariable("globalSubscriberId") + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service creation" + logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationType", operationType) + + def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint",execution) + execution.setVariable("CSSOS_dbAdapterEndpoint", dbAdapterEndpoint) + logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint) + def dbAdapterAuth = UrnPropertiesReader.getVariable("mso.requestDb.auth") + Map<String, String> CSSOS_headerMap = [:] + CSSOS_headerMap.put("content-type", "application/soap+xml") + CSSOS_headerMap.put("Authorization", dbAdapterAuth) + execution.setVariable("CSSOS_headerMap", CSSOS_headerMap) + logger.debug("DB Adapter Header is: " + CSSOS_headerMap) + + String payload = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> + <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> + <operationType>${MsoUtils.xmlEscape(operationType)}</operationType> + <userId>${MsoUtils.xmlEscape(userId)}</userId> + <result>${MsoUtils.xmlEscape(result)}</result> + <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent> + <progress>${MsoUtils.xmlEscape(progress)}</progress> + <reason>${MsoUtils.xmlEscape(reason)}</reason> + </ns:initServiceOperationStatus> + </soapenv:Body> + </soapenv:Envelope>""" + + payload = utils.formatXml(payload) + execution.setVariable("CSSOS_updateServiceOperStatusRequest", payload) + logger.debug("Outgoing updateServiceOperStatusRequest: \n" + payload) + }catch(Exception e){ + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) + } + logger.debug("Finish prepareInitServiceOperationStatus") + } + + public void prepareUpdateServiceOperationStatus(DelegateExecution execution) { + logger.debug("Start preUpdateServiceOperationStatus") + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + String userId = execution.getVariable("globalSubscriberId") + String result = execution.getVariable("operationResult") + String progress = execution.getVariable("operationProgress") + String reason = execution.getVariable("operationReason") + String operationContent = "service: " + result + " progress: " + progress + + String payload = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> + <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> + <operationType>${MsoUtils.xmlEscape(operationType)}</operationType> + <userId>${MsoUtils.xmlEscape(userId)}</userId> + <result>${MsoUtils.xmlEscape(result)}</result> + <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent> + <progress>${MsoUtils.xmlEscape(progress)}</progress> + <reason>${MsoUtils.xmlEscape(reason)}</reason> + </ns:initServiceOperationStatus> + </soapenv:Body> + </soapenv:Envelope>""" + + payload = utils.formatXml(payload) + execution.setVariable("CSSOS_updateServiceOperStatusRequest", payload) + logger.debug("Outgoing updateServiceOperStatusRequest: \n" + payload) + + }catch(Exception e){ + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "Exception Occured Processing preUpdateServiceOperationStatus.", "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e.getMessage()) + } + logger.debug("Finish preUpdateServiceOperationStatus") + } + + public void sendSyncResponse(DelegateExecution execution) { + logger.debug("Start sendSyncResponse") + try { + String operationId = execution.getVariable("operationId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + // RESTResponse for API Handler (APIH) Reply Task + String createServiceRestRequest = """{"service":{"serviceId":"${serviceInstanceId}","operationId":"${operationId}"}}""".trim() + logger.debug("sendSyncResponse to APIH:" + "\n" + createServiceRestRequest) + sendWorkflowResponse(execution, 202, createServiceRestRequest) + execution.setVariable("sentSyncResponse", true) + } catch (Exception e) { + String msg = "Exceptuion in sendSyncResponse:" + e.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("Finish sendSyncResponse") + } + + public void prepareCompletionRequest (DelegateExecution execution) { + logger.trace("Start prepareCompletionRequest") + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String source = execution.getVariable("source") + + String msoCompletionRequest = + """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:ns="http://org.onap/so/request/types/v1"> + <request-info xmlns="http://org.onap/so/infra/vnf-request/v1"> + <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> + <action>CREATE</action> + <source>${MsoUtils.xmlEscape(source)}</source> + </request-info> + <status-message>Service Instance was created successfully.</status-message> + <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId> + <mso-bpel-name>CreateGenericALaCarteServiceInstance</mso-bpel-name> + </aetgt:MsoCompletionRequest>""" + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable("completionRequest", xmlMsoCompletionRequest) + logger.debug("Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } catch (Exception ex) { + String msg = " Exception in prepareCompletion:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.trace("Finish prepareCompletionRequest") + } + +} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateCommunicationService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateCommunicationService.bpmn new file mode 100644 index 0000000000..1f0e10b1c1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateCommunicationService.bpmn @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_152rp63" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> + <bpmn:process id="DoCreateCommunicationService" name="DoCreateCommunicationService" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="start"> + <bpmn:outgoing>SequenceFlow_0r43nhn</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_0r43nhn" sourceRef="StartEvent_1" targetRef="Task_1n00ul2" /> + <bpmn:scriptTask id="Task_1n00ul2" name="Pre Process Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0r43nhn</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ojuala</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def csi= new DoCreateCommunicationService() +csi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_13cimkc" name="Create Communication Service Profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0mxvw9q</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_15e8qrt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def csi= new DoCreateCommunicationService() +csi.createCommunicationServiceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_02h3nyo" name="Create Communication Service" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1ojuala</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0mxvw9q</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def csi= new DoCreateCommunicationService() +csi.createCommunicationService(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:endEvent id="EndEvent_0tx74b8" name="end"> + <bpmn:incoming>SequenceFlow_15e8qrt</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0mxvw9q" sourceRef="Task_02h3nyo" targetRef="Task_13cimkc" /> + <bpmn:sequenceFlow id="SequenceFlow_15e8qrt" sourceRef="Task_13cimkc" targetRef="EndEvent_0tx74b8" /> + <bpmn:sequenceFlow id="SequenceFlow_1ojuala" sourceRef="Task_1n00ul2" targetRef="Task_02h3nyo" /> + <bpmn:subProcess id="SubProcess_0hvqoiu" name="Java Exception Handling Sub Process" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_06faevu"> + <bpmn:outgoing>SequenceFlow_1jckdn4</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1idslt4" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1xkvl7n"> + <bpmn:incoming>SequenceFlow_0ixyf17</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_15u2oe2" name="Process Error" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1jckdn4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0ixyf17</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil exceptionUtil = new ExceptionUtil() +exceptionUtil.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0ixyf17" sourceRef="ScriptTask_15u2oe2" targetRef="EndEvent_1xkvl7n" /> + <bpmn:sequenceFlow id="SequenceFlow_1jckdn4" sourceRef="StartEvent_06faevu" targetRef="ScriptTask_15u2oe2" /> + </bpmn:subProcess> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateCommunicationService"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="179" y="99" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="186" y="142" width="23" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0r43nhn_di" bpmnElement="SequenceFlow_0r43nhn"> + <di:waypoint x="215" y="117" /> + <di:waypoint x="290" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1ilqwj5_di" bpmnElement="Task_1n00ul2"> + <dc:Bounds x="290" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0vpnfpe_di" bpmnElement="Task_13cimkc"> + <dc:Bounds x="660" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_03bitgg_di" bpmnElement="Task_02h3nyo"> + <dc:Bounds x="480" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0tx74b8_di" bpmnElement="EndEvent_0tx74b8"> + <dc:Bounds x="912" y="99" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="921" y="142" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0mxvw9q_di" bpmnElement="SequenceFlow_0mxvw9q"> + <di:waypoint x="580" y="117" /> + <di:waypoint x="660" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_15e8qrt_di" bpmnElement="SequenceFlow_15e8qrt"> + <di:waypoint x="760" y="117" /> + <di:waypoint x="912" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ojuala_di" bpmnElement="SequenceFlow_1ojuala"> + <di:waypoint x="390" y="117" /> + <di:waypoint x="480" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="SubProcess_0hvqoiu_di" bpmnElement="SubProcess_0hvqoiu" isExpanded="true"> + <dc:Bounds x="290" y="250" width="417" height="161" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_06faevu_di" bpmnElement="StartEvent_06faevu"> + <dc:Bounds x="327" y="317" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1xkvl7n_di" bpmnElement="EndEvent_1xkvl7n"> + <dc:Bounds x="613" y="317" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_15u2oe2_di" bpmnElement="ScriptTask_15u2oe2"> + <dc:Bounds x="438" y="295" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0ixyf17_di" bpmnElement="SequenceFlow_0ixyf17"> + <di:waypoint x="538" y="335" /> + <di:waypoint x="613" y="335" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1jckdn4_di" bpmnElement="SequenceFlow_1jckdn4"> + <di:waypoint x="363" y="335" /> + <di:waypoint x="438" y="335" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> |