summaryrefslogtreecommitdiffstats
path: root/applications/common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'applications/common/src/main')
-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
-rw-r--r--applications/common/src/main/resources/persistence.xml38
8 files changed, 52 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);
diff --git a/applications/common/src/main/resources/persistence.xml b/applications/common/src/main/resources/persistence.xml
new file mode 100644
index 00000000..e3f4a2f6
--- /dev/null
+++ b/applications/common/src/main/resources/persistence.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP
+ ================================================================================
+ Copyright (C) 2019 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=========================================================
+ -->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0">
+
+ <persistence-unit name="OperationsHistoryPU" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.pdp.xacml.application.common.operationshistory.Dbao</class>
+
+ <properties>
+ <property name="javax.persistence.schema-generation.database.action" value="create" />
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+ </properties>
+ </persistence-unit>
+
+</persistence>
+ \ No newline at end of file