summaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/main/java
diff options
context:
space:
mode:
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>2020-08-06 13:03:38 +0100
committeraditya puthuparambil <aditya.puthuparambil@bell.ca>2020-08-07 17:15:10 +0000
commitf4895ff98b3ed83b44733adc20ad8cf0092a3d83 (patch)
tree5bc5037f746fe5babef73ee6a0670f68214cc881 /services/services-engine/src/main/java
parenta926cdc113b5fad19a34dbf45e66bd7cbb5ed6e0 (diff)
Handling apex-pdp multi policy deployment failure:
1.Include the list of duplicate parameters in the logs for easier troubleshooting 2.Also fix 4 Sonar blockers in ApexMainTest.java Issue-ID: POLICY-2712 Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca> Change-Id: I145a7e03f76f880f8e3cbde97284748468b354a5
Diffstat (limited to 'services/services-engine/src/main/java')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
index 1e2447b2e..a928f208c 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
@@ -24,6 +24,7 @@ package org.onap.policy.apex.service.engine.main;
import java.io.IOException;
import java.util.AbstractMap;
+import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@@ -133,16 +134,19 @@ public class ApexActivator {
new LinkedHashSet<>(apexParametersMap.entrySet());
apexParamsEntrySet.stream().forEach(apexParamsEntry -> {
ApexParameters apexParams = apexParamsEntry.getValue();
- boolean duplicateInputParameterExist =
- apexParams.getEventInputParameters().keySet().stream().anyMatch(inputParametersMap::containsKey);
- boolean duplicateOutputParameterExist =
- apexParams.getEventOutputParameters().keySet().stream().anyMatch(outputParametersMap::containsKey);
- if (duplicateInputParameterExist || duplicateOutputParameterExist) {
- LOGGER.error("I/O Parameters for {}:{} has duplicates. So this policy is not executed.",
- apexParamsEntry.getKey().getName(), apexParamsEntry.getKey().getVersion());
+ List<String> duplicateInputParameters = new ArrayList<>(apexParams.getEventInputParameters().keySet());
+ duplicateInputParameters.retainAll(inputParametersMap.keySet());
+ List<String> duplicateOutputParameters = new ArrayList<>(apexParams.getEventOutputParameters().keySet());
+ duplicateOutputParameters.retainAll(outputParametersMap.keySet());
+
+ if (!(duplicateInputParameters.isEmpty() && duplicateOutputParameters.isEmpty())) {
+ LOGGER.error("I/O Parameters {}/{} for {}:{} are duplicates. So this policy is not executed.",
+ duplicateInputParameters, duplicateOutputParameters, apexParamsEntry.getKey().getName(),
+ apexParamsEntry.getKey().getVersion());
apexParametersMap.remove(apexParamsEntry.getKey());
return;
}
+
inputParametersMap.putAll(apexParams.getEventInputParameters());
outputParametersMap.putAll(apexParams.getEventOutputParameters());
// Check if a policy model file has been specified