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
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
+import org.springframework.web.util.UriUtils \r
+import org.openecomp.mso.rest.RESTClient \r
+import org.openecomp.mso.rest.RESTConfig\r
+import org.openecomp.mso.rest.APIResponse;\r
\r
/**\r
* This groovy class supports the <class>CreateGenericE2EServiceInstance.bpmn</class> process.\r
*/\r
public class CreateGenericE2EServiceInstance extends AbstractServiceTaskProcessor {\r
\r
+ String createUrl = "/vfc/vfcadapters/v1/ns"\r
+ \r
+ String instantiateUrl = "/vfcvfcadatpers/v1/ns/{nsInstanceId}/instantiate"\r
+ \r
+ String queryJobUrl = "/vfc/vfcadatpers/v1/jobs/{jobId}"\r
+ \r
ExceptionUtil exceptionUtil = new ExceptionUtil()\r
\r
JsonUtils jsonUtil = new JsonUtils()\r
\r
- VidUtils vidUtils = new VidUtils()\r
-\r
/**\r
* Pre Process the BPMN Flow Request\r
* Inclouds:\r
- * Deal with the parameters\r
- * generate the service instance id\r
- * generate the operation id\r
+ * generate the nsOperationKey\r
+ * generate the nsParameters\r
*/\r
public void preProcessRequest (Execution execution) {\r
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)\r
}\r
\r
-\r
public void createNetworkService(Execution execution) {\r
+\r
}\r
\r
public void instantiateNetworkService(Execution execution) {\r
\r
public void finishNSCreate(Execution execution) {\r
}\r
+\r
+ /**\r
+ * post request\r
+ * url: the url of the request\r
+ * requestBody: the body of the request\r
+ */\r
+ private APIResponse postRequest(String url, String requestBody){\r
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
+ taskProcessor.logDebug( " ======== Started Execute VFC adapter Post Process ======== ", isDebugEnabled)\r
+ taskProcessor.logDebug( "url:"+url +"\nrequestBody:"+ requestBody, isDebugEnabled)\r
+ APIResponse apiResponse = null\r
+ try{\r
+ RESTConfig config = new RESTConfig(url);\r
+ RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/json");\r
+ apiResponse = client.httpPost(requestBody)\r
+ taskProcessor.logDebug( "======== Completed Execute VF-C adapter Post Process ======== ", isDebugEnabled)\r
+ }catch(Exception e){\r
+ taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled)\r
+ throw new BpmnError("MSOWorkflowException")\r
+ }\r
+ return apiResponse\r
+ }\r
}\r