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>
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
*
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;
+ }
}
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;
+ }
}
//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;
} // 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
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()){
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;
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);
/**
* 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
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;
* @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);
}
@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);
*/
public class KieUtils {
+ private KieUtils() {
+ throw new IllegalStateException("Utility class");
+ }
+
/**
* Installs a rules artifact in the local maven repository
*
private static Logger logger = LoggerFactory.getLogger(SingleThreadedDmaapTopicSource.class);
- protected boolean allowSelfSignedCerts;
+
protected final String userName;
protected final String password;
/**
* build http client from properties
*/
- public ArrayList<HttpClient> build(Properties properties)
+ public List<HttpClient> build(Properties properties)
throws KeyManagementException, NoSuchAlgorithmException;
/**
}
@Override
- public synchronized ArrayList<HttpClient> build(Properties properties)
+ public synchronized List<HttpClient> build(Properties properties)
throws KeyManagementException, NoSuchAlgorithmException {
ArrayList<HttpClient> clientList = new ArrayList<>();
* @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
}
@Override
- public synchronized ArrayList<HttpServletServer> build(Properties properties)
+ public synchronized List<HttpServletServer> build(Properties properties)
throws IllegalArgumentException {
ArrayList<HttpServletServer> serviceList = new ArrayList<>();
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;
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) {
* Feature providers implementing this interface
*/
public static final OrderedServiceImpl<DroolsControllerFeatureAPI> providers =
- new OrderedServiceImpl<DroolsControllerFeatureAPI>(DroolsControllerFeatureAPI.class);
+ new OrderedServiceImpl<>(DroolsControllerFeatureAPI.class);
}