summaryrefslogtreecommitdiffstats
path: root/applications/common/src/main/java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-12 11:03:44 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-04-12 20:28:17 -0400
commit70736cfbf6ad1a068f8ee53adddd4faa3b6fa8a8 (patch)
tree6f883bb4cf79cd18eaac33c46446ac86a42934ce /applications/common/src/main/java
parenta5b035d9bb633cf5d520a62c451250db4b018a13 (diff)
Add statistics and sonar cleanup and blacklist
* Adding in the statistics for decisions and errors. * Cleaned up sonar issues and added code coverage. * Sped up JUnit tests * Fix JUnit issues with not finding application path * Fix TestDecision not finding persistence.xml * Fix for lingering statistics from previous runs. That needs to be addressed at a later time. * Changed persistence to use properties for configuration of database rather than hard coding the persistence.xml * Fix for Josh's comment to use else-if * Changed to use apache Pair * Added blacklist guard policy Issue-ID: POLICY-1440 Change-Id: I56af8c3dcc82463f7381f1eaea7f1440b76200bd Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/common/src/main/java')
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java1
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java5
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java3
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java4
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java7
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java1
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java5
7 files changed, 14 insertions, 12 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java
index 50eb50bf..c48dd360 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java
@@ -25,7 +25,6 @@ package org.onap.policy.pdp.xacml.application.common;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java
index d4cce5c1..b20ce32f 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java
@@ -21,9 +21,12 @@
package org.onap.policy.pdp.xacml.application.common;
+import com.att.research.xacml.api.Response;
+
import java.nio.file.Path;
import java.util.List;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -98,6 +101,6 @@ public interface XacmlApplicationServiceProvider {
* @param request Incoming DecisionRequest object
* @return response Responding DecisionResponse object
*/
- DecisionResponse makeDecision(DecisionRequest request);
+ Pair<DecisionResponse, Response> makeDecision(DecisionRequest request);
}
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java
index c18ad5fa..00f7680b 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java
@@ -68,7 +68,8 @@ public class CountRecentOperationsPip extends StdOnapPip {
//
// In case there are any overloaded properties for the JPA
//
- Properties emProperties = new Properties(properties);
+ Properties emProperties = new Properties();
+ emProperties.putAll(properties);
//
// Create the entity manager factory
//
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
index 717e537d..4f327cf5 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
@@ -32,7 +32,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
-import javax.persistence.NoResultException;
import javax.persistence.Persistence;
import org.onap.policy.pdp.xacml.application.common.ToscaDictionary;
@@ -65,7 +64,8 @@ public class GetOperationOutcomePip extends StdOnapPip {
//
// In case there are any overloaded properties for the JPA
//
- Properties emProperties = new Properties(properties);
+ Properties emProperties = new Properties();
+ emProperties.putAll(properties);
//
// Create the entity manager factory
//
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
index 9d3c6264..ae144211 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
@@ -200,8 +200,7 @@ public class StdMatchableTranslator implements ToscaPolicyTranslator {
try {
jsonPolicy = coder.encode(toscaPolicy);
} catch (CoderException e) {
- LOGGER.error("Failed to encode policy to json", e);
- throw new ToscaPolicyConversionException(e);
+ throw new ToscaPolicyConversionException("Failed to encode policy to json", e);
}
addObligation(rule, jsonPolicy);
//
@@ -237,7 +236,7 @@ public class StdMatchableTranslator implements ToscaPolicyTranslator {
//
// Add in the Policy Version
//
- policy.setVersion(map.get("policy-version").toString());
+ policy.setVersion(map.get("policy-version"));
}
return policy;
}
@@ -325,7 +324,7 @@ public class StdMatchableTranslator implements ToscaPolicyTranslator {
//
AttributeValueType value = new AttributeValueType();
value.setDataType(ToscaDictionary.ID_OBLIGATION_POLICY_MONITORING_DATATYPE.stringValue());
- value.getContent().add(jsonPolicy.toString());
+ value.getContent().add(jsonPolicy);
//
// Create our AttributeAssignmentExpression where we will
// store the contents of the policy in JSON format.
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java
index 70d49418..739ccba9 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java
@@ -35,7 +35,6 @@ import com.att.research.xacml.std.pip.StdPIPRequest;
import com.att.research.xacml.std.pip.engines.StdConfigurableEngine;
import java.math.BigInteger;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
index 95a642e9..2b8048c4 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
@@ -44,6 +44,7 @@ import java.util.Properties;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -240,7 +241,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
}
@Override
- public DecisionResponse makeDecision(DecisionRequest request) {
+ public Pair<DecisionResponse, Response> makeDecision(DecisionRequest request) {
//
// Convert to a XacmlRequest
//
@@ -252,7 +253,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
//
// Convert to a DecisionResponse
//
- return this.getTranslator().convertResponse(xacmlResponse);
+ return Pair.of(this.getTranslator().convertResponse(xacmlResponse), xacmlResponse);
}
protected abstract ToscaPolicyTranslator getTranslator(String type);