From c65613938d30565d4dc913fbf2d48002390119d3 Mon Sep 17 00:00:00 2001 From: xuegao Date: Tue, 21 Apr 2020 13:39:50 +0200 Subject: Prevent adding same type of Op policy Add the logic to prevent user adding the same type of Operational Policy Issue-ID: CLAMP-828 Change-Id: Iec6774ec7a9494740f7aed0873165ba073d73e45 Signed-off-by: xuegao --- src/main/java/org/onap/clamp/loop/LoopService.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java index 6658c5a30..d14667ea7 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 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; } -- cgit 1.2.3-korg