aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSébastien Determe <sebastien.determe@intl.att.com>2020-04-21 12:27:17 +0000
committerGerrit Code Review <gerrit@onap.org>2020-04-21 12:27:17 +0000
commit8b9918e7e3b1398ece5470f36be1d9dd13e29bee (patch)
tree8d2607bf1a90a8b32bc2e3e65832453d9d030348 /src
parentdcfbed79c6da8b9c737c979b9a0410d37142499d (diff)
parentc65613938d30565d4dc913fbf2d48002390119d3 (diff)
Merge "Prevent adding same type of Op policy"
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index ca3681b6..3f568a33 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -118,6 +118,12 @@ public class LoopService {
Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) throws IOException {
Loop loop = getLoop(loopName);
PolicyModel policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
+ Set<OperationalPolicy> opPolicySet = loop.getOperationalPolicies();
+ for (OperationalPolicy opPolicy : opPolicySet) {
+ if (opPolicy.getPolicyModel().equals(policyModel)) {
+ throw new IllegalArgumentException("This type of Operational Policy is already added to the loop. Please choose another one.");
+ }
+ }
if (policyModel == null) {
return null;
}