aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnusen, Drew (dm741q) <dm741q@att.com>2018-04-17 11:59:43 -0500
committerPamela Dragosh <pdragosh@research.att.com>2018-04-19 18:24:06 +0000
commitdbdef1e3e3803b5848a1fad746c652f9359d4313 (patch)
tree5d16019fa041dd0279f6eeb1c6ef49b3c2a8b210
parent4efc7394cf405b0dfe6c3dbadc09d067217847e4 (diff)
Sonar cleanup
More sonar cleanup. Resolved some of the simpler issues. Issue-ID: POLICY-728 Change-Id: If9c4718f10c6d3524239d2a05c09badb791ef2f0 Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java4
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpEntity.java20
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java20
-rw-r--r--feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java9
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java4
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java4
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java7
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java4
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java2
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/drools/http/client/HttpClientFactory.java4
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/drools/http/server/HttpServletServerFactory.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/drools/http/server/test/HttpClientTest.java6
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/features/DroolsControllerFeatureAPI.java2
13 files changed, 69 insertions, 21 deletions
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java
index 6e26334b..a70c71f6 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyProperties.java
@@ -45,6 +45,10 @@ public class ActiveStandbyProperties {
public static final String DB_PWD = "javax.persistence.jdbc.password";
private static Properties properties = null;
+
+ private ActiveStandbyProperties() {
+ throw new IllegalStateException("Utility class");
+ }
/*
* Initialize the parameter values from the droolsPersitence.properties file values
*
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 ec1ce579..ed10f4c2 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
@@ -133,5 +133,25 @@ public class DroolsPdpEntity extends DroolsPdpObject implements Serializable{
public void setDesignatedDate(Date designatedDate) {
this.designatedDate = designatedDate;
}
+
+ @Override
+ public boolean equals(Object obj){
+
+ if (obj instanceof DroolsPdp) {
+ DroolsPdpEntity d = (DroolsPdpEntity) obj;
+ return this.pdpId.equals(d.getPdpId());
+ } else {
+ return false;
+ }
+
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (this.pdpId == null ? 0 : this.pdpId.hashCode());
+ return result;
+ }
}
diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
index 141d5857..f54a18cc 100644
--- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
+++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpImpl.java
@@ -89,4 +89,24 @@ public class DroolsPdpImpl extends DroolsPdpObject {
this.designatedDate = designatedDate;
}
+
+ @Override
+ public boolean equals(Object obj){
+
+
+ if (obj instanceof DroolsPdp) {
+ DroolsPdpImpl p = (DroolsPdpImpl) obj;
+ return this.pdpId.equals(p.getPdpId());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (this.pdpId == null ? 0 : this.pdpId.hashCode());
+ return result;
+ }
}
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 1a09d920..9b172e13 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
@@ -196,7 +196,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
//It is possible that multiple PDPs are designated lead. So, we will make a list of all designated
//PDPs and then decide which one really should be designated at the end.
- ArrayList<DroolsPdp> listOfDesignated = new ArrayList<>();
+ List<DroolsPdp> listOfDesignated = new ArrayList<>();
Collection<DroolsPdp> pdps = pdpsConnector.getDroolsPdps();
DroolsPdp designatedPdp = null;
@@ -635,11 +635,11 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
} // end run
}
- public ArrayList<DroolsPdp> santizeDesignatedList(ArrayList<DroolsPdp> listOfDesignated){
+ public List<DroolsPdp> santizeDesignatedList(List<DroolsPdp> listOfDesignated){
boolean containsDesignated = false;
boolean containsHotStandby = false;
- ArrayList<DroolsPdp> listForRemoval = new ArrayList<DroolsPdp>();
+ List<DroolsPdp> listForRemoval = new ArrayList<>();
for(DroolsPdp pdp : listOfDesignated){
if(logger.isDebugEnabled()){
logger.debug
@@ -656,12 +656,11 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker {
if(containsDesignated && containsHotStandby){
//remove the hot standby from the list
listOfDesignated.removeAll(listForRemoval);
- containsHotStandby = false;
}
return listOfDesignated;
}
- public DroolsPdp computeMostRecentPrimary(Collection<DroolsPdp> pdps, ArrayList<DroolsPdp> listOfDesignated){
+ public DroolsPdp computeMostRecentPrimary(Collection<DroolsPdp> pdps, List<DroolsPdp> listOfDesignated){
boolean containsDesignated = false;
for(DroolsPdp pdp : listOfDesignated){
if(pdp.isDesignated()){
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
index 66af3eaa..0ad21f03 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
@@ -26,8 +26,8 @@ import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import java.util.Properties;
-
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
@@ -321,7 +321,7 @@ public class StandbyStateManagementTest {
DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, new Date());
DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, new Date());
- ArrayList<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
+ List<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
listOfDesignated.add(pdp1);
listOfDesignated.add(pdp2);
listOfDesignated.add(pdp3);
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 8fa6dfab..fb3da657 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
@@ -186,12 +186,12 @@ class HealthCheckMonitor implements HealthCheck {
/**
* attached http servers
*/
- protected volatile ArrayList<HttpServletServer> servers = new ArrayList<>();
+ protected volatile List<HttpServletServer> servers = new ArrayList<>();
/**
* attached http clients
*/
- protected volatile ArrayList<HttpClient> clients = new ArrayList<>();
+ protected volatile List<HttpClient> clients = new ArrayList<>();
/**
* healthcheck configuration
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 46bba914..83d4f040 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
@@ -22,6 +22,7 @@ package org.onap.policy.drools.statemanagement;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.im.IntegrityMonitorException;
@@ -60,11 +61,11 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
* @param url the JMX URL of the MBean server
* @param properties properties used locally, as well as by
* 'IntegrityMonitor'
- * @throws Exception (passed from superclass)
+ * @throws IntegrityMonitorException (passed from superclass)
*/
private DroolsPDPIntegrityMonitor(String resourceName,
Properties consolidatedProperties
- ) throws Exception {
+ ) throws IntegrityMonitorException {
super(resourceName, consolidatedProperties);
}
@@ -385,7 +386,7 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
@Override
public boolean start() {
try {
- ArrayList<HttpServletServer> servers = HttpServletServer.factory.build(integrityMonitorRestServerProperties);
+ List<HttpServletServer> servers = HttpServletServer.factory.build(integrityMonitorRestServerProperties);
if (!servers.isEmpty()) {
server = servers.get(0);
diff --git a/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java b/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java
index 59ee5119..16e166d2 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java
@@ -41,6 +41,10 @@ import org.kie.scanner.MavenRepository;
*/
public class KieUtils {
+ private KieUtils() {
+ throw new IllegalStateException("Utility class");
+ }
+
/**
* Installs a rules artifact in the local maven repository
*
diff --git a/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
index 88d67fd2..b0c456da 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
@@ -38,7 +38,7 @@ public class SingleThreadedDmaapTopicSource extends SingleThreadedBusTopicSource
private static Logger logger = LoggerFactory.getLogger(SingleThreadedDmaapTopicSource.class);
- protected boolean allowSelfSignedCerts;
+
protected final String userName;
protected final String password;
diff --git a/policy-endpoints/src/main/java/org/onap/policy/drools/http/client/HttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/drools/http/client/HttpClientFactory.java
index 06aa4630..1094a2fb 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/drools/http/client/HttpClientFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/drools/http/client/HttpClientFactory.java
@@ -50,7 +50,7 @@ public interface HttpClientFactory {
/**
* build http client from properties
*/
- public ArrayList<HttpClient> build(Properties properties)
+ public List<HttpClient> build(Properties properties)
throws KeyManagementException, NoSuchAlgorithmException;
/**
@@ -106,7 +106,7 @@ class IndexedHttpClientFactory implements HttpClientFactory {
}
@Override
- public synchronized ArrayList<HttpClient> build(Properties properties)
+ public synchronized List<HttpClient> build(Properties properties)
throws KeyManagementException, NoSuchAlgorithmException {
ArrayList<HttpClient> clientList = new ArrayList<>();
diff --git a/policy-endpoints/src/main/java/org/onap/policy/drools/http/server/HttpServletServerFactory.java b/policy-endpoints/src/main/java/org/onap/policy/drools/http/server/HttpServletServerFactory.java
index b6366d00..8c35602b 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/drools/http/server/HttpServletServerFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/drools/http/server/HttpServletServerFactory.java
@@ -58,7 +58,7 @@ public interface HttpServletServerFactory {
* @return list of http servers
* @throws IllegalArgumentException when invalid parameters are provided
*/
- public ArrayList<HttpServletServer> build(Properties properties) throws IllegalArgumentException;
+ public List<HttpServletServer> build(Properties properties) throws IllegalArgumentException;
/**
* gets a server based on the port
@@ -119,7 +119,7 @@ class IndexedHttpServletServerFactory implements HttpServletServerFactory {
}
@Override
- public synchronized ArrayList<HttpServletServer> build(Properties properties)
+ public synchronized List<HttpServletServer> build(Properties properties)
throws IllegalArgumentException {
ArrayList<HttpServletServer> serviceList = new ArrayList<>();
diff --git a/policy-endpoints/src/test/java/org/onap/policy/drools/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/drools/http/server/test/HttpClientTest.java
index dd9a7c2b..6a84d142 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/drools/http/server/test/HttpClientTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/drools/http/server/test/HttpClientTest.java
@@ -23,7 +23,7 @@ package org.onap.policy.drools.http.server.test;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
-import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
import javax.ws.rs.core.Response;
@@ -180,10 +180,10 @@ public class HttpClientTest {
httpProperties.setProperty(PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "PDP"
+ PolicyProperties.PROPERTY_MANAGED_SUFFIX, "true");
- final ArrayList<HttpServletServer> servers = HttpServletServer.factory.build(httpProperties);
+ final List<HttpServletServer> servers = HttpServletServer.factory.build(httpProperties);
assertTrue(servers.size() == 2);
- final ArrayList<HttpClient> clients = HttpClient.factory.build(httpProperties);
+ final List<HttpClient> clients = HttpClient.factory.build(httpProperties);
assertTrue(clients.size() == 2);
for (final HttpServletServer server : servers) {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/features/DroolsControllerFeatureAPI.java b/policy-management/src/main/java/org/onap/policy/drools/features/DroolsControllerFeatureAPI.java
index dbcdb943..f4158804 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/features/DroolsControllerFeatureAPI.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/features/DroolsControllerFeatureAPI.java
@@ -52,5 +52,5 @@ public interface DroolsControllerFeatureAPI extends OrderedService {
* Feature providers implementing this interface
*/
public static final OrderedServiceImpl<DroolsControllerFeatureAPI> providers =
- new OrderedServiceImpl<DroolsControllerFeatureAPI>(DroolsControllerFeatureAPI.class);
+ new OrderedServiceImpl<>(DroolsControllerFeatureAPI.class);
}