2  * ============LICENSE_START=======================================================
\r 
   4  * ================================================================================
\r 
   5  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
\r 
   6  * ================================================================================
\r 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
\r 
   8  * you may not use this file except in compliance with the License.
\r 
   9  * You may obtain a copy of the License at
\r 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
\r 
  13  * Unless required by applicable law or agreed to in writing, software
\r 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
\r 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r 
  16  * See the License for the specific language governing permissions and
\r 
  17  * limitations under the License.
\r 
  18  * ============LICENSE_END=========================================================
\r 
  21 package org.openecomp.mso.bpmn.infrastructure.scripts;
\r 
  23 import static org.apache.commons.lang3.StringUtils.*;
\r 
  24 import groovy.xml.XmlUtil
\r 
  25 import groovy.json.*
\r 
  26 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor 
\r 
  27 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil 
\r 
  28 import org.openecomp.mso.bpmn.common.scripts.VidUtils 
\r 
  29 import org.openecomp.mso.bpmn.core.WorkflowException 
\r 
  30 import org.openecomp.mso.bpmn.core.json.JsonUtils 
\r 
  31 import org.openecomp.mso.rest.APIResponse
\r 
  33 import java.util.UUID;
\r 
  35 import org.camunda.bpm.engine.delegate.BpmnError 
\r 
  36 import org.camunda.bpm.engine.runtime.Execution
\r 
  37 import org.apache.commons.lang3.*
\r 
  38 import org.apache.commons.codec.binary.Base64;
\r 
  39 import org.springframework.web.util.UriUtils
\r 
  42  * This groovy class supports the <class>CreateGenericE2EServiceInstance.bpmn</class> process.
\r 
  43  * flow for E2E ServiceInstance Create
\r 
  45 public class CreateGenericE2EServiceInstance extends AbstractServiceTaskProcessor {
\r 
  47     ExceptionUtil exceptionUtil = new ExceptionUtil()
\r 
  49     JsonUtils jsonUtil = new JsonUtils()
\r 
  51     VidUtils vidUtils = new VidUtils()
\r 
  54      * Pre Process the BPMN Flow Request
\r 
  56      * Deal with the parameters
\r 
  57      * generate the service instance id
\r 
  58      * generate the operation id
\r 
  60     public void preProcessRequest (Execution execution) {
\r 
  61            def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r 
  63        utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled)
\r 
  65            String globalSubscriberId = execution.getVariable("globalSubscriberId")
\r 
  66            utils.log("DEBUG", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)
\r 
  67            String serviceType = execution.getVariable("serviceType")
\r 
  68            utils.log("DEBUG", "serviceType:" + serviceType, isDebugEnabled)
\r 
  69            String serviceId = execution.getVariable("serviceId")
\r 
  70            utils.log("DEBUG", "serviceId:" + serviceId, isDebugEnabled)
\r 
  71            String operationId = execution.getVariable("operationId")
\r 
  72            utils.log("DEBUG", "serviceType:" + serviceType, isDebugEnabled)
\r 
  73            String nodeTemplateUUID = execution.getVariable("nodeTemplateUUID")
\r 
  74            utils.log("DEBUG", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)
\r 
  76             * segmentInformation needed as a object of segment
\r 
  79             *     "nodeTemplateName":"",
\r 
  82             *       //this is the nsParameters sent to VF-C
\r 
  86            String siRequest = execution.getVariable("segmentInformation")
\r 
  87            utils.log("DEBUG", "Input Request:" + siRequest, isDebugEnabled)
\r 
  88            String nsOperationKey = "{\"globalSubscriberId\":" + globalSubscriberId + ",\"serviceType:\""
\r 
  89                  + serviceType + ",\"serviceId\":" + serviceId + ",\"operationId\":" + operationId
\r 
  90                  +",\"nodeTemplateUUID\":" + nodeTemplateUUID + "}";
\r 
  91            execution.setVariable("nsOperationKey", nsOperationKey);
\r 
  92            execution.setVariable("nsParameters", jsonUtil.getJsonValue(siRequest, "nsParameters"))
\r 
  94        } catch (BpmnError e) {
\r 
  96        } catch (Exception ex){
\r 
  97            msg = "Exception in preProcessRequest " + ex.getMessage()
\r 
  98            utils.log("DEBUG", msg, isDebugEnabled)
\r 
  99            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r 
 101        utils.log("DEBUG"," ***** Exit preProcessRequest *****",  isDebugEnabled)
\r 
 105     public void createNetworkService(Execution execution) {
\r 
 108     public void instantiateNetworkService(Execution execution) {
\r 
 111     public void queryNSProgress(Execution execution) {
\r 
 114     public void timeDelay(Execution execution) {
\r 
 117     public void finishNSCreate(Execution execution) {
\r