From 06e637b461890124a5f8e34217f3031439b76d62 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 24 Apr 2020 10:21:57 -0400 Subject: 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 --- .../pap/main/rest/PdpGroupStateChangeProvider.java | 19 ++----------------- 1 file 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 activePdpGroups = databaseProvider.getFilteredPdpGroups(filter); final List 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 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 pdpGroups, final PdpState pdpState) throws PfModelException { pdpGroups.get(0).setPdpGroupState(pdpState); -- cgit 1.2.3-korg