1710 Rebase - Second Attempt
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / openecomp / mso / bpmn / common / scripts / AbstractServiceTaskProcessor.groovy
index e86f77c..4bfeabf 100644 (file)
@@ -385,7 +385,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
        /**\r
         * Returns the process definition key (i.e. the process name) of the\r
         * current process.\r
-        *\r
+        * \r
         * @param execution the execution\r
         */\r
        public String getProcessKey(Execution execution) {\r
@@ -481,6 +481,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
                def nodeText = utils.getNodeText1(xml, elementName)\r
                return (nodeText == null) ? defaultValue : nodeText\r
        }\r
+\r
        /**\r
         * Get the text for the specified element from the specified xml.  If\r
         * the element does not exist, return an empty string.\r
@@ -579,7 +580,6 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
                logDebug('Outgoing SuccessIndicator is: ' + execution.getVariable(prefix+'SuccessIndicator') + '', isDebugLogEnabled)\r
        }\r
 \r
-\r
        /**\r
         * Sends a Error Sync Response\r
         *\r
@@ -597,17 +597,6 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
                }\r
        }\r
 \r
-       /**\r
-        * Create a WorkflowException - uses ExceptionUtil to build a WorkflowException\r
-        * @param execution\r
-        * @param errorCode\r
-        * @param errorMessage\r
-        * @param isDebugEnabled\r
-        */\r
-       public void buildWorkflowException(Execution execution, int errorCode, String errorMessage, boolean isDebugEnabled) {\r
-               (new ExceptionUtil()).buildWorkflowException(execution, errorCode, errorMessage)\r
-       }\r
-       \r
        /**\r
         * Executes a named groovy script method in the current object\r
         */\r
@@ -721,7 +710,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
                        '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') +\r
                        '/' + UriUtils.encodePathSegment(correlator, 'UTF-8')\r
        }\r
-       \r
+\r
        /**\r
         *\r
         * Constructs a workflow message callback URL for the specified message type and correlator.\r
@@ -747,4 +736,52 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
                        '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') +\r
                        '/' + UriUtils.encodePathSegment(correlator, 'UTF-8')\r
        }\r
+       \r
+       public void setRollbackEnabled(Execution execution, isDebugLogEnabled) {\r
+               \r
+               // Rollback settings\r
+               def prefix = execution.getVariable('prefix')\r
+               def disableRollback = execution.getVariable("disableRollback")\r
+               def defaultRollback = execution.getVariable("URN_mso_rollback").toBoolean()\r
+               \r
+               logDebug('disableRollback: ' + disableRollback, isDebugLogEnabled)\r
+               logDebug('defaultRollback: ' + defaultRollback, isDebugLogEnabled)\r
+               \r
+               def rollbackEnabled\r
+               \r
+               if(disableRollback == null || disableRollback == '' ) {\r
+                       // get from default urn settings for mso_rollback\r
+                       disableRollback = !defaultRollback\r
+                       rollbackEnabled = defaultRollback\r
+                       logDebug('disableRollback is null or empty!', isDebugLogEnabled)\r
+               }\r
+               else {\r
+                       if(disableRollback == true) {\r
+                               rollbackEnabled = false\r
+                       }\r
+                       else if(disableRollback == false){\r
+                               rollbackEnabled = true\r
+                       }\r
+                       else {\r
+                               rollbackEnabled = defaultRollback\r
+                       }\r
+               }\r
+               \r
+               execution.setVariable(prefix+"backoutOnFailure", rollbackEnabled)\r
+               logDebug('rollbackEnabled (aka backoutOnFailure): ' + rollbackEnabled, isDebugLogEnabled)\r
+       }\r
+       \r
+       public void setBasicDBAuthHeader(Execution execution, isDebugLogEnabled) {\r
+               try {\r
+                       String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")\r
+                       utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled)\r
+                       \r
+                       def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))\r
+                       execution.setVariable("BasicAuthHeaderValueDB",encodedString)\r
+               } catch (IOException ex) {\r
+                       String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()\r
+                       utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled)\r
+                       (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)\r
+               }\r
+       }\r
 }
\ No newline at end of file