def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
String msg = ""\r
utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled)\r
- try { \r
+ try {\r
+ //deal with nsName and Description\r
+ String nsServiceName = execution.getVariable("nsServiceName")\r
+ String nsServiceDescription = execution.getVariable("nsServiceDescription")\r
+ utils.log("DEBUG", "nsServiceName:" + nsServiceName + " nsServiceDescription:" + nsServiceDescription, isDebugEnabled)\r
+ //deal with operation key\r
String globalSubscriberId = execution.getVariable("globalSubscriberId")\r
utils.log("DEBUG", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)\r
String serviceType = execution.getVariable("serviceType")\r
*/\r
String siRequest = execution.getVariable("segmentInformation")\r
utils.log("DEBUG", "Input Request:" + siRequest, isDebugEnabled)\r
- String nsOperationKey = "{\"globalSubscriberId\":" + globalSubscriberId + ",\"serviceType:\""\r
- + serviceType + ",\"serviceId\":" + serviceId + ",\"operationId\":" + operationId\r
- +",\"nodeTemplateUUID\":" + nodeTemplateUUID + "}";\r
+ String nsOperationKey = "{\"globalSubscriberId\":\"" + globalSubscriberId + "\",\"serviceType:\""\r
+ + serviceType + "\",\"serviceId\":\"" + serviceId + "\",\"operationId\":\"" + operationId\r
+ +"\",\"nodeTemplateUUID\":\"" + nodeTemplateUUID + "\"}";\r
execution.setVariable("nsOperationKey", nsOperationKey);\r
execution.setVariable("nsParameters", jsonUtil.getJsonValue(siRequest, "nsParameters"))\r
+ \r
\r
} catch (BpmnError e) {\r
throw e;\r
utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)\r
}\r
\r
+ /**\r
+ * create NS task\r
+ */\r
public void createNetworkService(Execution execution) {\r
-\r
+ \r
+ String nsOperationKey = excution.getVariable("nsOperationKey");\r
+ String nsParameters = excution.getVariable("nsParameters");\r
+ String nsServiceName = execution.getVariable("nsServiceName")\r
+ String nsServiceDescription = execution.getVariable("nsServiceDescription")\r
+ String reqBody = "{\"nsServiceName\":\"" + nsServiceName + "\",\"nsServiceDescription\":\"" + nsServiceDescription\r
+ +"\",\"nsOperationKey\":" + nsOperationKey + ",\"nsParameters\":" + nsParameters\r
+ APIResponse createRsp = postRequest(createUrl, reqBody)\r
+ String returnCode = apiResponse.getStatusCode()\r
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()\r
+ String nsInstanceId = "";\r
+ if(returnCode== "200"){\r
+ nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId")\r
+ }\r
+ execution.setVariable("nsInstanceId", nsInstanceId)\r
+ \r
}\r
\r
+ /**\r
+ * instantiate NS task\r
+ */\r
public void instantiateNetworkService(Execution execution) {\r
+ String nsOperationKey = excution.getVariable("nsOperationKey");\r
+ String nsParameters = excution.getVariable("nsParameters");\r
+ String nsServiceName = execution.getVariable("nsServiceName")\r
+ String nsServiceDescription = execution.getVariable("nsServiceDescription")\r
+ String reqBody = "{\"nsServiceName\":\"" + nsServiceName + "\",\"nsServiceDescription\":\"" + nsServiceDescription\r
+ +"\",\"nsOperationKey\":" + nsOperationKey + ",\"nsParameters\":" + nsParameters\r
+ String url = instantiateUrl.replaceAll("{nsInstanceId}", execution.getVariable("nsInstanceId")) \r
+ APIResponse createRsp = postRequest(url, reqBody)\r
+ String returnCode = apiResponse.getStatusCode()\r
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()\r
+ String jobId = "";\r
+ if(returnCode== "200"){\r
+ jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")\r
+ }\r
+ execution.setVariable("jobId", nsInstanceId)\r
}\r
\r
+ /**\r
+ * query NS task\r
+ */\r
public void queryNSProgress(Execution execution) {\r
+ String jobId = execution.getVariable("jobId")\r
+ String nsOperationKey = excution.getVariable("nsOperationKey");\r
+ String url = queryJobUrl.replaceAll("{jobId}", execution.getVariable("jobId")) \r
+ APIResponse createRsp = postRequest(url, nsOperationKey)\r
+ String returnCode = apiResponse.getStatusCode()\r
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()\r
+ String operationStatus = "error"\r
+ if(returnCode== "200"){\r
+ operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status")\r
+ }\r
+ exection.setVariable("operationStatus", operationStatus)\r
}\r
\r
+ /**\r
+ * delay 5 sec \r
+ */\r
public void timeDelay(Execution execution) {\r
+ try {\r
+ Thread.sleep(5000);\r
+ } catch(InterruptedException e) { \r
+ taskProcessor.utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)\r
+ }\r
}\r
\r
+ /**\r
+ * finish NS task\r
+ */\r
public void finishNSCreate(Execution execution) {\r
+ //no need to do anything util now\r
}\r
\r
/**\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( "response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString(), isDebugEnabled)\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
+ } \r
return apiResponse\r
}\r
}\r