--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * OPENECOMP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.bpmn.infrastructure.scripts;\r
+\r
+import static org.apache.commons.lang3.StringUtils.*;\r
+import groovy.xml.XmlUtil\r
+import groovy.json.*\r
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor \r
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil \r
+import org.openecomp.mso.bpmn.common.scripts.VidUtils \r
+import org.openecomp.mso.bpmn.core.WorkflowException \r
+import org.openecomp.mso.bpmn.core.json.JsonUtils \r
+import org.openecomp.mso.rest.APIResponse\r
+\r
+import java.util.UUID;\r
+\r
+import org.camunda.bpm.engine.delegate.BpmnError \r
+import org.camunda.bpm.engine.runtime.Execution\r
+import org.apache.commons.lang3.*\r
+import org.apache.commons.codec.binary.Base64;\r
+import org.springframework.web.util.UriUtils\r
+\r
+/**\r
+ * This groovy class supports the <class>CreateGenericE2EServiceInstance.bpmn</class> process.\r
+ * flow for E2E ServiceInstance Create\r
+ */\r
+public class CreateGenericE2EServiceInstance extends AbstractServiceTaskProcessor {\r
+\r
+ ExceptionUtil exceptionUtil = new ExceptionUtil()\r
+\r
+ JsonUtils jsonUtil = new JsonUtils()\r
+\r
+ VidUtils vidUtils = new VidUtils()\r
+\r
+ public void preProcessRequest (Execution execution) {\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+ String msg = ""\r
+ utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled)\r
+ try {\r
+\r
+ String siRequest = execution.getVariable("bpmnRequest")\r
+ utils.logAudit(siRequest)\r
+\r
+ String requestId = execution.getVariable("mso-request-id")\r
+ execution.setVariable("msoRequestId", requestId)\r
+ utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled)\r
+\r
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
+ if (isBlank(serviceInstanceId)) {\r
+ serviceInstanceId = UUID.randomUUID().toString()\r
+ }\r
+ utils.log("DEBUG", "Generated new Service Instance:" + serviceInstanceId, isDebugEnabled)\r
+ serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8")\r
+ execution.setVariable("serviceInstanceId", serviceInstanceId)\r
+\r
+ //subscriberInfo, TBD , there is no globalSubscriberId in R1 for E2E Service.\r
+ //requestInfo TBD , there is no requestDetails for R1 E2E service\r
+\r
+ //set service Instance Name\r
+ execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(siRequest, "service.name"))\r
+ execution.setVariable("serviceDescription", jsonUtil.getJsonValue(siRequest, "service.description"))\r
+ execution.setVariable("templateId", jsonUtil.getJsonValue(siRequest, "service.templateId"))\r
+ \r
+ //serviceParamters\r
+ String serviceParamters = jsonUtil.getJsonValue(siRequest, "service.parameters")\r
+ if (isBlank(serviceParamters)) {\r
+ msg = "Input service paramters is null"\r
+ utils.log("DEBUG", msg, isDebugEnabled)\r
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)\r
+ } else\r
+ {\r
+ execution.setVariable("serviceParamters", serviceParamters)\r
+ }\r
+\r
+ utils.log("DEBUG", "service parameters:" + serviceParamters, isDebugEnabled)\r
+ } catch (BpmnError e) {\r
+ throw e;\r
+ } catch (Exception ex){\r
+ msg = "Exception in preProcessRequest " + ex.getMessage()\r
+ utils.log("DEBUG", msg, isDebugEnabled)\r
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)\r
+ }\r
+ utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)\r
+ }\r
+\r
+ public void sendSyncResponse(Execution execution) {\r
+ }\r
+\r
+ public void preCreateRequest(Execution execution) {\r
+ }\r
+\r
+ public void postConfigRequest(Execution execution) {\r
+ }\r
+\r
+ public void preVFCRequest(Execution execution) {\r
+ }\r
+\r
+ public void preAdaptorDataRequest(Execution execution) {\r
+ }\r
+\r
+ public void preSDNCRequest(Execution execution) {\r
+ }\r
+}\r