AT&T 1712 and 1802 release code
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / openecomp / mso / bpmn / common / scripts / ManualHandling.groovy
index ad3cc3b..e79071f 100644 (file)
@@ -1,6 +1,6 @@
 /*-\r
  * ============LICENSE_START=======================================================\r
- * OPENECOMP - MSO\r
+ * ONAP - SO\r
  * ================================================================================\r
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
  * ================================================================================\r
@@ -23,6 +23,8 @@ import static org.apache.commons.lang3.StringUtils.*;
 \r
 import java.time.chrono.AbstractChronology\r
 import java.util.List\r
+import java.text.SimpleDateFormat\r
+import java.util.Date\r
 \r
 import org.apache.commons.lang3.*\r
 import org.camunda.bpm.engine.TaskService\r
@@ -31,12 +33,13 @@ import org.camunda.bpm.engine.task.TaskQuery
 import org.camunda.bpm.engine.delegate.BpmnError\r
 import org.camunda.bpm.engine.delegate.DelegateTask\r
 import org.camunda.bpm.engine.delegate.DelegateExecution\r
-import org.camunda.bpm.engine.runtime.Execution\r
+import org.camunda.bpm.engine.delegate.DelegateExecution\r
 import org.json.JSONObject;\r
 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition\r
 import org.openecomp.mso.bpmn.core.json.JsonUtils\r
+import org.openecomp.mso.client.ruby.*\r
 \r
 \r
 \r
@@ -57,6 +60,7 @@ import org.openecomp.mso.bpmn.core.json.JsonUtils
  * @param - errorCode\r
  * @param - errorText\r
  * @param - validResponses\r
+ * @param - vnfName\r
  *\r
  * Outputs:\r
  * @param - WorkflowException\r
@@ -70,13 +74,14 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
        \r
        JsonUtils jsonUtils = new JsonUtils()\r
 \r
-       public void preProcessRequest (Execution execution) {\r
+       public void preProcessRequest (DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")\r
                String msg = ""\r
                utils.log("DEBUG"," ***** preProcessRequest of ManualHandling *****",  isDebugLogEnabled)\r
 \r
                try {\r
                        execution.setVariable("prefix", Prefix)\r
+                       setBasicDBAuthHeader(execution, isDebugLogEnabled)\r
                        // check for required input\r
                        String requestId = execution.getVariable("msoRequestId")\r
                        utils.log("DEBUG", "msoRequestId is: " + requestId, isDebugLogEnabled)          \r
@@ -109,7 +114,7 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
                utils.log("DEBUG"," ***** Exit preProcessRequest of RainyDayHandler *****",  isDebugLogEnabled)\r
        }\r
 \r
-       public void createManualTask (Execution execution) {\r
+       public void createManualTask (DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")\r
                String msg = ""\r
                utils.log("DEBUG"," ***** createManualTask of ManualHandling *****",  isDebugLogEnabled)\r
@@ -247,7 +252,94 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)\r
                }\r
                utils.log("DEBUG"," ***** Exit completeTask of ManualHandling *****",  isDebugLogEnabled)\r
-       }       \r
+       }\r
+       \r
+       public void prepareRequestsDBStatusUpdate (DelegateExecution execution, String requestStatus){\r
+               \r
+               def method = getClass().getSimpleName() + '.prepareRequestsDBStatusUpdate(' +'execution=' + execution.getId() +')'\r
+               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
+               utils.log("DEBUG"," ***** prepareRequestsDBStatusUpdate of ManualHandling *****",  isDebugLogEnabled)\r
+               try {\r
+                       def requestId = execution.getVariable("msoRequestId")\r
+                       String payload = """\r
+                               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">\r
+                                                  <soapenv:Header/>\r
+                                                  <soapenv:Body>\r
+                                                     <req:updateInfraRequest>\r
+                                                        <requestId>${requestId}</requestId>\r
+                                                        <lastModifiedBy>ManualHandling</lastModifiedBy>                                                         \r
+                                                        <requestStatus>${requestStatus}</requestStatus>                                                                 \r
+                                                     </req:updateInfraRequest>\r
+                                                  </soapenv:Body>\r
+                                               </soapenv:Envelope>\r
+                               """\r
+                       \r
+                       execution.setVariable("setUpdateDBstatusPayload", payload)\r
+                       utils.log("DEBUG", "Outgoing Update Mso Request Payload is: " + payload, isDebugLogEnabled)\r
+                       utils.logAudit("setUpdateDBstatusPayload: " + payload)\r
+               \r
+               } catch (BpmnError e) {\r
+                       throw e;\r
+               } catch (Exception e) {\r
+                       logError('Caught exception in ' + method, e)\r
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)\r
+               }\r
+               \r
+               utils.log("DEBUG"," ***** Exit prepareRequestsDBStatusUpdate of ManualHandling *****",  isDebugLogEnabled)\r
+       }\r
+       \r
+       public void createAOTSTicket (DelegateExecution execution) {\r
+               def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")\r
+               String msg = ""\r
+               utils.log("DEBUG"," ***** createAOTSTicket of ManualHandling *****",  isDebugLogEnabled)\r
+               \r
+               // This method will not be throwing an exception, but rather log the error\r
+\r
+               try {\r
+                       execution.setVariable("prefix", Prefix)\r
+                       setBasicDBAuthHeader(execution, isDebugLogEnabled)\r
+                       // check for required input\r
+                       String requestId = execution.getVariable("msoRequestId")\r
+                       utils.log("DEBUG", "requestId is: " + requestId, isDebugLogEnabled)                     \r
+                       def currentActivity = execution.getVariable("currentActivity")\r
+                       utils.log("DEBUG", "currentActivity is: " + currentActivity, isDebugLogEnabled)\r
+                       def workStep = execution.getVariable("workStep")\r
+                       utils.log("DEBUG", "workStep is: " + workStep, isDebugLogEnabled)\r
+                       def failedActivity = execution.getVariable("failedActivity")\r
+                       utils.log("DEBUG", "failedActivity is: " + failedActivity, isDebugLogEnabled)\r
+                       def errorCode = execution.getVariable("errorCode")\r
+                       utils.log("DEBUG", "errorCode is: " + errorCode, isDebugLogEnabled)\r
+                       def errorText = execution.getVariable("errorText")\r
+                       utils.log("DEBUG", "errorText is: " + errorText, isDebugLogEnabled)\r
+                       def vnfName = execution.getVariable("vnfName")\r
+                       utils.log("DEBUG", "vnfName is: " + vnfName, isDebugLogEnabled)                 \r
+                       \r
+                       String rubyRequestId = UUID.randomUUID()\r
+                       utils.log("DEBUG", "rubyRequestId: " + rubyRequestId, isDebugLogEnabled)\r
+                       String sourceName = vnfName\r
+                       utils.log("DEBUG", "sourceName: " + sourceName, isDebugLogEnabled)\r
+                       String reason = "VID Workflow failed at " + failedActivity + " " + workStep + " call with error " + errorCode\r
+                       utils.log("DEBUG", "reason: " + reason, isDebugLogEnabled)\r
+                       String workflowId = requestId\r
+                       utils.log("DEBUG", "workflowId: " + workflowId, isDebugLogEnabled)\r
+                       String notification = "Request originated from VID | Workflow fallout on " + vnfName + " | Workflow step failure: " + workStep + " failed | VID workflow ID: " + workflowId\r
+                       utils.log("DEBUG", "notification: " + notification, isDebugLogEnabled)                  \r
+                       \r
+                       utils.log("DEBUG", "Creating AOTS Ticket request")                      \r
+                       \r
+                       RubyClient rubyClient = new RubyClient()\r
+                       rubyClient.rubyCreateTicketCheckRequest(rubyRequestId, sourceName, reason, workflowId, notification)                    \r
+                       \r
+               } catch (BpmnError e) {\r
+                       msg = "BPMN error in createAOTSTicket " + ex.getMessage()\r
+                       utils.log("ERROR", msg, isDebugLogEnabled)                      \r
+               } catch (Exception ex){\r
+                       msg = "Exception in createAOTSTicket " + ex.getMessage()\r
+                       utils.log("ERROR", msg, isDebugLogEnabled)                      \r
+               }\r
+               utils.log("DEBUG"," ***** Exit createAOTSTicket of ManualHandling *****",  isDebugLogEnabled)\r
+       }\r
+\r
        \r
        \r
 }\r