aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/groovy
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/groovy')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy169
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy18
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsFactory.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy148
4 files changed, 121 insertions, 218 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
index dba6a1a2bb..484be19137 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -32,111 +34,15 @@ import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.client.aai.AAIResourcesClient
import org.springframework.web.util.UriUtils
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import groovy.json.JsonSlurper
public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcessor {
- public MsoUtils utils = new MsoUtils()
-
-
- /**
- * Logs a message at the ERROR level.
- * @param message the message
- */
- public void logError(String message) {
- log('ERROR', message, null, "true")
- }
-
- /**
- * Logs a message at the ERROR level.
- * @param message the message
- * @param cause the cause (stracktrace will be included in the output)
- */
- public void logError(String message, Throwable cause) {
- log('ERROR', message, cause, "true")
- }
-
- /**
- * Logs a message at the WARN level.
- * @param message the message
- */
- public void logWarn(String message) {
- log('WARN', message, null, "true")
- }
-
- /**
- * Logs a message at the WARN level.
- * @param message the message
- * @param cause the cause (stracktrace will be included in the output)
- */
- public void logWarn(String message, Throwable cause) {
- log('WARN', message, cause, "true")
- }
-
- /**
- * Logs a message at the DEBUG level.
- * @param message the message
- * @param isDebugLogEnabled a flag indicating if DEBUG level is enabled
- */
- public void logDebug(String message, String isDebugLogEnabled) {
- log('DEBUG', message, null, isDebugLogEnabled)
- }
+ private static final Logger logger = LoggerFactory.getLogger( MsoUtils.class);
- /**
- * Logs a message at the DEBUG level.
- * @param message the message
- * @param cause the cause (stracktrace will be included in the output)
- * @param isDebugLogEnabled a flag indicating if DEBUG level is enabled
- */
- public void logDebug(String message, Throwable cause, String isDebugLogEnabled) {
- log('DEBUG', message, cause, isDebugLogEnabled)
- }
-
- /**
- * Logs a message at the specified level.
- * @param level the level (DEBUG, INFO, WARN, ERROR)
- * @param message the message
- * @param isLevelEnabled a flag indicating if the level is enabled
- * (used only at the DEBUG level)
- */
- public void log(String level, String message, String isLevelEnabled) {
- log(level, message, null, isLevelEnabled)
- }
-
- /**
- * Logs a message at the specified level.
- * @param level the level (DEBUG, INFO, WARN, ERROR)
- * @param message the message
- * @param cause the cause (stracktrace will be included in the output)
- * @param isLevelEnabled a flag indicating if the level is enabled
- * (used only at the DEBUG level)
- */
- public void log(String level, String message, Throwable cause, String isLevelEnabled) {
- if (cause == null) {
- utils.log(level, message, isLevelEnabled);
- } else {
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
- printWriter.println(message);
- cause.printStackTrace(printWriter);
- utils.log(level, stringWriter.toString(), isLevelEnabled);
- printWriter.close();
- }
- }
-
- /**
- * 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) {
- logError(message);
- } else {
- logError(message + ": " + workflowException)
- }
- }
+ public MsoUtils utils = new MsoUtils()
/**
* Saves the WorkflowException in the execution to the specified variable,
@@ -173,7 +79,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
', requredVariables=' + requiredVariables +
')'
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
+ logger.debug('Entered ' + method)
String processKey = getProcessKey(execution)
def prefix = execution.getVariable("prefix")
@@ -236,13 +142,13 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
serviceInstanceId = (String) execution.getVariable("mso-service-instance-id")
}
- logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled)
- logDebug('Exited ' + method, isDebugLogEnabled)
+ logger.debug('Incoming message: ' + System.lineSeparator() + request)
+ logger.debug('Exited ' + method)
return request
} catch (BpmnError e) {
throw e
} catch (Exception e) {
- logError('Caught exception in ' + method, e)
+ logger.error('Caught exception in ' + method, e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message")
}
}
@@ -258,7 +164,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
'execution=' + execution.getId() +
')'
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
+ logger.debug('Entered ' + method)
String processKey = getProcessKey(execution);
def prefix = execution.getVariable("prefix")
@@ -278,8 +184,8 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
def parsed = jsonSlurper.parseText(request)
- logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled)
- logDebug('Exited ' + method, isDebugLogEnabled)
+ logger.debug('Incoming message: ' + System.lineSeparator() + request)
+ logger.debug('Exited ' + method)
return parsed
}
@@ -309,10 +215,10 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
}
if (String.valueOf(execution.getVariable(processKey + "WorkflowResponseSent")).equals("true")) {
- logDebug("Sync response has already been sent for " + processKey, isDebugLogEnabled)
+ logger.debug("Sync response has already been sent for " + processKey)
}else{
- logDebug("Building " + processKey + " response ", isDebugLogEnabled)
+ logger.debug("Building " + processKey + " response ")
int intResponseCode;
@@ -337,11 +243,10 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
execution.setVariable(processKey + "Status", status);
execution.setVariable("WorkflowResponse", response)
- logDebug("Sending response for " + processKey
+ logger.debug("Sending response for " + processKey
+ " ResponseCode=" + intResponseCode
+ " Status=" + status
- + " Response=\n" + response,
- isDebugLogEnabled)
+ + " Response=\n" + response)
// TODO: ensure that this flow was invoked asynchronously?
@@ -362,7 +267,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
}
} catch (Exception ex) {
- logError("Unable to send workflow response to client ....", ex)
+ logger.error("Unable to send workflow response to client ....", ex)
}
}
@@ -432,7 +337,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
def element = utils.getNodeXml(xml, elementName, false)
if (element.trim().isEmpty()) {
def msg = 'Required element \'' + elementName + '\' is missing or empty'
- logError(msg)
+ logger.error(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
} else {
return element
@@ -454,7 +359,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
def elementText = utils.getNodeText(xml, elementName)
if ((elementText == null) || (elementText.isEmpty())) {
def msg = 'Required element \'' + elementName + '\' is missing or empty'
- logError(msg)
+ logger.error(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
} else {
return elementText
@@ -569,9 +474,9 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
String prefix = execution.getVariable('prefix')
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered SetSuccessIndicator Method', isDebugLogEnabled)
+ logger.debug('Entered SetSuccessIndicator Method')
execution.setVariable(prefix+'SuccessIndicator', isSuccess)
- logDebug('Outgoing SuccessIndicator is: ' + execution.getVariable(prefix+'SuccessIndicator') + '', isDebugLogEnabled)
+ logger.debug('Outgoing SuccessIndicator is: ' + execution.getVariable(prefix+'SuccessIndicator') + '')
}
/**
@@ -579,14 +484,14 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
*
*/
public void sendSyncError(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
String requestId = execution.getVariable("mso-request-id")
- logDebug('sendSyncError, requestId: ' + requestId, isDebugEnabled)
+ logger.debug('sendSyncError, requestId: ' + requestId)
WorkflowException workflowExceptionObj = execution.getVariable("WorkflowException")
if (workflowExceptionObj != null) {
String errorMessage = workflowExceptionObj.getErrorMessage()
def errorCode = workflowExceptionObj.getErrorCode()
- logDebug('sendSyncError, requestId: ' + requestId + ' | errorMessage: ' + errorMessage + ' | errorCode: ' + errorCode, isDebugEnabled)
+ logger.debug('sendSyncError, requestId: ' + requestId + ' | errorMessage: ' + errorMessage + ' | errorCode: ' + errorCode)
sendWorkflowResponse(execution, errorCode, errorMessage)
}
}
@@ -602,27 +507,27 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
DelegateExecution execution = (DelegateExecution) args[0]
def classAndMethod = getClass().getSimpleName() + '.' + methodName + '(execution=' + execution.getId() + ')'
- def isDebugEnabled = execution.getVariable('isDebugLogEnabled')
+ def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + classAndMethod, isDebugEnabled)
- logDebug('Received parameters: ' + args, isDebugEnabled)
+ logger.debug('Entered ' + classAndMethod)
+ logger.debug('Received parameters: ' + args)
try{
def methodToCall = this.metaClass.getMetaMethod(methodName, args)
- logDebug('Method to call: ' + methodToCall, isDebugEnabled)
+ logger.debug('Method to call: ' + methodToCall)
methodToCall?.invoke(this, args)
}
catch(BpmnError bpmnError) {
- logDebug('Rethrowing BpmnError ' + bpmnError.getMessage(), isDebugEnabled)
+ logger.debug('Rethrowing BpmnError ' + bpmnError.getMessage())
throw bpmnError
}
catch(Exception e) {
e.printStackTrace()
- logDebug('Unexpected error encountered - ' + e.getMessage(), isDebugEnabled)
+ logger.debug('Unexpected error encountered - ' + e.getMessage())
(new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
}
finally {
- logDebug('Exited ' + classAndMethod, isDebugEnabled)
+ logger.debug('Exited ' + classAndMethod)
}
}
}
@@ -718,8 +623,8 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
def disableRollback = execution.getVariable("disableRollback")
def defaultRollback = UrnPropertiesReader.getVariable("mso.rollback", execution).toBoolean()
- logDebug('disableRollback: ' + disableRollback, isDebugLogEnabled)
- logDebug('defaultRollback: ' + defaultRollback, isDebugLogEnabled)
+ logger.debug('disableRollback: ' + disableRollback)
+ logger.debug('defaultRollback: ' + defaultRollback)
def rollbackEnabled
@@ -727,7 +632,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
// get from default urn settings for mso_rollback
disableRollback = !defaultRollback
rollbackEnabled = defaultRollback
- logDebug('disableRollback is null or empty!', isDebugLogEnabled)
+ logger.debug('disableRollback is null or empty!')
}
else {
if(disableRollback == true) {
@@ -742,7 +647,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
}
execution.setVariable(prefix+"backoutOnFailure", rollbackEnabled)
- logDebug('rollbackEnabled (aka backoutOnFailure): ' + rollbackEnabled, isDebugLogEnabled)
+ logger.debug('rollbackEnabled (aka backoutOnFailure): ' + rollbackEnabled)
}
public void setBasicDBAuthHeader(DelegateExecution execution, isDebugLogEnabled) {
@@ -752,7 +657,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
execution.setVariable("BasicAuthHeaderValueDB",encodedString)
} catch (IOException ex) {
String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
- utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled)
+ logger.debug(dataErrorMessage)
(new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy
index 0d9b3c5b94..d5b0b31a39 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy
@@ -51,13 +51,13 @@ class CatalogDbUtils {
private static final Logger logger = LoggerFactory.getLogger( CatalogDbUtils.class);
private HttpClientFactory httpClientFactory
- private MsoUtils msoUtils
- private JsonUtils jsonUtils
+ private MsoUtils utils
+ private JsonUtils jsonUtils
static private String defaultDbAdapterVersion = "v2"
- CatalogDbUtils(HttpClientFactory httpClientFactory, MsoUtils msoUtils, JsonUtils jsonUtils) {
+ CatalogDbUtils(HttpClientFactory httpClientFactory, JsonUtils jsonUtils) {
this.httpClientFactory = httpClientFactory
- this.msoUtils = msoUtils
+ this.utils = new MsoUtils()
this.jsonUtils = jsonUtils
}
@@ -105,7 +105,7 @@ class CatalogDbUtils {
}
}
catch (Exception e) {
- msoUtils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
+ logger.error("Exception in Querying Catalog DB: " + e.message)
throw e
}
@@ -488,7 +488,7 @@ class CatalogDbUtils {
}
}
catch (Exception e) {
- msoUtils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
+ logger.error("Exception in Querying Catalog DB: " + e.message)
throw e
}
@@ -500,13 +500,13 @@ class CatalogDbUtils {
String encodedString = null
try {
String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution)
- msoUtils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB)
+ logger.debug("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB)
- encodedString = msoUtils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution))
+ encodedString = utils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution))
execution.setVariable("BasicAuthHeaderValueDB",encodedString)
} catch (IOException ex) {
String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
- msoUtils.log("ERROR", dataErrorMessage)
+ logger.error(dataErrorMessage)
}
return encodedString
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsFactory.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsFactory.groovy
index faa0037169..bf7d07cbb3 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsFactory.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsFactory.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 NOKIA.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -26,6 +28,6 @@ import org.onap.so.client.HttpClientFactory
public class CatalogDbUtilsFactory {
CatalogDbUtils create() {
- return new CatalogDbUtils(new HttpClientFactory(), new MsoUtils(), new JsonUtils())
+ return new CatalogDbUtils(new HttpClientFactory(), new JsonUtils())
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
index ccbd682ef6..92c1579aa0 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
@@ -28,7 +28,6 @@ import java.text.SimpleDateFormat
import org.apache.commons.codec.binary.Base64
import org.apache.commons.lang3.StringEscapeUtils
-import org.onap.so.bpmn.core.BPMNLogger
import org.onap.so.bpmn.core.xml.XmlTool
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
@@ -89,7 +88,7 @@ class MsoUtils {
}
return nodes
}
-
+
def getNodeXml(xmlInput,element){
return getNodeXml(xmlInput, element, true)
}
@@ -106,7 +105,7 @@ class MsoUtils {
return unescapeNodeContents(nodeToSerialize, nodeAsText)
}
-
+
def unescapeNodeContents(NodeChild node, String text) {
if (!node.childNodes().hasNext()) {
return StringEscapeUtils.unescapeXml(text)
@@ -125,7 +124,7 @@ class MsoUtils {
}
}
-
+
/***** Utilities when using XmlParser *****/
/**
@@ -139,12 +138,12 @@ class MsoUtils {
nodeAsString = removeXmlPreamble(nodeAsString)
return formatXml(nodeAsString)
}
-
+
/**
* Get the specified child Node of the specified parent. If there are
* multiple children of the same name, only the first one is returned.
* If there are no children with the specified name, 'null' is returned.
- *
+ *
* @param parent Parent Node in which to find a child.
* @param childNodeName Name of the child Node to get.
* @return the (first) child Node with the specified name or 'null'
@@ -158,11 +157,11 @@ class MsoUtils {
return nodeList.get(0)
}
}
-
+
/**
* Get the textual value of the specified child Node of the specified parent.
* If there are no children with the specified name, 'null' is returned.
- *
+ *
* @param parent Parent Node in which to find a child.
* @param childNodeName Name of the child Node whose value to get.
* @return the textual value of child Node with the specified name or 'null'
@@ -176,11 +175,11 @@ class MsoUtils {
return childNode.text()
}
}
-
+
/**
* Get all of the child nodes from the specified parent that have the
* specified name. The returned NodeList could be empty.
- *
+ *
* @param parent Parent Node in which to find children.
* @param childNodeName Name of the children to get.
* @return a NodeList of all the children from the parent with the specified
@@ -192,14 +191,14 @@ class MsoUtils {
/***** End of Utilities when using XmlParser *****/
-
+
/** these are covered under the common function above**/
def getSubscriberName(xmlInput,element){
def rtn=null
if(xmlInput!=null){
def xml= new XmlSlurper().parseText(xmlInput)
rtn= xml.'**'.find{node->node.name()==element}.text()
- }
+ }
return rtn
}
def getTenantInformation(xmlInput,element){
@@ -227,7 +226,7 @@ class MsoUtils {
}
return ret
}
-
+
def searchMetaDataNode(fxml, searchName, searchValue){
def ret = fxml.'**'.find {it.metaname.text() == searchName && it.metaval.text() == searchValue}
if(ret != null){
@@ -235,7 +234,7 @@ class MsoUtils {
}
return ret
}
-
+
// for Trinity L3 add/delete bonding
def getPBGFList(isDebugLogEnabled, xmlInput){
log("DEBUG", "getPBGFList: xmlInput " + xmlInput,isDebugLogEnabled)
@@ -271,20 +270,18 @@ class MsoUtils {
}
myNodes.add(XmlUtil.serialize(nodeToAdd))
}
-
}
}
-
return myNodes
}else{
return null
}
}
-
+
def getPBGFList(xmlInput){
getPBGFList("false", xmlInput)
}
-
+
def getMetaVal(node, name){
try{
return node.'**'.find {it.metaname.text() == name}.metaval.text()
@@ -293,18 +290,17 @@ class MsoUtils {
}
}
- def log(logmode,logtxt,isDebugLogEnabled="false"){
+ def private log(logmode,logtxt,isDebugLogEnabled="false"){
if ("INFO"==logmode) {
- logger.info(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, logtxt, "BPMN");
+ logger.info(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), logtxt, "BPMN");
} else if ("WARN"==logmode) {
logger.warn ("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), logtxt, "BPMN",
ErrorCode.UnknownError.getValue(), logtxt);
} else if ("ERROR"==logmode) {
logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), logtxt, "BPMN",
ErrorCode.UnknownError.getValue(), logtxt);
-
} else {
- BPMNLogger.debug(isDebugLogEnabled, logtxt);
+ logger.debug(logtxt);
}
}
@@ -317,7 +313,7 @@ class MsoUtils {
}
return rtn
}
-
+
/**
* Gets the children of the specified element.
*/
@@ -336,10 +332,10 @@ class MsoUtils {
}
return out.toString();
}
-
+
/**
* Encodes a value so it can be used inside an XML text element.
- *
+ *
* <b>Will double encode</b>
* @param s the string to encode
* @return the encoded string
@@ -347,7 +343,7 @@ class MsoUtils {
public static String xmlEscape(Object value) {
return XmlTool.encode(value)
}
-
+
/**
* Removes the preamble, if present, from an XML document.
* Also, for historical reasons, this also trims leading and trailing
@@ -395,29 +391,29 @@ class MsoUtils {
public String formatXml(def xml) {
return XmlTool.normalize(xml);
}
-
+
// build single elements
def buildElements(xmlInput, elementList, parentName) {
String var = ""
def xmlBuild = ""
if (parentName != "") {
xmlBuild += "<tns2:"+parentName+">"
- }
+ }
if (xmlInput != null) {
for (element in elementList) {
def xml= new XmlSlurper().parseText(xmlInput)
var = xml.'**'.find {it.name() == element}
if (var != null) {
xmlBuild += "<tns2:"+element+">"+var.toString()+"</tns2:"+element+">"
- }
+ }
}
}
if (parentName != "") {
xmlBuild += "</tns2:"+parentName+">"
- }
+ }
return xmlBuild
}
-
+
// build the Unbounded elements
def buildElementsUnbounded(xmlInput, elementList, parentName) {
def varParents = ""
@@ -445,7 +441,7 @@ class MsoUtils {
}
return xmlBuildUnbounded
}
-
+
// Build l2-homing-information
def buildL2HomingInformation(xmlInput) {
def elementsL2HomingList = ["evc-name", "topology", "preferred-aic-clli","aic-version"]
@@ -455,7 +451,7 @@ class MsoUtils {
}
return rebuildL2Home
}
-
+
// Build internet-evc-access-information
def buildInternetEvcAccessInformation(xmlInput) {
def elementsInternetEvcAccessInformationList = ["internet-evc-speed-value", "internet-evc-speed-units", "ip-version"]
@@ -465,7 +461,7 @@ class MsoUtils {
}
return rebuildInternetEvcAccess
}
-
+
// Build ucpe-vms-service-information
def buildUcpeVmsServiceInformation(xmlInput) {
def rebuildUcpeVmsServiceInformation = ''
@@ -497,7 +493,7 @@ class MsoUtils {
log("DEBUG", " rebuildUcpeVmsServiceInformation - " + rebuildUcpeVmsServiceInformation)
return rebuildUcpeVmsServiceInformation
}
-
+
// Build internet-service-change-details
def buildInternetServiceChangeDetails(xmlInput) {
def rebuildInternetServiceChangeDetails = ""
@@ -527,33 +523,33 @@ class MsoUtils {
}
}
return rebuildInternetServiceChangeDetails
- }
-
- // Build vr-lan
+ }
+
+ // Build vr-lan
def buildVrLan(xmlInput) {
-
+
def rebuildVrLan = ''
if (xmlInput != null) {
-
+
rebuildVrLan = "<tns2:vr-lan>"
def vrLan = getNodeXml(xmlInput, "vr-lan").drop(38).trim()
rebuildVrLan += buildElements(vrLan, ["routing-protocol"], "")
-
+
// vr-lan-interface
def rebuildVrLanInterface = "<tns2:vr-lan-interface>"
def vrLanInterface = getNodeXml(vrLan, "vr-lan-interface").drop(38).trim()
rebuildVrLanInterface += buildVrLanInterfacePartial(vrLanInterface)
-
+
// dhcp
def dhcp = getNodeXml(vrLan, "dhcp").drop(38).trim()
def rebuildDhcp = buildDhcp(dhcp)
rebuildVrLanInterface += rebuildDhcp
-
+
// pat
def pat = getNodeXml(vrLan, "pat").drop(38).trim()
def rebuildPat = buildPat(pat)
rebuildVrLanInterface += rebuildPat
-
+
// nat
def rebuildNat = ""
try { // optional
@@ -563,31 +559,31 @@ class MsoUtils {
log("ERROR", " Optional - Exception 'nat' ")
}
rebuildVrLanInterface += rebuildNat
-
+
// firewall-lite
def firewallLite = getNodeXml(vrLan, "firewall-lite").drop(38).trim()
def rebuildFirewallLite = buildFirewallLite(firewallLite)
rebuildVrLanInterface += rebuildFirewallLite
-
+
// static-routes
def rebuildStaticRoutes = ""
- try { // optional
+ try { // optional
def staticRoutes = getNodeXml(vrLan, "static-routes").drop(38).trim()
rebuildStaticRoutes = buildStaticRoutes(staticRoutes)
} catch (Exception e) {
log("ERROR", " Optional - Exception 'static-routes' ")
}
rebuildVrLanInterface += rebuildStaticRoutes
-
+
rebuildVrLan += rebuildVrLanInterface
rebuildVrLan += "</tns2:vr-lan-interface>"
rebuildVrLan += "</tns2:vr-lan>"
-
+
}
log("DEBUG", " rebuildVrLan - " + rebuildVrLan)
- return rebuildVrLan
+ return rebuildVrLan
}
-
+
// Build vr-lan-interface
def buildVrLanInterfacePartial(xmlInput) {
def rebuildingVrLanInterface = ''
@@ -616,7 +612,7 @@ class MsoUtils {
log("DEBUG", " rebuildingVrLanInterface - " + rebuildingVrLanInterface)
return rebuildingVrLanInterface
}
-
+
// Build dhcp
def buildDhcp(xmlInput) {
def rebuildingDhcp = ''
@@ -686,10 +682,10 @@ class MsoUtils {
log("ERROR", " Optional - Exception DHCP 'v6-dhcp-pools' ")
}
rebuildingDhcp += "</tns2:dhcp>"
- }
+ }
log("DEBUG", " rebuildingDhcp - " + rebuildingDhcp)
return rebuildingDhcp
- }
+ }
// Build pat
def buildPat(xmlInput) {
@@ -710,7 +706,7 @@ class MsoUtils {
log("DEBUG", " rebuildingPat - " + rebuildingPat)
return rebuildingPat
}
-
+
// Build nat
def buildNat(xmlInput) {
def rebuildingNat = ''
@@ -728,19 +724,19 @@ class MsoUtils {
}
log("DEBUG", " rebuildingNat - " + rebuildingNat)
return rebuildingNat
- }
-
+ }
+
// Build firewall-lite
def buildFirewallLite(xmlInput) {
def rebuildingFirewallLite = ''
-
+
if (xmlInput != null) {
-
+
def firewallLiteData = new XmlSlurper().parseText(xmlInput)
rebuildingFirewallLite = "<tns2:firewall-lite>"
def firewallLiteList = ["stateful-firewall-lite-v4-enabled", "stateful-firewall-lite-v6-enabled"]
rebuildingFirewallLite += buildElements(xmlInput, firewallLiteList, "")
-
+
try { // optional
def v4FirewallPacketFilters = firewallLiteData.'**'.findAll {it.name() == "v4-firewall-packet-filters"}
def v4FirewallPacketFiltersSize = v4FirewallPacketFilters.size()
@@ -768,7 +764,7 @@ class MsoUtils {
} catch (Exception e) {
log("ERROR", " Optional - Exception FIREWALL-LITE 'v4-firewall-packet-filters' ")
}
-
+
try { // optional
def v6FirewallPacketFilters = firewallLiteData.'**'.findAll {it.name() == "v6-firewall-packet-filters"}
def v6FirewallPacketFiltersSize = v6FirewallPacketFilters.size()
@@ -801,7 +797,7 @@ class MsoUtils {
log("DEBUG", " rebuildingFirewallLite - " + rebuildingFirewallLite)
return rebuildingFirewallLite
}
-
+
def buildStaticRoutes(xmlInput) {
def rebuildingStaticRoutes = ''
if (xmlInput != null) {
@@ -815,21 +811,21 @@ class MsoUtils {
log("DEBUG", " rebuildingStaticRoutes - " + rebuildingStaticRoutes)
return rebuildingStaticRoutes
}
-
+
public String generateCurrentTimeInUtc(){
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
final String utcTime = sdf.format(new Date());
return utcTime;
}
-
+
public String generateCurrentTimeInGMT(){
final SimpleDateFormat sdf = new SimpleDateFormat("E, d MMM yyyy h:m:s z");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
final String utcTime = sdf.format(new Date());
return utcTime;
}
-
+
/**
* @param encryptedAuth: encrypted credentials from urn properties
@@ -850,7 +846,7 @@ class MsoUtils {
throw ex
}
}
-
+
def encrypt(toEncrypt, msokey){
try {
String result = CryptoUtils.encrypt(toEncrypt, msokey);
@@ -860,7 +856,7 @@ class MsoUtils {
log("ERROR", "Failed to encrypt credentials")
}
}
-
+
def decrypt(toDecrypt, msokey){
try {
String result = CryptoUtils.decrypt(toDecrypt, msokey);
@@ -871,7 +867,7 @@ class MsoUtils {
throw e
}
}
-
+
/**
* Return URL with qualified host name (if any) or urn mapping
* @param String url from urn mapping
@@ -890,9 +886,9 @@ class MsoUtils {
log("DEBUG", "unable to grab qualified host name, using what's in urn properties for callbackurl. Exception was: " + e.printStackTrace())
}
return callbackUrlToUse
-
+
}
-
+
/**
* Retrieves text context of the element if the element exists, returns empty string otherwise
* @param com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl element to parse
@@ -907,7 +903,7 @@ class MsoUtils {
}
return text
}
-
+
/**
*
* Find the lowest unused module-index value in a given xml
@@ -915,14 +911,14 @@ class MsoUtils {
public String getLowestUnusedIndex(String xml) {
if (xml == null || xml.isEmpty()) {
return "0"
- }
- def moduleIndexList = getMultNodes(xml, "module-index")
- if (moduleIndexList == null || moduleIndexList.size() == 0) {
+ }
+ def moduleIndexList = getMultNodes(xml, "module-index")
+ if (moduleIndexList == null || moduleIndexList.size() == 0) {
return "0"
}
-
+
def sortedModuleIndexList = moduleIndexList.sort{ a, b -> a as Integer <=> b as Integer}
-
+
for (i in 0..sortedModuleIndexList.size()-1) {
if (Integer.parseInt(sortedModuleIndexList[i]) != i) {
return i.toString()