summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-09-28 04:58:26 -0400
committerPamela Dragosh <pdragosh@research.att.com>2018-10-01 10:28:44 -0400
commita0e0c7840f72392152a970d88a5a66d394c4a793 (patch)
tree1a1976844cb52020407b4d20e019f81ec25d5abf
parent367f9d25434202a4fd6f5e54cb19196c7ec3d058 (diff)
Set drools-pdp checkstyle config
Fixed last remaining checkstyle issues along with setting the pom.xml to the correct path setting. Fixed forbidden summary fragments, not allowed to prepend summary with "This method returns" Issue-ID: POLICY-1153 Change-Id: I267842080494132a7b5507731e14f027a3f6fe44 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
-rw-r--r--api-active-standby-management/checkstyle-suppressions.xml30
-rw-r--r--api-active-standby-management/pom.xml41
-rw-r--r--api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureAPI.java64
-rw-r--r--api-state-management/checkstyle-suppressions.xml30
-rw-r--r--api-state-management/pom.xml46
-rw-r--r--api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java49
-rw-r--r--feature-active-standby-management/checkstyle-suppressions.xml30
-rw-r--r--feature-active-standby-management/pom.xml36
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java16
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java2
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java6
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java4
-rw-r--r--feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java6
-rw-r--r--feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java2
-rw-r--r--feature-healthcheck/checkstyle-suppressions.xml30
-rw-r--r--feature-healthcheck/pom.xml36
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/AafHealthCheckFilter.java2
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java10
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java2
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/TestAafHealthCheckFilter.java2
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java2
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Forward.java2
-rw-r--r--feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java6
-rw-r--r--feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java47
-rw-r--r--feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/EntityMgrTransTest.java4
-rw-r--r--feature-state-management/checkstyle-suppressions.xml30
-rw-r--r--feature-state-management/pom.xml36
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java5
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java2
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java33
-rw-r--r--feature-test-transaction/checkstyle-suppressions.xml33
-rw-r--r--feature-test-transaction/pom.xml36
-rw-r--r--feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java2
-rw-r--r--policy-core/checkstyle-suppressions.xml30
-rw-r--r--policy-core/pom.xml40
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java22
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java52
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java (renamed from policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPI.java)6
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java12
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApiTest.java (renamed from policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPITest.java)8
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java16
-rw-r--r--policy-management/checkstyle-suppressions.xml33
-rw-r--r--policy-management/pom.xml36
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java4
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureAPI.java2
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java2
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java184
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java2
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java1134
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java582
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java112
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java102
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java185
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java533
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafBase.java6
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafTelemetryAuthFilter.java2
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/Main.java281
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyController.java27
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java206
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java182
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java60
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java16
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/server/restful/test/TestAafTelemetryAuthFilter.java2
-rw-r--r--policy-utils/checkstyle-suppressions.xml33
-rw-r--r--policy-utils/pom.xml75
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java8
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MDCTransaction.java2
-rw-r--r--pom.xml36
68 files changed, 2976 insertions, 1739 deletions
diff --git a/api-active-standby-management/checkstyle-suppressions.xml b/api-active-standby-management/checkstyle-suppressions.xml
new file mode 100644
index 00000000..b6fa7eff
--- /dev/null
+++ b/api-active-standby-management/checkstyle-suppressions.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 AT&T Technologies. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks="AbbreviationAsWordInName"
+ files="ActiveStandbyFeatureAPI.java"
+ lines="1-9999"/>
+</suppressions>
diff --git a/api-active-standby-management/pom.xml b/api-active-standby-management/pom.xml
index eec22ee4..665ef777 100644
--- a/api-active-standby-management/pom.xml
+++ b/api-active-standby-management/pom.xml
@@ -46,4 +46,45 @@
<scope>provided</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureAPI.java b/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureAPI.java
index ef02c617..ac1f1ce5 100644
--- a/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureAPI.java
+++ b/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureAPI.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* api-active-standby-management
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,40 +24,38 @@ import org.onap.policy.drools.utils.OrderedService;
import org.onap.policy.drools.utils.OrderedServiceImpl;
/**
- * This interface provides a way to invoke optional features at various
- * points in the code. At appropriate points in the
- * application, the code iterates through this list, invoking these optional
- * methods.
+ * This interface provides a way to invoke optional features at various points in the code. At
+ * appropriate points in the application, the code iterates through this list, invoking these
+ * optional methods.
*/
-public interface ActiveStandbyFeatureAPI extends OrderedService
-{
- /**
- * 'FeatureAPI.impl.getList()' returns an ordered list of objects
- * implementing the 'FeatureAPI' interface.
- */
- public static OrderedServiceImpl<ActiveStandbyFeatureAPI> impl =
- new OrderedServiceImpl<>(ActiveStandbyFeatureAPI.class);
+public interface ActiveStandbyFeatureAPI extends OrderedService {
+ /**
+ * 'FeatureAPI.impl.getList()' returns an ordered list of objects implementing the 'FeatureAPI'
+ * interface.
+ */
+ public static OrderedServiceImpl<ActiveStandbyFeatureAPI> impl =
+ new OrderedServiceImpl<>(ActiveStandbyFeatureAPI.class);
- /**
- * This method returns the resourceName (PDP ID) for the Drools-PDP that is
- * currently designated as active.
- *
- * @return String (resourceName)
- */
- public String getPdpdNowActive();
+ /**
+ * Returns the resourceName (PDP ID) for the Drools-PDP that is
+ * currently designated as active.
+ *
+ * @return String (resourceName)
+ */
+ public String getPdpdNowActive();
- /**
- * This method returns the resourceName (PDP ID) for the Drools-PDP that was
- * previously designated as active.
- *
- * @return String (resourceName)
- */
- public String getPdpdLastActive();
-
- /**
- * This method returns the resourceName associated with this instance of the feature
- * @return String (resourceName)
- */
- public String getResourceName();
+ /**
+ * Returns the resourceName (PDP ID) for the Drools-PDP that is
+ * previously designated as active.
+ *
+ * @return String (resourceName)
+ */
+ public String getPdpdLastActive();
+ /**
+ * Returns the resourceName associated with this instance of the feature.
+ *
+ * @return String (resourceName)
+ */
+ public String getResourceName();
}
diff --git a/api-state-management/checkstyle-suppressions.xml b/api-state-management/checkstyle-suppressions.xml
new file mode 100644
index 00000000..f208c3ab
--- /dev/null
+++ b/api-state-management/checkstyle-suppressions.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 AT&T Technologies. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks="AbbreviationAsWordInName"
+ files="StateManagementFeatureAPI.java"
+ lines="1-9999"/>
+</suppressions>
diff --git a/api-state-management/pom.xml b/api-state-management/pom.xml
index 564e5d91..9e2965ba 100644
--- a/api-state-management/pom.xml
+++ b/api-state-management/pom.xml
@@ -40,11 +40,6 @@
<swagger.version>1.5.0</swagger.version>
</properties>
- <build>
- <plugins>
- <!-- none -->
- </plugins>
- </build>
<dependencies>
<dependency>
@@ -59,4 +54,45 @@
<version>${project.version}</version>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java b/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java
index 3afd0c74..be229ef3 100644
--- a/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java
+++ b/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-core
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* fail if any module has set the value ALLNOTWELL, stopping the forward progress counter and
* eventually causing the operational state to become disabled.
*
- * ALLSEEMSWELL is passed to the method when the client is healthy ALLNOTWELL is passed to the
+ * <p>ALLSEEMSWELL is passed to the method when the client is healthy ALLNOTWELL is passed to the
* method when the client is disabled
*
* @param key - This should be a unique identifier for the entity making the call (e.g., class
@@ -91,48 +91,48 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* @param msg - A message is required. It should indicate why all is not well or a message
* indicating that a component has been restored to health (perhaps indicating the
* problem that has resolved).
- * @throws AllSeemsWellException
+ * @throws AllSeemsWellException exception
*/
public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
throws AllSeemsWellException;
/**
- * This method is called to add an Observer to receive notifications of state changes
+ * This method is called to add an Observer to receive notifications of state changes.
*
- * @param stateChangeObserver
+ * @param stateChangeObserver observer
*/
public void addObserver(Observer stateChangeObserver);
/**
- * This method returns the X.731 Administrative State for this resource
+ * Returns the X.731 Administrative State for this resource.
*
* @return String (locked, unlocked)
*/
public String getAdminState();
/**
- * This method returns the X.731 Operational State for this resource
+ * Returns the X.731 Operational State for this resource.
*
* @return String (enabled, disabled)
- */
+ */
public String getOpState();
/**
- * This method returns the X.731 Availability Status for this resource
+ * Returns the X.731 Availability Status for this resource.
*
* @return String (failed; dependency; dependency,failed)
- */
+ */
public String getAvailStatus();
/**
- * This method returns the X.731 Standby Status for this resource
+ * Returns the X.731 Standby Status for this resource.
*
* @return String (providingservice, hotstandby or coldstandby)
- */
+ */
public String getStandbyStatus();
/**
- * This method returns the X.731 Standby Status for the named resource
+ * Returns the X.731 Standby Status for the named resource
*
* @param String (resourceName)
* @return String (providingservice, hotstandby or coldstandby)
@@ -144,8 +144,8 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* and the Availability Status to a value of failed. As a consequence the Standby Status value
* will take a value of coldstandby.
*
- * @param String (resourceName)
- * @throws Exception
+ * @param resourceName resource name
+ * @throws Exception exception
*/
public void disableFailed(String resourceName) throws Exception;
@@ -154,8 +154,7 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* the Availability Status to a value of failed. As a consequence the Standby Status value will
* take a value of coldstandby.
*
- * @param String (resourceName)
- * @throws Exception
+ * @throws Exception exception
*/
public void disableFailed() throws Exception;
@@ -165,7 +164,7 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* value is null, it will move to providingservice assuming the Operational State is enabled and
* Administrative State is unlocked.
*
- * @throws Exception
+ * @throws Exception exception
*/
public void promote() throws Exception;
@@ -174,28 +173,28 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* hotstandby. If the current value is null, it will move to hotstandby assuming the Operational
* State is enabled and Administrative State is unlocked. Else, it will move to coldstandby
*
- * @throws Exception
+ * @throws Exception exception
*/
public void demote() throws Exception;
/**
- * This method returns the resourceName associated with this instance of the
- * StateManagementFeature
+ * Returns the resourceName associated with this instance of the
+ * StateManagementFeature.
*
* @return String (resourceName)
*/
public String getResourceName();
/**
- * This Lockable method will lock the StateManagement object Admin state
+ * This Lockable method will lock the StateManagement object Admin state.
*
- * @return true if successfull, false otherwise
+ * @return true if successful, false otherwise
*/
@Override
public boolean lock();
/**
- * This Lockable method will unlock the StateManagement object Admin state
+ * This Lockable method will unlock the StateManagement object Admin state.
*
* @return true if successfull, false otherwise
*/
@@ -203,7 +202,7 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
public boolean unlock();
/**
- * This Lockable method indicates the Admin state StateManagement object
+ * This Lockable method indicates the Admin state StateManagement object.
*
* @return true if locked, false otherwise
*/
diff --git a/feature-active-standby-management/checkstyle-suppressions.xml b/feature-active-standby-management/checkstyle-suppressions.xml
new file mode 100644
index 00000000..cce89398
--- /dev/null
+++ b/feature-active-standby-management/checkstyle-suppressions.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 AT&T Technologies. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks="AbbreviationAsWordInName"
+ files="PMStandbyStateChangeNotifier.java"
+ lines="1-9999"/>
+</suppressions>
diff --git a/feature-active-standby-management/pom.xml b/feature-active-standby-management/pom.xml
index 00beae0c..086431c0 100644
--- a/feature-active-standby-management/pom.xml
+++ b/feature-active-standby-management/pom.xml
@@ -82,6 +82,42 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</build>
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
index 9e481f01..1b7d91bd 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeature.java
@@ -62,12 +62,12 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureAPI,
public static final int SEQ_NUM = 1;
- /**************************/
+ /*========================*/
/* 'FeatureAPI' interface */
- /**************************/
+ /*========================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public int getSequenceNumber() {
@@ -75,7 +75,7 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void globalInit(String[] args, String configDir) {
@@ -121,7 +121,7 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureAPI,
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean afterStart(PolicyEngine engine) {
@@ -210,7 +210,7 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String getPdpdNowActive() {
@@ -218,7 +218,7 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String getPdpdLastActive() {
@@ -226,7 +226,7 @@ public class ActiveStandbyFeature implements ActiveStandbyFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String getResourceName() {
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
index f0fd2789..12d716a6 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java
@@ -39,7 +39,7 @@ import org.onap.policy.drools.activestandby.DroolsPdpObject;
@NamedQueries({
@NamedQuery(name = "DroolsPdpEntity.findAll", query = "SELECT e FROM DroolsPdpEntity e "),
@NamedQuery(name = "DroolsPdpEntity.deleteAll", query = "DELETE FROM DroolsPdpEntity WHERE 1=1")
-})
+ })
public class DroolsPdpEntity extends DroolsPdpObject implements Serializable {
private static final long serialVersionUID = 1L;
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
index 08592f23..fddf0246 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java
@@ -637,7 +637,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
* Sanitize designated list.
*
* @param listOfDesignated list of designated pdps
- * @return
+ * @return list of drools pdps
*/
public List<DroolsPdp> santizeDesignatedList(List<DroolsPdp> listOfDesignated) {
@@ -668,7 +668,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
*
* @param pdps collection of pdps
* @param listOfDesignated list of designated pdps
- * @return
+ * @return drools pdp object
*/
public DroolsPdp computeMostRecentPrimary(Collection<DroolsPdp> pdps, List<DroolsPdp> listOfDesignated) {
boolean containsDesignated = false;
@@ -778,7 +778,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
*
* @param listOfDesignated list of designated pdps
* @param mostRecentPrimary most recent primary pdpd
- * @return
+ * @return drools pdp object
*/
public DroolsPdp computeDesignatedPdp(List<DroolsPdp> listOfDesignated, DroolsPdp mostRecentPrimary) {
DroolsPdp designatedPdp = null;
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java
index 554376ce..53f825d0 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PMStandbyStateChangeNotifier.java
@@ -122,7 +122,7 @@ public class PMStandbyStateChangeNotifier extends StateChangeNotifier {
String pdpId = ActiveStandbyProperties.getProperty(ActiveStandbyProperties.NODE_NAME);
if (logger.isDebugEnabled()) {
- logger.debug("handleStateChange: previousStandbyStatus = {}" + "; standbyStatus = {}",
+ logger.debug("handleStateChange: previousStandbyStatus = {}; standbyStatus = {}",
previousStandbyStatus, standbyStatus);
}
@@ -201,7 +201,7 @@ public class PMStandbyStateChangeNotifier extends StateChangeNotifier {
} else if (standbyStatus.equals(StateManagement.PROVIDING_SERVICE)) {
if (logger.isDebugEnabled()) {
- logger.debug("handleStateChange: standbyStatus= {} " + "scheduling activation of PDP={}", standbyStatus,
+ logger.debug("handleStateChange: standbyStatus= {} scheduling activation of PDP={}", standbyStatus,
pdpId);
}
if (previousStandbyStatus.equals(StateManagement.PROVIDING_SERVICE)) {
diff --git a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java
index 17f65459..86b5a66c 100644
--- a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java
+++ b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java
@@ -28,14 +28,14 @@ import java.util.UUID;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSourceFactory;
import org.onap.policy.common.utils.properties.exception.PropertyException;
-import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureAPI;
+import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureApi;
import org.onap.policy.drools.features.PolicyEngineFeatureAPI;
import org.onap.policy.drools.persistence.SystemPersistence;
import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class DistributedLockingFeature implements PolicyEngineFeatureAPI, PolicyResourceLockFeatureAPI {
+public class DistributedLockingFeature implements PolicyEngineFeatureAPI, PolicyResourceLockFeatureApi {
/**
* Logger instance.
@@ -165,7 +165,7 @@ public class DistributedLockingFeature implements PolicyEngineFeatureAPI, Policy
try (Connection conn = dataSource.getConnection();
PreparedStatement statement = conn.prepareStatement(
- "DELETE FROM pooling.locks WHERE host = ? OR expirationTime < now()");
+ "DELETE FROM pooling.locks WHERE host = ? OR expirationTime < now()")
) {
statement.setString(1, uuid.toString());
diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java
index 60a721b7..49f1026d 100644
--- a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java
+++ b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java
@@ -31,7 +31,7 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureAPI.OperResult;
+import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureApi.OperResult;
import org.onap.policy.drools.persistence.SystemPersistence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/feature-healthcheck/checkstyle-suppressions.xml b/feature-healthcheck/checkstyle-suppressions.xml
new file mode 100644
index 00000000..ed04d894
--- /dev/null
+++ b/feature-healthcheck/checkstyle-suppressions.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 AT&T Technologies. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks="OneTopLevelClass"
+ files="HealthCheck.java"
+ lines="1-9999"/>
+</suppressions>
diff --git a/feature-healthcheck/pom.xml b/feature-healthcheck/pom.xml
index 1acfb2d1..3ed46abc 100644
--- a/feature-healthcheck/pom.xml
+++ b/feature-healthcheck/pom.xml
@@ -86,6 +86,42 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</build>
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/AafHealthCheckFilter.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/AafHealthCheckFilter.java
index 3cb9def6..47a617b3 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/AafHealthCheckFilter.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/AafHealthCheckFilter.java
@@ -24,7 +24,7 @@ import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter;
import org.onap.policy.drools.server.restful.aaf.AafBase;
/**
- * Healthcheck AAF Authorization Filter
+ * Healthcheck AAF Authorization Filter.
*/
public class AafHealthCheckFilter extends AafGranularAuthFilter {
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
index d35b7371..40e4f354 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
@@ -201,7 +201,7 @@ class HealthCheckMonitor implements HealthCheck {
protected volatile Properties healthCheckProperties = null;
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public Reports healthCheck() {
@@ -242,7 +242,7 @@ class HealthCheckMonitor implements HealthCheck {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean start() {
@@ -265,7 +265,7 @@ class HealthCheckMonitor implements HealthCheck {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean stop() {
@@ -290,7 +290,7 @@ class HealthCheckMonitor implements HealthCheck {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void shutdown() {
@@ -298,7 +298,7 @@ class HealthCheckMonitor implements HealthCheck {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public synchronized boolean isAlive() {
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java
index 734a75e0..5047cb26 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java
@@ -49,7 +49,7 @@ import org.onap.policy.drools.healthcheck.HealthCheck.Reports;
tags = {
@Tag(name = "pdp-d-healthcheck", description = "Drools PDP Healthcheck Operations")
}
-)
+ )
public class RestHealthCheck {
@GET
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/TestAafHealthCheckFilter.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/TestAafHealthCheckFilter.java
index 03ca6897..9c34670c 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/TestAafHealthCheckFilter.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/TestAafHealthCheckFilter.java
@@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest;
import org.onap.policy.common.utils.network.NetworkUtil;
/**
- * Healthcheck AAF Authorization Filter
+ * Healthcheck AAF Authorization Filter.
*/
public class TestAafHealthCheckFilter extends AafHealthCheckFilter {
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java
index 94956d6b..e8e0174d 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java
@@ -34,7 +34,7 @@ public interface PoolingManager {
/**
* Gets the properties used to configure the manager.
*
- * @return
+ * @return pooling properties
*/
public PoolingProperties getProperties();
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Forward.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Forward.java
index d4037e90..38acb8c9 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Forward.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Forward.java
@@ -60,7 +60,7 @@ public class Forward extends Message {
private String requestId;
/**
- *
+ * Constructor.
*/
public Forward() {
super();
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java
index 381a896e..b85a6854 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java
@@ -98,13 +98,13 @@ public class JpaDroolsSessionConnector implements DroolsSessionConnector {
*/
private boolean update(EntityManager em, DroolsSession sess) {
- DroolsSessionEntity s = em.find(DroolsSessionEntity.class, sess.getSessionName());
- if (s == null) {
+ DroolsSessionEntity session = em.find(DroolsSessionEntity.class, sess.getSessionName());
+ if (session == null) {
return false;
}
logger.info("update: Updating session id to {}", sess.getSessionId());
- s.setSessionId(sess.getSessionId());
+ session.setSessionId(sess.getSessionId());
return true;
}
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java
index 7b17de6c..332e2984 100644
--- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java
+++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java
@@ -119,14 +119,16 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public int getSequenceNumber() {
return 1;
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public void globalInit(String[] args, String configDir) {
@@ -160,7 +162,8 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public PolicySession.ThreadModel selectThreadModel(PolicySession session) {
@@ -172,7 +175,8 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public void disposeKieSession(PolicySession policySession) {
@@ -184,7 +188,8 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public void destroyKieSession(PolicySession policySession) {
@@ -196,14 +201,16 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public boolean afterStart(PolicyEngine engine) {
return false;
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public boolean beforeStart(PolicyEngine engine) {
synchronized (cleanupLock) {
@@ -214,7 +221,8 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public boolean beforeActivate(PolicyEngine engine) {
synchronized (cleanupLock) {
@@ -225,7 +233,8 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public boolean afterActivate(PolicyEngine engine) {
return false;
@@ -686,19 +695,21 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine
return "Session " + session.getFullName() + " (persistent)";
}
- /** ************************ */
+ /*=========================*/
/* 'ThreadModel' interface */
- /** ************************ */
+ /*=========================*/
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public void start() {
thread.start();
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public void stop() {
// tell the thread to stop
@@ -720,19 +731,21 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine
}
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public void updated() {
// the container artifact has been updated -- adjust the thread name
thread.setName(getThreadName());
}
- /** ********************* */
+ /*======================*/
/* 'Runnable' interface */
- /** ********************* */
+ /*======================*/
/**
- * {@inheritDoc} */
+ * {@inheritDoc}.
+ **/
@Override
public void run() {
logger.info("PersistentThreadModel running");
diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/EntityMgrTransTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/EntityMgrTransTest.java
index c622a933..fb0d1102 100644
--- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/EntityMgrTransTest.java
+++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/EntityMgrTransTest.java
@@ -98,7 +98,7 @@ public class EntityMgrTransTest {
*/
@Test
public void testEntityMgrTrans_Inactive() throws Exception {
- EntityMgrTrans emt = new EntityMgrTrans(mgr);
+ final EntityMgrTrans emt = new EntityMgrTrans(mgr);
// verify that transaction was started
verify(trans).begin();
@@ -123,7 +123,7 @@ public class EntityMgrTransTest {
when(trans.getStatus()).thenReturn(Status.STATUS_ACTIVE);
- EntityMgrTrans emt = new EntityMgrTrans(mgr);
+ final EntityMgrTrans emt = new EntityMgrTrans(mgr);
// verify that transaction was not re-started started
verify(trans, never()).begin();
diff --git a/feature-state-management/checkstyle-suppressions.xml b/feature-state-management/checkstyle-suppressions.xml
new file mode 100644
index 00000000..3c394a9c
--- /dev/null
+++ b/feature-state-management/checkstyle-suppressions.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 AT&T Technologies. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks="AbbreviationAsWordInName"
+ files="DroolsPDPIntegrityMonitor.java"
+ lines="1-9999"/>
+</suppressions>
diff --git a/feature-state-management/pom.xml b/feature-state-management/pom.xml
index 4f8a9cf4..dd662f76 100644
--- a/feature-state-management/pom.xml
+++ b/feature-state-management/pom.xml
@@ -82,6 +82,42 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</build>
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java
index 3cb99f23..8dd211b4 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java
@@ -83,7 +83,6 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor {
* Static initialization -- create Drools Integrity Monitor, and an HTTP server to handle REST
* 'test' requests.
*
- * @throws StateManagementPropertiesException exception
* @throws IntegrityMonitorException exception
*/
public static DroolsPDPIntegrityMonitor init(String configDir) throws IntegrityMonitorException {
@@ -134,7 +133,7 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor {
// Now that we've validated the properties, create Drools Integrity Monitor
// with these properties.
im = makeMonitor(resourceName, stateManagementProperties);
- logger.info("init: New DroolsPDPIntegrityMonitor instantiated, resourceName = ", resourceName);
+ logger.info("init: New DroolsPDPIntegrityMonitor instantiated, resourceName = {}", resourceName);
// create http server
makeRestServer(testHost, testPort, stateManagementProperties);
@@ -174,7 +173,7 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor {
throws IntegrityMonitorException {
try {
- logger.info("init: Starting HTTP server, addr= {}", testHost + ":" + testPort);
+ logger.info("init: Starting HTTP server, addr= {}:{}", testHost, testPort);
IntegrityMonitorRestServer server = new IntegrityMonitorRestServer();
server.init(properties);
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java
index 49e4577c..77c188d0 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java
@@ -59,7 +59,7 @@ public class IntegrityMonitorRestManager {
code = 500,
message = "Integrity monitor sanity check encountered an exception. "
+ "This can indicate operational state disabled or administrative state locked")
- })
+ })
@GET
@Path("test")
public Response test() {
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java
index d7f9d108..94f35409 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java
@@ -91,7 +91,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void addObserver(Observer stateChangeObserver) {
@@ -105,7 +105,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String getAdminState() {
@@ -113,7 +113,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String getOpState() {
@@ -121,7 +121,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String getAvailStatus() {
@@ -129,7 +129,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String getStandbyStatus() {
@@ -137,7 +137,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String getStandbyStatus(String resourceName) {
@@ -145,7 +145,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void disableFailed(String resourceName) throws Exception {
@@ -154,7 +154,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void disableFailed() throws Exception {
@@ -162,7 +162,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void promote() throws Exception {
@@ -170,7 +170,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void demote() throws Exception {
@@ -178,7 +178,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String getResourceName() {
@@ -186,8 +186,9 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
- * @return
+ * {@inheritDoc}.
+ *
+ * @return true if locked or false if failed
*/
@Override
public boolean lock() {
@@ -201,7 +202,8 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
+ *
* @throws Exception exception
*/
@Override
@@ -216,7 +218,8 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
+ *
* @throws Exception exception
*/
@Override
diff --git a/feature-test-transaction/checkstyle-suppressions.xml b/feature-test-transaction/checkstyle-suppressions.xml
new file mode 100644
index 00000000..7112bbe4
--- /dev/null
+++ b/feature-test-transaction/checkstyle-suppressions.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 AT&T Technologies. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks="AbbreviationAsWordInName"
+ files="TestTransaction.java"
+ lines="1-9999"/>
+ <suppress checks="OneTopLevelClass"
+ files="TestTransaction.java"
+ lines="1-9999"/>
+</suppressions>
diff --git a/feature-test-transaction/pom.xml b/feature-test-transaction/pom.xml
index 92c8e217..f16a50f2 100644
--- a/feature-test-transaction/pom.xml
+++ b/feature-test-transaction/pom.xml
@@ -84,6 +84,42 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</build>
<dependencies>
diff --git a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java
index 3adecddc..c778bf67 100644
--- a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java
+++ b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java
@@ -141,7 +141,7 @@ class TTControllerTask implements Runnable {
if (!(this.controller.getDrools().isBrained())) {
this.alive = false;
- logger.error(this + ": unknown drools controller");
+ logger.error("{}: unknown drools controller", this);
return;
}
diff --git a/policy-core/checkstyle-suppressions.xml b/policy-core/checkstyle-suppressions.xml
new file mode 100644
index 00000000..d771a027
--- /dev/null
+++ b/policy-core/checkstyle-suppressions.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 AT&T Technologies. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks="AbbreviationAsWordInName"
+ files="PolicyResourceLockFeatureAPI.java|PolicySessionFeatureAPI.java"
+ lines="1-9999"/>
+</suppressions>
diff --git a/policy-core/pom.xml b/policy-core/pom.xml
index 34a78a39..70df3745 100644
--- a/policy-core/pom.xml
+++ b/policy-core/pom.xml
@@ -124,4 +124,44 @@
<scope>test</scope>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java
index f2a084e4..2c5d87f8 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java
@@ -109,7 +109,7 @@ public class PolicyContainer implements Startable {
}
synchronized (containers) {
if (newReleaseId != null) {
- logger.info("Add a new kieContainer in containers: releaseId: {}", newReleaseId.toString());
+ logger.info("Add a new kieContainer in containers: releaseId: {}", newReleaseId);
} else {
logger.warn("input releaseId is null");
}
@@ -289,8 +289,8 @@ public class PolicyContainer implements Startable {
}
logger.info("activatePolicySession:new session was added in sessions with name {}", name);
}
- logger.info("activatePolicySession:session - " + (session == null ? "null" : session.getFullName())
- + " is returned.");
+ logger.info("activatePolicySession:session - {} is returned.",
+ session == null ? "null" : session.getFullName());
return session;
}
}
@@ -317,7 +317,7 @@ public class PolicyContainer implements Startable {
logger.warn("adoptKieSession:input kieSession is null");
throw new IllegalArgumentException("KieSession '" + name + "' is null " + getName());
} else {
- logger.info("adoptKieSession:name: " + name + " kieSession: " + kieSession);
+ logger.info("adoptKieSession:name: {} kieSession: {}", name, kieSession);
}
// fetch KieBase, and verify it belongs to this KieContainer
boolean match = false;
@@ -507,12 +507,12 @@ public class PolicyContainer implements Startable {
return rval;
}
- /*************************/
+ /*=======================*/
/* 'Startable' interface */
- /*************************/
+ /*=======================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public synchronized boolean start() {
@@ -537,7 +537,7 @@ public class PolicyContainer implements Startable {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public synchronized boolean stop() {
@@ -576,7 +576,7 @@ public class PolicyContainer implements Startable {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public synchronized void shutdown() {
@@ -594,15 +594,13 @@ public class PolicyContainer implements Startable {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean isAlive() {
return isStarted;
}
- /*************************/
-
/**
* This method is similar to 'shutdown', but it also frees any persistence resources as well.
*/
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java
index bb2148c0..958933fb 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java
@@ -232,12 +232,12 @@ public class PolicySession
}
}
- /***********************************/
+ /*=================================*/
/* 'AgendaEventListener' interface */
- /***********************************/
+ /*=================================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void afterMatchFired(AfterMatchFiredEvent event) {
@@ -249,7 +249,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event) {
@@ -261,7 +261,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void afterRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event) {
@@ -273,7 +273,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void agendaGroupPopped(AgendaGroupPoppedEvent event) {
@@ -285,7 +285,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void agendaGroupPushed(AgendaGroupPushedEvent event) {
@@ -297,7 +297,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event) {
@@ -309,7 +309,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void beforeRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event) {
@@ -321,7 +321,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void beforeRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event) {
@@ -333,7 +333,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void matchCancelled(MatchCancelledEvent event) {
@@ -344,7 +344,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void matchCreated(MatchCreatedEvent event) {
@@ -354,12 +354,12 @@ public class PolicySession
}
}
- /****************************************/
+ /*======================================*/
/* 'RuleRuntimeEventListener' interface */
- /****************************************/
+ /*======================================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void objectDeleted(ObjectDeletedEvent event) {
@@ -370,7 +370,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void objectInserted(ObjectInsertedEvent event) {
@@ -381,7 +381,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void objectUpdated(ObjectUpdatedEvent event) {
@@ -390,7 +390,7 @@ public class PolicySession
+ ": AgendaEventListener.objectUpdated(" + event + ")");
}
}
-
+
/* ============================================================ */
/**
@@ -451,12 +451,12 @@ public class PolicySession
return "Session " + session.getFullName();
}
- /***************************/
+ /*=========================*/
/* 'ThreadModel' interface */
- /***************************/
+ /*=========================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void start() {
@@ -465,7 +465,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void stop() {
@@ -486,7 +486,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void updated() {
@@ -494,12 +494,12 @@ public class PolicySession
thread.setName(getThreadName());
}
- /************************/
+ /*======================*/
/* 'Runnable' interface */
- /************************/
+ /*======================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void run() {
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPI.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java
index 105d6ec9..66766453 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPI.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java
@@ -35,14 +35,14 @@ import org.onap.policy.drools.utils.OrderedServiceImpl;
* For instance, they may choose to implement an engine-wide locking scheme, or they may
* choose to implement a global locking scheme (e.g., through a shared DB).
*/
-public interface PolicyResourceLockFeatureAPI extends OrderedService {
+public interface PolicyResourceLockFeatureApi extends OrderedService {
/**
* 'FeatureAPI.impl.getList()' returns an ordered list of objects implementing the
* 'FeatureAPI' interface.
*/
- public static OrderedServiceImpl<PolicyResourceLockFeatureAPI> impl =
- new OrderedServiceImpl<>(PolicyResourceLockFeatureAPI.class);
+ public static OrderedServiceImpl<PolicyResourceLockFeatureApi> impl =
+ new OrderedServiceImpl<>(PolicyResourceLockFeatureApi.class);
/**
* Result of a requested operation.
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
index 3612b29d..33f4668c 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
@@ -23,7 +23,7 @@ package org.onap.policy.drools.core.lock;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
-import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureAPI.OperResult;
+import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureApi.OperResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -184,7 +184,7 @@ public class PolicyResourceLockManager extends SimpleLockManager {
* @param defaultFunc default function
* @return {@code true} if success, {@code false} otherwise
*/
- private boolean doBoolIntercept(Function<PolicyResourceLockFeatureAPI, OperResult> interceptFunc,
+ private boolean doBoolIntercept(Function<PolicyResourceLockFeatureApi, OperResult> interceptFunc,
Supplier<Boolean> defaultFunc) {
OperResult result = doIntercept(OperResult.OPER_UNHANDLED, interceptFunc);
@@ -205,9 +205,9 @@ public class PolicyResourceLockManager extends SimpleLockManager {
* @return first non-null value returned by an implementer, <i>continueValue</i> if
* they all returned <i>continueValue</i>
*/
- private static <T> T doIntercept(T continueValue, Function<PolicyResourceLockFeatureAPI, T> func) {
+ private static <T> T doIntercept(T continueValue, Function<PolicyResourceLockFeatureApi, T> func) {
- for (PolicyResourceLockFeatureAPI impl : factory.getImplementers()) {
+ for (PolicyResourceLockFeatureApi impl : factory.getImplementers()) {
try {
T result = func.apply(impl);
if (result != continueValue) {
@@ -248,8 +248,8 @@ public class PolicyResourceLockManager extends SimpleLockManager {
*
* @return the list of feature implementers
*/
- public List<PolicyResourceLockFeatureAPI> getImplementers() {
- return PolicyResourceLockFeatureAPI.impl.getList();
+ public List<PolicyResourceLockFeatureApi> getImplementers() {
+ return PolicyResourceLockFeatureApi.impl.getList();
}
}
}
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPITest.java b/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApiTest.java
index 522a3f51..999ae50f 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPITest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApiTest.java
@@ -25,21 +25,21 @@ import static org.junit.Assert.assertFalse;
import org.junit.Before;
import org.junit.Test;
-import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureAPI.OperResult;
+import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureApi.OperResult;
-public class PolicyResourceLockFeatureAPITest {
+public class PolicyResourceLockFeatureApiTest {
private static final String RESOURCE_ID = "the resource";
private static final String OWNER = "the owner";
- private PolicyResourceLockFeatureAPI api;
+ private PolicyResourceLockFeatureApi api;
/**
* set up.
*/
@Before
public void setUp() {
- api = new PolicyResourceLockFeatureAPI() {
+ api = new PolicyResourceLockFeatureApi() {
@Override
public int getSequenceNumber() {
return 0;
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java
index 962fb96a..8acafccf 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java
@@ -41,7 +41,7 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureAPI.OperResult;
+import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureApi.OperResult;
import org.onap.policy.drools.core.lock.PolicyResourceLockManager.Factory;
public class PolicyResourceLockManagerTest {
@@ -64,9 +64,9 @@ public class PolicyResourceLockManagerTest {
*/
private static Factory saveFactory;
- private PolicyResourceLockFeatureAPI impl1;
- private PolicyResourceLockFeatureAPI impl2;
- private List<PolicyResourceLockFeatureAPI> implList;
+ private PolicyResourceLockFeatureApi impl1;
+ private PolicyResourceLockFeatureApi impl2;
+ private List<PolicyResourceLockFeatureApi> implList;
private PolicyResourceLockManager mgr;
@@ -85,8 +85,8 @@ public class PolicyResourceLockManagerTest {
*/
@Before
public void setUp() {
- impl1 = mock(PolicyResourceLockFeatureAPI.class);
- impl2 = mock(PolicyResourceLockFeatureAPI.class);
+ impl1 = mock(PolicyResourceLockFeatureApi.class);
+ impl2 = mock(PolicyResourceLockFeatureApi.class);
initImplementer(impl1);
initImplementer(impl2);
@@ -97,7 +97,7 @@ public class PolicyResourceLockManagerTest {
PolicyResourceLockManager.setFactory(new Factory() {
@Override
- public List<PolicyResourceLockFeatureAPI> getImplementers() {
+ public List<PolicyResourceLockFeatureApi> getImplementers() {
return implList;
}
});
@@ -110,7 +110,7 @@ public class PolicyResourceLockManagerTest {
*
* @param impl implementer
*/
- private void initImplementer(PolicyResourceLockFeatureAPI impl) {
+ private void initImplementer(PolicyResourceLockFeatureApi impl) {
when(impl.beforeLock(anyString(), anyString(), anyInt())).thenReturn(OperResult.OPER_UNHANDLED);
when(impl.beforeRefresh(anyString(), anyString(), anyInt())).thenReturn(OperResult.OPER_UNHANDLED);
when(impl.beforeUnlock(anyString(), anyString())).thenReturn(OperResult.OPER_UNHANDLED);
diff --git a/policy-management/checkstyle-suppressions.xml b/policy-management/checkstyle-suppressions.xml
new file mode 100644
index 00000000..d2b9d1d4
--- /dev/null
+++ b/policy-management/checkstyle-suppressions.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 AT&T Technologies. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks="AbbreviationAsWordInName"
+ files="DroolsControllerFeatureAPI.java|PolicyControllerFeatureAPI.java|PolicyEngineFeatureAPI.java|EventProtocolCoder.java|ProtocolCoderToolset.java|PdpdConfiguration.java"
+ lines="1-9999"/>
+ <suppress checks="OneTopLevelClass"
+ files="EventProtocolCoder.java|ProtocolCoderToolset.java|PolicyControllerFactory.java|DroolsControllerFactory.java|PolicyEngine.java"
+ lines="1-9999"/>
+</suppressions>
diff --git a/policy-management/pom.xml b/policy-management/pom.xml
index 58c858be..e988b4a5 100644
--- a/policy-management/pom.xml
+++ b/policy-management/pom.xml
@@ -126,6 +126,42 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</build>
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 93cbc65e..2aaef916 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
@@ -25,9 +25,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.core.PolicyContainer;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
/**
@@ -88,7 +88,7 @@ public class NullDroolsController implements DroolsController {
@Override
public String getVersion() {
return NO_VERSION;
- }
+ }
@Override
public List<String> getSessionNames() {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureAPI.java b/policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureAPI.java
index 66b206b6..c86f6e0d 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureAPI.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureAPI.java
@@ -220,7 +220,7 @@ public interface PolicyEngineFeatureAPI extends OrderedService {
* of the operation preventing the invocation of
* lower priority features. False, otherwise..
*/
- public default boolean beforeShutdown(PolicyEngine engine){
+ public default boolean beforeShutdown(PolicyEngine engine) {
return false;
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java b/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
index 6864a346..2fcb07d5 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
@@ -305,7 +305,7 @@ public class FileSystemPersistence implements SystemPersistence {
*/
protected File[] sortedListFiles() {
final File[] dirFiles = this.configurationDirectory.toFile().listFiles();
- Arrays.sort(dirFiles, (a, b) -> a.getName().compareTo(b.getName()));
+ Arrays.sort(dirFiles, (e1, e2) -> e1.getName().compareTo(e2.getName()));
return dirFiles;
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java
index 3e4e7ecd..6d752897 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java
@@ -183,56 +183,54 @@ public interface EventProtocolCoder {
*/
public List<CoderFilters> getDecoderFilters(String groupId, String artifactId, String topic);
-
/**
- * Given a controller id and a topic, it gives back the decoding configuration.
+ * gets all decoders associated with the group and artifact ids.
*
* @param groupId of the controller
* @param artifactId of the controller
- * @param topic the topic
*
- * @return decoding toolset
- *
- * @throw IllegalArgumentException if an invalid parameter is passed
+ * @throws IllegalArgumentException if invalid arguments have been provided
*/
- public ProtocolCoderToolset getDecoders(String groupId, String artifactId, String topic);
+ public List<CoderFilters> getDecoderFilters(String groupId, String artifactId);
/**
- * Given a controller id and a topic, it gives back all the decoding configurations.
+ * Given a controller id, a topic, and a classname, it gives back the classes that implements the decoding.
*
* @param groupId of the controller
* @param artifactId of the controller
+ * @param topic the topic
+ * @param classname classname
*
- * @return decoding toolset
+ * @return list of decoders
*
* @throw IllegalArgumentException if an invalid parameter is passed
- */
- public List<ProtocolCoderToolset> getDecoders(String groupId, String artifactId);
+ */
+ public CoderFilters getDecoderFilters(String groupId, String artifactId, String topic, String classname);
/**
- * gets all decoders associated with the group and artifact ids.
+ * Given a controller id and a topic, it gives back the decoding configuration.
*
* @param groupId of the controller
* @param artifactId of the controller
+ * @param topic the topic
*
- * @throws IllegalArgumentException if invalid arguments have been provided
+ * @return decoding toolset
+ *
+ * @throw IllegalArgumentException if an invalid parameter is passed
*/
- public List<CoderFilters> getDecoderFilters(String groupId, String artifactId);
-
+ public ProtocolCoderToolset getDecoders(String groupId, String artifactId, String topic);
/**
- * Given a controller id, a topic, and a classname, it gives back the classes that implements the decoding.
+ * Given a controller id and a topic, it gives back all the decoding configurations.
*
* @param groupId of the controller
* @param artifactId of the controller
- * @param topic the topic
- * @param classname classname
*
- * @return list of decoders
+ * @return decoding toolset
*
* @throw IllegalArgumentException if an invalid parameter is passed
- */
- public CoderFilters getDecoderFilters(String groupId, String artifactId, String topic, String classname);
+ */
+ public List<ProtocolCoderToolset> getDecoders(String groupId, String artifactId);
/**
* Given a controller id and a topic, it gives back the classes that implements the encoding.
@@ -411,7 +409,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void addDecoder(String groupId, String artifactId, String topic,
@@ -429,7 +427,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void addEncoder(String groupId, String artifactId, String topic,
@@ -447,7 +445,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void removeDecoders(String groupId, String artifactId, String topic) {
@@ -456,7 +454,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void removeEncoders(String groupId, String artifactId, String topic) {
@@ -465,7 +463,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean isDecodingSupported(String groupId, String artifactId, String topic) {
@@ -473,7 +471,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean isEncodingSupported(String groupId, String artifactId, String topic) {
@@ -481,7 +479,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public Object decode(String groupId, String artifactId, String topic, String json) {
@@ -490,7 +488,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String encode(String groupId, String artifactId, String topic, Object event) {
@@ -499,7 +497,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String encode(String topic, Object event) {
@@ -508,7 +506,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String encode(String topic, Object event, DroolsController droolsController) {
@@ -517,7 +515,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public List<CoderFilters> getDecoderFilters(String groupId, String artifactId, String topic) {
@@ -525,7 +523,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public CoderFilters getDecoderFilters(String groupId, String artifactId, String topic, String classname) {
@@ -533,7 +531,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public List<CoderFilters> getDecoderFilters(String groupId, String artifactId) {
@@ -542,7 +540,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public ProtocolCoderToolset getDecoders(String groupId, String artifactId, String topic) {
@@ -582,7 +580,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public List<CoderFilters> getEncoderFilters(String groupId, String artifactId, String topic) {
@@ -590,7 +588,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public CoderFilters getEncoderFilters(String groupId, String artifactId, String topic, String classname) {
@@ -598,7 +596,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public List<CoderFilters> getEncoderFilters(String groupId, String artifactId) {
@@ -606,7 +604,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public List<CoderFilters> getReverseEncoderFilters(String topic, String encodedClass) {
@@ -614,7 +612,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public DroolsController getDroolsController(String topic, Object encodedClass) {
@@ -622,7 +620,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public List<DroolsController> getDroolsControllers(String topic, Object encodedClass) {
@@ -630,7 +628,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String toString() {
@@ -722,7 +720,7 @@ abstract class GenericEventProtocolCoder {
if (coders.containsKey(key)) {
Pair<ProtocolCoderToolset, ProtocolCoderToolset> toolsets = coders.get(key);
- logger.info("{}: adding coders for existing {}: ", this, key, toolsets.first());
+ logger.info("{}: adding coders for existing {}: {}", this, key, toolsets.first());
toolsets.first().addCoder(eventClass, protocolFilter, modelClassLoaderHash);
toolsets.second().addCoder(eventClass, protocolFilter, modelClassLoaderHash);
@@ -869,7 +867,7 @@ abstract class GenericEventProtocolCoder {
while (toolsetsIter.hasNext()) {
Pair<ProtocolCoderToolset, ProtocolCoderToolset> toolset = toolsetsIter.next();
if (toolset.first().getControllerId().equals(key)) {
- logger.info("{}: removed coder from toolset for {} from reverse mapping {}: ",
+ logger.info("{}: removed coder from toolset for {} from reverse mapping",
this, reverseKey);
toolsetsIter.remove();
}
@@ -1024,6 +1022,29 @@ abstract class GenericEventProtocolCoder {
/**
* encode an object into a json string.
*
+ * @param topic topic
+ * @param encodedClass object to convert to string
+ * @return the json string
+ * @throws IllegalArgumentException if invalid argument is provided
+ * @throws UnsupportedOperationException if the operation cannot be performed
+ */
+ public String encode(String topic, Object encodedClass, DroolsController droolsController) {
+
+ if (encodedClass == null) {
+ throw new IllegalArgumentException("Invalid encoded class");
+ }
+
+ if (topic == null || topic.isEmpty()) {
+ throw new IllegalArgumentException("Invalid topic");
+ }
+
+ String key = codersKey(droolsController.getGroupId(), droolsController.getArtifactId(), topic);
+ return this.encodeInternal(key, encodedClass);
+ }
+
+ /**
+ * encode an object into a json string.
+ *
* @param key identifier
* @param event object to convert to string
* @return the json string
@@ -1069,29 +1090,6 @@ abstract class GenericEventProtocolCoder {
}
/**
- * encode an object into a json string.
- *
- * @param topic topic
- * @param encodedClass object to convert to string
- * @return the json string
- * @throws IllegalArgumentException if invalid argument is provided
- * @throws UnsupportedOperationException if the operation cannot be performed
- */
- public String encode(String topic, Object encodedClass, DroolsController droolsController) {
-
- if (encodedClass == null) {
- throw new IllegalArgumentException("Invalid encoded class");
- }
-
- if (topic == null || topic.isEmpty()) {
- throw new IllegalArgumentException("Invalid topic");
- }
-
- String key = codersKey(droolsController.getGroupId(), droolsController.getArtifactId(), topic);
- return this.encodeInternal(key, encodedClass);
- }
-
- /**
* Drools creators.
*
* @param topic topic
@@ -1202,6 +1200,31 @@ abstract class GenericEventProtocolCoder {
}
/**
+ * get all filters by maven coordinates, topic, and classname.
+ *
+ * @param groupId group id
+ * @param artifactId artifact id
+ * @param topic topic
+ * @param classname classname
+ * @return list of coders
+ * @throws IllegalArgumentException if invalid input
+ */
+ public CoderFilters getFilters(String groupId, String artifactId, String topic, String classname) {
+
+ if (!isCodingSupported(groupId, artifactId, topic)) {
+ throw new IllegalArgumentException("Unsupported:" + codersKey(groupId, artifactId, topic));
+ }
+
+ if (classname == null || classname.isEmpty()) {
+ throw new IllegalArgumentException("classname must be provided");
+ }
+
+ String key = this.codersKey(groupId, artifactId, topic);
+ Pair<ProtocolCoderToolset,ProtocolCoderToolset> coderTools = coders.get(key);
+ return coderTools.first().getCoder(classname);
+ }
+
+ /**
* get all coders by maven coordinates and topic.
*
* @param groupId group id
@@ -1251,31 +1274,6 @@ abstract class GenericEventProtocolCoder {
}
/**
- * get all filters by maven coordinates, topic, and classname.
- *
- * @param groupId group id
- * @param artifactId artifact id
- * @param topic topic
- * @param classname classname
- * @return list of coders
- * @throws IllegalArgumentException if invalid input
- */
- public CoderFilters getFilters(String groupId, String artifactId, String topic, String classname) {
-
- if (!isCodingSupported(groupId, artifactId, topic)) {
- throw new IllegalArgumentException("Unsupported:" + codersKey(groupId, artifactId, topic));
- }
-
- if (classname == null || classname.isEmpty()) {
- throw new IllegalArgumentException("classname must be provided");
- }
-
- String key = this.codersKey(groupId, artifactId, topic);
- Pair<ProtocolCoderToolset,ProtocolCoderToolset> coderTools = coders.get(key);
- return coderTools.first().getCoder(classname);
- }
-
- /**
* get coded based on class and topic.
*
* @param topic topic
@@ -1342,7 +1340,7 @@ abstract class GenericEventProtocolCoder {
*
* @param topic topic
* @param fact fact
- * @return
+ * @return list of drools controllers
*/
List<DroolsController> getDroolsControllers(String topic, Object fact) {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
index 4fd2f522..f65efaed 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
@@ -287,7 +287,7 @@ public class JsonProtocolFilter {
* Get rules.
*
* @param name name
- * @return
+ * @return list of filter rules
*/
public List<FilterRule> getRules(String name) {
if (name == null || name.isEmpty()) {
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 7ee8b08a..ead6794c 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
@@ -20,6 +20,21 @@
package org.onap.policy.drools.protocol.coders;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
@@ -38,637 +53,630 @@ import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.Cust
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-
/**
- * Protocol Coding/Decoding Toolset
+ * Protocol Coding/Decoding Toolset.
*/
public abstract class ProtocolCoderToolset {
- /**
- * Logger
- */
- private static Logger logger = LoggerFactory.getLogger(ProtocolCoderToolset.class);
-
- /**
- * topic
- */
- protected final String topic;
-
- /**
- * controller id
- */
- protected final String controllerId;
-
- /**
- * group id
- */
- protected final String groupId;
-
- /**
- * artifact id
- */
- protected final String artifactId;
-
- /**
- * Protocols and associated Filters
- */
- protected final List<CoderFilters> coders = new CopyOnWriteArrayList<>();
-
- /**
- * Tree model (instead of class model) generic parsing to be able to inspect elements
- */
- protected JsonParser filteringParser = new JsonParser();
-
- /**
- * custom coder
- */
- protected CustomCoder customCoder;
-
- /**
- * Constructor
- *
- * @param topic the topic
- * @param controllerId the controller id
- * @param codedClass the decoded class
- * @param filters list of filters that apply to the selection of this decodedClass in case of
- * multiplicity
- * @throws IllegalArgumentException if invalid data has been passed in
- */
- public ProtocolCoderToolset(String topic, String controllerId, String groupId, String artifactId,
- String codedClass, JsonProtocolFilter filters, CustomCoder customCoder,
- int modelClassLoaderHash) {
-
- if (topic == null || controllerId == null || groupId == null || artifactId == null
- || codedClass == null || filters == null || topic.isEmpty() || controllerId.isEmpty()) {
- throw new IllegalArgumentException("Invalid input");
+ /**
+ * Logger.
+ */
+ private static Logger logger = LoggerFactory.getLogger(ProtocolCoderToolset.class);
+
+ /**
+ * topic.
+ */
+ protected final String topic;
+
+ /**
+ * controller id.
+ */
+ protected final String controllerId;
+
+ /**
+ * group id.
+ */
+ protected final String groupId;
+
+ /**
+ * artifact id.
+ */
+ protected final String artifactId;
+
+ /**
+ * Protocols and associated Filters.
+ */
+ protected final List<CoderFilters> coders = new CopyOnWriteArrayList<>();
+
+ /**
+ * Tree model (instead of class model) generic parsing to be able to inspect elements.
+ */
+ protected JsonParser filteringParser = new JsonParser();
+
+ /**
+ * custom coder.
+ */
+ protected CustomCoder customCoder;
+
+ /**
+ * Constructor.
+ *
+ * @param topic the topic
+ * @param controllerId the controller id
+ * @param codedClass the decoded class
+ * @param filters list of filters that apply to the selection of this decodedClass in case of
+ * multiplicity
+ * @throws IllegalArgumentException if invalid data has been passed in
+ */
+ public ProtocolCoderToolset(String topic, String controllerId, String groupId, String artifactId,
+ String codedClass, JsonProtocolFilter filters, CustomCoder customCoder,
+ int modelClassLoaderHash) {
+
+ if (topic == null || controllerId == null || groupId == null || artifactId == null
+ || codedClass == null || filters == null || topic.isEmpty() || controllerId.isEmpty()) {
+ throw new IllegalArgumentException("Invalid input");
+ }
+
+ this.topic = topic;
+ this.controllerId = controllerId;
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.coders.add(new CoderFilters(codedClass, filters, modelClassLoaderHash));
+ this.customCoder = customCoder;
+ }
+
+ /**
+ * gets the coder + filters associated with this class name.
+ *
+ * @param classname class name
+ * @return the decoder filters or null if not found
+ */
+ public CoderFilters getCoder(String classname) {
+ if (classname == null || classname.isEmpty()) {
+ throw new IllegalArgumentException("no classname provided");
+ }
+
+ for (final CoderFilters decoder : this.coders) {
+ if (decoder.factClass.equals(classname)) {
+ return decoder;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * get a copy of the coder filters in use.
+ *
+ * @return coder filters
+ */
+ public List<CoderFilters> getCoders() {
+ return new ArrayList<>(this.coders);
+ }
+
+ /**
+ * add coder or replace it exists.
+ *
+ * @param eventClass decoder
+ * @param filter filter
+ */
+ public void addCoder(String eventClass, JsonProtocolFilter filter, int modelClassLoaderHash) {
+ if (eventClass == null || eventClass.isEmpty()) {
+ throw new IllegalArgumentException("no event class provided");
+ }
+
+ for (final CoderFilters coder : this.coders) {
+ if (coder.getCodedClass().equals(eventClass)) {
+ coder.setFilter(filter);
+ coder.setFromClassLoaderHash(modelClassLoaderHash);
+ return;
+ }
+ }
+ this.coders.add(new CoderFilters(eventClass, filter, modelClassLoaderHash));
+ }
+
+ /**
+ * remove coder.
+ *
+ * @param eventClass event class
+ */
+ public void removeCoders(String eventClass) {
+ if (eventClass == null || eventClass.isEmpty()) {
+ throw new IllegalArgumentException("no event class provided");
+ }
+
+ List<CoderFilters> temp = new ArrayList<>();
+ for (final CoderFilters coder : this.coders) {
+ if (coder.factClass.equals(eventClass)) {
+ temp.add(coder);
+ }
+ }
+
+ this.coders.removeAll(temp);
}
- this.topic = topic;
- this.controllerId = controllerId;
- this.groupId = groupId;
- this.artifactId = artifactId;
- this.coders.add(new CoderFilters(codedClass, filters, modelClassLoaderHash));
- this.customCoder = customCoder;
- }
-
- /**
- * gets the coder + filters associated with this class name
- *
- * @param classname class name
- * @return the decoder filters or null if not found
- */
- public CoderFilters getCoder(String classname) {
- if (classname == null || classname.isEmpty())
- throw new IllegalArgumentException("no classname provided");
-
- for (final CoderFilters decoder : this.coders) {
- if (decoder.factClass.equals(classname)) {
- return decoder;
- }
+ /**
+ * gets the topic.
+ *
+ * @return the topic
+ */
+ public String getTopic() {
+ return this.topic;
}
- return null;
- }
-
- /**
- * get a copy of the coder filters in use
- *
- * @return coder filters
- */
- public List<CoderFilters> getCoders() {
- return new ArrayList<>(this.coders);
- }
-
- /**
- * add coder or replace it exists
- *
- * @param eventClass decoder
- * @param filter filter
- */
- public void addCoder(String eventClass, JsonProtocolFilter filter, int modelClassLoaderHash) {
- if (eventClass == null || eventClass.isEmpty())
- throw new IllegalArgumentException("no event class provided");
-
- for (final CoderFilters coder : this.coders) {
- if (coder.getCodedClass().equals(eventClass)) {
- coder.setFilter(filter);
- coder.setFromClassLoaderHash(modelClassLoaderHash);
- return;
- }
+
+ /**
+ * gets the controller id.
+ *
+ * @return the controller id
+ */
+ public String getControllerId() {
+ return this.controllerId;
}
- this.coders.add(new CoderFilters(eventClass, filter, modelClassLoaderHash));
- }
-
- /**
- * remove coder
- * @param eventClass event class
- */
- public void removeCoders(String eventClass) {
- if (eventClass == null || eventClass.isEmpty())
- throw new IllegalArgumentException("no event class provided");
-
- List<CoderFilters> temp = new ArrayList<>();
- for (final CoderFilters coder : this.coders) {
- if (coder.factClass.equals(eventClass)) {
- temp.add(coder);
- }
+
+ /**
+ * Get group id.
+ *
+ * @return the groupId
+ */
+ public String getGroupId() {
+ return this.groupId;
}
- this.coders.removeAll(temp);
- }
-
- /**
- * gets the topic
- *
- * @return the topic
- */
- public String getTopic() {
- return this.topic;
- }
-
- /**
- * gets the controller id
- *
- * @return the controller id
- */
- public String getControllerId() {
- return this.controllerId;
- }
-
- /**
- * @return the groupId
- */
- public String getGroupId() {
- return this.groupId;
- }
-
- /**
- * @return the artifactId
- */
- public String getArtifactId() {
- return this.artifactId;
- }
-
- /**
- * @return the customCoder
- */
- public CustomCoder getCustomCoder() {
- return this.customCoder;
- }
-
- /**
- * @param customCoder the customCoder to set
- */
- public void setCustomCoder(CustomCoder customCoder) {
- this.customCoder = customCoder;
- }
-
- /**
- * performs filtering on a json string
- *
- * @param json json string
- * @return the decoder that passes the filter, otherwise null
- * @throws UnsupportedOperationException can't filter
- * @throws IllegalArgumentException invalid input
- */
- protected CoderFilters filter(String json) {
-
-
- // 1. Get list of decoding classes for this controller Id and topic
- // 2. If there are no classes, return error
- // 3. Otherwise, from the available classes for decoding, pick the first one that
- // passes the filters
-
- // Don't parse if it is not necessary
-
- if (this.coders.isEmpty()) {
- throw new IllegalStateException("No coders available");
+ /**
+ * Get artifact id.
+ *
+ * @return the artifactId
+ */
+ public String getArtifactId() {
+ return this.artifactId;
}
- if (this.coders.size() == 1) {
- final JsonProtocolFilter filter = this.coders.get(0).getFilter();
- if (!filter.isRules()) {
- return this.coders.get(0);
- }
+ /**
+ * Get custom coder.
+ *
+ * @return the customCoder
+ */
+ public CustomCoder getCustomCoder() {
+ return this.customCoder;
}
- JsonElement event;
- try {
- event = this.filteringParser.parse(json);
- } catch (final Exception e) {
- throw new UnsupportedOperationException(e);
+ /**
+ * Set custom coder.
+ *
+ * @param customCoder the customCoder to set.
+ */
+ public void setCustomCoder(CustomCoder customCoder) {
+ this.customCoder = customCoder;
}
- for (final CoderFilters decoder : this.coders) {
- try {
- final boolean accepted = decoder.getFilter().accept(event);
- if (accepted) {
- return decoder;
+ /**
+ * performs filtering on a json string.
+ *
+ * @param json json string
+ * @return the decoder that passes the filter, otherwise null
+ * @throws UnsupportedOperationException can't filter
+ * @throws IllegalArgumentException invalid input
+ */
+ protected CoderFilters filter(String json) {
+
+
+ // 1. Get list of decoding classes for this controller Id and topic
+ // 2. If there are no classes, return error
+ // 3. Otherwise, from the available classes for decoding, pick the first one that
+ // passes the filters
+
+ // Don't parse if it is not necessary
+
+ if (this.coders.isEmpty()) {
+ throw new IllegalStateException("No coders available");
}
- } catch (final Exception e) {
- logger.info("{}: unexpected failure accepting {} because of {}", this, event,
- e.getMessage(), e);
- // continue
- }
+
+ if (this.coders.size() == 1) {
+ final JsonProtocolFilter filter = this.coders.get(0).getFilter();
+ if (!filter.isRules()) {
+ return this.coders.get(0);
+ }
+ }
+
+ JsonElement event;
+ try {
+ event = this.filteringParser.parse(json);
+ } catch (final Exception e) {
+ throw new UnsupportedOperationException(e);
+ }
+
+ for (final CoderFilters decoder : this.coders) {
+ try {
+ final boolean accepted = decoder.getFilter().accept(event);
+ if (accepted) {
+ return decoder;
+ }
+ } catch (final Exception e) {
+ logger.info("{}: unexpected failure accepting {} because of {}", this, event,
+ e.getMessage(), e);
+ // continue
+ }
+ }
+
+ return null;
}
- return null;
- }
-
- /**
- * Decode json into a POJO object
- *
- * @param json json string
- *
- * @return a POJO object for the json string
- * @throws IllegalArgumentException if an invalid parameter has been received
- * @throws UnsupportedOperationException if parsing into POJO is not possible
- */
- public abstract Object decode(String json);
-
- /**
- * Encodes a POJO object into a JSON String
- *
- * @param event JSON POJO event to be converted to String
- * @return JSON string version of POJO object
- * @throws IllegalArgumentException if an invalid parameter has been received
- * @throws UnsupportedOperationException if parsing into POJO is not possible
- */
- public abstract String encode(Object event);
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("ProtocolCoderToolset [topic=").append(this.topic).append(", controllerId=")
+ /**
+ * Decode json into a POJO object.
+ *
+ * @param json json string
+ *
+ * @return a POJO object for the json string
+ * @throws IllegalArgumentException if an invalid parameter has been received
+ * @throws UnsupportedOperationException if parsing into POJO is not possible
+ */
+ public abstract Object decode(String json);
+
+ /**
+ * Encodes a POJO object into a JSON String.
+ *
+ * @param event JSON POJO event to be converted to String
+ * @return JSON string version of POJO object
+ * @throws IllegalArgumentException if an invalid parameter has been received
+ * @throws UnsupportedOperationException if parsing into POJO is not possible
+ */
+ public abstract String encode(Object event);
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("ProtocolCoderToolset [topic=").append(this.topic).append(", controllerId=")
.append(this.controllerId).append(", groupId=").append(this.groupId).append(", artifactId=")
.append(this.artifactId).append(", coders=").append(this.coders)
.append(", filteringParser=").append(this.filteringParser).append(", customCoder=")
.append(this.customCoder).append("]");
- return builder.toString();
- }
+ return builder.toString();
+ }
}
/**
- * Tools used for encoding/decoding using Jackson
+ * Tools used for encoding/decoding using Jackson.
*/
class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
- private static final String WARN_FETCH_FAILED = "{}: cannot fetch application class {}";
-private static final String WARN_FETCH_FAILED_BECAUSE = "{}: cannot fetch application class {} because of {}";
-private static final String FETCH_FAILED = "cannot fetch application class ";
-private static final String ENCODE_FAILED = "event cannot be encoded";
-private static Logger logger = LoggerFactory.getLogger(JacksonProtocolCoderToolset.class);
- /**
- * decoder
- */
- @JsonIgnore
- protected final ObjectMapper decoder = new ObjectMapper();
-
- /**
- * encoder
- */
- @JsonIgnore
- protected final ObjectMapper encoder = new ObjectMapper();
-
- /**
- * Toolset to encode/decode tools associated with a topic
- *
- * @param topic topic
- * @param decodedClass decoded class of an event
- * @param filter
- */
- public JacksonProtocolCoderToolset(String topic, String controllerId, String groupId,
- String artifactId, String decodedClass, JsonProtocolFilter filter,
- CustomJacksonCoder customJacksonCoder, int modelClassLoaderHash) {
- super(topic, controllerId, groupId, artifactId, decodedClass, filter, customJacksonCoder,
- modelClassLoaderHash);
- this.decoder.registerModule(new JavaTimeModule());
- this.decoder.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- }
-
- /**
- * gets the Jackson decoder
- *
- * @return the Jackson decoder
- */
- @JsonIgnore
- protected ObjectMapper getDecoder() {
- return this.decoder;
- }
-
- /**
- * gets the Jackson encoder
- *
- * @return the Jackson encoder
- */
- @JsonIgnore
- protected ObjectMapper getEncoder() {
- return this.encoder;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Object decode(String json) {
-
- // 0. Use custom coder if available
-
- if (this.customCoder != null) {
- throw new UnsupportedOperationException(
- "Jackon Custom Decoder is not supported at this time");
+ private static final String WARN_FETCH_FAILED = "{}: cannot fetch application class {}";
+ private static final String WARN_FETCH_FAILED_BECAUSE = "{}: cannot fetch application class {} because of {}";
+ private static final String FETCH_FAILED = "cannot fetch application class ";
+ private static final String ENCODE_FAILED = "event cannot be encoded";
+ private static Logger logger = LoggerFactory.getLogger(JacksonProtocolCoderToolset.class);
+
+ /**
+ * decoder.
+ */
+ @JsonIgnore
+ protected final ObjectMapper decoder = new ObjectMapper();
+
+ /**
+ * encoder.
+ */
+ @JsonIgnore
+ protected final ObjectMapper encoder = new ObjectMapper();
+
+ /**
+ * Toolset to encode/decode tools associated with a topic.
+ *
+ * @param topic topic
+ * @param decodedClass decoded class of an event
+ * @param filter filter
+ */
+ public JacksonProtocolCoderToolset(String topic, String controllerId, String groupId,
+ String artifactId, String decodedClass, JsonProtocolFilter filter,
+ CustomJacksonCoder customJacksonCoder, int modelClassLoaderHash) {
+ super(topic, controllerId, groupId, artifactId, decodedClass, filter, customJacksonCoder,
+ modelClassLoaderHash);
+ this.decoder.registerModule(new JavaTimeModule());
+ this.decoder.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
- final DroolsController droolsController =
- DroolsController.factory.get(this.groupId, this.artifactId, "");
- if (droolsController == null) {
- logger.warn("{}: no drools-controller to process {}", this, json);
- throw new IllegalStateException("no drools-controller to process event");
+ /**
+ * gets the Jackson decoder.
+ *
+ * @return the Jackson decoder
+ */
+ @JsonIgnore
+ protected ObjectMapper getDecoder() {
+ return this.decoder;
}
- final CoderFilters decoderFilter = this.filter(json);
- if (decoderFilter == null) {
- logger.debug("{}: no decoder to process {}", this, json);
- throw new UnsupportedOperationException("no decoder to process event");
+ /**
+ * gets the Jackson encoder.
+ *
+ * @return the Jackson encoder
+ */
+ @JsonIgnore
+ protected ObjectMapper getEncoder() {
+ return this.encoder;
}
- Class<?> decoderClass;
- try {
- decoderClass = droolsController.fetchModelClass(decoderFilter.getCodedClass());
- if (decoderClass == null) {
- logger.warn(WARN_FETCH_FAILED, this, decoderFilter.getCodedClass());
- throw new IllegalStateException(
- FETCH_FAILED + decoderFilter.getCodedClass());
- }
- } catch (final Exception e) {
- logger.warn(WARN_FETCH_FAILED_BECAUSE, this,
- decoderFilter.getCodedClass(), e.getMessage());
- throw new UnsupportedOperationException(
- FETCH_FAILED + decoderFilter.getCodedClass(), e);
- }
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public Object decode(String json) {
+ // 0. Use custom coder if available
- try {
- return this.decoder.readValue(json, decoderClass);
- } catch (final Exception e) {
- logger.warn("{} cannot decode {} into {} because of {}", this, json, decoderClass.getName(),
- e.getMessage(), e);
- throw new UnsupportedOperationException(
- "cannont decode into " + decoderFilter.getCodedClass(), e);
- }
- }
+ if (this.customCoder != null) {
+ throw new UnsupportedOperationException(
+ "Jackon Custom Decoder is not supported at this time");
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public String encode(Object event) {
+ final DroolsController droolsController =
+ DroolsController.factory.get(this.groupId, this.artifactId, "");
+ if (droolsController == null) {
+ logger.warn("{}: no drools-controller to process {}", this, json);
+ throw new IllegalStateException("no drools-controller to process event");
+ }
- // 0. Use custom coder if available
+ final CoderFilters decoderFilter = this.filter(json);
+ if (decoderFilter == null) {
+ logger.debug("{}: no decoder to process {}", this, json);
+ throw new UnsupportedOperationException("no decoder to process event");
+ }
- if (this.customCoder != null) {
- throw new UnsupportedOperationException(
- "Jackon Custom Encoder is not supported at this time");
+ Class<?> decoderClass;
+ try {
+ decoderClass = droolsController.fetchModelClass(decoderFilter.getCodedClass());
+ if (decoderClass == null) {
+ logger.warn(WARN_FETCH_FAILED, this, decoderFilter.getCodedClass());
+ throw new IllegalStateException(
+ FETCH_FAILED + decoderFilter.getCodedClass());
+ }
+ } catch (final Exception e) {
+ logger.warn(WARN_FETCH_FAILED_BECAUSE, this,
+ decoderFilter.getCodedClass(), e.getMessage());
+ throw new UnsupportedOperationException(
+ FETCH_FAILED + decoderFilter.getCodedClass(), e);
+ }
+
+
+ try {
+ return this.decoder.readValue(json, decoderClass);
+ } catch (final Exception e) {
+ logger.warn("{} cannot decode {} into {} because of {}", this, json, decoderClass.getName(),
+ e.getMessage(), e);
+ throw new UnsupportedOperationException(
+ "cannont decode into " + decoderFilter.getCodedClass(), e);
+ }
}
- try {
- return this.encoder.writeValueAsString(event);
- } catch (final JsonProcessingException e) {
- logger.error("{} cannot encode {} because of {}", this, event, e.getMessage(), e);
- throw new UnsupportedOperationException(ENCODE_FAILED);
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public String encode(Object event) {
+
+ // 0. Use custom coder if available
+
+ if (this.customCoder != null) {
+ throw new UnsupportedOperationException(
+ "Jackon Custom Encoder is not supported at this time");
+ }
+
+ try {
+ return this.encoder.writeValueAsString(event);
+ } catch (final JsonProcessingException e) {
+ logger.error("{} cannot encode {} because of {}", this, event, e.getMessage(), e);
+ throw new UnsupportedOperationException(ENCODE_FAILED);
+ }
}
- }
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("JacksonProtocolCoderToolset [toString()=").append(super.toString()).append("]");
- return builder.toString();
- }
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("JacksonProtocolCoderToolset [toString()=").append(super.toString()).append("]");
+ return builder.toString();
+ }
}
/**
- * Tools used for encoding/decoding using Jackson
+ * Tools used for encoding/decoding using Jackson.
*/
class GsonProtocolCoderToolset extends ProtocolCoderToolset {
- /**
- * Logger
- */
- private static final Logger logger = LoggerFactory.getLogger(GsonProtocolCoderToolset.class);
-
- /**
- * Formatter for JSON encoding/decoding
- */
- @JsonIgnore
- public static final DateTimeFormatter format =
- DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
-
- @JsonIgnore
- public static final DateTimeFormatter zuluFormat = DateTimeFormatter.ISO_INSTANT;
-
- /**
- * Adapter for ZonedDateTime
- */
- public static class GsonUTCAdapter
- implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
- @Override
- public ZonedDateTime deserialize(JsonElement element, Type type,
- JsonDeserializationContext context) {
- try {
- return ZonedDateTime.parse(element.getAsString(), format);
- } catch (final Exception e) {
- logger.info("GsonUTCAdapter: cannot parse {} because of {}", element, e.getMessage(), e);
- }
- return null;
- }
+ /**
+ * Logger.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(GsonProtocolCoderToolset.class);
+
+ /**
+ * Formatter for JSON encoding/decoding.
+ */
+ @JsonIgnore
+ public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+
+ @JsonIgnore
+ public static final DateTimeFormatter zuluFormat = DateTimeFormatter.ISO_INSTANT;
+
+ /**
+ * Adapter for ZonedDateTime.
+ */
+ public static class GsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ @Override
+ public ZonedDateTime deserialize(JsonElement element, Type type,
+ JsonDeserializationContext context) {
+ try {
+ return ZonedDateTime.parse(element.getAsString(), format);
+ } catch (final Exception e) {
+ logger.info("GsonUTCAdapter: cannot parse {} because of {}", element, e.getMessage(), e);
+ }
+ return null;
+ }
- @Override
- public JsonElement serialize(ZonedDateTime datetime, Type type,
- JsonSerializationContext context) {
- return new JsonPrimitive(datetime.format(format));
+ @Override
+ public JsonElement serialize(ZonedDateTime datetime, Type type,
+ JsonSerializationContext context) {
+ return new JsonPrimitive(datetime.format(format));
+ }
}
- }
- public static class GsonInstantAdapter
- implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+ public static class GsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
- @Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
- return Instant.ofEpochMilli(json.getAsLong());
- }
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
- @Override
- public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
- return new JsonPrimitive(src.toEpochMilli());
- }
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
+ }
- }
-
-
- /**
- * decoder
- */
- @JsonIgnore
- protected final Gson decoder = new GsonBuilder().disableHtmlEscaping()
- .registerTypeAdapter(ZonedDateTime.class, new GsonUTCAdapter())
- .registerTypeAdapter(Instant.class, new GsonInstantAdapter()).create();
-
- /**
- * encoder
- */
- @JsonIgnore
- protected final Gson encoder = new GsonBuilder().disableHtmlEscaping()
- .registerTypeAdapter(ZonedDateTime.class, new GsonUTCAdapter())
- .registerTypeAdapter(Instant.class, new GsonInstantAdapter()).create();
-
- /**
- * Toolset to encode/decode tools associated with a topic
- *
- * @param topic topic
- * @param decodedClass decoded class of an event
- * @param filter
- */
- public GsonProtocolCoderToolset(String topic, String controllerId, String groupId,
- String artifactId, String decodedClass, JsonProtocolFilter filter,
- CustomGsonCoder customGsonCoder, int modelClassLoaderHash) {
- super(topic, controllerId, groupId, artifactId, decodedClass, filter, customGsonCoder,
- modelClassLoaderHash);
- }
-
- /**
- * gets the Gson decoder
- *
- * @return the Gson decoder
- */
- @JsonIgnore
- protected Gson getDecoder() {
- return this.decoder;
- }
-
- /**
- * gets the Gson encoder
- *
- * @return the Gson encoder
- */
- @JsonIgnore
- protected Gson getEncoder() {
- return this.encoder;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Object decode(String json) {
-
- final DroolsController droolsController =
- DroolsController.factory.get(this.groupId, this.artifactId, "");
- if (droolsController == null) {
- logger.warn("{}: no drools-controller to process {}", this, json);
- throw new IllegalStateException("no drools-controller to process event");
}
- final CoderFilters decoderFilter = this.filter(json);
- if (decoderFilter == null) {
- logger.debug("{}: no decoder to process {}", this, json);
- throw new UnsupportedOperationException("no decoder to process event");
+
+ /**
+ * decoder.
+ */
+ @JsonIgnore
+ protected final Gson decoder = new GsonBuilder().disableHtmlEscaping()
+ .registerTypeAdapter(ZonedDateTime.class, new GsonUTCAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter()).create();
+
+ /**
+ * encoder.
+ */
+ @JsonIgnore
+ protected final Gson encoder = new GsonBuilder().disableHtmlEscaping()
+ .registerTypeAdapter(ZonedDateTime.class, new GsonUTCAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter()).create();
+
+ /**
+ * Toolset to encode/decode tools associated with a topic.
+ *
+ * @param topic topic
+ * @param decodedClass decoded class of an event
+ * @param filter filter
+ */
+ public GsonProtocolCoderToolset(String topic, String controllerId, String groupId,
+ String artifactId, String decodedClass, JsonProtocolFilter filter,
+ CustomGsonCoder customGsonCoder, int modelClassLoaderHash) {
+ super(topic, controllerId, groupId, artifactId, decodedClass, filter, customGsonCoder,
+ modelClassLoaderHash);
}
- Class<?> decoderClass;
- try {
- decoderClass = droolsController.fetchModelClass(decoderFilter.getCodedClass());
- if (decoderClass == null) {
- logger.warn("{}: cannot fetch application class {}", this, decoderFilter.getCodedClass());
- throw new IllegalStateException(
- "cannot fetch application class " + decoderFilter.getCodedClass());
- }
- } catch (final Exception e) {
- logger.warn("{}: cannot fetch application class {} because of {}", this,
- decoderFilter.getCodedClass(), e.getMessage());
- throw new UnsupportedOperationException(
- "cannot fetch application class " + decoderFilter.getCodedClass(), e);
+ /**
+ * gets the Gson decoder.
+ *
+ * @return the Gson decoder
+ */
+ @JsonIgnore
+ protected Gson getDecoder() {
+ return this.decoder;
}
- if (this.customCoder != null) {
- try {
- final Class<?> gsonClassContainer =
- droolsController.fetchModelClass(this.customCoder.getClassContainer());
- final Field gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
- final Object gsonObject = gsonField.get(null);
- final Method fromJsonMethod = gsonObject.getClass().getDeclaredMethod("fromJson",
- new Class[] {String.class, Class.class});
- return fromJsonMethod.invoke(gsonObject, json, decoderClass);
- } catch (final Exception e) {
- logger.warn("{}: cannot fetch application class {} because of {}", this,
- decoderFilter.getCodedClass(), e.getMessage());
- throw new UnsupportedOperationException(
- "cannot fetch application class " + decoderFilter.getCodedClass(), e);
- }
- } else {
- try {
- return this.decoder.fromJson(json, decoderClass);
- } catch (final Exception e) {
- logger.warn("{} cannot decode {} into {} because of {}", this, json, decoderClass.getName(),
- e.getMessage(), e);
- throw new UnsupportedOperationException(
- "cannont decode into " + decoderFilter.getCodedClass(), e);
- }
+ /**
+ * gets the Gson encoder.
+ *
+ * @return the Gson encoder
+ */
+ @JsonIgnore
+ protected Gson getEncoder() {
+ return this.encoder;
}
- }
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public Object decode(String json) {
+
+ final DroolsController droolsController =
+ DroolsController.factory.get(this.groupId, this.artifactId, "");
+ if (droolsController == null) {
+ logger.warn("{}: no drools-controller to process {}", this, json);
+ throw new IllegalStateException("no drools-controller to process event");
+ }
+ final CoderFilters decoderFilter = this.filter(json);
+ if (decoderFilter == null) {
+ logger.debug("{}: no decoder to process {}", this, json);
+ throw new UnsupportedOperationException("no decoder to process event");
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public String encode(Object event) {
+ Class<?> decoderClass;
+ try {
+ decoderClass = droolsController.fetchModelClass(decoderFilter.getCodedClass());
+ if (decoderClass == null) {
+ logger.warn("{}: cannot fetch application class {}", this, decoderFilter.getCodedClass());
+ throw new IllegalStateException(
+ "cannot fetch application class " + decoderFilter.getCodedClass());
+ }
+ } catch (final Exception e) {
+ logger.warn("{}: cannot fetch application class {} because of {}", this,
+ decoderFilter.getCodedClass(), e.getMessage());
+ throw new UnsupportedOperationException(
+ "cannot fetch application class " + decoderFilter.getCodedClass(), e);
+ }
- if (this.customCoder != null) {
- try {
- final DroolsController droolsController =
- DroolsController.factory.get(this.groupId, this.artifactId, null);
- final Class<?> gsonClassContainer =
- droolsController.fetchModelClass(this.customCoder.getClassContainer());
- final Field gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
- final Object gsonObject = gsonField.get(null);
- final Method toJsonMethod =
- gsonObject.getClass().getDeclaredMethod("toJson", new Class[] {Object.class});
- return (String) toJsonMethod.invoke(gsonObject, event);
- } catch (final Exception e) {
- logger.warn("{} cannot custom-encode {} because of {}", this, event, e.getMessage(), e);
- throw new UnsupportedOperationException("event cannot be encoded", e);
- }
- } else {
- try {
- return this.encoder.toJson(event);
- } catch (final Exception e) {
- logger.warn("{} cannot encode {} because of {}", this, event, e.getMessage(), e);
- throw new UnsupportedOperationException("event cannot be encoded", e);
- }
+ if (this.customCoder != null) {
+ try {
+ final Class<?> gsonClassContainer =
+ droolsController.fetchModelClass(this.customCoder.getClassContainer());
+ final Field gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
+ final Object gsonObject = gsonField.get(null);
+ final Method fromJsonMethod = gsonObject.getClass().getDeclaredMethod("fromJson",
+ new Class[] {String.class, Class.class});
+ return fromJsonMethod.invoke(gsonObject, json, decoderClass);
+ } catch (final Exception e) {
+ logger.warn("{}: cannot fetch application class {} because of {}", this,
+ decoderFilter.getCodedClass(), e.getMessage());
+ throw new UnsupportedOperationException(
+ "cannot fetch application class " + decoderFilter.getCodedClass(), e);
+ }
+ } else {
+ try {
+ return this.decoder.fromJson(json, decoderClass);
+ } catch (final Exception e) {
+ logger.warn("{} cannot decode {} into {} because of {}", this, json, decoderClass.getName(),
+ e.getMessage(), e);
+ throw new UnsupportedOperationException(
+ "cannont decode into " + decoderFilter.getCodedClass(), e);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public String encode(Object event) {
+
+ if (this.customCoder != null) {
+ try {
+ final DroolsController droolsController =
+ DroolsController.factory.get(this.groupId, this.artifactId, null);
+ final Class<?> gsonClassContainer =
+ droolsController.fetchModelClass(this.customCoder.getClassContainer());
+ final Field gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
+ final Object gsonObject = gsonField.get(null);
+ final Method toJsonMethod =
+ gsonObject.getClass().getDeclaredMethod("toJson", new Class[] {Object.class});
+ return (String) toJsonMethod.invoke(gsonObject, event);
+ } catch (final Exception e) {
+ logger.warn("{} cannot custom-encode {} because of {}", this, event, e.getMessage(), e);
+ throw new UnsupportedOperationException("event cannot be encoded", e);
+ }
+ } else {
+ try {
+ return this.encoder.toJson(event);
+ } catch (final Exception e) {
+ logger.warn("{} cannot encode {} because of {}", this, event, e.getMessage(), e);
+ throw new UnsupportedOperationException("event cannot be encoded", e);
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("GsonProtocolCoderToolset [toString()=").append(super.toString()).append("]");
+ return builder.toString();
}
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("GsonProtocolCoderToolset [toString()=").append(super.toString()).append("]");
- return builder.toString();
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java
index 7c1b128f..f7fc4d21 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java
@@ -24,286 +24,308 @@ import java.util.List;
public class TopicCoderFilterConfiguration {
- /**
- * Custom coder, contains class and static field to access parser that the controller
- * desires to use instead of the framework provided parser
- */
- public abstract static class CustomCoder {
- protected String className;
- protected String staticCoderField;
-
- /**
- * create custom coder from raw string in the following format
- * (typically embedded in a property file):
- *
- * Note this is to support decoding/encoding of partial structures that are
- * only known by the model.
- *
- * @param rawCustomCoder with format: <class-containing-custom-coder>,<static-coder-field>
- */
- public CustomCoder(String rawCustomCoder) {
- if (rawCustomCoder != null && !rawCustomCoder.isEmpty()) {
-
- this.className = rawCustomCoder.substring(0,rawCustomCoder.indexOf(","));
- if (this.className == null || this.className.isEmpty()) {
- throw new IllegalArgumentException("No classname to create CustomCoder cannot be created");
- }
-
- this.staticCoderField = rawCustomCoder.substring(rawCustomCoder.indexOf(",")+1);
- if (this.staticCoderField == null || this.staticCoderField.isEmpty()) {
- throw new IllegalArgumentException
- ("No staticCoderField to create CustomCoder cannot be created for class " +
- className);
- }
-
- }
- }
- /**
- * @param classContainer
- * @param staticCoderField
- */
- public CustomCoder(String className, String staticCoderField) {
- if (className == null || className.isEmpty()) {
- throw new IllegalArgumentException("No classname to create CustomCoder cannot be created");
- }
-
- if (staticCoderField == null || staticCoderField.isEmpty()) {
- throw new IllegalArgumentException
- ("No staticCoderField to create CustomCoder cannot be created for class " +
- className);
- }
-
- this.className = className;
- this.staticCoderField = staticCoderField;
- }
-
- /**
- * @return the className
- */
- public String getClassContainer() {
- return className;
- }
-
- /**
- * @param className the className to set
- */
- public void setClassContainer(String className) {
- this.className = className;
- }
-
- /**
- * @return the staticCoderField
- */
- public String getStaticCoderField() {
- return staticCoderField;
- }
-
- /**
- * @param staticCoderField the staticGson to set
- */
- public void setStaticCoderField(String staticCoderField) {
- this.staticCoderField = staticCoderField;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("CustomCoder [className=").append(className).append(", staticCoderField=")
- .append(staticCoderField).append("]");
- return builder.toString();
- }
- }
-
- public static class CustomGsonCoder extends CustomCoder {
-
- public CustomGsonCoder(String className, String staticCoderField) {
- super(className, staticCoderField);
- }
-
- public CustomGsonCoder(String customGson) {
- super(customGson);
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("CustomGsonCoder [toString()=").append(super.toString()).append("]");
- return builder.toString();
- }
-
- }
-
- public static class CustomJacksonCoder extends CustomCoder {
-
- public CustomJacksonCoder(String className, String staticCoderField) {
- super(className, staticCoderField);
- }
-
- public CustomJacksonCoder(String customJackson) {
- super(customJackson);
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("CustomJacksonCoder [toString()=").append(super.toString()).append("]");
- return builder.toString();
- }
-
- }
-
- /**
- * Coder/Decoder class and Filter container. The decoder class is potential,
- * in order to be operational needs to be fetched from an available
- * class loader.
- *
- */
- public static class PotentialCoderFilter {
-
- /**
- * decoder class (pending from being able to be fetched and found
- * in some class loader)
- */
- protected String codedClass;
-
- /**
- * filters to apply to the selection of the decodedClass;
- */
- protected JsonProtocolFilter filter;
-
- /**
- * constructor
- *
- * @param codedClass decoder class
- * @param filter filters to apply
- */
- public PotentialCoderFilter(String codedClass, JsonProtocolFilter filter) {
- this.codedClass = codedClass;
- this.filter = filter;
- }
-
- /**
- * @return the decodedClass
- */
- public String getCodedClass() {
- return codedClass;
- }
-
- /**
- * @param decodedClass the decodedClass to set
- */
- public void setCodedClass(String decodedClass) {
- this.codedClass = decodedClass;
- }
-
- /**
- * @return the filter
- */
- public JsonProtocolFilter getFilter() {
- return filter;
- }
-
- /**
- * @param filter the filter to set
- */
- public void setFilter(JsonProtocolFilter filter) {
- this.filter = filter;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("PotentialCoderFilter [codedClass=").append(codedClass).append(", filter=").append(filter)
- .append("]");
- return builder.toString();
- }
- }
-
- /**
- * the source topic
- */
- protected final String topic;
-
- /**
- * List of decoder -> filters
- */
- protected final List<PotentialCoderFilter> coderFilters;
-
- /**
- * custom gson coder that this controller prefers to use instead of the framework ones
- */
- protected CustomGsonCoder customGsonCoder;
-
- /**
- * custom jackson coder that this controller prefers to use instead of the framework ones
- */
- protected CustomJacksonCoder customJacksonCoder;
-
- /**
- * Constructor
- *
- * @param decoderFilters list of decoders and associated filters
- * @param topic the topic
- */
- public TopicCoderFilterConfiguration(String topic, List<PotentialCoderFilter> decoderFilters,
- CustomGsonCoder customGsonCoder,
- CustomJacksonCoder customJacksonCoder) {
- this.coderFilters = decoderFilters;
- this.topic = topic;
- this.customGsonCoder = customGsonCoder;
- this.customJacksonCoder = customJacksonCoder;
- }
-
- /**
- * @return the topic
- */
- public String getTopic() {
- return topic;
- }
-
- /**
- * @return the decoderFilters
- */
- public List<PotentialCoderFilter> getCoderFilters() {
- return coderFilters;
- }
-
- /**
- * @return the customGsonCoder
- */
- public CustomGsonCoder getCustomGsonCoder() {
- return customGsonCoder;
- }
-
- /**
- * @param customGsonCoder the customGsonCoder to set
- */
- public void setCustomGsonCoder(CustomGsonCoder customGsonCoder) {
- this.customGsonCoder = customGsonCoder;
- }
-
- /**
- * @return the customJacksonCoder
- */
- public CustomJacksonCoder getCustomJacksonCoder() {
- return customJacksonCoder;
- }
-
- /**
- * @param customJacksonCoder the customJacksonCoder to set
- */
- public void setCustomJacksonCoder(CustomJacksonCoder customJacksonCoder) {
- this.customJacksonCoder = customJacksonCoder;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("TopicCoderFilterConfiguration [topic=").append(topic).append(", coderFilters=")
- .append(coderFilters).append(", customGsonCoder=").append(customGsonCoder)
- .append(", customJacksonCoder=").append(customJacksonCoder).append("]");
- return builder.toString();
- }
+ /**
+ * Custom coder, contains class and static field to access parser that the controller desires to
+ * use instead of the framework provided parser.
+ */
+ public abstract static class CustomCoder {
+ protected String className;
+ protected String staticCoderField;
+ /**
+ * create custom coder from raw string in the following format (typically embedded in a property
+ * file):
+ *
+ * <p>Note this is to support decoding/encoding of partial structures that are only known by the
+ * model.
+ *
+ * @param rawCustomCoder with format: &lt;class-containing-custom-coder&gt;,&lt;static-coder-field&gt.
+ */
+ public CustomCoder(String rawCustomCoder) {
+ if (rawCustomCoder != null && !rawCustomCoder.isEmpty()) {
+ this.className = rawCustomCoder.substring(0, rawCustomCoder.indexOf(","));
+ if (this.className == null || this.className.isEmpty()) {
+ throw new IllegalArgumentException(
+ "No classname to create CustomCoder cannot be created");
+ }
+
+ this.staticCoderField = rawCustomCoder.substring(rawCustomCoder.indexOf(",") + 1);
+ if (this.staticCoderField == null || this.staticCoderField.isEmpty()) {
+ throw new IllegalArgumentException(
+ "No staticCoderField to create CustomCoder cannot be created for class " + className);
+ }
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param className class name
+ * @param staticCoderField static coder field
+ */
+ public CustomCoder(String className, String staticCoderField) {
+ if (className == null || className.isEmpty()) {
+ throw new IllegalArgumentException("No classname to create CustomCoder cannot be created");
+ }
+
+ if (staticCoderField == null || staticCoderField.isEmpty()) {
+ throw new IllegalArgumentException(
+ "No staticCoderField to create CustomCoder cannot be created for class " + className);
+ }
+
+ this.className = className;
+ this.staticCoderField = staticCoderField;
+ }
+
+ /**
+ * Get class container.
+ *
+ * @return the className
+ **/
+ public String getClassContainer() {
+ return className;
+ }
+
+ /**
+ * Set class container.
+ *
+ * @param className the className to set
+ **/
+ public void setClassContainer(String className) {
+ this.className = className;
+ }
+
+ /**
+ * Get static coder field.
+ *
+ * @return the staticCoderField
+ **/
+ public String getStaticCoderField() {
+ return staticCoderField;
+ }
+
+ /**
+ * Set static coder field.
+ *
+ * @param staticCoderField the staticGson to set
+ **/
+ public void setStaticCoderField(String staticCoderField) {
+ this.staticCoderField = staticCoderField;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder
+ .append("CustomCoder [className=")
+ .append(className)
+ .append(", staticCoderField=")
+ .append(staticCoderField)
+ .append("]");
+ return builder.toString();
+ }
+ }
+
+ public static class CustomGsonCoder extends CustomCoder {
+
+ public CustomGsonCoder(String className, String staticCoderField) {
+ super(className, staticCoderField);
+ }
+
+ public CustomGsonCoder(String customGson) {
+ super(customGson);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("CustomGsonCoder [toString()=").append(super.toString()).append("]");
+ return builder.toString();
+ }
+ }
+
+ public static class CustomJacksonCoder extends CustomCoder {
+
+ public CustomJacksonCoder(String className, String staticCoderField) {
+ super(className, staticCoderField);
+ }
+
+ public CustomJacksonCoder(String customJackson) {
+ super(customJackson);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("CustomJacksonCoder [toString()=").append(super.toString()).append("]");
+ return builder.toString();
+ }
+ }
+
+ /**
+ * Coder/Decoder class and Filter container. The decoder class is potential, in order to be
+ * operational needs to be fetched from an available class loader.
+ */
+ public static class PotentialCoderFilter {
+
+ /* decoder class (pending from being able to be fetched and found in some class loader) */
+ protected String codedClass;
+
+ /* filters to apply to the selection of the decodedClass; */
+ protected JsonProtocolFilter filter;
+
+ /**
+ * constructor.
+ *
+ * @param codedClass decoder class
+ * @param filter filters to apply
+ */
+ public PotentialCoderFilter(String codedClass, JsonProtocolFilter filter) {
+ this.codedClass = codedClass;
+ this.filter = filter;
+ }
+
+ /**
+ * Get coded class.
+ *
+ * @return the decodedClass
+ **/
+ public String getCodedClass() {
+ return codedClass;
+ }
+
+ /** Set coded class.
+ *
+ * @param decodedClass the decodedClass to set
+ **/
+ public void setCodedClass(String decodedClass) {
+ this.codedClass = decodedClass;
+ }
+
+ /**
+ * Get filter.
+ *
+ * @return the filter
+ **/
+ public JsonProtocolFilter getFilter() {
+ return filter;
+ }
+
+ /**
+ * Set filter.
+ *
+ * @param filter the filter to set
+ **/
+ public void setFilter(JsonProtocolFilter filter) {
+ this.filter = filter;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder
+ .append("PotentialCoderFilter [codedClass=")
+ .append(codedClass)
+ .append(", filter=")
+ .append(filter)
+ .append("]");
+ return builder.toString();
+ }
+ }
+
+ /* the source topic */
+ protected final String topic;
+
+ /* List of decoder -> filters */
+ protected final List<PotentialCoderFilter> coderFilters;
+
+ /* custom gson coder that this controller prefers to use instead of the framework ones */
+ protected CustomGsonCoder customGsonCoder;
+
+ /* custom jackson coder that this controller prefers to use instead of the framework ones */
+ protected CustomJacksonCoder customJacksonCoder;
+
+ /**
+ * Constructor.
+ *
+ * @param decoderFilters list of decoders and associated filters
+ * @param topic the topic
+ */
+ public TopicCoderFilterConfiguration(
+ String topic,
+ List<PotentialCoderFilter> decoderFilters,
+ CustomGsonCoder customGsonCoder,
+ CustomJacksonCoder customJacksonCoder) {
+ this.coderFilters = decoderFilters;
+ this.topic = topic;
+ this.customGsonCoder = customGsonCoder;
+ this.customJacksonCoder = customJacksonCoder;
+ }
+
+ /**
+ * Get topic.
+ * @return the topic
+ **/
+ public String getTopic() {
+ return topic;
+ }
+
+ /** Get coder filters.
+ *
+ * @return the decoderFilters
+ **/
+ public List<PotentialCoderFilter> getCoderFilters() {
+ return coderFilters;
+ }
+
+ /**
+ * Get custom gson coder.
+ *
+ * @return the customGsonCoder
+ **/
+ public CustomGsonCoder getCustomGsonCoder() {
+ return customGsonCoder;
+ }
+
+ /**
+ * Set custom gson coder.
+ *
+ * @param customGsonCoder the customGsonCoder to set
+ **/
+ public void setCustomGsonCoder(CustomGsonCoder customGsonCoder) {
+ this.customGsonCoder = customGsonCoder;
+ }
+
+ /** Get custom jackson coder.
+ *
+ * @return the customJacksonCoder
+ **/
+ public CustomJacksonCoder getCustomJacksonCoder() {
+ return customJacksonCoder;
+ }
+
+ /**
+ * Set custom Jackson coder.
+ * @param customJacksonCoder the customJacksonCoder to set
+ **/
+ public void setCustomJacksonCoder(CustomJacksonCoder customJacksonCoder) {
+ this.customJacksonCoder = customJacksonCoder;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder
+ .append("TopicCoderFilterConfiguration [topic=")
+ .append(topic)
+ .append(", coderFilters=")
+ .append(coderFilters)
+ .append(", customGsonCoder=")
+ .append(customGsonCoder)
+ .append(", customJacksonCoder=")
+ .append(customJacksonCoder)
+ .append("]");
+ return builder.toString();
+ }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
index 62b66611..69e13b43 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
@@ -20,6 +20,12 @@
package org.onap.policy.drools.protocol.configuration;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
import java.util.HashMap;
import java.util.Map;
@@ -27,41 +33,34 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
/**
- * Drools Related Information
+ * Drools Related Information.
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ControllerConfiguration {
- public static final String CONFIG_CONTROLLER_OPERATION_CREATE = "create";
- public static final String CONFIG_CONTROLLER_OPERATION_UPDATE = "update";
- public static final String CONFIG_CONTROLLER_OPERATION_LOCK = "lock";
- public static final String CONFIG_CONTROLLER_OPERATION_UNLOCK = "unlock";
-
+ public static final String CONFIG_CONTROLLER_OPERATION_CREATE = "create";
+ public static final String CONFIG_CONTROLLER_OPERATION_UPDATE = "update";
+ public static final String CONFIG_CONTROLLER_OPERATION_LOCK = "lock";
+ public static final String CONFIG_CONTROLLER_OPERATION_UNLOCK = "unlock";
+
/**
- *
- * (Required)
+ * (Required).
*
*/
@JsonProperty("name")
private String name;
/**
* Set of operations that can be applied to a controller: create, lock
- * (Required)
+ * (Required).
*
*/
@JsonProperty("operation")
private String operation;
/**
- * Maven Related Information
+ * Maven Related Information.
*
*/
@JsonProperty("drools")
@@ -71,18 +70,19 @@ public class ControllerConfiguration {
protected static final Object NOT_FOUND_VALUE = new Object();
/**
- * No args constructor for use in serialization
+ * No args constructor for use in serialization.
*
*/
public ControllerConfiguration() {
- // Empty
+ // Empty
}
/**
+ * Constructor.
*
- * @param name
- * @param drools
- * @param operation
+ * @param name name
+ * @param operation operation
+ * @param drools drools
*/
public ControllerConfiguration(String name, String operation, DroolsConfiguration drools) {
this.name = name;
@@ -91,8 +91,7 @@ public class ControllerConfiguration {
}
/**
- *
- * (Required)
+ * (Required).
*
* @return
* The name
@@ -103,8 +102,7 @@ public class ControllerConfiguration {
}
/**
- *
- * (Required)
+ * (Required).
*
* @param name
* The name
@@ -121,7 +119,7 @@ public class ControllerConfiguration {
/**
* Set of operations that can be applied to a controller: create, lock
- * (Required)
+ * (Required).
*
* @return
* The operation
@@ -133,7 +131,7 @@ public class ControllerConfiguration {
/**
* Set of operations that can be applied to a controller: create, lock
- * (Required)
+ * (Required).
*
* @param operation
* The operation
@@ -149,7 +147,7 @@ public class ControllerConfiguration {
}
/**
- * Maven Related Information
+ * Maven Related Information.
*
* @return
* The drools
@@ -160,7 +158,7 @@ public class ControllerConfiguration {
}
/**
- * Maven Related Information
+ * Maven Related Information.
*
* @param drools
* The drools
@@ -224,24 +222,43 @@ public class ControllerConfiguration {
}
}
+ /**
+ * Get.
+ *
+ * @param name name
+ * @return the object
+ */
@SuppressWarnings({
"unchecked"
- })
- public<T >T get(String name) {
+ })
+ public <T> T get(String name) {
Object value = declaredPropertyOrNotFound(name, ControllerConfiguration.NOT_FOUND_VALUE);
- if (ControllerConfiguration.NOT_FOUND_VALUE!= value) {
+ if (ControllerConfiguration.NOT_FOUND_VALUE != value) {
return ((T) value);
} else {
return ((T) getAdditionalProperties().get(name));
}
}
+ /**
+ * Set the property.
+ *
+ * @param name property name
+ * @param value property value
+ */
public void set(String name, Object value) {
if (!declaredProperty(name, value)) {
getAdditionalProperties().put(name, (Object) value);
}
}
+ /**
+ * With - sets the property and additionally returns the object.
+ *
+ * @param name property name
+ * @param value property value
+ * @return this
+ */
public ControllerConfiguration with(String name, Object value) {
if (!declaredProperty(name, value)) {
getAdditionalProperties().put(name, (Object) value);
@@ -251,7 +268,8 @@ public class ControllerConfiguration {
@Override
public int hashCode() {
- return new HashCodeBuilder().append(name).append(operation).append(drools).append(additionalProperties).toHashCode();
+ return new HashCodeBuilder().append(name).append(operation).append(drools).append(additionalProperties)
+ .toHashCode();
}
@Override
@@ -263,30 +281,50 @@ public class ControllerConfiguration {
return false;
}
ControllerConfiguration rhs = ((ControllerConfiguration) other);
- return new EqualsBuilder().append(name, rhs.name).append(operation, rhs.operation).append(drools, rhs.drools).append(additionalProperties, rhs.additionalProperties).isEquals();
+ return new EqualsBuilder().append(name, rhs.name).append(operation, rhs.operation).append(drools, rhs.drools)
+ .append(additionalProperties, rhs.additionalProperties).isEquals();
}
+ /**
+ * Call set name.
+ *
+ * @param value value
+ */
public void callSetName(Object value) {
if (value instanceof String) {
setName((String) value);
} else {
- throw new IllegalArgumentException("property \"name\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ throw new IllegalArgumentException("property \"name\" is of type \"java.lang.String\", but got "
+ + value.getClass().toString());
}
}
+ /**
+ * Call set operation.
+ *
+ * @param value value
+ */
public void callSetOperation(Object value) {
if (value instanceof String) {
setOperation((String) value);
} else {
- throw new IllegalArgumentException("property \"operation\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ throw new IllegalArgumentException("property \"operation\" is of type \"java.lang.String\", but got "
+ + value.getClass().toString());
}
}
+ /**
+ * Call set drools.
+ *
+ * @param value value
+ */
public void callSetDrools(Object value) {
if (value instanceof DroolsConfiguration) {
setDrools((DroolsConfiguration) value);
} else {
- throw new IllegalArgumentException("property \"drools\" is of type \"org.onap.policy.drools.protocol.configuration.Drools\", but got "+ value.getClass().toString());
+ throw new IllegalArgumentException("property \"drools\" is of type"
+ + "\"org.onap.policy.drools.protocol.configuration.Drools\", but got "
+ + value.getClass().toString());
}
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
index cac4f565..e1f7f63a 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
@@ -20,22 +20,21 @@
package org.onap.policy.drools.protocol.configuration;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
- * Maven Related Information
+ * Maven Related Information.
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -43,21 +42,23 @@ public class DroolsConfiguration {
/**
* Maven Artifact ID
- * (Required)
+ * (Required).
*
*/
@JsonProperty("artifactId")
private String artifactId;
+
/**
* Maven Group ID
- * (Required)
+ * (Required).
*
*/
@JsonProperty("groupId")
private String groupId;
+
/**
* Maven Version
- * (Required)
+ * (Required).
*
*/
@JsonProperty("version")
@@ -67,18 +68,19 @@ public class DroolsConfiguration {
protected static final Object NOT_FOUND_VALUE = new Object();
/**
- * No args constructor for use in serialization
+ * No args constructor for use in serialization.
*
*/
public DroolsConfiguration() {
- // Empty
+ // Empty
}
/**
+ * Constructor.
*
- * @param groupId
- * @param artifactId
- * @param version
+ * @param groupId group id
+ * @param artifactId artifact id
+ * @param version version
*/
public DroolsConfiguration(String artifactId, String groupId, String version) {
this.artifactId = artifactId;
@@ -88,7 +90,7 @@ public class DroolsConfiguration {
/**
* Maven Artifact ID
- * (Required)
+ * (Required).
*
* @return
* The artifactId
@@ -100,7 +102,7 @@ public class DroolsConfiguration {
/**
* Maven Artifact ID
- * (Required)
+ * (Required).
*
* @param artifactId
* The artifactId
@@ -117,7 +119,7 @@ public class DroolsConfiguration {
/**
* Maven Group ID
- * (Required)
+ * (Required).
*
* @return
* The groupId
@@ -129,7 +131,7 @@ public class DroolsConfiguration {
/**
* Maven Group ID
- * (Required)
+ * (Required).
*
* @param groupId
* The groupId
@@ -146,7 +148,7 @@ public class DroolsConfiguration {
/**
* Maven Version
- * (Required)
+ * (Required).
*
* @return
* The version
@@ -158,7 +160,7 @@ public class DroolsConfiguration {
/**
* Maven Version
- * (Required)
+ * (Required).
*
* @param version
* The version
@@ -222,24 +224,43 @@ public class DroolsConfiguration {
}
}
+ /**
+ * Get declared property.
+ *
+ * @param name property name
+ * @return the property object
+ */
@SuppressWarnings({
"unchecked"
- })
- public<T >T get(String name) {
+ })
+ public <T> T get(String name) {
Object value = declaredPropertyOrNotFound(name, DroolsConfiguration.NOT_FOUND_VALUE);
- if (DroolsConfiguration.NOT_FOUND_VALUE!= value) {
+ if (DroolsConfiguration.NOT_FOUND_VALUE != value) {
return (T) value;
} else {
return (T) getAdditionalProperties().get(name);
}
}
+ /**
+ * Set property value.
+ *
+ * @param name property name
+ * @param value property value
+ */
public void set(String name, Object value) {
if (!declaredProperty(name, value)) {
getAdditionalProperties().put(name, value);
}
}
+ /**
+ * Set property value and return object.
+ *
+ * @param name property name
+ * @param value property value
+ * @return this
+ */
public DroolsConfiguration with(String name, Object value) {
if (!declaredProperty(name, value)) {
getAdditionalProperties().put(name, value);
@@ -249,7 +270,8 @@ public class DroolsConfiguration {
@Override
public int hashCode() {
- return new HashCodeBuilder().append(artifactId).append(groupId).append(version).append(additionalProperties).toHashCode();
+ return new HashCodeBuilder().append(artifactId).append(groupId).append(version).append(additionalProperties)
+ .toHashCode();
}
@Override
@@ -261,30 +283,50 @@ public class DroolsConfiguration {
return false;
}
DroolsConfiguration rhs = ((DroolsConfiguration) other);
- return new EqualsBuilder().append(artifactId, rhs.artifactId).append(groupId, rhs.groupId).append(version, rhs.version).append(additionalProperties, rhs.additionalProperties).isEquals();
+ return new EqualsBuilder().append(artifactId, rhs.artifactId)
+ .append(groupId, rhs.groupId).append(version, rhs.version)
+ .append(additionalProperties, rhs.additionalProperties).isEquals();
}
+ /**
+ * Call set artifact id.
+ *
+ * @param value id
+ */
public void callSetArtifactId(Object value) {
if (value instanceof String) {
setArtifactId((String) value);
} else {
- throw new IllegalArgumentException("property \"artifactId\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ throw new IllegalArgumentException("property \"artifactId\" is of type \"java.lang.String\", but got "
+ + value.getClass().toString());
}
}
+ /**
+ * Call set group id.
+ *
+ * @param value id
+ */
public void callSetGroupId(Object value) {
if (value instanceof String) {
setGroupId((String) value);
} else {
- throw new IllegalArgumentException("property \"groupId\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ throw new IllegalArgumentException("property \"groupId\" is of type \"java.lang.String\", but got "
+ + value.getClass().toString());
}
}
+ /**
+ * Call set version.
+ *
+ * @param value version
+ */
public void callSetVersion(Object value) {
if (value instanceof String) {
setVersion((String) value);
} else {
- throw new IllegalArgumentException("property \"version\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ throw new IllegalArgumentException("property \"version\" is of type \"java.lang.String\", but got "
+ + value.getClass().toString());
}
}
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
index 29888bbb..58cd67fd 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
@@ -20,84 +20,65 @@
package org.onap.policy.drools.protocol.configuration;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
/**
- * ENGINE-CONFIGURATION
- * <p>
- *
- *
+ * ENGINE-CONFIGURATION.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PdpdConfiguration {
-
- /**
- * Controller Entity ID
- */
- public static final String CONFIG_ENTITY_CONTROLLER = "controller";
- /**
- * Unique Transaction ID. This is an UUID.
- * (Required)
- *
- */
+ /** Controller Entity ID. */
+ public static final String CONFIG_ENTITY_CONTROLLER = "controller";
+
+ /** Unique Transaction ID. This is an UUID. (Required) */
@JsonProperty("requestID")
private String requestID;
- /**
- * Set of entities on which configuration can be performed: controller
- * (Required)
- *
- */
+ /* Set of entities on which configuration can be performed: controller (Required) */
@JsonProperty("entity")
private String entity;
- /**
- * Controller Information, only applicable when the entity is set to controller
- *
- */
+ /* Controller Information, only applicable when the entity is set to controller */
@JsonProperty("controllers")
private List<ControllerConfiguration> controllers = new ArrayList<>();
- @JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<>();
+
+ @JsonIgnore private Map<String, Object> additionalProperties = new HashMap<>();
protected static final Object NOT_FOUND_VALUE = new Object();
- /**
- * No args constructor for use in serialization
- *
- */
+ /** No args constructor for use in serialization. */
public PdpdConfiguration() {
- // Empty
+ // Empty
}
/**
+ * Constructor.
*
- * @param controller
- * @param requestID
- * @param entity
+ * @param requestID request id
+ * @param entity entity
+ * @param controllers controllers
*/
- public PdpdConfiguration(String requestID, String entity, List<ControllerConfiguration> controllers) {
+ public PdpdConfiguration(
+ String requestID, String entity, List<ControllerConfiguration> controllers) {
this.requestID = requestID;
this.entity = entity;
this.controllers = controllers;
}
/**
- * Unique Transaction ID. This is an UUID.
- * (Required)
- *
- * @return
- * The requestID
+ * Unique Transaction ID. This is an UUID. (Required)
+ *
+ * @return The requestID
*/
@JsonProperty("requestID")
public String getRequestID() {
@@ -105,11 +86,9 @@ public class PdpdConfiguration {
}
/**
- * Unique Transaction ID. This is an UUID.
- * (Required)
- *
- * @param requestID
- * The requestID
+ * Unique Transaction ID. This is an UUID. (Required)
+ *
+ * @param requestID The requestID
*/
@JsonProperty("requestID")
public void setRequestID(String requestID) {
@@ -122,11 +101,9 @@ public class PdpdConfiguration {
}
/**
- * Set of entities on which configuration can be performed: controller
- * (Required)
- *
- * @return
- * The entity
+ * Set of entities on which configuration can be performed: controller (Required).
+ *
+ * @return The entity
*/
@JsonProperty("entity")
public String getEntity() {
@@ -134,11 +111,9 @@ public class PdpdConfiguration {
}
/**
- * Set of entities on which configuration can be performed: controller
- * (Required)
- *
- * @param entity
- * The entity
+ * Set of entities on which configuration can be performed: controller (Required).
+ *
+ * @param entity The entity
*/
@JsonProperty("entity")
public void setEntity(String entity) {
@@ -151,10 +126,9 @@ public class PdpdConfiguration {
}
/**
- * Controller Information, only applicable when the entity is set to controller
- *
- * @return
- * The controller
+ * Controller Information, only applicable when the entity is set to controller.
+ *
+ * @return The controller
*/
@JsonProperty("controller")
public List<ControllerConfiguration> getControllers() {
@@ -162,10 +136,9 @@ public class PdpdConfiguration {
}
/**
- * Controller Information, only applicable when the entity is set to controller
- *
- * @param controller
- * The controller
+ * Controller Information, only applicable when the entity is set to controller.
+ *
+ * @param controllers controllers
*/
@JsonProperty("controller")
public void setControllers(List<ControllerConfiguration> controllers) {
@@ -226,24 +199,37 @@ public class PdpdConfiguration {
}
}
- @SuppressWarnings({
- "unchecked"
- })
- public<T >T get(String name) {
+ /**
+ * Get.
+ *
+ * @param name name
+ * @return object
+ */
+ @SuppressWarnings({"unchecked"})
+ public <T> T get(String name) {
Object value = declaredPropertyOrNotFound(name, PdpdConfiguration.NOT_FOUND_VALUE);
- if (PdpdConfiguration.NOT_FOUND_VALUE!= value) {
+ if (PdpdConfiguration.NOT_FOUND_VALUE != value) {
return (T) value;
} else {
return (T) getAdditionalProperties().get(name);
}
}
+ /**
+ * Set property.
+ *
+ * @param name name
+ * @param value value
+ */
public void set(String name, Object value) {
if (!declaredProperty(name, value)) {
getAdditionalProperties().put(name, value);
}
}
+ /**
+ * With - sets and returns the object.
+ */
public PdpdConfiguration with(String name, Object value) {
if (!declaredProperty(name, value)) {
getAdditionalProperties().put(name, value);
@@ -253,7 +239,12 @@ public class PdpdConfiguration {
@Override
public int hashCode() {
- return new HashCodeBuilder().append(requestID).append(entity).append(controllers).append(additionalProperties).toHashCode();
+ return new HashCodeBuilder()
+ .append(requestID)
+ .append(entity)
+ .append(controllers)
+ .append(additionalProperties)
+ .toHashCode();
}
@Override
@@ -265,31 +256,59 @@ public class PdpdConfiguration {
return false;
}
PdpdConfiguration rhs = (PdpdConfiguration) other;
- return new EqualsBuilder().append(requestID, rhs.requestID).append(entity, rhs.entity).append(controllers, rhs.controllers).append(additionalProperties, rhs.additionalProperties).isEquals();
+ return new EqualsBuilder()
+ .append(requestID, rhs.requestID)
+ .append(entity, rhs.entity)
+ .append(controllers, rhs.controllers)
+ .append(additionalProperties, rhs.additionalProperties)
+ .isEquals();
}
-
+
+ /**
+ * Call set request id.
+ *
+ * @param value value
+ */
public void callSetRequestId(Object value) {
if (value instanceof String) {
setRequestID((String) value);
} else {
- throw new IllegalArgumentException("property \"requestID\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
- }
+ throw new IllegalArgumentException(
+ "property \"requestID\" is of type \"java.lang.String\", but got "
+ + value.getClass().toString());
+ }
}
-
+
+ /**
+ * Call set entity.
+ *
+ * @param value value
+ */
public void callSetEntity(Object value) {
if (value instanceof String) {
setEntity((String) value);
} else {
- throw new IllegalArgumentException("property \"entity\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
- }
+ throw new IllegalArgumentException(
+ "property \"entity\" is of type \"java.lang.String\", but got "
+ + value.getClass().toString());
+ }
}
+ /**
+ * Call set controllers.
+ *
+ * @param value value
+ */
@SuppressWarnings("unchecked")
- public void callSetControllers(Object value) {
+ public void callSetControllers(Object value) {
if (value instanceof List) {
- setControllers((List<ControllerConfiguration> ) value);
+ setControllers((List<ControllerConfiguration>) value);
} else {
- throw new IllegalArgumentException("property \"controllers\" is of type \"java.util.List<org.onap.policy.drools.protocol.configuration.Controller>\", but got "+ value.getClass().toString());
- }
+ throw new IllegalArgumentException(
+ "property \"controllers\" is of type "
+ + "\"java.util.List<org.onap.policy.drools.protocol.configuration.Controller>\", "
+ + "but got "
+ + value.getClass().toString());
+ }
}
}
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 00da884e..64fd6823 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
@@ -21,7 +21,14 @@
package org.onap.policy.drools.server.restful;
import ch.qos.logback.classic.LoggerContext;
-
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Info;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -70,18 +77,9 @@ import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.SwaggerDefinition;
-import io.swagger.annotations.Tag;
-
/**
- * Telemetry JAX-RS Interface to the PDP-D
+ * Telemetry JAX-RS Interface to the PDP-D.
*/
@Path("/policy/pdp")
@@ -94,10 +92,15 @@ import io.swagger.annotations.Tag;
tags = {@Tag(name = "pdp-d-telemetry", description = "Drools PDP Telemetry Operations")})
public class RestManager {
/**
- * Logger
+ * Logger.
*/
private static Logger logger = LoggerFactory.getLogger(RestManager.class);
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine")
@ApiOperation(value = "Retrieves the Engine Operational Status",
@@ -106,6 +109,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(PolicyEngine.manager).build();
}
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
@DELETE
@Path("engine")
@ApiOperation(value = "Shuts down the Engine",
@@ -122,6 +130,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(PolicyEngine.manager).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/features")
@ApiOperation(value = "Engine Features",
@@ -139,6 +152,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(PolicyEngine.manager.getFeatureProviders()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/features/{featureName}")
@ApiOperation(value = "Engine Feature", notes = "Provides Details for a given feature Engine Provider",
@@ -155,6 +173,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/inputs")
@ApiOperation(value = "Engine Input Ports", notes = "List of input ports", responseContainer = "List")
@@ -162,6 +185,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(Arrays.asList(Inputs.values())).build();
}
+ /**
+ * POST.
+ *
+ * @return response object
+ */
@POST
@Path("engine/inputs/configuration")
@ApiOperation(value = "Engine Input Configuration Requests",
@@ -186,6 +214,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/properties")
@ApiOperation(value = "Engine Configuration Properties", notes = "Used for booststrapping the engine",
@@ -194,6 +227,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(PolicyEngine.manager.getProperties()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/environment")
@ApiOperation(value = "Engine Environment Properties",
@@ -202,6 +240,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(PolicyEngine.manager.getEnvironment()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/environment/{envProperty}")
@Consumes(MediaType.TEXT_PLAIN)
@@ -212,6 +255,11 @@ public class RestManager {
.build();
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/environment/{envProperty}")
@Consumes(MediaType.TEXT_PLAIN)
@@ -224,6 +272,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(previousValue).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/switches")
@ApiOperation(value = "Engine Control Switches", notes = "List of the Engine Control Switches",
@@ -232,6 +285,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(Arrays.asList(Switches.values())).build();
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/switches/activation")
@ApiOperation(value = "Switches on the Engine Activation Switch",
@@ -255,6 +313,11 @@ public class RestManager {
}
}
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
@DELETE
@Path("engine/switches/activation")
@ApiOperation(value = "Switches off Engine Activation Switch",
@@ -278,6 +341,11 @@ public class RestManager {
}
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/switches/lock")
@ApiOperation(value = "Switches on the Engine Lock Control",
@@ -294,6 +362,11 @@ public class RestManager {
}
}
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
@DELETE
@Path("engine/switches/lock")
@ApiOperation(value = "Switches off the Lock control",
@@ -310,6 +383,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers")
@ApiOperation(value = "Lists the Policy Controllers Names", notes = "Unique Policy Controller Identifiers",
@@ -318,6 +396,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(PolicyEngine.manager.getPolicyControllerIds()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/inventory")
@ApiOperation(value = "Lists the Policy Controllers", notes = "Detailed list of Policy Controllers",
@@ -326,6 +409,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(PolicyEngine.manager.getPolicyControllers()).build();
}
+ /**
+ * POST.
+ *
+ * @return response object
+ */
@POST
@Path("engine/controllers")
@ApiOperation(value = "Creates and starts a new Policy Controller",
@@ -389,6 +477,11 @@ public class RestManager {
return Response.status(Response.Status.CREATED).entity(controller).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/features")
@ApiOperation(value = "Lists of Feature Providers Identifiers", notes = "Unique Policy Controller Identifiers",
@@ -397,6 +490,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(PolicyEngine.manager.getFeatures()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/features/inventory")
@ApiOperation(value = "Detailed Controllers Feature Inventory",
@@ -406,6 +504,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(PolicyController.factory.getFeatureProviders()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/features/{featureName}")
@ApiOperation(value = "Controller Feature",
@@ -423,6 +526,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}")
@ApiOperation(value = "Retrieves a Policy Controller",
@@ -447,6 +555,11 @@ public class RestManager {
}
}
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
@DELETE
@Path("engine/controllers/{controller}")
@ApiOperation(value = "Deletes a Policy Controller",
@@ -489,6 +602,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(controller).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/properties")
@ApiOperation(value = "Retrieves the configuration properties of a Policy Controller",
@@ -512,6 +630,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/inputs")
@ApiOperation(value = "Policy Controller Input Ports", notes = "List of input ports", responseContainer = "List")
@@ -519,6 +642,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(Arrays.asList(Inputs.values())).build();
}
+ /**
+ * POST.
+ *
+ * @return response object
+ */
@POST
@Path("engine/controllers/{controller}/inputs/configuration")
@ApiOperation(value = "Policy Controller Input Configuration Requests",
@@ -558,6 +686,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(controller).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/switches")
@ApiOperation(value = "Policy Controller Switches", notes = "List of the Policy Controller Switches",
@@ -566,6 +699,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(Arrays.asList(Switches.values())).build();
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/controllers/{controller}/switches/lock")
@ApiOperation(value = "Switches on the Policy Controller Lock Control",
@@ -584,6 +722,11 @@ public class RestManager {
}
}
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
@DELETE
@Path("engine/controllers/{controller}/switches/lock")
@ApiOperation(value = "Switches off the Policy Controller Lock Control",
@@ -602,6 +745,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/drools")
@ApiOperation(value = "Retrieves the Drools Controller subcomponent of the Policy Controller",
@@ -625,6 +773,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/drools/facts")
@ApiOperation(value = "Retrieves Facts Summary information for a given controller",
@@ -652,6 +805,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/drools/facts/{session}")
@ApiOperation(value = "Retrieves Fact Types (classnames) for a given controller and its count",
@@ -676,6 +834,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/drools/facts/{session}/{factType}")
@ApiOperation(
@@ -710,47 +873,16 @@ public class RestManager {
}
}
- @DELETE
- @Path("engine/controllers/{controller}/drools/facts/{session}/{factType}")
- @ApiOperation(
- value = "Deletes all the fact objects of a given type from the drools working memory"
- + "for a given controller and session. The objects retracted from the working "
- + "memory are provided in the response.",
- notes = "The fact types are the classnames of the objects inserted in the drools working memory",
- responseContainer = "List")
- @ApiResponses(value = {@ApiResponse(code = 404, message = "The controller, session, or fact type, cannot be found"),
- @ApiResponse(code = 406,
- message = "The system is an administrative state that prevents " + "this request to be fulfilled"),
- @ApiResponse(code = 500, message = "A server error has occurred processing this request")})
- public Response droolsFactsDelete(
- @ApiParam(value = "Policy Controller Name", required = true) @PathParam("controller") String controllerName,
- @ApiParam(value = "Drools Session Name", required = true) @PathParam("session") String sessionName,
- @ApiParam(value = "Drools Fact Type", required = true) @PathParam("factType") String factType) {
- try {
- final DroolsController drools = this.getDroolsController(controllerName);
- final List<Object> facts = drools.facts(sessionName, factType, true);
- return Response.status(Response.Status.OK).entity(facts).build();
- } catch (final 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 (final 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 (final 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();
- }
- }
-
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/drools/facts/{session}/{query}/{queriedEntity}")
@ApiOperation(
- value = "Gets all the fact objects returned by a DRL query with no parameters from the drools working memory"
+ value = "Gets all the fact objects returned by a DRL query with no parameters "
+ + "from the drools working memory"
+ "for a given controller and session",
notes = "The DRL query must be defined in the DRL file", responseContainer = "List")
@ApiResponses(value = {
@@ -794,6 +926,11 @@ public class RestManager {
}
}
+ /**
+ * POST.
+ *
+ * @return response object
+ */
@POST
@Path("engine/controllers/{controller}/drools/facts/{session}/{query}/{queriedEntity}")
@ApiOperation(
@@ -846,10 +983,58 @@ public class RestManager {
}
}
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
+ @DELETE
+ @Path("engine/controllers/{controller}/drools/facts/{session}/{factType}")
+ @ApiOperation(
+ value = "Deletes all the fact objects of a given type from the drools working memory"
+ + "for a given controller and session. The objects retracted from the working "
+ + "memory are provided in the response.",
+ notes = "The fact types are the classnames of the objects inserted in the drools working memory",
+ responseContainer = "List")
+ @ApiResponses(value = {@ApiResponse(code = 404, message = "The controller, session, or fact type, cannot be found"),
+ @ApiResponse(code = 406,
+ message = "The system is an administrative state that prevents " + "this request to be fulfilled"),
+ @ApiResponse(code = 500, message = "A server error has occurred processing this request")})
+ public Response droolsFactsDelete(
+ @ApiParam(value = "Policy Controller Name", required = true) @PathParam("controller") String controllerName,
+ @ApiParam(value = "Drools Session Name", required = true) @PathParam("session") String sessionName,
+ @ApiParam(value = "Drools Fact Type", required = true) @PathParam("factType") String factType) {
+ try {
+ final DroolsController drools = this.getDroolsController(controllerName);
+ final List<Object> facts = drools.facts(sessionName, factType, true);
+ return Response.status(Response.Status.OK).entity(facts).build();
+ } catch (final 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 (final 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 (final 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();
+ }
+ }
+
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
@DELETE
@Path("engine/controllers/{controller}/drools/facts/{session}/{query}/{queriedEntity}")
@ApiOperation(
- value = "Deletes all the fact objects returned by a DRL query with parameters from the drools working memory"
+ value = "Deletes all the fact objects returned by a DRL query with parameters "
+ + "from the drools working memory "
+ "for a given controller and session",
notes = "The DRL query with parameters must be defined in the DRL file", responseContainer = "List")
@ApiResponses(value = {
@@ -898,6 +1083,11 @@ public class RestManager {
}
}
+ /**
+ * POST.
+ *
+ * @return response object
+ */
@POST
@Path("engine/controllers/tools/coders/decoders/filters/rules/{ruleName}")
@ApiOperation(value = "Produces a Decoder Rule Filter in a format that the Policy Controller can understand",
@@ -915,6 +1105,11 @@ public class RestManager {
return Response.status(Status.OK).entity(new JsonProtocolFilter.FilterRule(name, literalRegex)).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/decoders")
@ApiOperation(value = "Gets all the decoders used by a controller",
@@ -945,6 +1140,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/decoders/filters")
@ApiOperation(value = "Gets all the filters used by a controller",
@@ -976,6 +1176,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/decoders/{topic}")
@ApiOperation(value = "Gets all the decoders in use by a controller for a networked topic",
@@ -1008,6 +1213,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/decoders/{topic}/filters")
@ApiOperation(value = "Gets all filters attached to decoders for a given networked topic in use by a controller",
@@ -1046,6 +1256,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/decoders/{topic}/filters/{factType}")
@ApiOperation(
@@ -1086,6 +1301,11 @@ public class RestManager {
}
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/controllers/{controller}/decoders/{topic}/filters/{factType}")
@ApiOperation(value = "Attaches filters to the decoder for a given networked topic " + "and fact type",
@@ -1137,6 +1357,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/decoders/{topic}/filters/{factType}/rules")
@ApiOperation(value = "Gets the filter rules attached to a topic decoder of a controller",
@@ -1183,6 +1408,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/decoders/{topic}/filters/{factType}/rules/{ruleName}")
@ApiOperation(value = "Gets a filter rule by name attached to a topic decoder of a controller",
@@ -1236,6 +1466,11 @@ public class RestManager {
}
}
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
@DELETE
@Path("engine/controllers/{controller}/decoders/{topic}/filters/{factType}/rules/{ruleName}")
@ApiOperation(value = "Deletes a filter rule by name attached to a topic decoder of a controller",
@@ -1303,6 +1538,11 @@ public class RestManager {
}
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/controllers/{controller}/decoders/{topic}/filters/{factType}/rules")
@ApiOperation(value = "Places a new filter rule in a topic decoder",
@@ -1347,19 +1587,26 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(filter.getRules()).build();
} catch (final 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);
+ "{}: 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 (final 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);
+ "{}: 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")).build();
}
}
+ /**
+ * POST.
+ *
+ * @return response object
+ */
@POST
@Path("engine/controllers/{controller}/decoders/{topic}")
@Consumes(MediaType.TEXT_PLAIN)
@@ -1416,6 +1663,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(result).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/controllers/{controller}/encoders")
@ApiOperation(value = "Retrieves the encoder filters of a controller",
@@ -1461,6 +1713,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(Arrays.asList(Switches.values())).build();
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/topics/switches/lock")
@ApiOperation(value = "Locks all the managed topics", notes = "The operation affects all managed sources and sinks",
@@ -1476,6 +1733,11 @@ public class RestManager {
}
}
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
@DELETE
@Path("engine/topics/switches/lock")
@ApiOperation(value = "Unlocks all the managed topics",
@@ -1491,6 +1753,11 @@ public class RestManager {
}
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sources")
@ApiOperation(value = "Retrieves the managed topic sources", notes = "Network Topic Sources Agregation",
@@ -1499,6 +1766,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getTopicSources()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sinks")
@ApiOperation(value = "Retrieves the managed topic sinks", notes = "Network Topic Sinks Agregation",
@@ -1507,6 +1779,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getTopicSinks()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sources/ueb")
@ApiOperation(value = "Retrieves the UEB managed topic sources", notes = "UEB Topic Sources Agregation",
@@ -1515,6 +1792,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getUebTopicSources()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sinks/ueb")
@ApiOperation(value = "Retrieves the UEB managed topic sinks", notes = "UEB Topic Sinks Agregation",
@@ -1523,6 +1805,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getUebTopicSinks()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sources/dmaap")
@ApiOperation(value = "Retrieves the DMaaP managed topic sources", notes = "DMaaP Topic Sources Agregation",
@@ -1531,6 +1818,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getDmaapTopicSources()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sinks/dmaap")
@ApiOperation(value = "Retrieves the DMaaP managed topic sinks", notes = "DMaaP Topic Sinks Agregation",
@@ -1539,6 +1831,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getDmaapTopicSinks()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sources/ueb/{topic}")
@ApiOperation(value = "Retrieves an UEB managed topic source",
@@ -1548,6 +1845,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getUebTopicSource(topic)).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sinks/ueb/{topic}")
@ApiOperation(value = "Retrieves an UEB managed topic sink",
@@ -1557,6 +1859,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getUebTopicSink(topic)).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sources/dmaap/{topic}")
@ApiOperation(value = "Retrieves a DMaaP managed topic source",
@@ -1567,6 +1874,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getDmaapTopicSource(topic)).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sinks/dmaap/{topic}")
@ApiOperation(value = "Retrieves a DMaaP managed topic sink",
@@ -1576,6 +1888,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getDmaapTopicSink(topic)).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sources/ueb/{topic}/events")
@ApiOperation(value = "Retrieves the latest events received by an UEB topic",
@@ -1586,6 +1903,11 @@ public class RestManager {
.entity(Arrays.asList(TopicEndpoint.manager.getUebTopicSource(topic).getRecentEvents())).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sinks/ueb/{topic}/events")
@ApiOperation(value = "Retrieves the latest events sent from a topic",
@@ -1596,6 +1918,11 @@ public class RestManager {
.entity(Arrays.asList(TopicEndpoint.manager.getUebTopicSink(topic).getRecentEvents())).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sources/dmaap/{topic}/events")
@ApiOperation(value = "Retrieves the latest events received by a DMaaP topic",
@@ -1607,6 +1934,11 @@ public class RestManager {
.entity(Arrays.asList(TopicEndpoint.manager.getDmaapTopicSource(topic).getRecentEvents())).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sinks/dmaap/{topic}/events")
@ApiOperation(value = "Retrieves the latest events send through a DMaaP topic",
@@ -1617,6 +1949,11 @@ public class RestManager {
.entity(Arrays.asList(TopicEndpoint.manager.getDmaapTopicSink(topic).getRecentEvents())).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sinks/noop")
@ApiOperation(value = "Retrieves the NOOP managed topic sinks", notes = "NOOP Topic Sinks Agregation",
@@ -1625,6 +1962,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getNoopTopicSinks()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sinks/noop/{topic}")
@ApiOperation(value = "Retrieves a NOOP managed topic sink",
@@ -1633,6 +1975,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getNoopTopicSink(topic)).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sinks/noop/{topic}/events")
@ApiOperation(value = "Retrieves the latest events send through a NOOP topic",
@@ -1642,6 +1989,11 @@ public class RestManager {
.entity(Arrays.asList(TopicEndpoint.manager.getNoopTopicSink(topic).getRecentEvents())).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sources/ueb/{topic}/switches")
@ApiOperation(value = "UEB Topic Control Switches", notes = "List of the UEB Topic Control Switches",
@@ -1650,6 +2002,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(Arrays.asList(Switches.values())).build();
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/topics/sources/ueb/{topic}/switches/lock")
@ApiOperation(value = "Locks an UEB Source topic", response = UebTopicSource.class)
@@ -1665,6 +2022,11 @@ public class RestManager {
}
}
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
@DELETE
@Path("engine/topics/sources/ueb/{topic}/switches/lock")
@ApiOperation(value = "Unlocks an UEB Source topic", response = UebTopicSource.class)
@@ -1684,6 +2046,11 @@ public class RestManager {
return new Error("cannot perform operation on " + topic);
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/topics/sources/dmaap/{topic}/switches")
@ApiOperation(value = "DMaaP Topic Control Switches", notes = "List of the DMaaP Topic Control Switches",
@@ -1692,6 +2059,11 @@ public class RestManager {
return Response.status(Response.Status.OK).entity(Arrays.asList(Switches.values())).build();
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/topics/sources/dmaap/{topic}/switches/lock")
@ApiOperation(value = "Locks an DMaaP Source topic", response = DmaapTopicSource.class)
@@ -1707,6 +2079,11 @@ public class RestManager {
}
}
+ /**
+ * DELETE.
+ *
+ * @return response object
+ */
@DELETE
@Path("engine/topics/sources/dmaap/{topic}/switches/lock")
@ApiOperation(value = "Unlocks an DMaaP Source topic", response = DmaapTopicSource.class)
@@ -1723,6 +2100,11 @@ public class RestManager {
}
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/topics/sources/ueb/{topic}/events")
@Consumes(MediaType.TEXT_PLAIN)
@@ -1762,6 +2144,11 @@ public class RestManager {
logger.debug("{}: cannot offer for encoder ueb topic for {} because of {}", this, topic, ex.getMessage(), ex);
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/topics/sources/dmaap/{topic}/events")
@Consumes(MediaType.TEXT_PLAIN)
@@ -1801,6 +2188,11 @@ public class RestManager {
logger.debug("{}: cannot offer for encoder dmaap topic for {} because of {}", this, topic, ex.getMessage(), ex);
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/tools/uuid")
@ApiOperation(value = "Produces an UUID", notes = "UUID generation utility")
@@ -1809,6 +2201,11 @@ public class RestManager {
return Response.status(Status.OK).entity(UUID.randomUUID().toString()).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/tools/loggers")
@ApiOperation(value = "all active loggers", responseContainer = "List")
@@ -1828,6 +2225,11 @@ public class RestManager {
return Response.status(Status.OK).entity(names).build();
}
+ /**
+ * GET.
+ *
+ * @return response object
+ */
@GET
@Path("engine/tools/loggers/{logger}")
@Produces(MediaType.TEXT_PLAIN)
@@ -1851,6 +2253,11 @@ public class RestManager {
return Response.status(Status.OK).entity(loggerLevel).build();
}
+ /**
+ * PUT.
+ *
+ * @return response object
+ */
@PUT
@Path("engine/tools/loggers/{logger}/{level}")
@Produces(MediaType.TEXT_PLAIN)
@@ -1878,7 +2285,7 @@ public class RestManager {
}
/**
- * gets the underlying drools controller from the named policy controller
+ * gets the underlying drools controller from the named policy controller.
*
* @param controllerName the policy controller name
* @return the underlying drools controller
@@ -1910,22 +2317,22 @@ public class RestManager {
}
/**
- * Coding/Encoding Results Aggregation Helper class
+ * Coding/Encoding Results Aggregation Helper class.
*/
public static class CodingResult {
/**
- * serialized output
+ * serialized output.
*/
private String jsonEncoding;
/**
- * encoding result
+ * encoding result.
*/
private Boolean encoding;
/**
- * decoding result
+ * decoding result.
*/
private Boolean decoding;
@@ -1955,7 +2362,7 @@ public class RestManager {
}
/**
- * Generic Error Reporting class
+ * Generic Error Reporting class.
*/
public static class Error {
private String msg;
@@ -1974,14 +2381,14 @@ public class RestManager {
}
/**
- * Feed Ports into Resources
+ * Feed Ports into Resources.
*/
public enum Inputs {
configuration,
}
/**
- * Resource Toggles
+ * Resource Toggles.
*/
public enum Switches {
activation, lock,
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafBase.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafBase.java
index 0c8465a7..955fb242 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafBase.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafBase.java
@@ -24,12 +24,12 @@ import org.onap.policy.common.endpoints.http.server.aaf.AafAuthFilter;
import org.onap.policy.drools.system.PolicyEngine;
/**
- * AAF Base Class
+ * AAF Base Class.
*/
public abstract class AafBase extends AafAuthFilter {
public static final String AAF_NODETYPE = "pdpd";
public static final String AAF_ROOT_PERMISSION_PROPERTY = "aaf.root.permission";
public static final String AAF_ROOT_PERMISSION =
- PolicyEngine.manager.getProperties().getProperty
- (AAF_ROOT_PERMISSION_PROPERTY, DEFAULT_NAMESPACE + "." + AAF_NODETYPE);
+ PolicyEngine.manager.getProperties().getProperty(
+ AAF_ROOT_PERMISSION_PROPERTY, DEFAULT_NAMESPACE + "." + AAF_NODETYPE);
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafTelemetryAuthFilter.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafTelemetryAuthFilter.java
index f2e50ee2..f76b3de2 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafTelemetryAuthFilter.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafTelemetryAuthFilter.java
@@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest;
import org.onap.policy.common.utils.network.NetworkUtil;
/**
- * AAF Telemetry Authorization
+ * AAF Telemetry Authorization.
*/
public class AafTelemetryAuthFilter extends AafBase {
private static final String RESOURCE_TYPE = AAF_ROOT_PERMISSION + "." + "telemetry";
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
index c8956839..79268b2c 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
@@ -32,130 +32,167 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Programmatic entry point to the management layer
+ * Programmatic entry point to the management layer.
*/
public class Main {
- /**
- * logback configuration file system property
- */
- public static final String LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY =
- "logback.configurationFile";
-
- /**
- * logback configuration file system property
- */
- public static final String LOGBACK_CONFIGURATION_FILE_DEFAULT = "config/logback.xml";
-
- /**
- * constructor (hides public default one)
- */
- private Main() {}
-
- /**
- * main
- *
- * @param args program arguments
- */
- public static void main(String[] args) {
-
- /* logging defaults */
-
- if (System.getProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY) == null) {
- if (Files.exists(Paths.get(LOGBACK_CONFIGURATION_FILE_DEFAULT))) {
- System.setProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY,
- LOGBACK_CONFIGURATION_FILE_DEFAULT);
- } else {
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, ch.qos.logback.classic.Level.INFO.toString());
- }
+ /** logback configuration file system property. */
+ public static final String LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY =
+ "logback.configurationFile";
+
+ /** logback configuration file system property. */
+ public static final String LOGBACK_CONFIGURATION_FILE_DEFAULT = "config/logback.xml";
+
+ /** constructor (hides public default one). */
+ private Main() {}
+
+ /**
+ * main.
+ *
+ * @param args program arguments.
+ */
+ public static void main(String[] args) {
+
+ /* logging defaults */
+
+ if (System.getProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY) == null) {
+ if (Files.exists(Paths.get(LOGBACK_CONFIGURATION_FILE_DEFAULT))) {
+ System.setProperty(
+ LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, LOGBACK_CONFIGURATION_FILE_DEFAULT);
+ } else {
+ LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, ch.qos.logback.classic.Level.INFO.toString());
+ }
+ }
+
+ /* make sure the default configuration directory is properly set up */
+
+ SystemPersistence.manager.setConfigurationDir(null);
+
+ /* logging defaults */
+
+ if (System.getProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY) == null) {
+ if (Files.exists(Paths.get(LOGBACK_CONFIGURATION_FILE_DEFAULT))) {
+ System.setProperty(
+ LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, LOGBACK_CONFIGURATION_FILE_DEFAULT);
+ } else {
+ LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, ch.qos.logback.classic.Level.INFO.toString());
+ }
+ }
+
+ /* 0. boot */
+
+ PolicyEngine.manager.boot(args);
+
+ /* start logger */
+
+ final Logger logger = LoggerFactory.getLogger(Main.class);
+
+ /* 1.a. Configure the Engine */
+
+ Properties engineProperties = SystemPersistence.manager.getEngineProperties();
+ if (engineProperties == null) {
+ engineProperties = PolicyEngine.manager.defaultTelemetryConfig();
+ }
+
+ PolicyEngine.manager.configure(engineProperties);
+
+ /* 1.b. Load Installation Environment(s) */
+
+ for (final Properties env : SystemPersistence.manager.getEnvironmentProperties()) {
+ PolicyEngine.manager.setEnvironment(env);
+ }
+
+ /* 2. Start the Engine with the basic services only (no Policy Controllers) */
+
+ MDCTransaction trans =
+ MDCTransaction.newTransaction(null, null)
+ .setServiceName(Main.class.getSimpleName())
+ .setTargetEntity("engine")
+ .setTargetServiceName("start");
+ try {
+ final boolean success = PolicyEngine.manager.start();
+ if (!success) {
+ trans.setStatusCode(false).setResponseDescription("partial start").flush();
+ logger.warn(
+ LoggerUtil.TRANSACTION_LOG_MARKER,
+ "Main: {} has been partially started",
+ PolicyEngine.manager);
+ } else {
+ trans.setStatusCode(true).transaction();
+ }
+ } catch (final IllegalStateException e) {
+ trans
+ .setStatusCode(false)
+ .setResponseCode(e.getClass().getSimpleName())
+ .setResponseDescription(e.getMessage())
+ .flush();
+ logger.warn(
+ LoggerUtil.TRANSACTION_LOG_MARKER,
+ "Main: cannot start {} (bad state) because of {}",
+ PolicyEngine.manager,
+ e.getMessage(),
+ e);
+ } catch (final Exception e) {
+ trans
+ .setStatusCode(false)
+ .setResponseCode(e.getClass().getSimpleName())
+ .setResponseDescription(e.getMessage())
+ .flush();
+ logger.warn(
+ LoggerUtil.TRANSACTION_LOG_MARKER,
+ "Main: cannot start {} because of {}",
+ PolicyEngine.manager,
+ e.getMessage(),
+ e);
+ System.exit(1);
+ }
+
+ /* 3. Create and start the controllers */
+
+ for (final Properties controllerProperties :
+ SystemPersistence.manager.getControllerProperties()) {
+ final String controllerName =
+ controllerProperties.getProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME);
+ try {
+ trans =
+ MDCTransaction.newTransaction(null, null)
+ .setServiceName(Main.class.getSimpleName())
+ .setTargetEntity("controller:" + controllerName)
+ .setTargetServiceName("start");
+
+ final PolicyController controller =
+ PolicyEngine.manager.createPolicyController(controllerName, controllerProperties);
+ controller.start();
+
+ trans
+ .setStatusCode(true)
+ .setResponseDescription(controller.getDrools().getCanonicalSessionNames().toString())
+ .transaction();
+ } catch (final Exception e) {
+ trans
+ .setStatusCode(false)
+ .setResponseCode(e.getClass().getSimpleName())
+ .setResponseDescription(e.getMessage())
+ .flush();
+ logger.error(
+ LoggerUtil.TRANSACTION_LOG_MARKER,
+ "Main: cannot instantiate policy-controller {} because of {}",
+ controllerName,
+ e.getMessage(),
+ e);
+ } catch (final LinkageError e) {
+ trans
+ .setStatusCode(false)
+ .setResponseCode(e.getClass().getSimpleName())
+ .setResponseDescription(e.getMessage())
+ .flush();
+ logger.warn(
+ LoggerUtil.TRANSACTION_LOG_MARKER,
+ "Main: cannot instantiate policy-controller {} (linkage) because of {}",
+ controllerName,
+ e.getMessage(),
+ e);
+ }
+ }
}
-
- /* make sure the default configuration directory is properly set up */
-
- SystemPersistence.manager.setConfigurationDir(null);
-
- /* logging defaults */
-
- if (System.getProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY) == null) {
- if (Files.exists(Paths.get(LOGBACK_CONFIGURATION_FILE_DEFAULT))) {
- System.setProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY,
- LOGBACK_CONFIGURATION_FILE_DEFAULT);
- } else {
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, ch.qos.logback.classic.Level.INFO.toString());
- }
- }
-
- /* 0. boot */
-
- PolicyEngine.manager.boot(args);
-
- /* start logger */
-
- final Logger logger = LoggerFactory.getLogger(Main.class);
-
- /* 1.a. Configure the Engine */
-
- Properties engineProperties = SystemPersistence.manager.getEngineProperties();
- if (engineProperties == null)
- engineProperties = PolicyEngine.manager.defaultTelemetryConfig();
-
- PolicyEngine.manager.configure(engineProperties);
-
- /* 1.b. Load Installation Environment(s) */
-
- for (final Properties env : SystemPersistence.manager.getEnvironmentProperties()) {
- PolicyEngine.manager.setEnvironment(env);
- }
-
- /* 2. Start the Engine with the basic services only (no Policy Controllers) */
-
- MDCTransaction trans =
- MDCTransaction.newTransaction(null, null).setServiceName(Main.class.getSimpleName()).
- setTargetEntity("engine").setTargetServiceName("start");
- try {
- final boolean success = PolicyEngine.manager.start();
- if (!success) {
- trans.setStatusCode(false).setResponseDescription("partial start").flush();
- logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER, "Main: {} has been partially started", PolicyEngine.manager);
- } else {
- trans.setStatusCode(true).transaction();
- }
- } catch (final IllegalStateException e) {
- trans.setStatusCode(false).setResponseCode(e.getClass().getSimpleName()).setResponseDescription(e.getMessage()).flush();
- logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER, "Main: cannot start {} (bad state) because of {}", PolicyEngine.manager, e.getMessage(), e);
- } catch (final Exception e) {
- trans.setStatusCode(false).setResponseCode(e.getClass().getSimpleName()).setResponseDescription(e.getMessage()).flush();
- logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER, "Main: cannot start {} because of {}", PolicyEngine.manager, e.getMessage(), e);
- System.exit(1);
- }
-
- /* 3. Create and start the controllers */
-
- for (final Properties controllerProperties : SystemPersistence.manager
- .getControllerProperties()) {
- final String controllerName =
- controllerProperties.getProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME);
- try {
- trans =
- MDCTransaction.newTransaction(null, null).setServiceName(Main.class.getSimpleName()).
- setTargetEntity("controller:" + controllerName).setTargetServiceName("start");
-
- final PolicyController controller =
- PolicyEngine.manager.createPolicyController(controllerName, controllerProperties);
- controller.start();
-
- trans.setStatusCode(true).
- setResponseDescription(controller.getDrools().getCanonicalSessionNames().toString()).
- transaction();
- } catch (final Exception e) {
- trans.setStatusCode(false).setResponseCode(e.getClass().getSimpleName()).setResponseDescription(e.getMessage()).flush();
- logger.error(LoggerUtil.TRANSACTION_LOG_MARKER, "Main: cannot instantiate policy-controller {} because of {}",
- controllerName, e.getMessage(), e);
- } catch (final LinkageError e) {
- trans.setStatusCode(false).setResponseCode(e.getClass().getSimpleName()).setResponseDescription(e.getMessage()).flush();
- logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER, "Main: cannot instantiate policy-controller {} (linkage) because of {}",
- controllerName, e.getMessage(), e);
- }
- }
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyController.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyController.java
index dcd4d11a..514dc364 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyController.java
@@ -23,9 +23,9 @@ package org.onap.policy.drools.system;
import java.util.List;
import java.util.Properties;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.capabilities.Lockable;
import org.onap.policy.common.capabilities.Startable;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.drools.controller.DroolsController;
@@ -41,32 +41,32 @@ import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
public interface PolicyController extends Startable, Lockable {
/**
- * Factory that tracks and manages Policy Controllers
+ * Factory that tracks and manages Policy Controllers.
*/
static PolicyControllerFactory factory = new IndexedPolicyControllerFactory();
/**
- * name of this Policy Controller
+ * name of this Policy Controller.
*/
String getName();
/**
- * Get the topic readers of interest for this controller
+ * Get the topic readers of interest for this controller.
*/
List<? extends TopicSource> getTopicSources();
/**
- * Get the topic readers of interest for this controller
+ * Get the topic readers of interest for this controller.
*/
List<? extends TopicSink> getTopicSinks();
/**
- * Get the Drools Controller
+ * Get the Drools Controller.
*/
DroolsController getDrools();
/**
- * update maven configuration
+ * update maven configuration.
*
* @param newDroolsConfiguration new drools configuration
* @return true if the update was successful, false otherwise
@@ -74,17 +74,16 @@ public interface PolicyController extends Startable, Lockable {
boolean updateDrools(DroolsConfiguration newDroolsConfiguration);
/**
- * Get the Properties
+ * Get the Properties.
*/
Properties getProperties();
/**
- * Attempts delivering of an String over communication infrastructure "busType"
+ * Attempts delivering of an String over communication infrastructure "busType".
*
- * @param event Communication infrastructure identifier
- * @param busType
+ * @param busType bus type
* @param topic topic
- * @param event the event object to send
+ * @param event Communication infrastructure identifier
*
* @return true if successful, false if a failure has occurred.
* @throws IllegalArgumentException when invalid or insufficient properties are provided
@@ -96,9 +95,9 @@ public interface PolicyController extends Startable, Lockable {
boolean deliver(CommInfrastructure busType, String topic, Object event);
/**
- * halts and permanently releases all resources
+ * halts and permanently releases all resources.
*
- * @throws IllegalStateException
+ * @throws IllegalStateException throws illegal state exception
*/
void halt();
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java
index d8d4289f..1241acad 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java
@@ -20,31 +20,32 @@
package org.onap.policy.drools.system;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.features.PolicyControllerFeatureAPI;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
import org.onap.policy.drools.system.internal.AggregatedPolicyController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* Policy Controller Factory to manage controller creation, destruction,
- * and retrieval for management interfaces
+ * and retrieval for management interfaces.
*/
public interface PolicyControllerFactory {
/**
- * Build a controller from a properties file
+ * Build a controller from a properties file.
*
* @param name the global name of this controller
* @param properties input parameters in form of properties for controller
- * initialization.
+ * initialization.
*
* @return a Policy Controller
*
@@ -55,8 +56,8 @@ public interface PolicyControllerFactory {
/**
* patches (updates) a controller from a critical configuration update.
*
- * @param name
- * @param configController
+ * @param name name
+ * @param configController config controller
*
* @return a Policy Controller
*/
@@ -65,27 +66,46 @@ public interface PolicyControllerFactory {
/**
* rebuilds (updates) a controller from a configuration update.
*
- * @param controller
- * @param configController
- *
- * @return a Policy Controller
+ * @param controller controller
+ * @param configController config controller
*/
void patch(PolicyController controller,
DroolsConfiguration configController);
/**
- * get PolicyController from DroolsController
+ * get PolicyController from DroolsController.
*
- * @param droolsController
- * @return
- * @throws IllegalArgumentException
- * @throws IllegalStateException
+ * @param droolsController drools controller
+ * @return policy controller
+ * @throws IllegalArgumentException exception
+ * @throws IllegalStateException exception
*/
PolicyController get(DroolsController droolsController);
/**
+ * gets the Policy Controller identified by its name.
+ *
+ * @param policyControllerName name of policy controller
+ * @return policy controller object
+ * @throws IllegalArgumentException exception
+ * @throws IllegalStateException exception
+ */
+ PolicyController get(String policyControllerName);
+
+ /**
+ * gets the Policy Controller identified by group and artifact ids.
+ *
+ * @param groupId group id
+ * @param artifactId artifact id
+ * @return policy controller object
+ * @throws IllegalArgumentException exception
+ * @throws IllegalStateException exception
+ */
+ PolicyController get(String groupId, String artifactId);
+
+ /**
* Makes the Policy Controller identified by controllerName not operational, but
- * does not delete its associated data
+ * does not delete its associated data.
*
* @param controllerName name of the policy controller
* @throws IllegalArgumentException invalid arguments
@@ -94,7 +114,7 @@ public interface PolicyControllerFactory {
/**
* Makes the Policy Controller identified by controller not operational, but
- * does not delete its associated data
+ * does not delete its associated data.
*
* @param controller a Policy Controller
* @throws IllegalArgumentException invalid arguments
@@ -102,12 +122,12 @@ public interface PolicyControllerFactory {
void shutdown(PolicyController controller);
/**
- * Releases all Policy Controllers from operation
+ * Releases all Policy Controllers from operation.
*/
void shutdown();
/**
- * Destroys this Policy Controller
+ * Destroys this Policy Controller.
*
* @param controllerName name of the policy controller
* @throws IllegalArgumentException invalid arguments
@@ -115,7 +135,7 @@ public interface PolicyControllerFactory {
void destroy(String controllerName);
/**
- * Destroys this Policy Controller
+ * Destroys this Policy Controller.
*
* @param controller a Policy Controller
* @throws IllegalArgumentException invalid arguments
@@ -123,51 +143,33 @@ public interface PolicyControllerFactory {
void destroy(PolicyController controller);
/**
- * Releases all Policy Controller resources
+ * Releases all Policy Controller resources.
*/
void destroy();
/**
- * gets the Policy Controller identified by its name
- *
- * @param policyControllerName
- * @return
- * @throws IllegalArgumentException
- * @throws IllegalStateException
- */
- PolicyController get(String policyControllerName);
-
- /**
- * gets the Policy Controller identified by group and artifact ids
- *
- * @param groupId group id
- * @param artifactId artifact id
- * @return
- * @throws IllegalArgumentException
- * @throws IllegalStateException
- */
- PolicyController get(String groupId, String artifactId);
-
- /**
- * get features attached to the Policy Controllers
+ * get features attached to the Policy Controllers.
+ *
* @return list of features
*/
List<PolicyControllerFeatureAPI> getFeatureProviders();
/**
- * get named feature attached to the Policy Controllers
+ * get named feature attached to the Policy Controllers.
+ *
* @return the feature
*/
PolicyControllerFeatureAPI getFeatureProvider(String featureName);
/**
- * get features attached to the Policy Controllers
+ * get features attached to the Policy Controllers.
+ *
* @return list of features
*/
List<String> getFeatures();
/**
- * returns the current inventory of Policy Controllers
+ * returns the current inventory of Policy Controllers.
*
* @return a list of Policy Controllers
*/
@@ -175,26 +177,26 @@ public interface PolicyControllerFactory {
}
/**
- * Factory of Policy Controllers indexed by the name of the Policy Controller
+ * Factory of Policy Controllers indexed by the name of the Policy Controller.
*/
class IndexedPolicyControllerFactory implements PolicyControllerFactory {
// get an instance of logger
private static final Logger logger = LoggerFactory.getLogger(PolicyControllerFactory.class);
/**
- * Policy Controller Name Index
+ * Policy Controller Name Index.
*/
private final HashMap<String,PolicyController> policyControllers =
new HashMap<>();
/**
- * Group/Artifact Ids Index
+ * Group/Artifact Ids Index.
*/
private final HashMap<String,PolicyController> coordinates2Controller =
new HashMap<>();
/**
- * produces key for indexing controller names
+ * produces key for indexing controller names.
*
* @param groupId group id
* @param artifactId artifact id
@@ -205,7 +207,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public synchronized PolicyController build(String name, Properties properties) {
@@ -225,14 +227,15 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
this.policyControllers.put(name, controller);
- if (controller.getDrools().isBrained())
+ if (controller.getDrools().isBrained()) {
this.coordinates2Controller.put(coordinates, controller);
+ }
return controller;
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public synchronized PolicyController patch(String name, DroolsConfiguration droolsConfig) {
@@ -244,51 +247,55 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
PolicyController controller = this.get(name);
if (controller == null) {
- logger.warn("A POLICY CONTROLLER of name " + name +
- "does not exist for patch operation: " + droolsConfig);
+ logger.warn("A POLICY CONTROLLER of name {} does not exist for patch operation: {}", name, droolsConfig);
throw new IllegalArgumentException("Not a valid controller of name " + name);
}
this.patch(controller, droolsConfig);
- if (logger.isInfoEnabled())
- logger.info("UPDATED drools configuration: " + droolsConfig + " on " + this);
+ if (logger.isInfoEnabled()) {
+ logger.info("UPDATED drools configuration: {} on {}", droolsConfig, this);
+ }
return controller;
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void patch(PolicyController controller, DroolsConfiguration droolsConfig) {
- if (controller == null)
+ if (controller == null) {
throw new IllegalArgumentException("Not a valid controller: null");
+ }
- if (droolsConfig == null)
+ if (droolsConfig == null) {
throw new IllegalArgumentException("Invalid Drools Configuration");
+ }
if (!controller.updateDrools(droolsConfig)) {
- logger.warn("Cannot update drools configuration: " + droolsConfig + " on " + this);
+ logger.warn("Cannot update drools configuration: {} on {}", droolsConfig, this);
throw new IllegalArgumentException("Cannot update drools configuration Drools Configuration");
}
- if (logger.isInfoEnabled())
- logger.info("UPDATED drools configuration: " + droolsConfig + " on " + this);
+ if (logger.isInfoEnabled()) {
+ logger.info("UPDATED drools configuration: {} on {}", droolsConfig, this);
+ }
String coordinates = toKey(controller.getDrools().getGroupId(),
controller.getDrools().getArtifactId());
- if (controller.getDrools().isBrained())
+ if (controller.getDrools().isBrained()) {
this.coordinates2Controller.put(coordinates, controller);
+ }
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void shutdown(String controllerName) {
@@ -297,7 +304,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
throw makeArgEx(controllerName);
}
- synchronized(this) {
+ synchronized (this) {
if (!this.policyControllers.containsKey(controllerName)) {
return;
}
@@ -308,7 +315,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void shutdown(PolicyController controller) {
@@ -317,7 +324,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void shutdown() {
@@ -326,17 +333,17 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
controller.shutdown();
}
- synchronized(this) {
+ synchronized (this) {
this.policyControllers.clear();
this.coordinates2Controller.clear();
}
}
/**
- * unmanage the controller
+ * unmanage the controller.
*
- * @param controller
- * @throws IllegalArgumentException
+ * @param controller controller
+ * @throws IllegalArgumentException exception
*/
private void unmanage(PolicyController controller) {
PolicyController tempController = controller;
@@ -344,7 +351,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
throw new IllegalArgumentException("Invalid Controller");
}
- synchronized(this) {
+ synchronized (this) {
if (!this.policyControllers.containsKey(tempController.getName())) {
return;
}
@@ -357,7 +364,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void destroy(String controllerName) {
@@ -366,7 +373,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
throw makeArgEx(controllerName);
}
- synchronized(this) {
+ synchronized (this) {
if (!this.policyControllers.containsKey(controllerName)) {
return;
}
@@ -377,7 +384,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void destroy(PolicyController controller) {
@@ -386,7 +393,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void destroy() {
@@ -395,14 +402,14 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
controller.halt();
}
- synchronized(this) {
+ synchronized (this) {
this.policyControllers.clear();
this.coordinates2Controller.clear();
}
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public PolicyController get(String name) {
@@ -411,7 +418,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
throw makeArgEx(name);
}
- synchronized(this) {
+ synchronized (this) {
if (this.policyControllers.containsKey(name)) {
return this.policyControllers.get(name);
} else {
@@ -421,17 +428,17 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public PolicyController get(String groupId, String artifactId) {
- if (groupId == null || groupId.isEmpty() ||
- artifactId == null || artifactId.isEmpty()) {
+ if (groupId == null || groupId.isEmpty()
+ || artifactId == null || artifactId.isEmpty()) {
throw new IllegalArgumentException("Invalid group/artifact ids");
}
- synchronized(this) {
+ synchronized (this) {
String key = toKey(groupId,artifactId);
if (this.coordinates2Controller.containsKey(key)) {
return this.coordinates2Controller.get(key);
@@ -442,7 +449,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public PolicyController get(DroolsController droolsController) {
@@ -451,27 +458,28 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
throw new IllegalArgumentException("No Drools Controller provided");
}
- synchronized(this) {
+ synchronized (this) {
String key = toKey(droolsController.getGroupId(), droolsController.getArtifactId());
if (this.coordinates2Controller.containsKey(key)) {
return this.coordinates2Controller.get(key);
} else {
- logger.error("Drools Controller not associated with Policy Controller " + droolsController + ":" + this);
- throw new IllegalStateException("Drools Controller not associated with Policy Controller " + droolsController + ":" + this);
+ logger.error("Drools Controller not associated with Policy Controller {}:{}", droolsController, this);
+ throw new IllegalStateException("Drools Controller not associated with Policy Controller "
+ + droolsController + ":" + this);
}
}
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public List<PolicyController> inventory() {
- return new ArrayList<>(this.policyControllers.values());
+ return new ArrayList<>(this.policyControllers.values());
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public List<String> getFeatures() {
@@ -483,7 +491,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@JsonIgnore
@Override
@@ -492,16 +500,18 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public PolicyControllerFeatureAPI getFeatureProvider(String featureName) {
- if (featureName == null || featureName.isEmpty())
+ 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))
+ if (feature.getName().equals(featureName)) {
return feature;
+ }
}
throw new IllegalArgumentException("Invalid Feature Name: " + featureName);
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 993c09c0..60e5a1b8 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
@@ -69,34 +69,34 @@ import org.slf4j.LoggerFactory;
*/
public interface PolicyEngine extends Startable, Lockable, TopicListener {
/**
- * Policy Engine Manager
+ * Policy Engine Manager.
*/
PolicyEngine manager = new PolicyEngineManager();
/**
- * Default Telemetry Server Port
+ * Default Telemetry Server Port.
*/
int TELEMETRY_SERVER_DEFAULT_PORT = 9696;
/**
- * Default Telemetry Server Hostname
+ * Default Telemetry Server Hostname.
*/
String TELEMETRY_SERVER_DEFAULT_HOST = "localhost";
/**
- * Default Telemetry Server Name
+ * Default Telemetry Server Name.
*/
String TELEMETRY_SERVER_DEFAULT_NAME = "TELEMETRY";
/**
- * Boot the engine
+ * Boot the engine.
*
* @param cliArgs command line arguments
*/
void boot(String[] cliArgs);
/**
- * configure the policy engine according to the given properties
+ * configure the policy engine according to the given properties.
*
* @param properties Policy Engine properties
* @throws IllegalArgumentException when invalid or insufficient properties are provided
@@ -104,6 +104,16 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
void configure(Properties properties);
/**
+ * updates the Policy Engine with the given configuration.
+ *
+ * @param configuration the configuration
+ * @return success or failure
+ * @throws IllegalArgumentException if invalid argument provided
+ * @throws IllegalStateException if the system is in an invalid state
+ */
+ boolean configure(PdpdConfiguration configuration);
+
+ /**
* configure the engine's environment. General lab installation configuration is made available
* to the Engine. Typically, custom lab installation that may be needed by arbitrary drools
* applications are made available, for example network component and database host addresses.
@@ -114,15 +124,15 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
void setEnvironment(Properties properties);
/**
- * gets the engine's environment
+ * gets the engine's environment.
*
- * @return
+ * @return properties object
*/
Properties getEnvironment();
/**
* gets an environment's value, by 1) first from the engine's environment, and 2) from the OS
- * environment
+ * environment.
*
* @param key environment key
* @return environment value or null if absent
@@ -130,11 +140,11 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
String getEnvironmentProperty(String key);
/**
- * sets an engine's environment property
+ * sets an engine's environment property.
*
- * @param key
- * @param value
- * @return
+ * @param key key
+ * @param value value
+ * @return property string
*/
String setEnvironmentProperty(String key, String value);
@@ -150,27 +160,17 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
PolicyController createPolicyController(String name, Properties properties);
/**
- * updates the Policy Engine with the given configuration
+ * updates a set of Policy Controllers with configuration information.
*
- * @param configuration the configuration
- * @return success or failure
- * @throws IllegalArgumentException if invalid argument provided
- * @throws IllegalStateException if the system is in an invalid state
- */
- boolean configure(PdpdConfiguration configuration);
-
- /**
- * updates a set of Policy Controllers with configuration information
- *
- * @param configuration
- * @return
- * @throws IllegalArgumentException
- * @throws IllegalStateException
+ * @param configuration list of configurations
+ * @return list of controllers
+ * @throws IllegalArgumentException exception
+ * @throws IllegalStateException exception
*/
List<PolicyController> updatePolicyControllers(List<ControllerConfiguration> configuration);
/**
- * updates an already existing Policy Controller with configuration information
+ * updates an already existing Policy Controller with configuration information.
*
* @param configuration configuration
* @return the updated Policy Controller
@@ -181,22 +181,21 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
PolicyController updatePolicyController(ControllerConfiguration configuration);
/**
- * removes the Policy Controller identified by its name from the Policy Engine
+ * removes the Policy Controller identified by its name from the Policy Engine.
*
* @param name name of the Policy Controller
- * @return the removed Policy Controller
*/
void removePolicyController(String name);
/**
- * removes a Policy Controller from the Policy Engine
+ * removes a Policy Controller from the Policy Engine.
*
* @param controller the Policy Controller to remove from the Policy Engine
*/
void removePolicyController(PolicyController controller);
/**
- * returns a list of the available Policy Controllers
+ * returns a list of the available Policy Controllers.
*
* @return list of Policy Controllers
*/
@@ -204,63 +203,63 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
/**
- * get policy controller names
+ * get policy controller names.
*
* @return list of controller names
*/
List<String> getPolicyControllerIds();
/**
- * get unmanaged sources
+ * get unmanaged sources.
*
* @return unmanaged sources
*/
List<TopicSource> getSources();
/**
- * get unmanaged sinks
+ * get unmanaged sinks.
*
* @return unmanaged sinks
*/
List<TopicSink> getSinks();
/**
- * get unmmanaged http servers list
+ * get unmmanaged http servers list.
*
* @return http servers
*/
List<HttpServletServer> getHttpServers();
/**
- * get properties configuration
+ * get properties configuration.
*
* @return properties objects
*/
Properties getProperties();
/**
- * get features attached to the Policy Engine
+ * get features attached to the Policy Engine.
*
* @return list of features
*/
List<PolicyEngineFeatureAPI> getFeatureProviders();
/**
- * get named feature attached to the Policy Engine
+ * get named feature attached to the Policy Engine.
*
* @return the feature
*/
PolicyEngineFeatureAPI getFeatureProvider(String featureName);
/**
- * get features attached to the Policy Engine
+ * get features attached to the Policy Engine.
*
* @return list of features
*/
List<String> getFeatures();
/**
- * Attempts the dispatching of an "event" object
+ * Attempts the dispatching of an "event" object.
*
* @param topic topic
* @param event the event object to send
@@ -272,7 +271,7 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
boolean deliver(String topic, Object event);
/**
- * Attempts the dispatching of an "event" object over communication infrastructure "busType"
+ * Attempts the dispatching of an "event" object over communication infrastructure "busType".
*
* @param topic topic
* @param event the event object to send
@@ -286,7 +285,7 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
boolean deliver(String busType, String topic, Object event);
/**
- * Attempts the dispatching of an "event" object over communication infrastructure "busType"
+ * Attempts the dispatching of an "event" object over communication infrastructure "busType".
*
* @param topic topic
* @param event the event object to send
@@ -300,7 +299,7 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
boolean deliver(CommInfrastructure busType, String topic, Object event);
/**
- * Attempts delivering of an String over communication infrastructure "busType"
+ * Attempts delivering of an String over communication infrastructure "busType".
*
* @param topic topic
* @param event the event object to send
@@ -324,7 +323,7 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
void deactivate();
/**
- * produces a default telemetry configuration
+ * produces a default telemetry configuration.
*
* @return policy engine configuration
*/
@@ -333,7 +332,7 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
/**
- * Policy Engine Manager Implementation
+ * Policy Engine Manager Implementation.
*/
class PolicyEngineManager implements PolicyEngine {
private static final String INVALID_TOPIC_MSG = "Invalid Topic";
@@ -345,47 +344,47 @@ class PolicyEngineManager implements PolicyEngine {
private static final String ENGINE_LOCKED_MSG = "Policy Engine is locked";
/**
- * logger
+ * logger.
*/
private static final Logger logger = LoggerFactory.getLogger(PolicyEngineManager.class);
/**
- * Is the Policy Engine running?
+ * Is the Policy Engine running.
*/
private volatile boolean alive = false;
/**
- * Is the engine locked?
+ * Is the engine locked.
*/
private volatile boolean locked = false;
/**
- * Properties used to initialize the engine
+ * Properties used to initialize the engine.
*/
private Properties properties;
/**
- * Environment Properties
+ * Environment Properties.
*/
private final Properties environment = new Properties();
/**
- * Policy Engine Sources
+ * Policy Engine Sources.
*/
private List<? extends TopicSource> sources = new ArrayList<>();
/**
- * Policy Engine Sinks
+ * Policy Engine Sinks.
*/
private List<? extends TopicSink> sinks = new ArrayList<>();
/**
- * Policy Engine HTTP Servers
+ * Policy Engine HTTP Servers.
*/
private List<HttpServletServer> httpServers = new ArrayList<>();
/**
- * gson parser to decode configuration requests
+ * gson parser to decode configuration requests.
*/
private final Gson decoder = new GsonBuilder().disableHtmlEscaping().create();
@@ -527,6 +526,35 @@ class PolicyEngineManager implements PolicyEngine {
}
@Override
+ public boolean configure(PdpdConfiguration config) {
+
+ if (config == null) {
+ throw new IllegalArgumentException("No configuration provided");
+ }
+
+ final String entity = config.getEntity();
+
+ MDCTransaction mdcTrans = MDCTransaction.newTransaction(config.getRequestID(), "brmsgw");
+ if (this.getSources().size() == 1) {
+ Topic topic = this.getSources().get(0);
+ mdcTrans.setServiceName(topic.getTopic()).setRemoteHost(topic.getServers().toString())
+ .setTargetEntity(config.getEntity());
+ }
+
+ switch (entity) {
+ case PdpdConfiguration.CONFIG_ENTITY_CONTROLLER:
+ boolean success = controllerConfig(config);
+ mdcTrans.resetSubTransaction().setStatusCode(success).transaction();
+ return success;
+ default:
+ final String msg = "Configuration Entity is not supported: " + entity;
+ mdcTrans.resetSubTransaction().setStatusCode(false).setResponseDescription(msg).flush();
+ logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER_NAME, msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ @Override
public synchronized PolicyController createPolicyController(String name, Properties properties) {
String tempName = name;
@@ -577,35 +605,6 @@ class PolicyEngineManager implements PolicyEngine {
@Override
- public boolean configure(PdpdConfiguration config) {
-
- if (config == null) {
- throw new IllegalArgumentException("No configuration provided");
- }
-
- final String entity = config.getEntity();
-
- MDCTransaction mdcTrans = MDCTransaction.newTransaction(config.getRequestID(), "brmsgw");
- if (this.getSources().size() == 1) {
- Topic topic = this.getSources().get(0);
- mdcTrans.setServiceName(topic.getTopic()).setRemoteHost(topic.getServers().toString())
- .setTargetEntity(config.getEntity());
- }
-
- switch (entity) {
- case PdpdConfiguration.CONFIG_ENTITY_CONTROLLER:
- boolean success = controllerConfig(config);
- mdcTrans.resetSubTransaction().setStatusCode(success).transaction();
- return success;
- default:
- final String msg = "Configuration Entity is not supported: " + entity;
- mdcTrans.resetSubTransaction().setStatusCode(false).setResponseDescription(msg).flush();
- logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER_NAME, msg);
- throw new IllegalArgumentException(msg);
- }
- }
-
- @Override
public List<PolicyController> updatePolicyControllers(List<ControllerConfiguration> configControllers) {
final List<PolicyController> policyControllers = new ArrayList<>();
@@ -619,7 +618,7 @@ class PolicyEngineManager implements PolicyEngine {
for (final ControllerConfiguration configController : configControllers) {
MDCTransaction mdcTrans = MDCTransaction.newSubTransaction(null).setTargetEntity(configController.getName())
.setTargetServiceName(configController.getOperation())
- .setTargetVirtualEntity(""+configController.getDrools());
+ .setTargetVirtualEntity("" + configController.getDrools());
try {
final PolicyController policyController = this.updatePolicyController(configController);
policyControllers.add(policyController);
@@ -672,7 +671,7 @@ class PolicyEngineManager implements PolicyEngine {
/* Recovery case */
- logger.warn("controller " + controllerName + " does not exist. " + "Attempting recovery from disk");
+ logger.warn("controller {} does not exist. Attempting recovery from disk", controllerName);
final Properties controllerProperties =
SystemPersistence.manager.getControllerProperties(controllerName);
@@ -686,8 +685,8 @@ class PolicyEngineManager implements PolicyEngine {
throw new IllegalArgumentException(controllerName + " is invalid");
}
- logger.warn("controller " + controllerName + " being recovered. "
- + "Reset controller's bad maven coordinates to brainless");
+ logger.warn("controller being recovered. {} Reset controller's bad maven coordinates to brainless",
+ controllerName);
/*
* try to bring up bad controller in brainless mode, after having it working, apply
@@ -1470,7 +1469,7 @@ class PolicyEngineManager implements PolicyEngine {
/* only this one supported for now */
final List<ControllerConfiguration> configControllers = config.getControllers();
if (configControllers == null || configControllers.isEmpty()) {
- logger.info("No controller configuration provided: {}" + config);
+ logger.info("No controller configuration provided: {}", config);
return false;
}
@@ -1485,8 +1484,7 @@ class PolicyEngineManager implements PolicyEngine {
@Override
public String toString() {
- return "PolicyEngineManager [alive=" + this.alive + ", locked=" + this.locked +
- "]";
+ return "PolicyEngineManager [alive=" + this.alive + ", locked=" + this.locked + "]";
}
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
index 0b6643f8..8d290674 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
@@ -47,33 +47,33 @@ import org.slf4j.LoggerFactory;
public class AggregatedPolicyController implements PolicyController, TopicListener {
/**
- * Logger
+ * Logger.
*/
private static final Logger logger = LoggerFactory.getLogger(AggregatedPolicyController.class);
/**
- * identifier for this policy controller
+ * identifier for this policy controller.
*/
private final String name;
/**
- * Abstracted Event Sources List regardless communication technology
+ * Abstracted Event Sources List regardless communication technology.
*/
private final List<? extends TopicSource> sources;
/**
- * Abstracted Event Sinks List regardless communication technology
+ * Abstracted Event Sinks List regardless communication technology.
*/
private final List<? extends TopicSink> sinks;
/**
- * Mapping topics to sinks
+ * Mapping topics to sinks.
*/
@JsonIgnore
private final HashMap<String, TopicSink> topic2Sinks = new HashMap<>();
/**
- * Is this Policy Controller running (alive) ? reflects invocation of start()/stop() only
+ * Is this Policy Controller running (alive) ? reflects invocation of start()/stop() only.
*/
private volatile boolean alive;
@@ -85,18 +85,18 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
private volatile boolean locked;
/**
- * Policy Drools Controller
+ * Policy Drools Controller.
*/
private volatile DroolsController droolsController;
/**
- * Properties used to initialize controller
+ * Properties used to initialize controller.
*/
private final Properties properties;
/**
* Constructor version mainly used for bootstrapping at initialization time a policy engine
- * controller
+ * controller.
*
* @param name controller name
* @param properties
@@ -127,7 +127,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * initialize drools layer
+ * initialize drools layer.
*
* @throws IllegalArgumentException if invalid parameters are passed in
*/
@@ -142,7 +142,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * initialize sinks
+ * initialize sinks.
*
* @throws IllegalArgumentException if invalid parameters are passed in
*/
@@ -154,7 +154,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean updateDrools(DroolsConfiguration newDroolsConfiguration) {
@@ -206,7 +206,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public String getName() {
@@ -214,7 +214,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean start() {
@@ -243,7 +243,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
this.alive = true;
}
- boolean success = this.droolsController.start();
+ final boolean success = this.droolsController.start();
// register for events
@@ -274,7 +274,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean stop() {
@@ -324,7 +324,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void shutdown() {
@@ -358,7 +358,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void halt() {
@@ -392,7 +392,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void onTopicEvent(Topic.CommInfrastructure commType, String topic, String event) {
@@ -435,7 +435,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean deliver(Topic.CommInfrastructure commType, String topic, Object event) {
@@ -494,7 +494,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean isAlive() {
@@ -502,7 +502,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean lock() {
@@ -547,7 +547,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean unlock() {
@@ -590,7 +590,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean isLocked() {
@@ -598,7 +598,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public List<? extends TopicSource> getTopicSources() {
@@ -606,7 +606,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public List<? extends TopicSink> getTopicSinks() {
@@ -614,7 +614,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public DroolsController getDrools() {
@@ -623,7 +623,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
@JsonIgnore
@@ -633,8 +633,8 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
@Override
public String toString() {
- return "AggregatedPolicyController [name=" + name + ", alive=" + alive +
- ", locked=" + locked + ", droolsController=" + droolsController + "]";
+ return "AggregatedPolicyController [name=" + name + ", alive=" + alive
+ + ", locked=" + locked + ", droolsController=" + droolsController + "]";
}
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
index ce34ec8a..5d6b11dc 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
@@ -117,14 +117,17 @@ public class RestManagerTest {
+ PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX,
"" + DEFAULT_TELEMETRY_PORT);
engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME + PolicyEndPointProperties.PROPERTY_HTTP_FILTER_CLASSES_SUFFIX,
- TestAafTelemetryAuthFilter.class.getName());
+ + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME
+ + PolicyEndPointProperties.PROPERTY_HTTP_FILTER_CLASSES_SUFFIX,
+ TestAafTelemetryAuthFilter.class.getName());
engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX,
- TELEMETRY_USER);
+ + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME
+ + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX,
+ TELEMETRY_USER);
engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX,
- TELEMETRY_PASSWORD);
+ + PolicyEngine.TELEMETRY_SERVER_DEFAULT_NAME
+ + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX,
+ TELEMETRY_PASSWORD);
/* other properties */
engineProps.put(PolicyEndPointProperties.PROPERTY_UEB_SOURCE_TOPICS, UEB_TOPIC);
@@ -288,6 +291,7 @@ public class RestManagerTest {
httpPut.setEntity(new StringEntity("FOOOO"));
response = client.execute(httpPut);
logger.info(httpPut.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
+
assertEquals(404, response.getStatusLine().getStatusCode());
httpPut.releaseConnection();
diff --git a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/TestAafTelemetryAuthFilter.java b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/TestAafTelemetryAuthFilter.java
index c7d52325..67e16183 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/TestAafTelemetryAuthFilter.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/TestAafTelemetryAuthFilter.java
@@ -25,7 +25,7 @@ import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.drools.server.restful.aaf.AafTelemetryAuthFilter;
/**
- * Test AAF Telemetry Authorization Filter for Junits
+ * Test AAF Telemetry Authorization Filter for Junits.
*/
public class TestAafTelemetryAuthFilter extends AafTelemetryAuthFilter {
diff --git a/policy-utils/checkstyle-suppressions.xml b/policy-utils/checkstyle-suppressions.xml
new file mode 100644
index 00000000..cbf6eacf
--- /dev/null
+++ b/policy-utils/checkstyle-suppressions.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 AT&T Technologies. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks="AbbreviationAsWordInName"
+ files="MDCTransaction.java"
+ lines="1-9999"/>
+ <suppress checks="OneTopLevelClass"
+ files="MDCTransaction.java"
+ lines="1-9999"/>
+</suppressions>
diff --git a/policy-utils/pom.xml b/policy-utils/pom.xml
index 6a7c9fbd..03265346 100644
--- a/policy-utils/pom.xml
+++ b/policy-utils/pom.xml
@@ -31,23 +31,60 @@
<version>1.3.0-SNAPSHOT</version>
</parent>
-
- <dependencies>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
-
+ <dependencies>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java
index f618b4c9..bb6c5428 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java
@@ -18,10 +18,6 @@
* ============LICENSE_END=========================================================
*/
-/**
- *
- */
-
package org.onap.policy.drools.utils;
import org.slf4j.Logger;
@@ -35,7 +31,7 @@ public class ReflectionUtil {
protected static final Logger logger = LoggerFactory.getLogger(ReflectionUtil.class);
- private ReflectionUtil(){
+ private ReflectionUtil() {
}
/**
@@ -83,7 +79,7 @@ public class ReflectionUtil {
*
* @param parent superclass
* @param presumedSubclass subclass
- * @return
+ * @return true if it is a sub class
*/
public static boolean isSubclass(Class<?> parent, Class<?> presumedSubclass) {
return parent.isAssignableFrom(presumedSubclass);
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MDCTransaction.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MDCTransaction.java
index c6e78b28..61c7b0c6 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MDCTransaction.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MDCTransaction.java
@@ -336,7 +336,7 @@ public interface MDCTransaction {
MDCTransaction setElapsedTime(Long elapsedTime);
/**
- * sets service instance id
+ * sets service instance id.
*/
MDCTransaction setServiceInstanceId(String serviceInstanceId);
diff --git a/pom.xml b/pom.xml
index 58b05597..dc304789 100644
--- a/pom.xml
+++ b/pom.xml
@@ -240,6 +240,42 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <!-- suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation -->
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>