summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java3
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java34
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/ia/DbAuditCompareEntriesTest.java2
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java101
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java543
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java27
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java12
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java60
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java17
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java57
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java44
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java30
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java49
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java154
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java443
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java88
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java4
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java2
-rw-r--r--pom.xml2
20 files changed, 1156 insertions, 518 deletions
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java
index 43031861b..a11e8b4b7 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java
@@ -95,7 +95,7 @@ public class BRMSHandler implements BackUpHandler{
}
}
}
- Boolean failureFlag = false;
+ Boolean failureFlag;
int i = 0;
do{
failureFlag = false;
@@ -118,6 +118,7 @@ public class BRMSHandler implements BackUpHandler{
* (non-Javadoc)
* @see org.onap.policy.utils.BackUpHandler#runOnNotification(org.onap.policy.api.PDPNotification)
*/
+ @Override
public void runOnNotification(PDPNotification notification){
if(notification.getNotificationType().equals(NotificationType.REMOVE)){
removedPolicies(notification.getRemovedPolicies());
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
index c923c3c34..6e8588acb 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
@@ -388,11 +388,11 @@ public class BRMSPush {
selectedName = responseAttributes.get(key);
}
// kmodule configurations
- else if (key.equals("kSessionName")) {
+ else if ("kSessionName".equals(key)) {
kSessionName = responseAttributes.get(key);
}
// Check User Specific values.
- if (key.equals("$controller:")) {
+ if ("$controller:".equals(key)) {
try {
PEDependency dependency = PolicyUtils.jsonStringToObject(responseAttributes.get(key),
PEDependency.class);
@@ -402,7 +402,7 @@ public class BRMSPush {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Controller: " + e);
}
- } else if (key.equals("$dependency$")) {
+ } else if ("$dependency$".equals(key)) {
String value = responseAttributes.get(key);
if (value.startsWith("[") && value.endsWith("]")) {
value = value.substring(1, value.length() - 1).trim();
@@ -500,7 +500,7 @@ public class BRMSPush {
List<?> pList = query.getResultList();
boolean createFlag = false;
BRMSPolicyInfo brmsPolicyInfo = new BRMSPolicyInfo();
- if (pList.size() > 0) {
+ if (!pList.isEmpty()) {
// Already exists.
brmsPolicyInfo = (BRMSPolicyInfo) pList.get(0);
if (!brmsPolicyInfo.getControllerName().getControllerName().equals(controllerName)) {
@@ -514,7 +514,7 @@ public class BRMSPush {
query.setParameter("cn", controllerName);
List<?> bList = query.getResultList();
BRMSGroupInfo brmsGroupInfo = new BRMSGroupInfo();
- if (bList.size() > 0) {
+ if (!bList.isEmpty()) {
brmsGroupInfo = (BRMSGroupInfo) bList.get(0);
}
brmsPolicyInfo.setPolicyName(policyName);
@@ -528,7 +528,7 @@ public class BRMSPush {
private void syncProject(String selectedName) {
boolean projectExists = checkProject(selectedName);
if (projectExists) {
- String version = null;
+ String version;
version = getVersion(selectedName);
if (version == null) {
LOGGER.error("Error getting local version for the given Controller Name:" + selectedName
@@ -599,7 +599,6 @@ public class BRMSPush {
}
fos.close();
is.close();
- f = null;
LOGGER.info(fileName + " Created..");
}
}
@@ -641,7 +640,7 @@ public class BRMSPush {
private boolean checkRemoteSync(String selectedName, String version) {
List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, version);
- return (artifacts.size() == 0) ? false : true;
+ return artifacts.isEmpty() ? false : true;
}
private List<NexusArtifact> getArtifactFromNexus(String selectedName, String version) {
@@ -690,7 +689,7 @@ public class BRMSPush {
if (artifact != null) {
newVersion = incrementVersion(artifact.getVersion());
}
- if (newVersion.equals("0.1.0")) {
+ if ("0.1.0".equals(newVersion)) {
createFlag = true;
}
setVersion(newVersion, selectedName);
@@ -736,8 +735,9 @@ public class BRMSPush {
}
if (!modifiedGroups.isEmpty()) {
Boolean flag = false;
- for (String group : modifiedGroups.keySet()) {
+ for (Map.Entry<String, String> entry : modifiedGroups.entrySet()) {
InvocationResult result = null;
+ String group = entry.getKey();
try {
InvocationRequest request = new DefaultInvocationRequest();
setVersion(group);
@@ -761,7 +761,7 @@ public class BRMSPush {
if (createFlag) {
addNotification(group, "create");
} else {
- addNotification(group, modifiedGroups.get(group));
+ addNotification(group, entry.getValue());
}
flag = true;
} else {
@@ -795,7 +795,7 @@ public class BRMSPush {
return policyMap.get(name);
} else {
syncGroupInfo();
- return (policyMap.containsKey(name)) ? policyMap.get(name) : null;
+ return policyMap.containsKey(name) ? policyMap.get(name) : null;
}
}
@@ -869,7 +869,7 @@ public class BRMSPush {
pub.send("MyPartitionKey", message);
final List<?> stuck = pub.close(uebDelay, TimeUnit.SECONDS);
- if (stuck.size() > 0) {
+ if (!stuck.isEmpty()) {
LOGGER.error(stuck.size() + " messages unsent");
} else {
LOGGER.debug("Clean exit; Message Published on UEB : " + uebList + "for Topic: " + pubTopic);
@@ -1018,7 +1018,7 @@ public class BRMSPush {
}
private void readGroups(Properties config) throws PolicyException {
- String[] groupNames = null;
+ String[] groupNames;
if (!config.containsKey("groupNames") || config.getProperty("groupNames")==null){
throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE
+ "groupNames property is missing or empty from the property file ");
@@ -1069,7 +1069,7 @@ public class BRMSPush {
query.setParameter("cn", name);
List<?> groupList = query.getResultList();
BRMSGroupInfo brmsGroupInfo = null;
- if (groupList.size() > 0) {
+ if (!groupList.isEmpty()) {
LOGGER.info("Controller name already Existing in DB. Will be updating the DB Values" + name);
brmsGroupInfo = (BRMSGroupInfo) groupList.get(0);
}
@@ -1122,8 +1122,8 @@ public class BRMSPush {
Query query = em.createQuery("select b from BRMSPolicyInfo as b where b.policyName = :pn");
query.setParameter("pn", policyName);
List<?> pList = query.getResultList();
- BRMSPolicyInfo brmsPolicyInfo = new BRMSPolicyInfo();
- if (pList.size() > 0) {
+ BRMSPolicyInfo brmsPolicyInfo;
+ if (!pList.isEmpty()) {
// Already exists.
brmsPolicyInfo = (BRMSPolicyInfo) pList.get(0);
if (brmsPolicyInfo.getControllerName().getControllerName().equals(controllerName)) {
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/ia/DbAuditCompareEntriesTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/ia/DbAuditCompareEntriesTest.java
index f913c181f..13255ba50 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/ia/DbAuditCompareEntriesTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/ia/DbAuditCompareEntriesTest.java
@@ -233,7 +233,7 @@ public class DbAuditCompareEntriesTest {
entry1.setFlag("flag1");
- entry1.setResoruceNodeName("node1");
+ entry1.setResourceNodeName("node1");
entry1.setResourceName("resourceName");
entry1.setTimeStamp(new Date());
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java
new file mode 100644
index 000000000..6600a9208
--- /dev/null
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.xacml.test.std.pap;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.xacml.api.pap.OnapPDP;
+import org.onap.policy.xacml.std.pap.StdEngine;
+
+import com.att.research.xacml.api.pap.PAPException;
+import com.att.research.xacml.std.pap.StdPDP;
+
+public class StdEngineTest {
+
+ private static Logger logger = FlexLogger.getLogger(StdEngineTest.class);
+ private Path repository;
+ Properties properties = new Properties();
+ StdEngine stdEngine = null;
+
+ @Before
+ public void setUp(){
+
+ repository = Paths.get("src/test/resources/pdps");
+ try {
+ stdEngine = new StdEngine(repository);
+ } catch (PAPException e) {
+ logger.info(e);
+ } catch (IOException e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetDefaultGroup(){
+ try {
+ assertTrue(stdEngine.getDefaultGroup() != null);
+ } catch (PAPException e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetGroup(){
+ try {
+ assertTrue(stdEngine.getGroup("1") == null);
+ } catch (PAPException e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetOnapPDPGroups(){
+ try {
+ assertTrue(stdEngine.getOnapPDPGroups() != null);
+ } catch (PAPException e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetPDP(){
+ try {
+ assertTrue(stdEngine.getPDP("1") == null);
+ } catch (PAPException e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetPDPGroup(){
+ try {
+ assertTrue(stdEngine.getPDPGroup(null) == null);
+ } catch (PAPException e) {
+ logger.info(e);
+ }
+ }
+}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java
new file mode 100644
index 000000000..da7476b67
--- /dev/null
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java
@@ -0,0 +1,543 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.xacml.test.std.pap;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.xacml.api.pap.OnapPDP;
+import org.onap.policy.xacml.std.pap.StdEngine;
+import org.onap.policy.xacml.std.pap.StdPAPPolicy;
+
+import com.att.research.xacml.api.pap.PAPException;
+import com.att.research.xacml.std.pap.StdPDP;
+
+public class StdPAPPolicyTest {
+
+ private static Logger logger = FlexLogger.getLogger(StdPAPPolicyTest.class);
+ private Path repository;
+ Properties properties = new Properties();
+ StdPAPPolicy stdPAPPolicy;
+
+ @Before
+ public void setUp(){
+
+ repository = Paths.get("src/test/resources/pdps");
+ try {
+ stdPAPPolicy = new StdPAPPolicy();
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetActionAttribute(){
+ try {
+ stdPAPPolicy.setActionAttribute("test");
+ assertTrue(stdPAPPolicy.getActionAttribute() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetActionBody(){
+ try {
+ stdPAPPolicy.setActionBody("actionBody");
+ assertTrue(stdPAPPolicy.getActionBody() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetActionDictHeader(){
+ try {
+ stdPAPPolicy.setActionDictHeader("actionDictHeader");
+ assertTrue(stdPAPPolicy.getActionDictHeader() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetActionDictMethod(){
+ try {
+ stdPAPPolicy.setActionDictMethod("actionDictMethod");
+ assertTrue(stdPAPPolicy.getActionDictMethod() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetActionDictType(){
+ try {
+ stdPAPPolicy.setActionDictType("actionDictType");
+ assertTrue(stdPAPPolicy.getActionDictType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetActionDictUrl(){
+ try {
+ stdPAPPolicy.setActionDictUrl("actionDictUrl");
+ assertTrue(stdPAPPolicy.getActionDictUrl() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetActionPerformer(){
+ try {
+ stdPAPPolicy.setActionPerformer("actionPerformer");
+ assertTrue(stdPAPPolicy.getActionPerformer() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetBrmsController(){
+ try {
+ stdPAPPolicy.setBrmsController("brmsController");
+ assertTrue(stdPAPPolicy.getBrmsController() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetBrmsDependency(){
+ try {
+ stdPAPPolicy.setBrmsDependency(new ArrayList());
+ assertTrue(stdPAPPolicy.getBrmsDependency() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetConfigBodyData(){
+ try {
+ stdPAPPolicy.setConfigBodyData("configBodyData");
+ assertTrue(stdPAPPolicy.getConfigBodyData() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+
+ @Test
+ public void testGetConfigName(){
+ try {
+ stdPAPPolicy.setConfigName("configName");
+ assertTrue(stdPAPPolicy.getConfigName() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetConfigPolicyType(){
+ try {
+ stdPAPPolicy.setConfigPolicyType("configPolicyType");
+ assertTrue(stdPAPPolicy.getConfigPolicyType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetConfigType(){
+ try {
+ stdPAPPolicy.setConfigType("configType");
+ assertTrue(stdPAPPolicy.getConfigType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDataTypeList(){
+ try {
+ stdPAPPolicy.setDataTypeList(new ArrayList<String>());
+ assertTrue(stdPAPPolicy.getDataTypeList() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetDeleteCondition(){
+ try {
+ stdPAPPolicy.setDeleteCondition("deleteCondition");
+ assertTrue(stdPAPPolicy.getDeleteCondition() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+
+ @Test
+ public void testGetDrlRuleAndUIParams(){
+ try {
+ stdPAPPolicy.setDrlRuleAndUIParams(new HashMap());
+ assertTrue(stdPAPPolicy.getDrlRuleAndUIParams() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDropDownMap(){
+ try {
+ stdPAPPolicy.setDropDownMap(new HashMap());
+ assertTrue(stdPAPPolicy.getDropDownMap() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetDynamicFieldConfigAttributes(){
+ try {
+ assertTrue(stdPAPPolicy.getDynamicFieldConfigAttributes() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDynamicRuleAlgorithmCombo(){
+ try {
+ stdPAPPolicy.setDynamicRuleAlgorithmCombo(new ArrayList());
+ assertTrue(stdPAPPolicy.getDynamicRuleAlgorithmCombo() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetDynamicRuleAlgorithmField1(){
+ try {
+ stdPAPPolicy.setDynamicRuleAlgorithmField1(new ArrayList());
+ assertTrue(stdPAPPolicy.getDynamicRuleAlgorithmField1() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetDictionary(){
+ try {
+ stdPAPPolicy.setDictionary("dictionary");
+ assertTrue(stdPAPPolicy.getDictionary() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDictionaryFields(){
+ try {
+ stdPAPPolicy.setDictionaryFields("dictionaryFields");
+ assertTrue(stdPAPPolicy.getDictionaryFields() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetDictionaryType(){
+ try {
+ stdPAPPolicy.setDictionaryType("dictionaryType");
+ assertTrue(stdPAPPolicy.getDictionaryType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDomainDir(){
+ try {
+ stdPAPPolicy.setDomainDir("domain");
+ assertTrue(stdPAPPolicy.getDomainDir() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testIsDraft(){
+ try {
+ stdPAPPolicy.setDraft(true);
+ assertTrue(stdPAPPolicy.isDraft() == true);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetDynamicRuleAlgorithmLabels(){
+ try {
+ stdPAPPolicy.setDynamicRuleAlgorithmLabels(new ArrayList());
+ assertTrue(stdPAPPolicy.getDynamicRuleAlgorithmLabels() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDynamicSettingsMap(){
+ try {
+ stdPAPPolicy.setDynamicSettingsMap(new HashMap());
+ assertTrue(stdPAPPolicy.getDynamicSettingsMap() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetDynamicVariableList(){
+ try {
+ stdPAPPolicy.setDynamicVariableList(new ArrayList());
+ assertTrue(stdPAPPolicy.getDynamicVariableList() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetGuard(){
+ try {
+ stdPAPPolicy.setGuard("domain");
+ assertTrue(stdPAPPolicy.getGuard() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetHighestVersion(){
+ try {
+ stdPAPPolicy.setHighestVersion(123);
+ assertTrue(stdPAPPolicy.getHighestVersion() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testgGtJsonBody(){
+ try {
+ stdPAPPolicy.setJsonBody("jsonBoby");
+ assertTrue(stdPAPPolicy.getJsonBody() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetLocation(){
+ try {
+ stdPAPPolicy.setLocation(new URI("test"));
+ assertTrue(stdPAPPolicy.getLocation() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetMsLocation(){
+ try {
+ stdPAPPolicy.setMsLocation("MsLocation");
+ assertTrue(stdPAPPolicy.getMsLocation() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testSetOldPolicyFileName(){
+ try {
+ stdPAPPolicy.setOldPolicyFileName("domain");
+ assertTrue(stdPAPPolicy.getOldPolicyFileName() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetOnapName(){
+ try {
+ stdPAPPolicy.setOnapName("onap");
+ assertTrue(stdPAPPolicy.getOnapName() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetPolicyDescription(){
+ try {
+ stdPAPPolicy.setPolicyDescription("description test");
+ assertTrue(stdPAPPolicy.getPolicyDescription() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetPolicyID(){
+ try {
+ stdPAPPolicy.setPolicyID("test");
+ assertTrue(stdPAPPolicy.getPolicyID() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testSetPolicyName(){
+ try {
+ stdPAPPolicy.setPolicyName("MsLocation");
+ assertTrue(stdPAPPolicy.getPolicyName() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testSetPriority(){
+ try {
+ stdPAPPolicy.setPriority("domain");
+ assertTrue(stdPAPPolicy.getPriority() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetProviderComboBox(){
+ try {
+ stdPAPPolicy.setProviderComboBox("onap");
+ assertTrue(stdPAPPolicy.getProviderComboBox() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetRiskLevel(){
+ try {
+ stdPAPPolicy.setRiskLevel("test");
+ assertTrue(stdPAPPolicy.getRiskLevel() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetRiskType(){
+ try {
+ stdPAPPolicy.setRiskType("test");
+ assertTrue(stdPAPPolicy.getRiskType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetRuleID(){
+ try {
+ stdPAPPolicy.setRuleID("MsLocation");
+ assertTrue(stdPAPPolicy.getRuleID() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetServiceType(){
+ try {
+ stdPAPPolicy.setServiceType("domain");
+ assertTrue(stdPAPPolicy.getServiceType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetTTLDate(){
+ try {
+ stdPAPPolicy.setTTLDate("09/20/17");
+ assertTrue(stdPAPPolicy.getTTLDate() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+
+ @Test
+ public void testGetUuid(){
+ try {
+ stdPAPPolicy.setUuid("11212122");
+ assertTrue(stdPAPPolicy.getUuid() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetVersion(){
+ try {
+ stdPAPPolicy.setVersion("testv01");
+ assertTrue(stdPAPPolicy.getVersion() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testIsEditPolicy(){
+ try {
+ stdPAPPolicy.setEditPolicy(true);
+ assertTrue(stdPAPPolicy.isEditPolicy() == true);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testToString(){
+ try {
+ assertTrue(stdPAPPolicy.toString() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
index a0f1ba86d..7c60ecfdf 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
@@ -202,7 +202,7 @@ class HtmlProcessor extends SimpleCallback {
combiningAlgo2human.put("only-one-applicable", "to honour the result of the first successfully evaluated $placeholder$ in order");
}
- private Map<String, AttributeIdentifiers> attributeIdentifiersMap = new HashMap<String, AttributeIdentifiers>();
+ private Map<String, AttributeIdentifiers> attributeIdentifiersMap = new HashMap<>();
private final StringWriter stringWriter = new StringWriter();
private final PrintWriter htmlOut = new PrintWriter(stringWriter);
@@ -357,7 +357,7 @@ class HtmlProcessor extends SimpleCallback {
else
policySet(policySet, "li");
- if (policySet.getPolicySetOrPolicyOrPolicySetIdReference().size() > 0)
+ if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty())
htmlOut.println("<ol>");
return super.onPreVisitPolicySet(parent, policySet);
@@ -377,7 +377,7 @@ class HtmlProcessor extends SimpleCallback {
LOGGER.trace("PolicySet: " + policySet.getPolicySetId() +
" Description: " + policySet.getDescription());
- if (policySet.getPolicySetOrPolicyOrPolicySetIdReference().size() > 0)
+ if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty())
htmlOut.println("</ol>");
htmlOut.println("<p></p>");
@@ -421,7 +421,7 @@ class HtmlProcessor extends SimpleCallback {
}
if (policySet.getPolicySetOrPolicyOrPolicySetIdReference() != null &&
- policySet.getPolicySetOrPolicyOrPolicySetIdReference().size() > 0) {
+ !policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) {
String algoDesc = combiningAlgo2human.get(combiningAlgorithm);
if (algoDesc != null) {
algoDesc = algoDesc.replace("$placeholder$", "policy") + " (" + "<i>" + combiningAlgorithm + "</i>)";
@@ -449,7 +449,7 @@ class HtmlProcessor extends SimpleCallback {
policy(policy);
- if (policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().size() > 0)
+ if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty())
htmlOut.println("<ol type=\"i\">");
return super.onPreVisitPolicy(parent, policy);
@@ -464,7 +464,7 @@ class HtmlProcessor extends SimpleCallback {
LOGGER.trace("PolicySet: " + policy.getPolicyId() +
"Parent PolicySet: " + parent.getPolicySetId() + " Version: " + parent.getVersion());
- if (policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().size() > 0)
+ if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty())
htmlOut.println("</ol>");
htmlOut.println("<p></p>");
@@ -506,7 +506,7 @@ class HtmlProcessor extends SimpleCallback {
}
if (policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition() != null &&
- policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().size() > 0) {
+ !policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty()) {
String algoDesc = combiningAlgo2human.get(combiningAlgorithm);
if (algoDesc != null) {
algoDesc = algoDesc.replace("$placeholder$", "rule") + " (<i>" + combiningAlgorithm + "</i>)";
@@ -710,7 +710,7 @@ class HtmlProcessor extends SimpleCallback {
//
StdAttribute attribute = null;
AttributeValueType value = match.getAttributeValue();
- String attributeDataType = null;
+ String attributeDataType;
if (match.getAttributeDesignator() != null && value != null) {
AttributeDesignatorType designator = match.getAttributeDesignator();
attribute = new StdAttribute(new IdentifierImpl(designator.getCategory()),
@@ -822,11 +822,12 @@ class HtmlProcessor extends SimpleCallback {
}
private String removePrimitives(String in) {
- in = in.replace("string-", "");
- in = in.replace("integer-", "");
- in = in.replace("double-", "");
- in = in.replace("boolean-", "");
- return in;
+ String newIn = in;
+ newIn = newIn.replace("string-", "");
+ newIn = newIn.replace("integer-", "");
+ newIn = newIn.replace("double-", "");
+ newIn = newIn.replace("boolean-", "");
+ return newIn;
}
private String stringifyCondition(ConditionType condition) {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java
index 353e08a44..32f40b9e7 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java
@@ -64,4 +64,6 @@ public class HibernateSession{
logSessionFactory = logSessionFactory1;
}
+ private HibernateSession(){
+ }
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java
index f10041e38..392adf039 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java
@@ -98,24 +98,24 @@ public class CreateClosedLoopPMController{
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
}
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
}
- if (attributeId.equals("ServiceType")){
+ if ("ServiceType".equals(attributeId)){
LinkedHashMap<String, String> serviceTypePolicyName1 = new LinkedHashMap<>();
String key = "serviceTypePolicyName";
serviceTypePolicyName1.put(key, value);
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java
index 25636fb45..862b654b8 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java
@@ -21,37 +21,39 @@
package org.onap.policy.api;
import java.util.Map;
+
/**
* <code>LoadedPolicy</code> defines the Policy that has been Loaded into the PDP.
- *
- * @version 0.2
+ *
+ * @version 0.2
*/
public interface LoadedPolicy {
- /**
- * Gets the <code>String</code> format of the Policy Name that has been Loaded into the PDP.
- *
- * @return <code>String</code> format of Policy Name
- */
- public String getPolicyName();
-
- /**
- * Gets the <code>String</code> format of the Policy Version that has been Loaded into the PDP.
- *
- * @return <code>String</code> format of the Policy Version.
- */
- public String getVersionNo();
-
- /**
- * Gets the <code>Map</code> of <code>String,String</code> format of the Matches if the policy Loaded is of Config Type.
- *
- * @return the <code>Map</code> of <code>String,String</code> format of the matches in the policy.
- */
- public Map<String, String> getMatches();
-
- /**
- * Gets the <code>UpdateType</code> of {@link org.onap.policy.api.UpdateType} received.
- *
- * @return <code>UpdateType</code> associated with this <code>PDPNotification</code>
- */
- public UpdateType getUpdateType();
+
+ /**
+ * Gets the <code>String</code> format of the Policy Name that has been Loaded into the PDP.
+ *
+ * @return <code>String</code> format of Policy Name
+ */
+ String getPolicyName();
+
+ /**
+ * Gets the <code>String</code> format of the Policy Version that has been Loaded into the PDP.
+ *
+ * @return <code>String</code> format of the Policy Version.
+ */
+ String getVersionNo();
+
+ /**
+ * Gets the <code>Map</code> of <code>String,String</code> format of the Matches if the policy Loaded is of Config Type.
+ *
+ * @return the <code>Map</code> of <code>String,String</code> format of the matches in the policy.
+ */
+ Map<String, String> getMatches();
+
+ /**
+ * Gets the <code>UpdateType</code> of {@link org.onap.policy.api.UpdateType} received.
+ *
+ * @return <code>UpdateType</code> associated with this <code>PDPNotification</code>
+ */
+ UpdateType getUpdateType();
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
index 837eba967..78b79a08f 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
@@ -19,17 +19,20 @@
*/
package org.onap.policy.api;
+
/**
* Defines the methods which need to run when an Event or Notification is received.
- *
+ *
* @version 0.1
*/
@FunctionalInterface
public interface NotificationHandler {
- /**
- * <code>notificationReceived</code> method will be triggered automatically whenever a Notification is received by the PEP.
- *
- * @param notification <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification} is the object that has information of the notification.
- */
- public void notificationReceived(PDPNotification notification);
+
+ /**
+ * <code>notificationReceived</code> method will be triggered automatically whenever a Notification is received by the PEP.
+ *
+ * @param notification <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification}
+ * is the object that has information of the notification.
+ */
+ void notificationReceived(PDPNotification notification);
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java
index 730ad022d..8b65a420d 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java
@@ -23,36 +23,35 @@ package org.onap.policy.api;
/**
* Enumeration of the Update Type that has occurred in the <code>PDPNotification</code> of
* {@link org.onap.policy.api.PDPNotification}
- *
+ *
* @version 0.1
*/
public enum NotificationType {
- /**
- * Indicates that a policy has been updated
- */
- UPDATE("update"),
- /**
- * Indicates that a policy has been removed
- */
- REMOVE("remove"),
- /**
- * Indicates that both update and removal of policy events has occurred.
- */
- BOTH("both")
- ;
-
- private String name;
-
- private NotificationType(String name){
- this.name = name;
- }
-
- /**
- * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>
- * @return the <code>String</code> Type of <code>UpdateType</code>
- */
- @Override
- public String toString(){
- return this.name;
- }
+ /**
+ * Indicates that a policy has been updated
+ */
+ UPDATE("update"),
+ /**
+ * Indicates that a policy has been removed
+ */
+ REMOVE("remove"),
+ /**
+ * Indicates that both update and removal of policy events has occurred.
+ */
+ BOTH("both");
+
+ private String name;
+
+ NotificationType(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>
+ * @return the <code>String</code> Type of <code>UpdateType</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java
index a88ec06cb..9ab508281 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java
@@ -24,29 +24,29 @@ import java.util.Collection;
/**
* Defines the <code>Notification</code> event sent from PDP to Client PEP.
- *
+ *
* @version 0.2
*/
public interface PDPNotification {
- /**
- * Gets the <code>Collection</code> of {@link org.onap.policy.api.RemovedPolicy} objects received.
- *
- * @return the <code>Collection</code> which consists of <code>RemovedPolicy</code> objects.
- */
- public Collection<RemovedPolicy> getRemovedPolicies();
-
- /**
- * Gets the <code>Collection</code> of {@link org.onap.policy.api.LoadedPolicy} objects receieved.
- *
- * @return the <code>Collection</code> which consists of <code>UpdatedPolicy</code> objects.
- */
- public Collection<LoadedPolicy> getLoadedPolicies();
-
- /**
- * Gets the <code>NotificationType</code> of {@link org.onap.policy.api.NotificationType} received.
- *
- * @return <code>NotificationType</code> associated with this <code>PDPNotification</code>
- */
- public NotificationType getNotificationType();
-
+
+ /**
+ * Gets the <code>Collection</code> of {@link org.onap.policy.api.RemovedPolicy} objects received.
+ *
+ * @return the <code>Collection</code> which consists of <code>RemovedPolicy</code> objects.
+ */
+ Collection<RemovedPolicy> getRemovedPolicies();
+
+ /**
+ * Gets the <code>Collection</code> of {@link org.onap.policy.api.LoadedPolicy} objects receieved.
+ *
+ * @return the <code>Collection</code> which consists of <code>UpdatedPolicy</code> objects.
+ */
+ Collection<LoadedPolicy> getLoadedPolicies();
+
+ /**
+ * Gets the <code>NotificationType</code> of {@link org.onap.policy.api.NotificationType} received.
+ *
+ * @return <code>NotificationType</code> associated with this <code>PDPNotification</code>
+ */
+ NotificationType getNotificationType();
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java
index f26c1499a..e8125a1dc 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java
@@ -19,23 +19,25 @@
*/
package org.onap.policy.api;
+
/**
* <code>RemovedPolicy</code> defines the Policy that has been removed
- *
+ *
* @version 0.1
*/
public interface RemovedPolicy {
- /**
- * Gets the <code>String</code> format of the Policy Name that has been removed.
- *
- * @return <code>String</code> format of Policy Name
- */
- public String getPolicyName();
-
- /**
- * Gets the <code>String</code> format of the Policy Version that has been removed.
- *
- * @return <code>String</code> format of Policy Version
- */
- public String getVersionNo();
+
+ /**
+ * Gets the <code>String</code> format of the Policy Name that has been removed.
+ *
+ * @return <code>String</code> format of Policy Name
+ */
+ String getPolicyName();
+
+ /**
+ * Gets the <code>String</code> format of the Policy Version that has been removed.
+ *
+ * @return <code>String</code> format of Policy Version
+ */
+ String getVersionNo();
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java
index deeecddd0..7f401fec0 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java
@@ -23,32 +23,31 @@ package org.onap.policy.api;
/**
* Enumeration of the Update Type that has occurred in the <code>UpdatedPolicy</code> of
* {@link org.onap.policy.api.LoadedPolicy}
- *
+ *
* @version 0.1
*/
public enum UpdateType {
- /**
- * Indicates that a policy has been updated
- */
- UPDATE("update"),
- /**
- * Indicates that a policy is new
- */
- NEW("new")
- ;
-
- private String name;
-
- private UpdateType(String name){
- this.name = name;
- }
-
- /**
- * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>
- * @return the <code>String</code> Type of <code>UpdateType</code>
- */
- @Override
- public String toString(){
- return this.name;
- }
+ /**
+ * Indicates that a policy has been updated
+ */
+ UPDATE("update"),
+ /**
+ * Indicates that a policy is new
+ */
+ NEW("new");
+
+ private String name;
+
+ UpdateType(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>
+ * @return the <code>String</code> Type of <code>UpdateType</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java b/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java
index f2e7f3ff8..1bfffce6c 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java
@@ -22,7 +22,6 @@ package org.onap.policy.jpa;
import java.io.Serializable;
import java.util.Date;
-
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -38,80 +37,81 @@ import javax.persistence.TemporalType;
@Entity
-@Table(name="BackUpMonitorEntity")
-@NamedQuery(name="BackUpMonitorEntity.findAll", query= "SELECT b FROM BackUpMonitorEntity b ")
-public class BackUpMonitorEntity implements Serializable{
- private static final long serialVersionUID = -9190606334322230630L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
- private int id;
-
- @Column(name="node_name", nullable=false)
- private String resourceNodeName;
-
- @Column(name="resource_name", nullable=false, unique=true)
- private String resourceName;
-
- @Column(name="flag", nullable=false)
- private String flag;
-
- @Lob
- @Column(name="notification_record")
- private String notificationRecord;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="last_seen")
- private Date timeStamp;
-
- @PrePersist
- public void prePersist(){
- this.timeStamp = new Date();
- }
-
- @PreUpdate
- public void preUpdate(){
- this.timeStamp = new Date();
- }
-
- public String getResourceName(){
- return this.resourceName;
- }
-
- public String getResourceNodeName(){
- return this.resourceNodeName;
- }
-
- public String getFlag(){
- return this.flag;
- }
-
- public String getNotificationRecord(){
- return this.notificationRecord;
- }
-
- public Date getTimeStamp(){
- return this.timeStamp;
- }
-
- public void setResourceName(String resourceName){
- this.resourceName = resourceName;
- }
-
- public void setResoruceNodeName(String resourceNodeName){
- this.resourceNodeName = resourceNodeName;
- }
-
- public void setFlag(String flag){
- this.flag = flag;
- }
-
- public void setNotificationRecord(String notificationRecord){
- this.notificationRecord = notificationRecord;
- }
-
- public void setTimeStamp(Date timeStamp){
- this.timeStamp = timeStamp;
- }
+@Table(name = "BackUpMonitorEntity")
+@NamedQuery(name = "BackUpMonitorEntity.findAll", query = "SELECT b FROM BackUpMonitorEntity b ")
+public class BackUpMonitorEntity implements Serializable {
+
+ private static final long serialVersionUID = -9190606334322230630L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private int id;
+
+ @Column(name = "node_name", nullable = false)
+ private String resourceNodeName;
+
+ @Column(name = "resource_name", nullable = false, unique = true)
+ private String resourceName;
+
+ @Column(name = "flag", nullable = false)
+ private String flag;
+
+ @Lob
+ @Column(name = "notification_record")
+ private String notificationRecord;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "last_seen")
+ private Date timeStamp;
+
+ @PrePersist
+ public void prePersist() {
+ this.timeStamp = new Date();
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.timeStamp = new Date();
+ }
+
+ public String getResourceName() {
+ return this.resourceName;
+ }
+
+ public String getResourceNodeName() {
+ return this.resourceNodeName;
+ }
+
+ public String getFlag() {
+ return this.flag;
+ }
+
+ public String getNotificationRecord() {
+ return this.notificationRecord;
+ }
+
+ public Date getTimeStamp() {
+ return this.timeStamp;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public void setResourceNodeName(String resourceNodeName) {
+ this.resourceNodeName = resourceNodeName;
+ }
+
+ public void setFlag(String flag) {
+ this.flag = flag;
+ }
+
+ public void setNotificationRecord(String notificationRecord) {
+ this.notificationRecord = notificationRecord;
+ }
+
+ public void setTimeStamp(Date timeStamp) {
+ this.timeStamp = timeStamp;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java b/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
index 259a70d37..8c6c9580d 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
@@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
-
import org.onap.policy.api.LoadedPolicy;
import org.onap.policy.api.NotificationType;
import org.onap.policy.api.PDPNotification;
@@ -38,229 +37,221 @@ import org.onap.policy.api.RemovedPolicy;
*
*/
public class NotificationStore {
- private static StdPDPNotification notificationRecord = new StdPDPNotification();
-
- public static StdPDPNotification getDeltaNotification(StdPDPNotification newNotification){
- StdPDPNotification notificationDelta = new StdPDPNotification();
- ArrayList<StdRemovedPolicy> removedDelta = new ArrayList<>();
- ArrayList<StdLoadedPolicy> updatedDelta = new ArrayList<>();
- Collection<StdLoadedPolicy> newUpdatedPolicies = new ArrayList<>();
- Collection<StdRemovedPolicy> newRemovedPolicies = new ArrayList<>();
- Collection<LoadedPolicy> oldUpdatedLostPolicies = notificationRecord.getLoadedPolicies();
- Collection<RemovedPolicy> oldRemovedPolicies = notificationRecord.getRemovedPolicies();
- Collection<LoadedPolicy> oldUpdatedPolicies = notificationRecord.getLoadedPolicies();
- Boolean update = false;
- Boolean remove = false;
- // if the NotificationRecord is empty
- if(notificationRecord.getRemovedPolicies()==null || notificationRecord.getLoadedPolicies()==null){
- if(newNotification!=null){
- notificationRecord = newNotification;
- }
- return notificationDelta;
- }
- // do the Delta operation.
- if(newNotification!=null){
- // check for old removed policies.
- if(!newNotification.getRemovedPolicies().isEmpty()){
- for(RemovedPolicy newRemovedPolicy: newNotification.getRemovedPolicies()){
- //Look for policy Not in Remove
- Boolean removed = true;
- for(RemovedPolicy oldRemovedPolicy: notificationRecord.getRemovedPolicies()){
- if(newRemovedPolicy.getPolicyName().equals(oldRemovedPolicy.getPolicyName())){
- if(newRemovedPolicy.getVersionNo().equals(oldRemovedPolicy.getVersionNo())){
- removed = false;
- // Don't want a duplicate.
- oldRemovedPolicies.remove(oldRemovedPolicy);
- }
- }
- }
- //We need to change our record we have an Update record of this remove.
- for(LoadedPolicy oldUpdatedPolicy: notificationRecord.getLoadedPolicies()){
- if(newRemovedPolicy.getPolicyName().equals(oldUpdatedPolicy.getPolicyName())){
- if(newRemovedPolicy.getVersionNo().equals(oldUpdatedPolicy.getVersionNo())){
- oldUpdatedPolicies.remove(oldUpdatedPolicy);
- oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
- }
- }
- }
- if(removed){
- remove = true;
- notificationRecord.getRemovedPolicies().add(newRemovedPolicy);
- removedDelta.add((StdRemovedPolicy)newRemovedPolicy);
- }
- // This will be converted to New Later.
- oldRemovedPolicies.add(newRemovedPolicy);
- }
- }
- // Check for old Updated Policies.
- if(!newNotification.getLoadedPolicies().isEmpty()){
- for(LoadedPolicy newUpdatedPolicy: newNotification.getLoadedPolicies()){
- // Look for policies which are not in Update
- Boolean updated = true;
- for(LoadedPolicy oldUpdatedPolicy: notificationRecord.getLoadedPolicies()){
- if(newUpdatedPolicy.getPolicyName().equals(oldUpdatedPolicy.getPolicyName())){
- if(newUpdatedPolicy.getVersionNo().equals(oldUpdatedPolicy.getVersionNo())){
- updated = false;
- // Remove the policy from copy.
- oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
- // Eliminating Duplicate.
- oldUpdatedPolicies.remove(oldUpdatedPolicy);
- }
- }
- }
- // Change the record if the policy has been Removed earlier.
- for(RemovedPolicy oldRemovedPolicy: notificationRecord.getRemovedPolicies()){
- if(oldRemovedPolicy.getPolicyName().equals(newUpdatedPolicy.getPolicyName())){
- if(oldRemovedPolicy.getVersionNo().equals(newUpdatedPolicy.getVersionNo())){
- oldRemovedPolicies.remove(oldRemovedPolicy);
- }
- }
- }
- if(updated){
- update = true;
- updatedDelta.add((StdLoadedPolicy)newUpdatedPolicy);
- }
- // This will be converted to new Later
- oldUpdatedPolicies.add(newUpdatedPolicy);
- }
- // Conversion of Update to Remove if that occurred.
- if(!oldUpdatedLostPolicies.isEmpty()){
- for(LoadedPolicy updatedPolicy: oldUpdatedLostPolicies){
- StdRemovedPolicy removedPolicy = new StdRemovedPolicy();
- removedPolicy.setPolicyName(updatedPolicy.getPolicyName());
- removedPolicy.setVersionNo(updatedPolicy.getVersionNo());
- removedDelta.add(removedPolicy);
- remove = true;
- }
- }
- }
- // Update our Record.
- if(!oldUpdatedPolicies.isEmpty()){
- for(LoadedPolicy updatedPolicy: oldUpdatedPolicies){
- newUpdatedPolicies.add((StdLoadedPolicy)updatedPolicy);
- }
- }
- if(!oldRemovedPolicies.isEmpty()){
- for(RemovedPolicy removedPolicy: oldRemovedPolicies){
- newRemovedPolicies.add((StdRemovedPolicy)removedPolicy);
- }
- }
- notificationRecord.setRemovedPolicies(newRemovedPolicies);
- notificationRecord.setLoadedPolicies(newUpdatedPolicies);
- // Update the notification Result.
- notificationDelta.setRemovedPolicies(removedDelta);
- notificationDelta.setLoadedPolicies(updatedDelta);
- if(remove&&update){
- notificationDelta.setNotificationType(NotificationType.BOTH);
- }else if(remove){
- notificationDelta.setNotificationType(NotificationType.REMOVE);
- }else if(update){
- notificationDelta.setNotificationType(NotificationType.UPDATE);
- }
- }
- return notificationDelta;
- }
-
- public static void recordNotification(StdPDPNotification notification){
- if(notification!=null){
- if(notificationRecord.getRemovedPolicies()==null || notificationRecord.getLoadedPolicies()==null){
- notificationRecord = notification;
- }else{
- // Check if there is anything new and update the record.
- if(notificationRecord.getLoadedPolicies()!=null || notificationRecord.getRemovedPolicies()!=null){
- HashSet<StdRemovedPolicy> removedPolicies = new HashSet<>();
- for(RemovedPolicy rPolicy: notificationRecord.getRemovedPolicies()){
- StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
- sRPolicy.setPolicyName(rPolicy.getPolicyName());
- sRPolicy.setVersionNo(rPolicy.getVersionNo());
- removedPolicies.add(sRPolicy);
- }
- HashSet<StdLoadedPolicy> updatedPolicies = new HashSet<>();
- for(LoadedPolicy uPolicy: notificationRecord.getLoadedPolicies()){
- StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
- sUPolicy.setMatches(uPolicy.getMatches());
- sUPolicy.setPolicyName(uPolicy.getPolicyName());
- sUPolicy.setVersionNo(uPolicy.getVersionNo());
- sUPolicy.setUpdateType(uPolicy.getUpdateType());
- updatedPolicies.add(sUPolicy);
- }
-
- // Checking with the new updated policies.
- if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
- for(LoadedPolicy newUpdatedPolicy: notification.getLoadedPolicies()){
- // If it was removed earlier then we need to remove from our record
- Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
- while(oldRemovedPolicy.hasNext()){
- RemovedPolicy policy = oldRemovedPolicy.next();
- if(newUpdatedPolicy.getPolicyName().equals(policy.getPolicyName())) {
- if(newUpdatedPolicy.getVersionNo().equals(policy.getVersionNo())) {
- oldRemovedPolicy.remove();
- }
- }
- }
- // If it was previously updated need to Overwrite it to the record.
- Iterator<StdLoadedPolicy> oldUpdatedPolicy = updatedPolicies.iterator();
- while(oldUpdatedPolicy.hasNext()){
- LoadedPolicy policy = oldUpdatedPolicy.next();
- if(newUpdatedPolicy.getPolicyName().equals(policy.getPolicyName())) {
- if(newUpdatedPolicy.getVersionNo().equals(policy.getVersionNo())) {
- oldUpdatedPolicy.remove();
- }
- }
- }
- StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
- sUPolicy.setMatches(newUpdatedPolicy.getMatches());
- sUPolicy.setPolicyName(newUpdatedPolicy.getPolicyName());
- sUPolicy.setVersionNo(newUpdatedPolicy.getVersionNo());
- sUPolicy.setUpdateType(newUpdatedPolicy.getUpdateType());
- updatedPolicies.add(sUPolicy);
- }
- }
- // Checking with New Removed Policies.
- if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
- for(RemovedPolicy newRemovedPolicy : notification.getRemovedPolicies()){
- // If it was previously removed Overwrite it to the record.
- Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
- while(oldRemovedPolicy.hasNext()){
- RemovedPolicy policy = oldRemovedPolicy.next();
- if(newRemovedPolicy.getPolicyName().equals(policy.getPolicyName())) {
- if(newRemovedPolicy.getVersionNo().equals(policy.getVersionNo())) {
- oldRemovedPolicy.remove();
- }
- }
- }
- // If it was added earlier then we need to remove from our record.
- Iterator<StdLoadedPolicy> oldUpdatedPolicy = updatedPolicies.iterator();
- while(oldUpdatedPolicy.hasNext()){
- LoadedPolicy policy = oldUpdatedPolicy.next();
- if(newRemovedPolicy.getPolicyName().equals(policy.getPolicyName())) {
- if(newRemovedPolicy.getVersionNo().equals(policy.getVersionNo())) {
- oldUpdatedPolicy.remove();
- }
- }
- }
- StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
- sRPolicy.setPolicyName(newRemovedPolicy.getPolicyName());
- sRPolicy.setVersionNo(newRemovedPolicy.getVersionNo());
- removedPolicies.add(sRPolicy);
- }
- }
- notificationRecord.setRemovedPolicies(removedPolicies);
- notificationRecord.setLoadedPolicies(updatedPolicies);
- }
- if(!notificationRecord.getLoadedPolicies().isEmpty() && !notificationRecord.getRemovedPolicies().isEmpty()){
- notificationRecord.setNotificationType(NotificationType.BOTH);
- }else if(!notificationRecord.getLoadedPolicies().isEmpty()){
- notificationRecord.setNotificationType(NotificationType.UPDATE);
- }else if(!notificationRecord.getRemovedPolicies().isEmpty()){
- notificationRecord.setNotificationType(NotificationType.REMOVE);
- }
- }
- }
- }
-
- // This should return the current Notification Record.
- public static PDPNotification getNotificationRecord(){
- return notificationRecord;
- }
+
+ private static StdPDPNotification notificationRecord = new StdPDPNotification();
+
+ public static StdPDPNotification getDeltaNotification(StdPDPNotification newNotification) {
+ StdPDPNotification notificationDelta = new StdPDPNotification();
+ ArrayList<StdRemovedPolicy> removedDelta = new ArrayList<>();
+ ArrayList<StdLoadedPolicy> updatedDelta = new ArrayList<>();
+ Collection<StdLoadedPolicy> newUpdatedPolicies = new ArrayList<>();
+ Collection<StdRemovedPolicy> newRemovedPolicies = new ArrayList<>();
+ Collection<LoadedPolicy> oldUpdatedLostPolicies = notificationRecord.getLoadedPolicies();
+ Collection<RemovedPolicy> oldRemovedPolicies = notificationRecord.getRemovedPolicies();
+ Collection<LoadedPolicy> oldUpdatedPolicies = notificationRecord.getLoadedPolicies();
+ Boolean update = false;
+ Boolean remove = false;
+ // if the NotificationRecord is empty
+ if (notificationRecord.getRemovedPolicies() == null || notificationRecord.getLoadedPolicies() == null) {
+ if (newNotification != null) {
+ notificationRecord = newNotification;
+ }
+ return notificationDelta;
+ }
+ // do the Delta operation.
+ if (newNotification != null) {
+ // check for old removed policies.
+ if (!newNotification.getRemovedPolicies().isEmpty()) {
+ for (RemovedPolicy newRemovedPolicy : newNotification.getRemovedPolicies()) {
+ //Look for policy Not in Remove
+ Boolean removed = true;
+ String policyName = newRemovedPolicy.getPolicyName();
+ String ver = newRemovedPolicy.getVersionNo();
+ for (RemovedPolicy oldRemovedPolicy : notificationRecord.getRemovedPolicies()) {
+ if (policyName.equals(oldRemovedPolicy.getPolicyName())
+ && ver.equals(oldRemovedPolicy.getVersionNo())) {
+ removed = false;
+ // Don't want a duplicate.
+ oldRemovedPolicies.remove(oldRemovedPolicy);
+ }
+ }
+ //We need to change our record we have an Update record of this remove.
+ for (LoadedPolicy oldUpdatedPolicy : notificationRecord.getLoadedPolicies()) {
+ if (policyName.equals(oldUpdatedPolicy.getPolicyName())
+ && ver.equals(oldUpdatedPolicy.getVersionNo())) {
+ oldUpdatedPolicies.remove(oldUpdatedPolicy);
+ oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
+ }
+ }
+ if (removed) {
+ remove = true;
+ notificationRecord.getRemovedPolicies().add(newRemovedPolicy);
+ removedDelta.add((StdRemovedPolicy) newRemovedPolicy);
+ }
+ // This will be converted to New Later.
+ oldRemovedPolicies.add(newRemovedPolicy);
+ }
+ }
+ // Check for old Updated Policies.
+ if (!newNotification.getLoadedPolicies().isEmpty()) {
+ for (LoadedPolicy newUpdatedPolicy : newNotification.getLoadedPolicies()) {
+ // Look for policies which are not in Update
+ Boolean updated = true;
+ String policyName = newUpdatedPolicy.getPolicyName();
+ String ver = newUpdatedPolicy.getVersionNo();
+ for (LoadedPolicy oldUpdatedPolicy : notificationRecord.getLoadedPolicies()) {
+ if (policyName.equals(oldUpdatedPolicy.getPolicyName())
+ && ver.equals(oldUpdatedPolicy.getVersionNo())) {
+ updated = false;
+ // Remove the policy from copy.
+ oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
+ // Eliminating Duplicate.
+ oldUpdatedPolicies.remove(oldUpdatedPolicy);
+ }
+ }
+ // Change the record if the policy has been Removed earlier.
+ for (RemovedPolicy oldRemovedPolicy : notificationRecord.getRemovedPolicies()) {
+ if (oldRemovedPolicy.getPolicyName().equals(policyName)
+ && oldRemovedPolicy.getVersionNo().equals(ver)) {
+ oldRemovedPolicies.remove(oldRemovedPolicy);
+ }
+ }
+ if (updated) {
+ update = true;
+ updatedDelta.add((StdLoadedPolicy) newUpdatedPolicy);
+ }
+ // This will be converted to new Later
+ oldUpdatedPolicies.add(newUpdatedPolicy);
+ }
+ // Conversion of Update to Remove if that occurred.
+ if (!oldUpdatedLostPolicies.isEmpty()) {
+ for (LoadedPolicy updatedPolicy : oldUpdatedLostPolicies) {
+ StdRemovedPolicy removedPolicy = new StdRemovedPolicy();
+ removedPolicy.setPolicyName(updatedPolicy.getPolicyName());
+ removedPolicy.setVersionNo(updatedPolicy.getVersionNo());
+ removedDelta.add(removedPolicy);
+ remove = true;
+ }
+ }
+ }
+ // Update our Record.
+ if (!oldUpdatedPolicies.isEmpty()) {
+ for (LoadedPolicy updatedPolicy : oldUpdatedPolicies) {
+ newUpdatedPolicies.add((StdLoadedPolicy) updatedPolicy);
+ }
+ }
+ if (!oldRemovedPolicies.isEmpty()) {
+ for (RemovedPolicy removedPolicy : oldRemovedPolicies) {
+ newRemovedPolicies.add((StdRemovedPolicy) removedPolicy);
+ }
+ }
+ notificationRecord.setRemovedPolicies(newRemovedPolicies);
+ notificationRecord.setLoadedPolicies(newUpdatedPolicies);
+ // Update the notification Result.
+ notificationDelta.setRemovedPolicies(removedDelta);
+ notificationDelta.setLoadedPolicies(updatedDelta);
+ if (remove && update) {
+ notificationDelta.setNotificationType(NotificationType.BOTH);
+ } else if (remove) {
+ notificationDelta.setNotificationType(NotificationType.REMOVE);
+ } else if (update) {
+ notificationDelta.setNotificationType(NotificationType.UPDATE);
+ }
+ }
+ return notificationDelta;
+ }
+
+ public static void recordNotification(StdPDPNotification notification) {
+ if (notification != null) {
+ if (notificationRecord.getRemovedPolicies() == null || notificationRecord.getLoadedPolicies() == null) {
+ notificationRecord = notification;
+ } else {
+ // Check if there is anything new and update the record.
+ if (notificationRecord.getLoadedPolicies() != null || notificationRecord.getRemovedPolicies() != null) {
+ HashSet<StdRemovedPolicy> removedPolicies = new HashSet<>();
+ for (RemovedPolicy rPolicy : notificationRecord.getRemovedPolicies()) {
+ StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
+ sRPolicy.setPolicyName(rPolicy.getPolicyName());
+ sRPolicy.setVersionNo(rPolicy.getVersionNo());
+ removedPolicies.add(sRPolicy);
+ }
+ HashSet<StdLoadedPolicy> updatedPolicies = new HashSet<>();
+ for (LoadedPolicy uPolicy : notificationRecord.getLoadedPolicies()) {
+ StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
+ sUPolicy.setMatches(uPolicy.getMatches());
+ sUPolicy.setPolicyName(uPolicy.getPolicyName());
+ sUPolicy.setVersionNo(uPolicy.getVersionNo());
+ sUPolicy.setUpdateType(uPolicy.getUpdateType());
+ updatedPolicies.add(sUPolicy);
+ }
+
+ // Checking with the new updated policies.
+ if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
+ for (LoadedPolicy newUpdatedPolicy : notification.getLoadedPolicies()) {
+ // If it was removed earlier then we need to remove from our record
+ Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
+ String policyName = newUpdatedPolicy.getPolicyName();
+ String ver = newUpdatedPolicy.getVersionNo();
+ while (oldRemovedPolicy.hasNext()) {
+ RemovedPolicy policy = oldRemovedPolicy.next();
+ if (policyName.equals(policy.getPolicyName())
+ && ver.equals(policy.getVersionNo())) {
+ oldRemovedPolicy.remove();
+ }
+ }
+ // If it was previously updated need to Overwrite it to the record.
+ updatedPolicies.removeIf(policy -> policyName.equals(policy.getPolicyName())
+ && ver.equals(policy.getVersionNo()));
+
+ StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
+ sUPolicy.setMatches(newUpdatedPolicy.getMatches());
+ sUPolicy.setPolicyName(newUpdatedPolicy.getPolicyName());
+ sUPolicy.setVersionNo(newUpdatedPolicy.getVersionNo());
+ sUPolicy.setUpdateType(newUpdatedPolicy.getUpdateType());
+ updatedPolicies.add(sUPolicy);
+ }
+ }
+ // Checking with New Removed Policies.
+ if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
+ for (RemovedPolicy newRemovedPolicy : notification.getRemovedPolicies()) {
+ // If it was previously removed Overwrite it to the record.
+ Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
+ String policyName = newRemovedPolicy.getPolicyName();
+ String ver = newRemovedPolicy.getVersionNo();
+ while (oldRemovedPolicy.hasNext()) {
+ RemovedPolicy policy = oldRemovedPolicy.next();
+ if (policyName.equals(policy.getPolicyName())
+ && ver.equals(policy.getVersionNo())) {
+ oldRemovedPolicy.remove();
+ }
+ }
+ // If it was added earlier then we need to remove from our record.
+ updatedPolicies.removeIf(policy -> policyName.equals(policy.getPolicyName())
+ && ver.equals(policy.getVersionNo()));
+
+ StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
+ sRPolicy.setPolicyName(policyName);
+ sRPolicy.setVersionNo(ver);
+ removedPolicies.add(sRPolicy);
+ }
+ }
+ notificationRecord.setRemovedPolicies(removedPolicies);
+ notificationRecord.setLoadedPolicies(updatedPolicies);
+ }
+ if (!notificationRecord.getLoadedPolicies().isEmpty() && !notificationRecord.getRemovedPolicies()
+ .isEmpty()) {
+ notificationRecord.setNotificationType(NotificationType.BOTH);
+ } else if (!notificationRecord.getLoadedPolicies().isEmpty()) {
+ notificationRecord.setNotificationType(NotificationType.UPDATE);
+ } else if (!notificationRecord.getRemovedPolicies().isEmpty()) {
+ notificationRecord.setNotificationType(NotificationType.REMOVE);
+ }
+ }
+ }
+ }
+
+ // This should return the current Notification Record.
+ public static PDPNotification getNotificationRecord() {
+ return notificationRecord;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java b/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java
index fe7807185..1640fe8db 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java
@@ -22,59 +22,53 @@ package org.onap.policy.std;
import java.util.Collection;
import java.util.HashSet;
-
import org.onap.policy.api.LoadedPolicy;
import org.onap.policy.api.NotificationType;
import org.onap.policy.api.PDPNotification;
import org.onap.policy.api.RemovedPolicy;
-public class StdPDPNotification implements PDPNotification{
- private Collection<StdRemovedPolicy> removedPolicies = null;
- private Collection<StdLoadedPolicy> loadedPolicies = null;
- private Collection<RemovedPolicy> removed = null;
- private Collection<LoadedPolicy> updated = null;
- private NotificationType notificationType= null;
-
- @Override
- public Collection<RemovedPolicy> getRemovedPolicies() {
- removed = new HashSet<RemovedPolicy>();
- if(removedPolicies!=null){
- for(RemovedPolicy removedPolicy: removedPolicies){
- removed.add(removedPolicy);
- }
- return this.removed;
- }else{
- return null;
- }
- }
+public class StdPDPNotification implements PDPNotification {
+
+ private Collection<StdRemovedPolicy> removedPolicies = null;
+ private Collection<StdLoadedPolicy> loadedPolicies = null;
+ private Collection<RemovedPolicy> removed = null;
+ private Collection<LoadedPolicy> updated = null;
+ private NotificationType notificationType = null;
+
+ @Override
+ public Collection<RemovedPolicy> getRemovedPolicies() {
+ removed = new HashSet<>();
+ if (removedPolicies != null) {
+ removed.addAll(removedPolicies);
+ return this.removed;
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<LoadedPolicy> getLoadedPolicies() {
+ updated = new HashSet<>();
+ if (loadedPolicies != null) {
+ updated.addAll(loadedPolicies);
+ return updated;
+ }
+ return null;
+ }
+
+ @Override
+ public NotificationType getNotificationType() {
+ return notificationType;
+ }
- @Override
- public Collection<LoadedPolicy> getLoadedPolicies() {
- updated = new HashSet<LoadedPolicy>();
- if(loadedPolicies!=null){
- for(LoadedPolicy updatedPolicy: loadedPolicies){
- updated.add(updatedPolicy);
- }
- return updated;
- }else{
- return null;
- }
- }
+ public void setNotificationType(NotificationType notificationType) {
+ this.notificationType = notificationType;
+ }
- @Override
- public NotificationType getNotificationType() {
- return notificationType;
- }
+ public void setLoadedPolicies(Collection<StdLoadedPolicy> loadedPolicies) {
+ this.loadedPolicies = loadedPolicies;
+ }
- public void setNotificationType(NotificationType notificationType){
- this.notificationType= notificationType;
- }
-
- public void setLoadedPolicies(Collection<StdLoadedPolicy> loadedPolicies) {
- this.loadedPolicies = loadedPolicies;
- }
-
- public void setRemovedPolicies(Collection<StdRemovedPolicy> removedPolicies) {
- this.removedPolicies = removedPolicies;
- }
+ public void setRemovedPolicies(Collection<StdRemovedPolicy> removedPolicies) {
+ this.removedPolicies = removedPolicies;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java
index 3cdb51577..9aab2ad45 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java
@@ -248,7 +248,7 @@ public class BackUpMonitor {
// This is New. create an entry as Master.
LOGGER.info("Adding resource " + resourceName + " to Database");
BackUpMonitorEntity bMEntity = new BackUpMonitorEntity();
- bMEntity.setResoruceNodeName(resourceNodeName);
+ bMEntity.setResourceNodeName(resourceNodeName);
bMEntity.setResourceName(resourceName);
bMEntity = setMaster(bMEntity);
bMEntity.setTimeStamp(new Date());
@@ -297,7 +297,7 @@ public class BackUpMonitor {
} else {
// Resource name is null -> No resource with same name.
selfEntity = new BackUpMonitorEntity();
- selfEntity.setResoruceNodeName(resourceNodeName);
+ selfEntity.setResourceNodeName(resourceNodeName);
selfEntity.setResourceName(resourceName);
selfEntity.setTimeStamp(new Date());
selfEntity = setSlave(selfEntity);
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java
index c5187c0fd..39434a7e7 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java
@@ -252,7 +252,7 @@ public class testBackUpMonitor {
origBM.setFlag("SLAVE");
origBM.setTimeStamp(new Date());
BackUpMonitorEntity bMEntity = new BackUpMonitorEntity();
- bMEntity.setResoruceNodeName(ResourceNode.BRMS.toString());
+ bMEntity.setResourceNodeName(ResourceNode.BRMS.toString());
bMEntity.setResourceName("brms_test2");
bMEntity.setFlag("MASTER");
bMEntity.setTimeStamp(new Date());
diff --git a/pom.xml b/pom.xml
index 96cc5015d..c615114d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>0.1.1</version>
<relativePath/>
</parent>