summaryrefslogtreecommitdiffstats
path: root/feature-state-management/src/main/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-08-31 08:22:13 -0400
committerJim Hahn <jrh3@att.com>2020-08-31 10:15:07 -0400
commitd5c365f60e492e37a361654974eba1719146bdc2 (patch)
treef717c2198c1aebe0cc03a5d3e9aec653d0d73807 /feature-state-management/src/main/java
parent7dc71c3d0aedb322aff0cdaaa84340354c41b089 (diff)
Fix more sonars in drools-pdp
Fixed more sonars in drools-pdp: - remove commented code - don't throw generic Exception - unused field (made it protected instead of private) - log conditionally - cognitive complexity - too many break/continue - return empty list instead of null - Random() is not secure Fixed more eclipse warnings: - parameterize generic types Issue-ID: POLICY-2616-sonars3 Change-Id: Ia5ad769b2ea763568cfae3d81807926d89153b09 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-state-management/src/main/java')
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPdpIntegrityMonitor.java2
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java41
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java10
3 files changed, 33 insertions, 20 deletions
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 2252a0f4..08c8e3a5 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
@@ -355,7 +355,7 @@ public class DroolsPdpIntegrityMonitor extends IntegrityMonitor {
* @param persistenceProperties Used for DB access
* @throws Exception passed in by the audit
*/
- abstract void invoke(Properties persistenceProperties) throws Exception;
+ abstract void invoke(Properties persistenceProperties) throws IntegrityMonitorException;
}
public static class IntegrityMonitorRestServer implements Startable {
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
index 8f33f929..438b6ec8 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
@@ -37,6 +37,7 @@ import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.onap.policy.common.im.IntegrityMonitorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -106,7 +107,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase {
* @param properties properties to be passed to the audit
*/
@Override
- public void invoke(Properties properties) throws IOException, InterruptedException {
+ public void invoke(Properties properties) throws IntegrityMonitorException {
logger.debug("Running 'RepositoryAudit.invoke'");
InvokeData data = new InvokeData();
@@ -121,25 +122,35 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase {
return;
}
- // Run audit for first nexus repository
- logger.debug("Running read-only audit on first nexus repository: repository");
- runAudit(data);
+ try {
+ // Run audit for first nexus repository
+ logger.debug("Running read-only audit on first nexus repository: repository");
+ runAudit(data);
- // set of indices for supported nexus repos (ex: repository2 -> 2)
- // TreeSet is used to maintain order so repos can be audited in numerical order
- TreeSet<Integer> repoIndices = countAdditionalNexusRepos();
- logger.debug("Additional nexus repositories: {}", repoIndices);
+ // set of indices for supported nexus repos (ex: repository2 -> 2)
+ // TreeSet is used to maintain order so repos can be audited in numerical
+ // order
+ TreeSet<Integer> repoIndices = countAdditionalNexusRepos();
+ logger.debug("Additional nexus repositories: {}", repoIndices);
- // Run audit for remaining 'numNexusRepos' repositories
- for (int index : repoIndices) {
- logger.debug("Running read-only audit on nexus repository = repository{}", index);
+ // Run audit for remaining 'numNexusRepos' repositories
+ for (int index : repoIndices) {
+ logger.debug("Running read-only audit on nexus repository = repository{}", index);
- data = new InvokeData(index);
- data.initIsActive();
+ data = new InvokeData(index);
+ data.initIsActive();
- if (data.isActive) {
- runAudit(data);
+ if (data.isActive) {
+ runAudit(data);
+ }
}
+
+ } catch (IOException e) {
+ throw new IntegrityMonitorException(e);
+
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IntegrityMonitorException(e);
}
}
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 75233376..3dbb8d3e 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
@@ -23,8 +23,10 @@ package org.onap.policy.drools.statemanagement;
import java.io.IOException;
import java.util.Properties;
import org.onap.policy.common.im.AllSeemsWellException;
+import org.onap.policy.common.im.IntegrityMonitorException;
import org.onap.policy.common.im.StateChangeNotifier;
import org.onap.policy.common.im.StateManagement;
+import org.onap.policy.common.im.StateManagementException;
import org.onap.policy.drools.core.PolicySessionFeatureApi;
import org.onap.policy.drools.features.PolicyEngineFeatureApi;
import org.onap.policy.drools.utils.PropertyUtil;
@@ -146,7 +148,7 @@ public class StateManagementFeature implements StateManagementFeatureApi,
* {@inheritDoc}.
*/
@Override
- public void disableFailed(String resourceName) throws Exception {
+ public void disableFailed(String resourceName) throws StateManagementException {
stateManagement.disableFailed(resourceName);
}
@@ -155,7 +157,7 @@ public class StateManagementFeature implements StateManagementFeatureApi,
* {@inheritDoc}.
*/
@Override
- public void disableFailed() throws Exception {
+ public void disableFailed() throws StateManagementException {
stateManagement.disableFailed();
}
@@ -163,7 +165,7 @@ public class StateManagementFeature implements StateManagementFeatureApi,
* {@inheritDoc}.
*/
@Override
- public void promote() throws Exception {
+ public void promote() throws IntegrityMonitorException {
stateManagement.promote();
}
@@ -171,7 +173,7 @@ public class StateManagementFeature implements StateManagementFeatureApi,
* {@inheritDoc}.
*/
@Override
- public void demote() throws Exception {
+ public void demote() throws StateManagementException {
stateManagement.demote();
}