import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.springframework.web.util.UriUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory
public MsoUtils utils = new MsoUtils()
+ /**
+ * Logs a WorkflowException at the ERROR level with the specified message.
+ * @param execution the execution
+ */
+ public void logWorkflowException(DelegateExecution execution, String message) {
+ def workflowException = execution.getVariable("WorkflowException")
+
+ if (workflowException == null) {
+ logger.error(message);
+ } else {
+ logger.error('{}: {}', message, workflowException)
+ }
+ }
+
/**
* Saves the WorkflowException in the execution to the specified variable,
* clearing the WorkflowException variable so the workflow can continue
} catch (BpmnError e) {
throw e
} catch (Exception e) {
- logger.error('Caught exception in ' + method, e)
+ logger.error('Caught exception in {}: {}', method, e.getMessage(), e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message")
}
}
*@param name
*@return
**/
- public String getVariable(DelegateExecution execution, String name) {
+ public static String getVariable(DelegateExecution execution, String name) {
def myObj = execution.getVariable(name)
if(myObj instanceof VariableMap){
VariableMap serializedObjectMap = (VariableMap) myObj
throw bpmnError
}
catch(Exception e) {
- e.printStackTrace()
- logger.debug('Unexpected error encountered - ' + e.getMessage())
+ logger.debug('Unexpected error encountered - {}', e.getMessage(), e)
(new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
}
finally {
rollbackEnabled = defaultRollback
}
}
-
+
execution.setVariable(prefix+"backoutOnFailure", rollbackEnabled)
logger.debug('rollbackEnabled (aka backoutOnFailure): ' + rollbackEnabled)
}
public AAIResourcesClient getAAIClient(){
return new AAIResourcesClient();
}
+
+ HttpClientFactory getHttpClientFactory(){
+ return new HttpClientFactory()
+ }
}