diff options
author | xuegao <xg353y@intl.att.com> | 2020-04-21 13:39:50 +0200 |
---|---|---|
committer | xuegao <xg353y@intl.att.com> | 2020-04-21 13:39:50 +0200 |
commit | c65613938d30565d4dc913fbf2d48002390119d3 (patch) | |
tree | 63cf31d45dad04969c63fdf1f89d3d6deb1c5657 /src | |
parent | 8b4027e3e359bba21014dd138da2545d54d117db (diff) |
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 <xg353y@intl.att.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/onap/clamp/loop/LoopService.java | 6 |
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 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<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; } |