summaryrefslogtreecommitdiffstats
path: root/policy-management/src
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-05-09 23:42:38 -0500
committerJorge Hernandez <jh1730@att.com>2017-05-10 00:02:56 -0500
commit0dfbb8790926ad24d1e124ee2acd18d108e358b5 (patch)
treebb50d804f92d530c7bc406710e9e26d73943f16e /policy-management/src
parent99dbede9a263e23a9f526a6a9ad5a7004ad5bec7 (diff)
[POLICY-11] Fact queries with variables + features
GET/PUT/DELETE operations through REST API. Report on optional features (modules) attached to the engine. Added javadoc comments in Healthcheck module. Change-Id: Ic8d2c06779dda4024e94ad39bb316211522e4e4c Signed-off-by: Jorge Hernandez <jh1730@att.com>
Diffstat (limited to 'policy-management/src')
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/controller/DroolsController.java8
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java10
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/NullDroolsController.java9
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/server/restful/RestManager.java240
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyController.java4
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java60
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java58
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java23
8 files changed, 352 insertions, 60 deletions
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/controller/DroolsController.java b/policy-management/src/main/java/org/openecomp/policy/drools/controller/DroolsController.java
index 0904d438..5a5f3123 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/controller/DroolsController.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/controller/DroolsController.java
@@ -180,9 +180,10 @@ public interface DroolsController extends Startable, Lockable {
*
* @param sessionName the session identifier
* @param className the class type
+ * @param delete retract from drools the results of the query?
* @return the list of facts returned by the query
*/
- public List<Object> facts(String sessionName, String className);
+ public List<Object> facts(String sessionName, String className, boolean delete);
/**
* gets the facts associated with a query for a give session for a given queried entity
@@ -190,9 +191,12 @@ public interface DroolsController extends Startable, Lockable {
* @param sessionName the session
* @param queryName the query identifier
* @param queriedEntity the queried entity
+ * @param delete retract from drools the results of the query?
+ * @param queryParams query parameters
* @return list of facts returned by the query
*/
- public List<Object> factQuery(String sessionName, String queryName, String queriedEntity);
+ public List<Object> factQuery(String sessionName, String queryName, String queriedEntity,
+ boolean delete, Object... queryParams);
/**
* halts and permanently releases all resources
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java
index 62ad6843..4396a0ce 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java
@@ -780,7 +780,7 @@ public class MavenDroolsController implements DroolsController {
* {@inheritDoc}
*/
@Override
- public List<Object> facts(String sessionName, String className) {
+ public List<Object> facts(String sessionName, String className, boolean delete) {
if (sessionName == null || sessionName.isEmpty())
throw new IllegalArgumentException("Invalid Session Name: " + sessionName);
@@ -801,6 +801,8 @@ public class MavenDroolsController implements DroolsController {
for (FactHandle factHandle : factHandles) {
try {
factObjects.add(kieSession.getObject(factHandle));
+ if (delete)
+ kieSession.delete(factHandle);
} catch (Exception e) {
if (logger.isInfoEnabled())
logger.info("Object cannot be retrieved from fact: " + factHandle);
@@ -814,7 +816,7 @@ public class MavenDroolsController implements DroolsController {
* {@inheritDoc}
*/
@Override
- public List<Object> factQuery(String sessionName, String queryName, String queriedEntity) {
+ public List<Object> factQuery(String sessionName, String queryName, String queriedEntity, boolean delete, Object... queryParams) {
if (sessionName == null || sessionName.isEmpty())
throw new IllegalArgumentException("Invalid Session Name: " + sessionName);
@@ -829,10 +831,12 @@ public class MavenDroolsController implements DroolsController {
List<Object> factObjects = new ArrayList<>();
- QueryResults queryResults = kieSession.getQueryResults(queryName);
+ QueryResults queryResults = kieSession.getQueryResults(queryName, queryParams);
for (QueryResultsRow row : queryResults) {
try {
factObjects.add(row.get(queriedEntity));
+ if (delete)
+ kieSession.delete(row.getFactHandle(queriedEntity));
} catch (Exception e) {
if (logger.isInfoEnabled())
logger.info("Object cannot be retrieved from fact: " + row);
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/NullDroolsController.java b/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/NullDroolsController.java
index ac07bb7d..4019beef 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/NullDroolsController.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/NullDroolsController.java
@@ -220,7 +220,8 @@ public class NullDroolsController implements DroolsController {
* {@inheritDoc}
*/
@Override
- public Map<String, Integer> factClassNames(String sessionName) throws IllegalArgumentException {
+ public Map<String, Integer> factClassNames(String sessionName)
+ throws IllegalArgumentException {
return new HashMap<String,Integer>();
}
@@ -236,7 +237,7 @@ public class NullDroolsController implements DroolsController {
* {@inheritDoc}
*/
@Override
- public List<Object> facts(String sessionName, String className) {
+ public List<Object> facts(String sessionName, String className, boolean delete) {
return new ArrayList<Object>();
}
@@ -244,7 +245,9 @@ public class NullDroolsController implements DroolsController {
* {@inheritDoc}
*/
@Override
- public List<Object> factQuery(String sessionName, String queryName, String queriedEntity) {
+ public List<Object> factQuery(String sessionName, String queryName,
+ String queriedEntity,
+ boolean delete, Object... queryParams) {
return new ArrayList<Object>();
}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/openecomp/policy/drools/server/restful/RestManager.java
index cb5d3688..a4aaa856 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/server/restful/RestManager.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/server/restful/RestManager.java
@@ -51,6 +51,8 @@ import org.openecomp.policy.drools.event.comm.bus.DmaapTopicSink;
import org.openecomp.policy.drools.event.comm.bus.DmaapTopicSource;
import org.openecomp.policy.drools.event.comm.bus.UebTopicSink;
import org.openecomp.policy.drools.event.comm.bus.UebTopicSource;
+import org.openecomp.policy.drools.features.PolicyControllerFeatureAPI;
+import org.openecomp.policy.drools.features.PolicyEngineFeatureAPI;
import org.openecomp.policy.drools.properties.PolicyProperties;
import org.openecomp.policy.drools.protocol.coders.EventProtocolCoder;
import org.openecomp.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
@@ -113,6 +115,33 @@ public class RestManager {
else
return Response.status(Response.Status.OK).entity(controller).build();
}
+
+ @GET
+ @Path("engine/features")
+ @Produces(MediaType.APPLICATION_JSON)
+ public List<PolicyEngineFeatureAPI> engineFeatures() {
+ return PolicyEngine.manager.getFeatureProviders();
+ }
+
+ @GET
+ @Path("engine/features/{featureName}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response engineFeature(@PathParam("featureName") String featureName) {
+ try {
+ return Response.status(Response.Status.OK).
+ entity(PolicyEngine.manager.getFeatureProvider(featureName)).build();
+ } catch(IllegalArgumentException iae) {
+ return Response.status(Response.Status.NOT_FOUND).
+ entity(new Error(iae.getMessage())).build();
+ }
+ }
+
+ @GET
+ @Path("engine/properties")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Properties engineProperties() {
+ return PolicyEngine.manager.getProperties();
+ }
/**
* Activates the Policy Engine
@@ -289,28 +318,71 @@ public class RestManager {
}
@GET
+ @Path("engine/controllers/features")
+ @Produces(MediaType.APPLICATION_JSON)
+ public List<PolicyControllerFeatureAPI> controllerFeatures() {
+ return PolicyController.factory.getFeatureProviders();
+ }
+
+ @GET
+ @Path("engine/controllers/features/{featureName}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response controllerFeature(@PathParam("controllerName") String controllerName,
+ @PathParam("featureName") String featureName) {
+ try {
+ return Response.status(Response.Status.OK).
+ entity(PolicyController.factory.getFeatureProvider(featureName)).
+ build();
+ } catch(IllegalArgumentException iae) {
+ return Response.status(Response.Status.NOT_FOUND).
+ entity(new Error(iae.getMessage())).build();
+ }
+ }
+
+ @GET
@Path("engine/controllers/{controllerName}")
@Produces(MediaType.APPLICATION_JSON)
public Response controller(@PathParam("controllerName") String controllerName) {
- PolicyController controller = null;
try {
- controller = PolicyController.factory.get(controllerName);
+ return Response.status(Response.Status.OK).
+ entity(PolicyController.factory.get(controllerName)).
+ build();
} catch (IllegalArgumentException e) {
- logger.info("Can't retrieve controller " + controllerName +
- ". Reason: " + e.getMessage());
+ return Response.status(Response.Status.NOT_FOUND).
+ entity(new Error(controllerName + " not found")).
+ build();
} catch (IllegalStateException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, this.toString());
return Response.status(Response.Status.NOT_ACCEPTABLE).
- entity(new Error(controllerName + " not acceptable")).build();
+ entity(new Error(controllerName + " not acceptable")).
+ build();
+ } catch (Exception e) {
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
+ entity(new Error(controllerName + " not acceptable")).
+ build();
}
-
- if (controller != null)
+ }
+ @GET
+ @Path("engine/controllers/{controllerName}/properties")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response controllerProperties(@PathParam("controllerName") String controllerName) {
+ try {
+ PolicyController controller = PolicyController.factory.get(controllerName);
return Response.status(Response.Status.OK).
- entity(controller).build();
- else
+ entity(controller.getProperties()).
+ build();
+ } catch (IllegalArgumentException e) {
return Response.status(Response.Status.NOT_FOUND).
- entity(new Error(controllerName + " not found")).build();
+ entity(new Error(controllerName + " not found")).
+ build();
+ } catch (IllegalStateException e) {
+ return Response.status(Response.Status.NOT_ACCEPTABLE).
+ entity(new Error(controllerName + " not acceptable")).
+ build();
+ } catch (Exception e) {
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
+ entity(new Error(controllerName + " not acceptable")).
+ build();
+ }
}
@DELETE
@@ -457,7 +529,7 @@ public class RestManager {
@PathParam("className") String className) {
try {
DroolsController drools = getDroolsController(controllerName);
- List<Object> facts = drools.facts(sessionName, className);
+ List<Object> facts = drools.facts(sessionName, className, false);
if (!count)
return Response.status(Response.Status.OK).entity(facts).build();
else
@@ -471,6 +543,27 @@ public class RestManager {
}
}
+ @DELETE
+ @Path("engine/controllers/{controllerName}/drools/facts/{sessionName}/{className}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response deleteDroolsFacts(@PathParam("controllerName") String controllerName,
+ @PathParam("sessionName") String sessionName,
+ @PathParam("className") String className) {
+ try {
+ DroolsController drools = getDroolsController(controllerName);
+ List<Object> facts = drools.facts(sessionName, className, true);
+ return Response.status(Response.Status.OK).entity(facts).build();
+ } catch (IllegalArgumentException | IllegalStateException e) {
+ return Response.status(Response.Status.BAD_REQUEST).
+ entity(new Error(e.getMessage())).
+ build();
+ } catch (Exception e) {
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
+ entity(new Error(e.getMessage())).
+ build();
+ }
+ }
+
@GET
@Path("engine/controllers/{controllerName}/drools/facts/{sessionName}/{queryName}/{queriedEntity}")
@Produces(MediaType.APPLICATION_JSON)
@@ -481,17 +574,73 @@ public class RestManager {
@PathParam("queriedEntity") String queriedEntity) {
try {
DroolsController drools = getDroolsController(controllerName);
- List<Object> facts = drools.factQuery(sessionName, queryName, queriedEntity);
+ List<Object> facts = drools.factQuery(sessionName, queryName, queriedEntity, false);
if (!count)
return Response.status(Response.Status.OK).entity(facts).build();
else
return Response.status(Response.Status.OK).entity(facts.size()).build();
} catch (IllegalArgumentException | IllegalStateException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, this.toString());
return Response.status(Response.Status.BAD_REQUEST).
entity(new Error(e.getMessage())).
build();
+ } catch (Exception e) {
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
+ entity(new Error(e.getMessage())).
+ build();
+ }
+ }
+
+ @PUT
+ @Path("engine/controllers/{controllerName}/drools/facts/{sessionName}/{queryName}/{queriedEntity}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response droolsFacts(@PathParam("controllerName") String controllerName,
+ @PathParam("sessionName") String sessionName,
+ @PathParam("queryName") String queryName,
+ @PathParam("queriedEntity") String queriedEntity,
+ List<Object> queryParameters) {
+ try {
+ DroolsController drools = getDroolsController(controllerName);
+ List<Object> facts;
+ if (queryParameters == null || queryParameters.isEmpty())
+ facts = drools.factQuery(sessionName, queryName, queriedEntity, false);
+ else
+ facts = drools.factQuery(sessionName, queryName, queriedEntity, false, queryParameters.toArray());
+ return Response.status(Response.Status.OK).entity(facts).build();
+ } catch (IllegalArgumentException | IllegalStateException e) {
+ return Response.status(Response.Status.BAD_REQUEST).
+ entity(new Error(e.getMessage())).
+ build();
+ } catch (Exception e) {
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
+ entity(new Error(e.getMessage())).
+ build();
+ }
+ }
+
+ @DELETE
+ @Path("engine/controllers/{controllerName}/drools/facts/{sessionName}/{queryName}/{queriedEntity}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response deleteDroolsFacts(@PathParam("controllerName") String controllerName,
+ @PathParam("sessionName") String sessionName,
+ @PathParam("queryName") String queryName,
+ @PathParam("queriedEntity") String queriedEntity,
+ List<Object> queryParameters) {
+ try {
+ DroolsController drools = getDroolsController(controllerName);
+ List<Object> facts;
+ if (queryParameters == null || queryParameters.isEmpty())
+ facts = drools.factQuery(sessionName, queryName, queriedEntity, true);
+ else
+ facts = drools.factQuery(sessionName, queryName, queriedEntity, true, queryParameters.toArray());
+ return Response.status(Response.Status.OK).entity(facts).build();
+ } catch (IllegalArgumentException | IllegalStateException e) {
+ return Response.status(Response.Status.BAD_REQUEST).
+ entity(new Error(e.getMessage())).
+ build();
+ } catch (Exception e) {
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
+ entity(new Error(e.getMessage())).
+ build();
}
}
@@ -1031,7 +1180,24 @@ public class RestManager {
build();
}
- @GET
+ @DELETE
+ @Path("engine/topics/lock")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response unlockTopics() {
+ boolean success = TopicEndpoint.manager.unlock();
+ if (success)
+ return Response.status(Status.OK).
+ entity("Endpoints are unlocked").
+ build();
+ else
+ return Response.status(Status.SERVICE_UNAVAILABLE).
+ entity("Endpoints cannot be unlocked").
+ build();
+ }
+
+
+ @GET
@Path("engine/topics/{topic}/dmaap/sink/events")
@Produces(MediaType.APPLICATION_JSON)
public Response dmaapSinkEvent(@PathParam("topic") String topicName) {
@@ -1054,11 +1220,10 @@ public class RestManager {
boolean success = uebReader.offer(json);
if (success)
return Response.status(Status.OK).
- entity("Successfully injected event over " + topicName).
build();
else
return Response.status(Status.NOT_ACCEPTABLE).
- entity("Failure to inject event over " + topicName).
+ entity(new Error("Failure to inject event over " + topicName)).
build();
} catch (Exception e) {
return Response.status(Response.Status.BAD_REQUEST).
@@ -1078,17 +1243,16 @@ public class RestManager {
boolean success = dmaapReader.offer(json);
if (success)
return Response.status(Status.OK).
- entity("Successfully injected event over " + topicName).
build();
else
return Response.status(Status.NOT_ACCEPTABLE).
- entity("Failure to inject event over " + topicName).
+ entity(new Error("Failure to inject event over " + topicName)).
build();
} catch (Exception e) {
return Response.status(Response.Status.BAD_REQUEST).
entity(new Error(e.getMessage())).
build();
- }
+ }
}
@PUT
@@ -1107,22 +1271,6 @@ public class RestManager {
build();
}
- @DELETE
- @Path("engine/topics/lock")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response unlockTopics() {
- boolean success = TopicEndpoint.manager.unlock();
- if (success)
- return Response.status(Status.OK).
- entity("Endpoints are unlocked").
- build();
- else
- return Response.status(Status.SERVICE_UNAVAILABLE).
- entity("Endpoints cannot be unlocked").
- build();
- }
-
@PUT
@Path("engine/topics/{topic}/ueb/sources/lock")
@Produces(MediaType.APPLICATION_JSON)
@@ -1212,7 +1360,12 @@ public class RestManager {
build();
}
-
+ /**
+ * gets the underlying drools controller from the named policy controller
+ * @param controllerName the policy controller name
+ * @return the underlying drools controller
+ * @throws IllegalArgumentException if an invalid controller name has been passed in
+ */
protected DroolsController getDroolsController(String controllerName) throws IllegalArgumentException {
PolicyController controller = PolicyController.factory.get(controllerName);
if (controller == null)
@@ -1230,6 +1383,9 @@ public class RestManager {
*/
+ /**
+ * Endpoints aggregation Helper class
+ */
public static class Endpoints {
public List<TopicSource> sources;
public List<TopicSink> sinks;
@@ -1241,6 +1397,9 @@ public class RestManager {
}
}
+ /**
+ * Endpoint Helper Class
+ */
public static class Endpoint {
public TopicSource source;
public TopicSink sink;
@@ -1252,6 +1411,9 @@ public class RestManager {
}
}
+ /**
+ * Coding (Encoding) Helper class
+ */
public static class CodingResult {
public String jsonEncoding;
public Boolean encoding;
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyController.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyController.java
index 543fd0e3..15d1acf3 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyController.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyController.java
@@ -69,9 +69,9 @@ public interface PolicyController extends Startable, Lockable {
public boolean updateDrools(DroolsConfiguration newDroolsConfiguration);
/**
- * Get the Initialization Properties
+ * Get the Properties
*/
- public Properties getInitializationProperties();
+ public Properties getProperties();
/**
* Attempts delivering of an String over communication
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java
index e105bbb9..c6020ea6 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java
@@ -25,12 +25,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
-import org.openecomp.policy.drools.controller.DroolsController;
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.openecomp.policy.drools.controller.DroolsController;
+import org.openecomp.policy.drools.features.PolicyControllerFeatureAPI;
import org.openecomp.policy.drools.protocol.configuration.DroolsConfiguration;
import org.openecomp.policy.drools.system.internal.AggregatedPolicyController;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
/**
* Policy Controller Factory to manage controller creation, destruction,
* and retrieval for management interfaces
@@ -150,6 +153,25 @@ public interface PolicyControllerFactory {
throws IllegalArgumentException, IllegalStateException;
/**
+ * get features attached to the Policy Controllers
+ * @return list of features
+ */
+ public List<PolicyControllerFeatureAPI> getFeatureProviders();
+
+ /**
+ * get named feature attached to the Policy Controllers
+ * @return the feature
+ */
+ public PolicyControllerFeatureAPI getFeatureProvider(String featureName)
+ throws IllegalArgumentException;
+
+ /**
+ * get features attached to the Policy Controllers
+ * @return list of features
+ */
+ public List<String> getFeatures();
+
+ /**
* returns the current inventory of Policy Controllers
*
* @return a list of Policy Controllers
@@ -461,4 +483,40 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
return controllers;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<String> getFeatures() {
+ List<String> features = new ArrayList<String>();
+ for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) {
+ features.add(feature.getName());
+ }
+ return features;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @JsonIgnore
+ @Override
+ public List<PolicyControllerFeatureAPI> getFeatureProviders() {
+ return PolicyControllerFeatureAPI.providers.getList();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public PolicyControllerFeatureAPI getFeatureProvider(String featureName) throws IllegalArgumentException {
+ if (featureName == null || featureName.isEmpty())
+ throw new IllegalArgumentException("A feature name must be provided");
+
+ for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) {
+ if (feature.getName().equals(featureName))
+ return feature;
+ }
+
+ throw new IllegalArgumentException("Invalid Feature Name: " + featureName);
+ }
}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java
index 6933003e..d2133374 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java
@@ -190,6 +190,25 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
public Properties getProperties();
/**
+ * get features attached to the Policy Engine
+ * @return list of features
+ */
+ public List<PolicyEngineFeatureAPI> getFeatureProviders();
+
+ /**
+ * get named feature attached to the Policy Engine
+ * @return the feature
+ */
+ public PolicyEngineFeatureAPI getFeatureProvider(String featureName)
+ throws IllegalArgumentException;
+
+ /**
+ * get features attached to the Policy Engine
+ * @return list of features
+ */
+ public List<String> getFeatures();
+
+ /**
* Attempts the dispatching of an "event" object
*
* @param topic topic
@@ -1031,6 +1050,7 @@ class PolicyEngineManager implements PolicyEngine {
* {@inheritDoc}
*/
@Override
+ @JsonIgnore
public Properties getProperties() {
return this.properties;
}
@@ -1062,6 +1082,44 @@ class PolicyEngineManager implements PolicyEngine {
return this.httpServers;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<String> getFeatures() {
+ List<String> features = new ArrayList<String>();
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ features.add(feature.getName());
+ }
+ return features;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @JsonIgnore
+ @Override
+ public List<PolicyEngineFeatureAPI> getFeatureProviders() {
+ return PolicyEngineFeatureAPI.providers.getList();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public PolicyEngineFeatureAPI getFeatureProvider(String featureName) throws IllegalArgumentException {
+ if (featureName == null || featureName.isEmpty())
+ throw new IllegalArgumentException("A feature name must be provided");
+
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ if (feature.getName().equals(featureName))
+ return feature;
+ }
+
+ throw new IllegalArgumentException("Invalid Feature Name: " + featureName);
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java
index 3badbd08..e41a8898 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java
@@ -24,18 +24,19 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.drools.controller.DroolsController;
import org.openecomp.policy.drools.event.comm.Topic;
import org.openecomp.policy.drools.event.comm.TopicEndpoint;
import org.openecomp.policy.drools.event.comm.TopicListener;
import org.openecomp.policy.drools.event.comm.TopicSink;
import org.openecomp.policy.drools.event.comm.TopicSource;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.drools.persistence.SystemPersistence;
import org.openecomp.policy.drools.properties.PolicyProperties;
import org.openecomp.policy.drools.protocol.configuration.DroolsConfiguration;
import org.openecomp.policy.drools.system.PolicyController;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
@@ -440,6 +441,16 @@ public class AggregatedPolicyController implements PolicyController,
public DroolsController getDrools() {
return this.droolsController;
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @JsonIgnore
+ public Properties getProperties() {
+ return this.properties;
+ }
@Override
public String toString() {
@@ -449,13 +460,5 @@ public class AggregatedPolicyController implements PolicyController,
return builder.toString();
}
- /**
- * {@inheritDoc}
- */
- @Override
- public Properties getInitializationProperties() {
- return this.properties;
- }
-
}