aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main
diff options
context:
space:
mode:
authoranupmarathe <anup.marathe@amdocs.com>2017-08-23 11:10:27 +0530
committeranupmarathe <anup.marathe@amdocs.com>2017-08-24 12:55:21 +0530
commitbba3151adcc8337697a09475cb268c93f27d6748 (patch)
treed2b56c76aaa200f914b20b0eff401b0bf3d237bb /bpmn/MSOCommonBPMN/src/main
parentbf69de1b2bb800fe59125746a7aa0ada0c8bd258 (diff)
Fix to pass transaction id to AAI
When SO is calling AAI REST API in groovy code, it is always passing new X-TransactionID. As per EELF logging guidelines, this id is used for tracking transaction across components. This fix checks if there is already an existing transaction id in MDC, if yes then pass same. If not found, then create one and set in MDC for use in next API calls in same transaction. Change-Id: If6e33b77d9615f4887e1c1fc367de4268eecc340 Issue-ID: SO-78 Signed-off-by: anupmarathe <anup.marathe@amdocs.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy12
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy9
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy21
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy5
4 files changed, 35 insertions, 12 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy
index b50bf68207..af650b49a4 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy
@@ -296,7 +296,7 @@ class AaiUtil {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug(" ======== STARTED Execute AAI Get Process ======== ", isDebugEnabled)
try{
- String uuid = UUID.randomUUID()
+ String uuid = utils.getRequestID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
@@ -335,7 +335,7 @@ class AaiUtil {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug( " ======== Started Execute AAI Put Process ======== ", isDebugEnabled)
try{
- String uuid = UUID.randomUUID()
+ String uuid = utils.getRequestID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
@@ -371,7 +371,7 @@ class AaiUtil {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug( " ======== Started Execute AAI Patch Process ======== ", isDebugEnabled)
try{
- String uuid = UUID.randomUUID()
+ String uuid = utils.getRequestID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
@@ -408,7 +408,7 @@ class AaiUtil {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled)
try{
- String uuid = UUID.randomUUID()
+ String uuid = utils.getRequestID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
@@ -445,7 +445,7 @@ class AaiUtil {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled)
try{
- String uuid = UUID.randomUUID()
+ String uuid = utils.getRequestID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
@@ -483,7 +483,7 @@ class AaiUtil {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled)
try{
- String uuid = UUID.randomUUID()
+ String uuid = utils.getRequestID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy
index 72ad1402e1..aaac86c8c9 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy
@@ -29,7 +29,8 @@ import org.openecomp.mso.rest.RESTConfig;
public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
def Prefix="DAAIVfMod_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ private MsoUtils utils = new MsoUtils()
public void initProcessVariables(Execution execution) {
execution.setVariable("prefix",Prefix)
execution.setVariable("DAAIVfMod_vnfId",null)
@@ -83,7 +84,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
def delModuleId = execution.getVariable("DAAIVfMod_vfModuleId")
def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + "?depth=1"
utils.logAudit("DeleteAAIVfModule endPoint: " + endPoint)
- def aaiRequestId = UUID.randomUUID().toString()
+ def aaiRequestId = utils.getRequestID()
RESTConfig config = new RESTConfig(endPoint);
utils.log("DEBUG","queryAAIForGenericVnf() endpoint-" + endPoint, isDebugEnabled)
@@ -118,7 +119,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
// note: to get here, all the modules associated with the Generic Vnf must already be deleted
public void deleteGenericVnf(Execution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- def aaiRequestId = UUID.randomUUID().toString()
+ def aaiRequestId = utils.getRequestID()
def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_genericVnfEndpoint") +
"/?resource-version=" + execution.getVariable("DAAIVfMod_genVnfRsrcVer")
utils.logAudit("AAI endPoint: " + endPoint)
@@ -153,7 +154,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_vfModuleEndpoint") +
"/?resource-version=" + execution.getVariable("DAAIVfMod_vfModRsrcVer")
- def aaiRequestId = UUID.randomUUID().toString()
+ def aaiRequestId = utils.getRequestID()
RESTConfig config = new RESTConfig(endPoint);
utils.log("DEBUG","deleteVfModule() endpoint-" + endPoint, isDebugEnabled)
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy
index a0256d33e9..26c30491bc 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy
@@ -30,6 +30,7 @@ import org.openecomp.mso.bpmn.core.xml.XmlTool
import org.openecomp.mso.logger.MessageEnum
import org.openecomp.mso.logger.MsoLogger
import org.openecomp.mso.utils.CryptoUtils
+import org.slf4j.MDC
import org.w3c.dom.Element
class MsoUtils {
@@ -947,5 +948,25 @@ class MsoUtils {
}
return sortedModuleIndexList.size().toString()
}
+ /**
+ * This utility checks if there is transaction id already present in MDC.
+ * If found, it returns same else creates new, sets in MDC for future use before returning
+ * @return String RequestId in UUID format.
+ */
+ public String getRequestID()
+ {
+ String requestId = MDC.get("RequestId")
+ if(requestId == null || requestId.isEmpty())
+ {
+ requestId = java.util.UUID.randomUUID()
+ MDC.put("RequestId",requestId)
+ log("DEBUG","MsoUtils - Created new RequestId: " + requestId)
+ }
+ else
+ {
+ log("DEBUG","MsoUtils - Using existing RequestId: " + requestId)
+ }
+ return requestId
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
index f30692c409..14732fbfb5 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
@@ -31,6 +31,7 @@ import org.springframework.web.util.UriUtils
public class PrepareUpdateAAIVfModule extends VfModuleBase {
ExceptionUtil exceptionUtil = new ExceptionUtil()
+ private MsoUtils utils = new MsoUtils()
/**
* Initialize the flow's variables.
*
@@ -116,7 +117,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
try {
RESTConfig config = new RESTConfig(endPoint);
def responseData = ''
- def aaiRequestId = UUID.randomUUID().toString()
+ String aaiRequestId = utils.getRequestID()
RESTClient client = new RESTClient(config).
addHeader('X-TransactionId', aaiRequestId).
addHeader('X-FromAppId', 'MSO').
@@ -255,7 +256,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
try {
RESTConfig config = new RESTConfig(endPoint);
def responseData = ''
- def aaiRequestId = UUID.randomUUID().toString()
+ def aaiRequestId = utils.getRequestID()
RESTClient client = new RESTClient(config).
addHeader('X-TransactionId', aaiRequestId).
addHeader('X-FromAppId', 'MSO').