Add generic post function
Add generic post function and correct the api define
Change-Id: I11c2a10f4aad00f389b68cf7b9c42dab4441027c
Issue-ID:SO-57
Signed-off-by: c00149107 <chenchuanyu@huawei.com>
diff --git a/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml
index 5bf8864..160dfb8 100644
--- a/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml
+++ b/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml
@@ -38,7 +38,7 @@
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
- <url-pattern>/rest/*</url-pattern>
+ <url-pattern>/vfcadapter/*</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java
index f4c2953..684933f 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java
@@ -49,7 +49,7 @@
* @author
* @version ONAP Amsterdam Release 2017-08-28
*/
-@Path("/v1/vfcdrivers")
+@Path("/vfcadapter/v1")
public class VfcAdapterRest {
private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
index 4a7f474..43a2731 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
@@ -25,7 +25,6 @@
import groovy.json.*
import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.VidUtils
import org.openecomp.mso.bpmn.core.WorkflowException
import org.openecomp.mso.bpmn.core.json.JsonUtils
import org.openecomp.mso.rest.APIResponse
@@ -36,7 +35,10 @@
import org.camunda.bpm.engine.runtime.Execution
import org.apache.commons.lang3.*
import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils
+import org.springframework.web.util.UriUtils
+import org.openecomp.mso.rest.RESTClient
+import org.openecomp.mso.rest.RESTConfig
+import org.openecomp.mso.rest.APIResponse;
/**
* This groovy class supports the <class>CreateGenericE2EServiceInstance.bpmn</class> process.
@@ -44,18 +46,21 @@
*/
public class CreateGenericE2EServiceInstance extends AbstractServiceTaskProcessor {
+ String createUrl = "/vfc/vfcadapters/v1/ns"
+
+ String instantiateUrl = "/vfcvfcadatpers/v1/ns/{nsInstanceId}/instantiate"
+
+ String queryJobUrl = "/vfc/vfcadatpers/v1/jobs/{jobId}"
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
- VidUtils vidUtils = new VidUtils()
-
/**
* Pre Process the BPMN Flow Request
* Inclouds:
- * Deal with the parameters
- * generate the service instance id
- * generate the operation id
+ * generate the nsOperationKey
+ * generate the nsParameters
*/
public void preProcessRequest (Execution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
@@ -101,8 +106,8 @@
utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
}
-
public void createNetworkService(Execution execution) {
+
}
public void instantiateNetworkService(Execution execution) {
@@ -116,4 +121,26 @@
public void finishNSCreate(Execution execution) {
}
+
+ /**
+ * post request
+ * url: the url of the request
+ * requestBody: the body of the request
+ */
+ private APIResponse postRequest(String url, String requestBody){
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ taskProcessor.logDebug( " ======== Started Execute VFC adapter Post Process ======== ", isDebugEnabled)
+ taskProcessor.logDebug( "url:"+url +"\nrequestBody:"+ requestBody, isDebugEnabled)
+ APIResponse apiResponse = null
+ try{
+ RESTConfig config = new RESTConfig(url);
+ RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/json");
+ apiResponse = client.httpPost(requestBody)
+ taskProcessor.logDebug( "======== Completed Execute VF-C adapter Post Process ======== ", isDebugEnabled)
+ }catch(Exception e){
+ taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled)
+ throw new BpmnError("MSOWorkflowException")
+ }
+ return apiResponse
+ }
}