summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-04-24 10:21:57 -0400
committerJim Hahn <jrh3@att.com>2020-04-24 10:24:23 -0400
commit06e637b461890124a5f8e34217f3031439b76d62 (patch)
tree9067fe6a6cd7029479ae570f55e53b26c1b66a90 /main
parent079667f565fbf5147001932fd4d44e8c47f7b8bd (diff)
Activating active group should be NOOP
Fixed the code so that if a request is made to activate a PDP Group that is already active, the group remains active. Issue-ID: POLICY-2522 Change-Id: I106332b1ce15fde8dbf0b3e72034fd11c250dc69 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java19
1 files changed, 2 insertions, 17 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java
index 97a214c7..0c90ae47 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pap.concepts.PdpGroupStateChangeResponse;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
-import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -82,16 +81,10 @@ public class PdpGroupStateChangeProvider extends PdpMessageGenerator {
private void handleActiveState(final String groupName) throws PfModelException {
try (PolicyModelsProvider databaseProvider = modelProviderWrapper.create()) {
- final PdpGroupFilter filter = PdpGroupFilter.builder().name(groupName).groupState(PdpState.ACTIVE).build();
- final List<PdpGroup> activePdpGroups = databaseProvider.getFilteredPdpGroups(filter);
final List<PdpGroup> pdpGroups = databaseProvider.getPdpGroups(groupName);
- if (activePdpGroups.isEmpty() && !pdpGroups.isEmpty()) {
+ if (!pdpGroups.isEmpty() && !PdpState.ACTIVE.equals(pdpGroups.get(0).getPdpGroupState())) {
updatePdpGroupAndPdp(databaseProvider, pdpGroups, PdpState.ACTIVE);
sendPdpMessage(pdpGroups.get(0), PdpState.ACTIVE, databaseProvider);
- } else if (!pdpGroups.isEmpty() && !activePdpGroups.isEmpty()) {
- updatePdpGroupAndPdp(databaseProvider, pdpGroups, PdpState.ACTIVE);
- updatePdpGroup(databaseProvider, activePdpGroups, PdpState.PASSIVE);
- sendPdpMessage(pdpGroups.get(0), PdpState.ACTIVE, databaseProvider);
}
}
}
@@ -106,14 +99,6 @@ public class PdpGroupStateChangeProvider extends PdpMessageGenerator {
}
}
- private void updatePdpGroup(final PolicyModelsProvider databaseProvider, final List<PdpGroup> pdpGroups,
- final PdpState pdpState) throws PfModelException {
- pdpGroups.get(0).setPdpGroupState(pdpState);
- databaseProvider.updatePdpGroups(pdpGroups);
-
- LOGGER.debug("Updated PdpGroup in DB - {} ", pdpGroups);
- }
-
private void updatePdpGroupAndPdp(final PolicyModelsProvider databaseProvider, final List<PdpGroup> pdpGroups,
final PdpState pdpState) throws PfModelException {
pdpGroups.get(0).setPdpGroupState(pdpState);