aboutsummaryrefslogtreecommitdiffstats
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/matchable/MatchablePolicyType.java4
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeList.java3
-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.java3
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java19
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java19
6 files changed, 47 insertions, 4 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java
index 3bbc6ea5..cf9d7a94 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java
@@ -48,6 +48,7 @@ public class MatchablePolicyType {
public static final String TOSCA_TYPE_LIST = "list";
public static final String TOSCA_TYPE_MAP = "map";
+ //@formatter:off
private static final Map<String, Function<ToscaProperty, MatchablePropertyTypeBase<?>>>
mapPrimitivesProperty = Map.of(
TOSCA_PRIMITIVE_STRING, MatchablePropertyTypeString::new,
@@ -65,6 +66,7 @@ public class MatchablePolicyType {
TOSCA_PRIMITIVE_BOOLEAN, MatchablePropertyTypeBoolean::new,
TOSCA_PRIMITIVE_TIMESTAMP, MatchablePropertyTypeTimestamp::new
);
+ //@formatter:on
ToscaPolicyIdentifier policyId;
Map<String, MatchableProperty> matchables = new HashMap<>();
@@ -170,7 +172,7 @@ public class MatchablePolicyType {
Function<ToscaEntrySchema, MatchablePropertyTypeBase<?>> function =
mapPrimitivesSchema.get(toscaSchema.getType());
if (function != null) {
- return new MatchableProperty(property, function.apply(toscaSchema)); // compilation err wants ToscaProperty
+ return new MatchableProperty(property, function.apply(toscaSchema));
}
throw new IllegalArgumentException("Not a primitive " + toscaSchema.getType());
}
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeList.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeList.java
index 55fea540..7b19ad47 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeList.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeList.java
@@ -23,7 +23,6 @@
package org.onap.policy.pdp.xacml.application.common.matchable;
import com.att.research.xacml.api.Identifier;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
@@ -50,7 +49,7 @@ public class MatchablePropertyTypeList extends MatchablePropertyTypeBase<List<Ma
@SuppressWarnings("unchecked")
@Override
public List<MatchablePropertyType<?>> validate(Object value) throws ToscaPolicyConversionException {
- if (value instanceof Collection) {
+ if (value instanceof List) {
return (List<MatchablePropertyType<?>>) value;
}
return Collections.emptyList();
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 4bf87779..f2d79804 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
@@ -62,6 +62,9 @@ public class CountRecentOperationsPip extends StdOnapPip {
*/
@Override
public PIPResponse getAttributes(PIPRequest pipRequest, PIPFinder pipFinder) throws PIPException {
+ if (this.shutdown) {
+ throw new PIPException("Engine is shutdown");
+ }
logger.debug("getAttributes requesting attribute {} of type {} for issuer {}",
pipRequest.getAttributeId(), pipRequest.getDataTypeId(), pipRequest.getIssuer());
//
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 0f970f7e..b269e25a 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
@@ -58,6 +58,9 @@ public class GetOperationOutcomePip extends StdOnapPip {
*/
@Override
public PIPResponse getAttributes(PIPRequest pipRequest, PIPFinder pipFinder) throws PIPException {
+ if (this.shutdown) {
+ throw new PIPException("Engine is shutdown");
+ }
logger.debug("getAttributes requesting attribute {} of type {} for issuer {}",
pipRequest.getAttributeId(), pipRequest.getDataTypeId(), pipRequest.getIssuer());
//
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 ca07f22f..5c99932e 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
@@ -70,6 +70,7 @@ public abstract class StdOnapPip extends StdConfigurableEngine {
protected Properties properties;
protected EntityManager em;
protected String issuer;
+ protected boolean shutdown = false;
public StdOnapPip() {
super();
@@ -81,7 +82,14 @@ public abstract class StdOnapPip extends StdConfigurableEngine {
}
@Override
- public void configure(String id, Properties properties) throws PIPException {
+ public synchronized void configure(String id, Properties properties) throws PIPException {
+ //
+ // This most likely will never get called since configure is called
+ // upon startup.
+ //
+ if (this.shutdown) {
+ throw new PIPException("Engine is shutdown.");
+ }
super.configure(id, properties);
logger.info("Configuring historyDb PIP {}", properties);
this.properties = properties;
@@ -114,6 +122,15 @@ public abstract class StdOnapPip extends StdConfigurableEngine {
}
}
+ @Override
+ public synchronized void shutdown() {
+ if (this.em != null) {
+ this.em.close();
+ this.em = null;
+ }
+ this.shutdown = true;
+ }
+
protected String getAttribute(PIPFinder pipFinder, PIPRequest pipRequest) {
//
// Get the actor value
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 9a8b63fb..ba562b83 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
@@ -283,6 +283,13 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
PDPEngineFactory factory = getPdpEngineFactory();
PDPEngine engine = factory.newEngine(properties);
if (engine != null) {
+ //
+ // If there is a previous engine have it shutdown.
+ //
+ this.destroyEngine();
+ //
+ // Save it off
+ //
this.pdpEngine = engine;
}
} catch (FactoryException e) {
@@ -290,6 +297,18 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
}
}
+ protected synchronized void destroyEngine() {
+ if (this.pdpEngine == null) {
+ return;
+ }
+ try {
+ this.pdpEngine.shutdown();
+ } catch (Exception e) {
+ LOGGER.warn("Exception thrown when destroying XACML PDP engine.", e);
+ }
+ this.pdpEngine = null;
+ }
+
/**
* Make a decision call.
*