summaryrefslogtreecommitdiffstats
path: root/policy-management/src/main
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-08-20 13:12:13 -0500
committerJorge Hernandez <jh1730@att.com>2017-08-20 13:17:56 -0500
commit88c788ee590aeff3e408338ad99df004a1213371 (patch)
treea0dd8aaef5e655c5b823bcadd76f27ca72feb37b /policy-management/src/main
parent7f04f800207d805922ec4915b20fa1f1c841927c (diff)
sonar criticals and some majors
Issue-ID: POLICY-114 Change-Id: I5fe12b6538379a4d018bb76173247fe53fba21d7 Signed-off-by: Jorge Hernandez <jh1730@att.com>
Diffstat (limited to 'policy-management/src/main')
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java80
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java155
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java106
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistence.java18
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java7
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java106
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java125
7 files changed, 203 insertions, 394 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java
index 8b733970..31b7cec7 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java
@@ -62,7 +62,7 @@ public interface DroolsControllerFactory {
public DroolsController build(Properties properties,
List<? extends TopicSource> eventSources,
List<? extends TopicSink> eventSinks)
- throws IllegalArgumentException, LinkageError;
+ throws LinkageError;
/**
* Explicit construction of a Drools Controller
@@ -82,7 +82,7 @@ public interface DroolsControllerFactory {
String version,
List<TopicCoderFilterConfiguration> decoderConfigurations,
List<TopicCoderFilterConfiguration> encoderConfigurations)
- throws IllegalArgumentException, LinkageError;
+ throws LinkageError;
/**
* Releases the Drools Controller from operation
@@ -121,8 +121,7 @@ public interface DroolsControllerFactory {
*/
public DroolsController get(String groupId,
String artifactId,
- String version)
- throws IllegalArgumentException;
+ String version);
/**
* returns the current inventory of Drools Controllers
@@ -147,8 +146,7 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
/**
* Policy Controller Name Index
*/
- protected HashMap<String, DroolsController> droolsControllers =
- new HashMap<String, DroolsController>();
+ protected HashMap<String, DroolsController> droolsControllers = new HashMap<>();
/**
* Null Drools Controller
@@ -168,14 +166,11 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public DroolsController build(Properties properties,
List<? extends TopicSource> eventSources,
List<? extends TopicSink> eventSinks)
- throws IllegalArgumentException, LinkageError {
+ throws LinkageError {
String groupId = properties.getProperty(PolicyProperties.RULES_GROUPID);
if (groupId == null || groupId.isEmpty())
@@ -210,14 +205,12 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
* @throws IllegalArgumentException invalid input data
*/
protected List<TopicCoderFilterConfiguration> codersAndFilters
- (Properties properties, List<? extends Topic> topicEntities)
- throws IllegalArgumentException {
+ (Properties properties, List<? extends Topic> topicEntities) {
String PROPERTY_TOPIC_ENTITY_PREFIX;
List<TopicCoderFilterConfiguration>
- topics2DecodedClasses2Filters =
- new ArrayList<TopicCoderFilterConfiguration>();
+ topics2DecodedClasses2Filters = new ArrayList<>();
if (topicEntities.isEmpty())
return topics2DecodedClasses2Filters;
@@ -225,7 +218,7 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
for (Topic topic: topicEntities) {
/* source or sink ? ueb or dmaap? */
- boolean isSource = (topic instanceof TopicSource);
+ boolean isSource = topic instanceof TopicSource;
CommInfrastructure commInfra = topic.getTopicCommInfrastructure();
if (commInfra == CommInfrastructure.UEB) {
if (isSource) {
@@ -295,10 +288,10 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
continue;
}
- List<PotentialCoderFilter> classes2Filters = new ArrayList<PotentialCoderFilter>();
+ List<PotentialCoderFilter> classes2Filters = new ArrayList<>();
List<String> aTopicClasses =
- new ArrayList<String>(Arrays.asList(eventClasses.split("\\s*,\\s*")));
+ new ArrayList<>(Arrays.asList(eventClasses.split("\\s*,\\s*")));
for (String aClass: aTopicClasses) {
@@ -312,7 +305,7 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
"." + aClass +
PolicyProperties.PROPERTY_TOPIC_EVENTS_FILTER_SUFFIX);
- List<Pair<String,String>> filters = new ArrayList<Pair<String,String>>();
+ List<Pair<String,String>> filters = new ArrayList<>();
if (filter == null || filter.isEmpty()) {
// 4. topic -> class -> with no filters
@@ -327,7 +320,7 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
// There are filters associated with the applicability of
// this class for decoding.
List<String> listOfFilters =
- new ArrayList<String>(Arrays.asList(filter.split("\\s*,\\s*")));
+ new ArrayList<>(Arrays.asList(filter.split("\\s*,\\s*")));
for (String nameValue: listOfFilters) {
String fieldName;
@@ -368,24 +361,22 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
return topics2DecodedClasses2Filters;
}
- /**
- * {@inheritDoc}
- * @param decoderConfiguration
- */
@Override
public DroolsController build(String newGroupId,
String newArtifactId,
String newVersion,
List<TopicCoderFilterConfiguration> decoderConfigurations,
List<TopicCoderFilterConfiguration> encoderConfigurations)
- throws IllegalArgumentException, LinkageError {
+ throws LinkageError {
- if (newGroupId == null || newArtifactId == null || newVersion == null ||
- newGroupId.isEmpty() || newArtifactId.isEmpty() || newVersion.isEmpty()) {
- throw new IllegalArgumentException("Missing maven coordinates: " +
- newGroupId + ":" + newArtifactId + ":" +
- newVersion);
- }
+ if (newGroupId == null || newGroupId.isEmpty())
+ throw new IllegalArgumentException("Missing maven group-id coordinate");
+
+ if (newArtifactId == null || newArtifactId.isEmpty())
+ throw new IllegalArgumentException("Missing maven artifact-id coordinate");
+
+ if (newVersion == null || newVersion.isEmpty())
+ throw new IllegalArgumentException("Missing maven version coordinate");
String controllerId = newGroupId + ":" + newArtifactId;
DroolsController controllerCopy = null;
@@ -430,18 +421,12 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
return controller;
}
- /**
- * {@inheritDoc}
- */
@Override
- public void destroy(DroolsController controller) throws IllegalArgumentException {
+ public void destroy(DroolsController controller) {
unmanage(controller);
controller.halt();
}
- /**
- * {@inheritDoc}
- */
@Override
public void destroy() {
List<DroolsController> controllers = this.inventory();
@@ -461,7 +446,7 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
* @return
* @throws IllegalArgumentException
*/
- protected void unmanage(DroolsController controller) throws IllegalArgumentException {
+ protected void unmanage(DroolsController controller) {
if (controller == null) {
throw new IllegalArgumentException("No controller provided");
}
@@ -481,18 +466,12 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
}
}
- /**
- * {@inheritDoc}
- */
@Override
- public void shutdown(DroolsController controller) throws IllegalArgumentException {
+ public void shutdown(DroolsController controller) {
this.unmanage(controller);
controller.shutdown();
}
- /**
- * {@inheritDoc}
- */
@Override
public void shutdown() {
List<DroolsController> controllers = this.inventory();
@@ -505,14 +484,10 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public DroolsController get(String groupId,
String artifactId,
- String version)
- throws IllegalArgumentException, IllegalStateException {
+ String version) {
if (groupId == null || artifactId == null ||
groupId.isEmpty() || artifactId.isEmpty()) {
@@ -532,13 +507,10 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public List<DroolsController> inventory() {
List<DroolsController> controllers =
- new ArrayList<DroolsController>(this.droolsControllers.values());
+ new ArrayList<>(this.droolsControllers.values());
return controllers;
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
index 79743b00..9689776c 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
@@ -127,25 +127,23 @@ public class MavenDroolsController implements DroolsController {
String artifactId,
String version,
List<TopicCoderFilterConfiguration> decoderConfigurations,
- List<TopicCoderFilterConfiguration> encoderConfigurations)
- throws IllegalArgumentException {
+ List<TopicCoderFilterConfiguration> encoderConfigurations) {
- if (logger.isInfoEnabled())
- logger.info("DROOLS CONTROLLER: instantiation " + this +
- " -> {" + groupId + ":" + artifactId + ":" + version + "}");
-
- if (groupId == null || artifactId == null || version == null ||
- groupId.isEmpty() || artifactId.isEmpty() || version.isEmpty()) {
- throw new IllegalArgumentException("Missing maven coordinates: " +
- groupId + ":" + artifactId + ":" +
- version);
- }
+ logger.info("drools-controller instantiation [{}:{}:{}]", groupId, artifactId, version);
+
+ if (groupId == null || groupId.isEmpty())
+ throw new IllegalArgumentException("Missing maven group-id coordinate");
+
+ if (artifactId == null || artifactId.isEmpty())
+ throw new IllegalArgumentException("Missing maven artifact-id coordinate");
+
+ if (version == null || version.isEmpty())
+ throw new IllegalArgumentException("Missing maven version coordinate");
this.policyContainer= new PolicyContainer(groupId, artifactId, version);
this.init(decoderConfigurations, encoderConfigurations);
- if (logger.isInfoEnabled())
- logger.info("DROOLS CONTROLLER: instantiation completed " + this);
+ logger.debug("{}: instantiation completed ", this);
}
/**
@@ -165,24 +163,22 @@ public class MavenDroolsController implements DroolsController {
this.modelClassLoaderHash = this.policyContainer.getClassLoader().hashCode();
}
- /**
- * {@inheritDoc}
- */
@Override
public void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
List<TopicCoderFilterConfiguration> decoderConfigurations,
List<TopicCoderFilterConfiguration> encoderConfigurations)
- throws IllegalArgumentException, LinkageError {
+ throws LinkageError {
- if (logger.isInfoEnabled())
- logger.info("UPDATE-TO-VERSION: " + this + " -> {" + newGroupId + ":" + newArtifactId + ":" + newVersion + "}");
+ logger.info("{}: updating version -> [{}:{}:{}]", newGroupId, newArtifactId, newVersion);
- if (newGroupId == null || newArtifactId == null || newVersion == null ||
- newGroupId.isEmpty() || newArtifactId.isEmpty() || newVersion.isEmpty()) {
- throw new IllegalArgumentException("Missing maven coordinates: " +
- newGroupId + ":" + newArtifactId + ":" +
- newVersion);
- }
+ if (newGroupId == null || newGroupId.isEmpty())
+ throw new IllegalArgumentException("Missing maven group-id coordinate");
+
+ if (newArtifactId == null || newArtifactId.isEmpty())
+ throw new IllegalArgumentException("Missing maven artifact-id coordinate");
+
+ if (newVersion == null || newVersion.isEmpty())
+ throw new IllegalArgumentException("Missing maven version coordinate");
if (newGroupId.equalsIgnoreCase(DroolsController.NO_GROUP_ID) ||
newArtifactId.equalsIgnoreCase(DroolsController.NO_ARTIFACT_ID) ||
@@ -234,8 +230,7 @@ public class MavenDroolsController implements DroolsController {
* @param decoderConfiguration list of topic -> decoders -> filters mapping
*/
protected void initCoders(List<TopicCoderFilterConfiguration> coderConfigurations,
- boolean decoder)
- throws IllegalArgumentException {
+ boolean decoder) {
if (logger.isInfoEnabled())
logger.info("INIT-CODERS: " + this);
@@ -318,8 +313,7 @@ public class MavenDroolsController implements DroolsController {
/**
* remove decoders.
*/
- protected void removeDecoders()
- throws IllegalArgumentException {
+ protected void removeDecoders(){
if (logger.isInfoEnabled())
logger.info("REMOVE-DECODERS: " + this);
@@ -338,8 +332,7 @@ public class MavenDroolsController implements DroolsController {
/**
* remove decoders.
*/
- protected void removeEncoders()
- throws IllegalArgumentException {
+ protected void removeEncoders() {
if (logger.isInfoEnabled())
logger.info("REMOVE-ENCODERS: " + this);
@@ -356,11 +349,8 @@ public class MavenDroolsController implements DroolsController {
}
- /**
- * {@inheritDoc}
- */
@Override
- public boolean ownsCoder(Class<? extends Object> coderClass, int modelHash) throws IllegalStateException {
+ public boolean ownsCoder(Class<? extends Object> coderClass, int modelHash) {
if (!ReflectionUtil.isClass
(this.policyContainer.getClassLoader(), coderClass.getCanonicalName())) {
logger.error(this + coderClass.getCanonicalName() + " cannot be retrieved. ");
@@ -382,9 +372,6 @@ public class MavenDroolsController implements DroolsController {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean start() {
@@ -401,9 +388,6 @@ public class MavenDroolsController implements DroolsController {
return this.policyContainer.start();
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean stop() {
@@ -419,12 +403,8 @@ public class MavenDroolsController implements DroolsController {
return this.policyContainer.stop();
}
-
- /**
- * {@inheritDoc}
- */
@Override
- public void shutdown() throws IllegalStateException {
+ public void shutdown() {
logger.info("{}: SHUTDOWN", this);
try {
@@ -438,12 +418,8 @@ public class MavenDroolsController implements DroolsController {
}
-
- /**
- * {@inheritDoc}
- */
@Override
- public void halt() throws IllegalStateException {
+ public void halt() {
logger.info("{}: HALT", this);
try {
@@ -475,17 +451,11 @@ public class MavenDroolsController implements DroolsController {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isAlive() {
return this.alive;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean offer(String topic, String event) {
logger.debug("{}: OFFER: {} <- {}", this, topic, event);
@@ -498,7 +468,7 @@ public class MavenDroolsController implements DroolsController {
// 0. Check if the policy container has any sessions
- if (this.policyContainer.getPolicySessions().size() <= 0) {
+ if (this.policyContainer.getPolicySessions().isEmpty()) {
// no sessions
return true;
}
@@ -550,14 +520,9 @@ public class MavenDroolsController implements DroolsController {
return true;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean deliver(TopicSink sink, Object event)
- throws IllegalArgumentException,
- IllegalStateException,
- UnsupportedOperationException {
+ throws UnsupportedOperationException {
if (logger.isInfoEnabled())
logger.info(this + "DELIVER: " + event + " FROM " + this + " TO " + sink);
@@ -589,25 +554,16 @@ public class MavenDroolsController implements DroolsController {
}
- /**
- * {@inheritDoc}
- */
@Override
public String getVersion() {
return this.policyContainer.getVersion();
}
- /**
- * {@inheritDoc}
- */
@Override
public String getArtifactId() {
return this.policyContainer.getArtifactId();
}
- /**
- * {@inheritDoc}
- */
@Override
public String getGroupId() {
return this.policyContainer.getGroupId();
@@ -620,9 +576,6 @@ public class MavenDroolsController implements DroolsController {
return modelClassLoaderHash;
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized boolean lock() {
logger.info("LOCK: " + this);
@@ -631,9 +584,6 @@ public class MavenDroolsController implements DroolsController {
return true;
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized boolean unlock() {
logger.info("UNLOCK: " + this);
@@ -642,34 +592,23 @@ public class MavenDroolsController implements DroolsController {
return true;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isLocked() {
return this.locked;
}
- /**
- * {@inheritDoc}
- */
@JsonIgnore
+ @Override
public PolicyContainer getContainer() {
return this.policyContainer;
}
- /**
- * {@inheritDoc}
- */
@JsonProperty("sessions")
@Override
public List<String> getSessionNames() {
return getSessionNames(true);
}
- /**
- * {@inheritDoc}
- */
@JsonProperty("sessionCoordinates")
@Override
public List<String> getCanonicalSessionNames() {
@@ -682,7 +621,7 @@ public class MavenDroolsController implements DroolsController {
* @return session names
*/
protected List<String> getSessionNames(boolean abbreviated) {
- List<String> sessionNames = new ArrayList<String>();
+ List<String> sessionNames = new ArrayList<>();
try {
for (PolicySession session: this.policyContainer.getPolicySessions()) {
if (abbreviated)
@@ -703,7 +642,7 @@ public class MavenDroolsController implements DroolsController {
* @return the attached Policy Container
*/
protected List<PolicySession> getSessions() {
- List<PolicySession> sessions = new ArrayList<PolicySession>();
+ List<PolicySession> sessions = new ArrayList<>();
sessions.addAll(this.policyContainer.getPolicySessions());
return sessions;
}
@@ -729,15 +668,11 @@ public class MavenDroolsController implements DroolsController {
throw new IllegalArgumentException("Invalid Session Name: " + sessionName);
}
- /**
- * {@inheritDoc}
- */
@Override
- public Map<String,Integer> factClassNames(String sessionName) throws IllegalArgumentException {
+ public Map<String,Integer> factClassNames(String sessionName) {
if (sessionName == null || sessionName.isEmpty())
throw new IllegalArgumentException("Invalid Session Name: " + sessionName);
-
- // List<String> classNames = new ArrayList<>();
+
Map<String,Integer> classNames = new HashMap<>();
PolicySession session = getSession(sessionName);
@@ -759,11 +694,8 @@ public class MavenDroolsController implements DroolsController {
return classNames;
}
- /**
- * {@inheritDoc}
- */
@Override
- public long factCount(String sessionName) throws IllegalArgumentException {
+ public long factCount(String sessionName) {
if (sessionName == null || sessionName.isEmpty())
throw new IllegalArgumentException("Invalid Session Name: " + sessionName);
@@ -771,9 +703,6 @@ public class MavenDroolsController implements DroolsController {
return session.getKieSession().getFactCount();
}
- /**
- * {@inheritDoc}
- */
@Override
public List<Object> facts(String sessionName, String className, boolean delete) {
if (sessionName == null || sessionName.isEmpty())
@@ -806,9 +735,6 @@ public class MavenDroolsController implements DroolsController {
return factObjects;
}
- /**
- * {@inheritDoc}
- */
@Override
public List<Object> factQuery(String sessionName, String queryName, String queriedEntity, boolean delete, Object... queryParams) {
if (sessionName == null || sessionName.isEmpty())
@@ -851,11 +777,8 @@ public class MavenDroolsController implements DroolsController {
return factObjects;
}
- /**
- * {@inheritDoc}
- */
@Override
- public Class<?> fetchModelClass(String className) throws IllegalStateException {
+ public Class<?> fetchModelClass(String className) {
Class<?> modelClass =
ReflectionUtil.fetchClass(this.policyContainer.getClassLoader(), className);
return modelClass;
@@ -883,10 +806,6 @@ public class MavenDroolsController implements DroolsController {
}
}
-
- /**
- * {@inheritDoc}
- */
@Override
public boolean isBrained() {
return true;
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java
index c4db6c7e..2c4e40be 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java
@@ -35,178 +35,111 @@ import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
*/
public class NullDroolsController implements DroolsController {
- /**
- * {@inheritDoc}
- */
@Override
- public boolean start() throws IllegalStateException {
+ public boolean start() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
- public boolean stop() throws IllegalStateException {
+ public boolean stop() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
- public void shutdown() throws IllegalStateException {
+ public void shutdown() {
return;
}
- /**
- * {@inheritDoc}
- */
@Override
- public void halt() throws IllegalStateException {
+ public void halt() {
return;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isAlive() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean lock() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean unlock() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isLocked() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getGroupId() {
return NO_GROUP_ID;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getArtifactId() {
return NO_ARTIFACT_ID;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getVersion() {
return NO_VERSION;
}
- /**
- * {@inheritDoc}
- */
@Override
public List<String> getSessionNames() {
- return new ArrayList<String>();
+ return new ArrayList<>();
}
- /**
- * {@inheritDoc}
- */
@Override
public List<String> getCanonicalSessionNames() {
- return new ArrayList<String>();
+ return new ArrayList<>();
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean offer(String topic, String event) {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
- public boolean deliver(TopicSink sink, Object event)
- throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
+ public boolean deliver(TopicSink sink, Object event) throws UnsupportedOperationException {
throw new IllegalStateException(this.getClass().getCanonicalName() + " invoked");
}
- /**
- * {@inheritDoc}
- */
@Override
public Object[] getRecentSourceEvents() {
return new String[0];
}
- /**
- * {@inheritDoc}
- */
@Override
public PolicyContainer getContainer() {
return null;
}
- /**
- * {@inheritDoc}
- */
@Override
public String[] getRecentSinkEvents() {
return new String[0];
}
- /**
- * {@inheritDoc}
- */
@Override
- public boolean ownsCoder(Class<? extends Object> coderClass, int modelHash) throws IllegalStateException {
+ public boolean ownsCoder(Class<? extends Object> coderClass, int modelHash) {
throw new IllegalStateException(this.getClass().getCanonicalName() + " invoked");
}
- /**
- * {@inheritDoc}
- */
@Override
- public Class<?> fetchModelClass(String className) throws IllegalArgumentException {
+ public Class<?> fetchModelClass(String className) {
throw new IllegalArgumentException(this.getClass().getCanonicalName() + " invoked");
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isBrained() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@@ -214,9 +147,6 @@ public class NullDroolsController implements DroolsController {
return builder.toString();
}
- /**
- * {@inheritDoc}
- */
@Override
public void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
List<TopicCoderFilterConfiguration> decoderConfigurations,
@@ -225,38 +155,26 @@ public class NullDroolsController implements DroolsController {
throw new IllegalArgumentException(this.getClass().getCanonicalName() + " invoked");
}
- /**
- * {@inheritDoc}
- */
@Override
public Map<String, Integer> factClassNames(String sessionName)
throws IllegalArgumentException {
return new HashMap<String,Integer>();
}
- /**
- * {@inheritDoc}
- */
@Override
- public long factCount(String sessionName) throws IllegalArgumentException {
+ public long factCount(String sessionName) {
return 0;
}
- /**
- * {@inheritDoc}
- */
@Override
public List<Object> facts(String sessionName, String className, boolean delete) {
- return new ArrayList<Object>();
+ return new ArrayList<>();
}
- /**
- * {@inheritDoc}
- */
@Override
public List<Object> factQuery(String sessionName, String queryName,
String queriedEntity,
boolean delete, Object... queryParams) {
- return new ArrayList<Object>();
+ return new ArrayList<>();
}
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistence.java b/policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistence.java
index 52aac744..bdda8e84 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistence.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistence.java
@@ -69,11 +69,11 @@ public interface SystemPersistence {
*
* @param controllerName the controller name
* @param configuration object containing the configuration
+ *
* @return true if storage is succesful, false otherwise
* @throws IllegalArgumentException if the configuration cannot be handled by the persistence manager
*/
- public boolean storeController(String controllerName, Object configuration)
- throws IllegalArgumentException;
+ public boolean storeController(String controllerName, Object configuration);
/**
* delete controller configuration
@@ -88,19 +88,20 @@ public interface SystemPersistence {
*
* @param controllerName controller name
* @return properties for this controller
+ *
* @throws IllegalArgumentException if the controller name does not lead to a properties configuration
*/
- public Properties getControllerProperties(String controllerName)
- throws IllegalArgumentException;
+ public Properties getControllerProperties(String controllerName);
/**
* get properties by name
*
* @param name
* @return properties
+ *
* @throws IllegalArgumentException if the name does not lead to a properties configuration
*/
- public Properties getProperties(String name) throws IllegalArgumentException;
+ public Properties getProperties(String name);
/**
* Persistence Manager. For now it is a file-based properties management,
@@ -196,6 +197,7 @@ class SystemPropertiesPersistence implements SystemPersistence {
/**
* deletes properties-based controller configuration
* @param controllerName the controller name
+ *
* @return true if the properties has been deleted from disk, false otherwise
*/
@Override
@@ -223,12 +225,12 @@ class SystemPropertiesPersistence implements SystemPersistence {
}
@Override
- public Properties getControllerProperties(String controllerName) throws IllegalArgumentException {
+ public Properties getControllerProperties(String controllerName) {
return this.getProperties(controllerName + CONTROLLER_SUFFIX_IDENTIFIER);
}
@Override
- public Properties getProperties(String name) throws IllegalArgumentException {
+ public Properties getProperties(String name) {
Path propertiesPath =
Paths.get(CONFIG_DIR_NAME, name + ".properties");
@@ -242,7 +244,7 @@ class SystemPropertiesPersistence implements SystemPersistence {
logger.warn("{}: can't read properties @ {}", name, propertiesPath);
throw new IllegalArgumentException("can't read properties for " +
name + " @ " +
- propertiesPath);
+ propertiesPath, e);
}
}
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java
index 8e7dec0b..1c8dafea 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java
@@ -473,21 +473,20 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
/**
* Logger
*/
- private static Logger logger = LoggerFactory.getLogger(GsonProtocolCoderToolset.class);
+ private static final Logger logger = LoggerFactory.getLogger(GsonProtocolCoderToolset.class);
/**
* Formatter for JSON encoding/decoding
*/
@JsonIgnore
- public static DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+ public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
@JsonIgnore
- public static DateTimeFormatter zuluFormat = DateTimeFormatter.ISO_INSTANT;
+ public static final DateTimeFormatter zuluFormat = DateTimeFormatter.ISO_INSTANT;
/**
* Adapter for ZonedDateTime
*/
-
public static class GsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
index 4f5e33e7..d877f1e9 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
@@ -176,6 +176,7 @@ public class RestManager {
return Response.status(Response.Status.OK).
entity(PolicyEngine.manager.getFeatureProvider(featureName)).build();
} catch(IllegalArgumentException iae) {
+ logger.debug("feature unavailable: {}", featureName, iae);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(iae.getMessage())).build();
}
@@ -478,6 +479,7 @@ public class RestManager {
entity(PolicyController.factory.getFeatureProvider(featureName)).
build();
} catch(IllegalArgumentException iae) {
+ logger.debug("{}: cannot feature {} because of {}", this, featureName, iae.getMessage(), iae);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(iae.getMessage())).build();
}
@@ -504,10 +506,12 @@ public class RestManager {
entity(PolicyController.factory.get(controllerName)).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " not acceptable")).
build();
@@ -541,12 +545,12 @@ public class RestManager {
entity(new Error(controllerName + " does not exist")).
build();
} catch (IllegalArgumentException e) {
- logger.info("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
+ logger.debug("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.BAD_REQUEST).
entity(new Error(controllerName + " not found: " + e.getMessage())).
build();
} catch (IllegalStateException e) {
- logger.info("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
+ logger.debug("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " not acceptable")).build();
}
@@ -554,7 +558,7 @@ public class RestManager {
try {
PolicyEngine.manager.removePolicyController(controllerName);
} catch (IllegalArgumentException | IllegalStateException e) {
- logger.info("{}: cannot remove policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
+ logger.debug("{}: cannot remove policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
entity(new Error(e.getMessage())).
build();
@@ -585,10 +589,12 @@ public class RestManager {
entity(controller.getProperties()).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " not acceptable")).
build();
@@ -736,10 +742,12 @@ public class RestManager {
entity(drools).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get drools-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get drools-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " not acceptable")).
build();
@@ -770,10 +778,12 @@ public class RestManager {
entity(sessionCounts).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " not acceptable")).
build();
@@ -802,10 +812,12 @@ public class RestManager {
entity(drools.factClassNames(sessionName)).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get drools-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error("entity not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get drools-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + sessionName + " not acceptable")).
build();
@@ -841,11 +853,13 @@ public class RestManager {
else
return Response.status(Response.Status.OK).entity(facts.size()).build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + sessionName + ":" + factType +
" not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + sessionName + ":" + factType +
" not acceptable")).
@@ -879,16 +893,22 @@ public class RestManager {
List<Object> facts = drools.facts(sessionName, factType, true);
return Response.status(Response.Status.OK).entity(facts).build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, factType {}, because of {}",
+ this, controllerName, sessionName, factType, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + sessionName + ":" + factType +
" not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, factType {}, because of {}",
+ this, controllerName, sessionName, factType, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + sessionName + ":" + factType +
" not acceptable")).
build();
} catch (Exception e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, factType {}, because of {}",
+ this, controllerName, sessionName, factType, e.getMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
entity(new Error(e.getMessage())).
build();
@@ -927,16 +947,22 @@ public class RestManager {
else
return Response.status(Response.Status.OK).entity(facts.size()).build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, query {}, entity {} because of {}",
+ this, controllerName, sessionName, queryName, queriedEntity, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + sessionName + ":" + queryName +
queriedEntity + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, query {}, entity {} because of {}",
+ this, controllerName, sessionName, queryName, queriedEntity, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + sessionName + ":" + queryName +
queriedEntity + " not acceptable")).
build();
} catch (Exception e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, query {}, entity {} because of {}",
+ this, controllerName, sessionName, queryName, queriedEntity, e.getMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
entity(new Error(e.getMessage())).
build();
@@ -976,16 +1002,22 @@ public class RestManager {
facts = drools.factQuery(sessionName, queryName, queriedEntity, false, queryParameters.toArray());
return Response.status(Response.Status.OK).entity(facts).build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, query {}, entity {}, params {} because of {}",
+ this, controllerName, sessionName, queryName, queriedEntity, queryParameters, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + sessionName + ":" + queryName +
queriedEntity + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, query {}, entity {}, params {} because of {}",
+ this, controllerName, sessionName, queryName, queriedEntity, queryParameters, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + sessionName + ":" + queryName +
queriedEntity + " not acceptable")).
build();
} catch (Exception e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, query {}, entity {}, params {} because of {}",
+ this, controllerName, sessionName, queryName, queriedEntity, queryParameters, e.getMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
entity(new Error(e.getMessage())).
build();
@@ -1025,16 +1057,22 @@ public class RestManager {
facts = drools.factQuery(sessionName, queryName, queriedEntity, true, queryParameters.toArray());
return Response.status(Response.Status.OK).entity(facts).build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, query {}, entity {}, params {} because of {}",
+ this, controllerName, sessionName, queryName, queriedEntity, queryParameters, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + sessionName + ":" + queryName +
queriedEntity + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, query {}, entity {}, params {} because of {}",
+ this, controllerName, sessionName, queryName, queriedEntity, queryParameters, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + sessionName + ":" + queryName +
queriedEntity + " not acceptable")).
build();
} catch (Exception e) {
+ logger.debug("{}: cannot get: drools-controller {}, session {}, query {}, entity {}, params {} because of {}",
+ this, controllerName, sessionName, queryName, queriedEntity, queryParameters, e.getMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
entity(new Error(e.getMessage())).
build();
@@ -1088,10 +1126,12 @@ public class RestManager {
entity(decoders).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get decoders for policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get decoders for policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " not acceptable")).
build();
@@ -1125,10 +1165,12 @@ public class RestManager {
entity(filters).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get decoders for policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get decoders for policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " not acceptable")).
build();
@@ -1163,10 +1205,14 @@ public class RestManager {
entity(decoder).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get decoders for policy-controller {} topic {} because of {}",
+ this, controllerName, topic, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + topic + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get decoders for policy-controller {} topic {} because of {}",
+ this, controllerName, topic, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + topic + " not acceptable")).
build();
@@ -1207,10 +1253,14 @@ public class RestManager {
entity(decoder.getCoders()).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get decoders for policy-controller {} topic {} because of {}",
+ this, controllerName, topic, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + topic + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get decoders for policy-controller {} topic {} because of {}",
+ this, controllerName, topic, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + topic + " not acceptable")).
build();
@@ -1254,11 +1304,15 @@ public class RestManager {
entity(filters).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get decoder filters for policy-controller {} topic {} type {} because of {}",
+ this, controllerName, topic, factClass, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get decoder filters for policy-controller {} topic {} type {} because of {}",
+ this, controllerName, topic, factClass, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + " not acceptable")).
@@ -1313,11 +1367,15 @@ public class RestManager {
entity(filters).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get decoder filters for policy-controller {} topic {} type {} filters {} because of {}",
+ this, controllerName, topic, factClass, configFilters, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get decoder filters for policy-controller {} topic {} type {} filters {} because of {}",
+ this, controllerName, topic, factClass, configFilters, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + " not acceptable")).
@@ -1368,11 +1426,15 @@ public class RestManager {
entity(filter.getRules()).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get decoder filters for policy-controller {} topic {} type {} because of {}",
+ this, controllerName, topic, factClass, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get decoder filters for policy-controller {} topic {} type {} because of {}",
+ this, controllerName, topic, factClass, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + " not acceptable")).
@@ -1425,11 +1487,15 @@ public class RestManager {
entity(filter.getRules(ruleName)).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get decoder filters for policy-controller {} topic {} type {} rule {} because of {}",
+ this, controllerName, topic, factClass, ruleName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + ": " + ruleName + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get decoder filters for policy-controller {} topic {} type {} rule {} because of {}",
+ this, controllerName, topic, factClass, ruleName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + ":" + ruleName + " not acceptable")).
@@ -1499,11 +1565,15 @@ public class RestManager {
entity(filter.getRules()).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get decoder filters for policy-controller {} topic {} type {} rule {} because of {}",
+ this, controllerName, topic, factClass, ruleName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + ": " + ruleName + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get decoder filters for policy-controller {} topic {} type {} rule {} because of {}",
+ this, controllerName, topic, factClass, ruleName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + ":" + ruleName + " not acceptable")).
@@ -1566,11 +1636,15 @@ public class RestManager {
entity(filter.getRules()).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot access decoder filter rules for policy-controller {} topic {} type {} rule {} because of {}",
+ this, controllerName, topic, factClass, ruleName, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot access decoder filter rules for policy-controller {} topic {} type {} rule {} because of {}",
+ this, controllerName, topic, factClass, ruleName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + topic + ":" +
factClass + " not acceptable")).
@@ -1603,11 +1677,15 @@ public class RestManager {
try {
policyController = PolicyController.factory.get(controllerName);
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get decoders for policy-controller {} topic {} because of {}",
+ this, controllerName, topic, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(controllerName + ":" + topic + ":" +
" not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get decoders for policy-controller {} topic {} because of {}",
+ this, controllerName, topic, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + ":" + topic + ":" +
" not acceptable")).
@@ -1628,6 +1706,8 @@ public class RestManager {
json);
result.decoding = true;
} catch (Exception e) {
+ logger.debug("{}: cannot get policy-controller {} topic {} because of {}",
+ this, controllerName, topic, e.getMessage(), e);
return Response.status(Response.Status.BAD_REQUEST).
entity(new Error(e.getMessage())).
build();
@@ -1638,6 +1718,8 @@ public class RestManager {
result.encoding = true;
} catch (Exception e) {
// continue so to propagate decoding results ..
+ logger.debug("{}: cannot encode for policy-controller {} topic {} because of {}",
+ this, controllerName, topic, e.getMessage(), e);
}
return Response.status(Response.Status.OK).
@@ -1667,10 +1749,14 @@ public class RestManager {
encoders = EventProtocolCoder.manager.getEncoderFilters
(drools.getGroupId(), drools.getArtifactId());
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot get encoder filters for policy-controller {} because of {}",
+ this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.BAD_REQUEST).
entity(new Error(controllerName + " not found: " + e.getMessage())).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot get encoder filters for policy-controller {} because of {}",
+ this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " is not accepting the request")).build();
}
@@ -2100,14 +2186,20 @@ public class RestManager {
entity(new Error("Failure to inject event over " + topic)).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot offer for encoder ueb topic for {} because of {}",
+ this, topic, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(topic + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot offer for encoder ueb topic for {} because of {}",
+ this, topic, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(topic + " not acceptable due to current state")).
build();
} catch (Exception e) {
+ logger.debug("{}: cannot offer for encoder ueb topic for {} because of {}",
+ this, topic, e.getMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
entity(new Error(e.getMessage())).
build();
@@ -2144,14 +2236,20 @@ public class RestManager {
entity(new Error("Failure to inject event over " + topic)).
build();
} catch (IllegalArgumentException e) {
+ logger.debug("{}: cannot offer for encoder dmaap topic for {} because of {}",
+ this, topic, e.getMessage(), e);
return Response.status(Response.Status.NOT_FOUND).
entity(new Error(topic + " not found")).
build();
} catch (IllegalStateException e) {
+ logger.debug("{}: cannot offer for encoder dmaap topic for {} because of {}",
+ this, topic, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(topic + " not acceptable due to current state")).
build();
} catch (Exception e) {
+ logger.debug("{}: cannot offer for encoder dmaap topic for {} because of {}",
+ this, topic, e.getMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
entity(new Error(e.getMessage())).
build();
@@ -2262,7 +2360,7 @@ public class RestManager {
* @return the underlying drools controller
* @throws IllegalArgumentException if an invalid controller name has been passed in
*/
- protected DroolsController getDroolsController(String controllerName) throws IllegalArgumentException {
+ protected DroolsController getDroolsController(String controllerName) {
PolicyController controller = PolicyController.factory.get(controllerName);
if (controller == null)
throw new IllegalArgumentException(controllerName + " does not exist");
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
index 1ee12304..36821659 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
@@ -97,7 +97,7 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
* @throws IllegalArgumentException when invalid or insufficient
* properties are provided
*/
- public void configure(Properties properties) throws IllegalArgumentException;
+ public void configure(Properties properties);
/**
* registers a new Policy Controller with the Policy Engine
@@ -111,8 +111,7 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
* this operation is not permitted.
* @return the newly instantiated Policy Controller
*/
- public PolicyController createPolicyController(String name, Properties properties)
- throws IllegalArgumentException, IllegalStateException;
+ public PolicyController createPolicyController(String name, Properties properties);
/**
* updates the Policy Engine with the given configuration
@@ -122,8 +121,7 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
* @throws IllegalArgumentException if invalid argument provided
* @throws IllegalStateException if the system is in an invalid state
*/
- public boolean configure(PdpdConfiguration configuration)
- throws IllegalArgumentException, IllegalStateException;
+ public boolean configure(PdpdConfiguration configuration);
/**
* updates a set of Policy Controllers with configuration information
@@ -133,8 +131,7 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
* @throws IllegalArgumentException
* @throws IllegalStateException
*/
- public List<PolicyController> updatePolicyControllers(List<ControllerConfiguration> configuration)
- throws IllegalArgumentException, IllegalStateException;
+ public List<PolicyController> updatePolicyControllers(List<ControllerConfiguration> configuration);
/**
* updates an already existing Policy Controller with configuration information
@@ -146,8 +143,7 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
* @throws IllegalStateException if the controller is in a bad state
* @throws Exception any other reason
*/
- public PolicyController updatePolicyController(ControllerConfiguration configuration)
- throws Exception;
+ public PolicyController updatePolicyController(ControllerConfiguration configuration);
/**
* removes the Policy Controller identified by its name from the Policy Engine
@@ -364,9 +360,6 @@ class PolicyEngineManager implements PolicyEngine {
protected Gson decoder = new GsonBuilder().disableHtmlEscaping().create();
- /**
- * {@inheritDoc}
- */
@Override
public synchronized void boot(String cliArgs[]) {
@@ -397,11 +390,8 @@ class PolicyEngineManager implements PolicyEngine {
}
}
- /**
- * {@inheritDoc}
- */
@Override
- public synchronized void configure(Properties properties) throws IllegalArgumentException {
+ public synchronized void configure(Properties properties) {
if (properties == null) {
logger.warn("No properties provided");
@@ -456,9 +446,6 @@ class PolicyEngineManager implements PolicyEngine {
return;
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized PolicyController createPolicyController(String name, Properties properties)
throws IllegalArgumentException, IllegalStateException {
@@ -507,11 +494,8 @@ class PolicyEngineManager implements PolicyEngine {
}
- /**
- * {@inheritDoc}
- */
@Override
- public boolean configure(PdpdConfiguration config) throws IllegalArgumentException, IllegalStateException {
+ public boolean configure(PdpdConfiguration config) {
if (config == null)
throw new IllegalArgumentException("No configuration provided");
@@ -541,9 +525,6 @@ class PolicyEngineManager implements PolicyEngine {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public List<PolicyController> updatePolicyControllers(List<ControllerConfiguration> configControllers)
throws IllegalArgumentException, IllegalStateException {
@@ -567,12 +548,8 @@ class PolicyEngineManager implements PolicyEngine {
return policyControllers;
}
- /**
- * {@inheritDoc}
- */
@Override
- public PolicyController updatePolicyController(ControllerConfiguration configController)
- throws Exception {
+ public PolicyController updatePolicyController(ControllerConfiguration configController) {
if (configController == null)
throw new IllegalArgumentException("No controller configuration has been provided");
@@ -595,7 +572,7 @@ class PolicyEngineManager implements PolicyEngine {
policyController = PolicyController.factory.get(controllerName);
} catch (IllegalArgumentException e) {
// not found
- logger.warn("Policy Controller " + controllerName + " not found");
+ logger.warn("Policy Controller " + controllerName + " not found", e);
}
if (policyController == null) {
@@ -669,11 +646,8 @@ class PolicyEngineManager implements PolicyEngine {
}
}
- /**
- * {@inheritDoc}
- */
@Override
- public synchronized boolean start() throws IllegalStateException {
+ public synchronized boolean start() {
/* policy-engine dispatch pre start hook */
for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
@@ -770,9 +744,6 @@ class PolicyEngineManager implements PolicyEngine {
return success;
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized boolean stop() {
@@ -858,11 +829,8 @@ class PolicyEngineManager implements PolicyEngine {
return success;
}
- /**
- * {@inheritDoc}
- */
@Override
- public synchronized void shutdown() throws IllegalStateException {
+ public synchronized void shutdown() {
/* policy-engine dispatch pre shutdown hook */
for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
@@ -948,17 +916,11 @@ class PolicyEngineManager implements PolicyEngine {
}).start();
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized boolean isAlive() {
return this.alive;
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized boolean lock() {
@@ -1006,9 +968,6 @@ class PolicyEngineManager implements PolicyEngine {
return success;
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized boolean unlock() {
@@ -1056,42 +1015,27 @@ class PolicyEngineManager implements PolicyEngine {
return success;
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized boolean isLocked() {
return this.locked;
}
- /**
- * {@inheritDoc}
- */
@Override
public void removePolicyController(String name) {
PolicyController.factory.destroy(name);
}
- /**
- * {@inheritDoc}
- */
@Override
public void removePolicyController(PolicyController controller) {
PolicyController.factory.destroy(controller);
}
- /**
- * {@inheritDoc}
- */
@JsonIgnore
@Override
public List<PolicyController> getPolicyControllers() {
return PolicyController.factory.inventory();
}
- /**
- * {@inheritDoc}
- */
@JsonProperty("controllers")
@Override
public List<String> getPolicyControllerIds() {
@@ -1102,9 +1046,6 @@ class PolicyEngineManager implements PolicyEngine {
return controllerNames;
}
- /**
- * {@inheritDoc}
- */
@Override
@JsonIgnore
public Properties getProperties() {
@@ -1112,36 +1053,23 @@ class PolicyEngineManager implements PolicyEngine {
}
- /**
- * {@inheritDoc}
- */
@SuppressWarnings("unchecked")
@Override
public List<TopicSource> getSources() {
return (List<TopicSource>) this.sources;
}
- /**
- * {@inheritDoc}
- */
@SuppressWarnings("unchecked")
@Override
public List<TopicSink> getSinks() {
return (List<TopicSink>) this.sinks;
}
- /**
- * {@inheritDoc}
- */
@Override
public List<HttpServletServer> getHttpServers() {
return this.httpServers;
}
-
- /**
- * {@inheritDoc}
- */
@Override
public List<String> getFeatures() {
List<String> features = new ArrayList<String>();
@@ -1150,21 +1078,15 @@ class PolicyEngineManager implements PolicyEngine {
}
return features;
}
-
- /**
- * {@inheritDoc}
- */
+
@JsonIgnore
@Override
public List<PolicyEngineFeatureAPI> getFeatureProviders() {
return PolicyEngineFeatureAPI.providers.getList();
}
- /**
- * {@inheritDoc}
- */
@Override
- public PolicyEngineFeatureAPI getFeatureProvider(String featureName) throws IllegalArgumentException {
+ public PolicyEngineFeatureAPI getFeatureProvider(String featureName) {
if (featureName == null || featureName.isEmpty())
throw new IllegalArgumentException("A feature name must be provided");
@@ -1176,9 +1098,6 @@ class PolicyEngineManager implements PolicyEngine {
throw new IllegalArgumentException("Invalid Feature Name: " + featureName);
}
- /**
- * {@inheritDoc}
- */
@Override
public void onTopicEvent(CommInfrastructure commType, String topic, String event) {
/* configuration request */
@@ -1191,9 +1110,6 @@ class PolicyEngineManager implements PolicyEngine {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean deliver(String topic, Object event)
throws IllegalArgumentException, IllegalStateException {
@@ -1224,9 +1140,6 @@ class PolicyEngineManager implements PolicyEngine {
topic, event);
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean deliver(String busType, String topic, Object event)
throws IllegalArgumentException, IllegalStateException,
@@ -1270,9 +1183,6 @@ class PolicyEngineManager implements PolicyEngine {
topic, event);
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean deliver(Topic.CommInfrastructure busType,
String topic, Object event)
@@ -1323,9 +1233,6 @@ class PolicyEngineManager implements PolicyEngine {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean deliver(Topic.CommInfrastructure busType,
String topic, String event)
@@ -1361,9 +1268,6 @@ class PolicyEngineManager implements PolicyEngine {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized void activate() {
@@ -1406,9 +1310,6 @@ class PolicyEngineManager implements PolicyEngine {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public synchronized void deactivate() {