summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMandar Sawant <ms5838@att.com>2020-04-09 21:09:55 +0000
committerGerrit Code Review <gerrit@onap.org>2020-04-09 21:09:55 +0000
commit436eaaeb2ea232fc1e989060c7e3b6db953b5a27 (patch)
treeecd1353b7a7ea1302bbf5f869f636b13a81b0692
parentb93c32999c79cf0234ee5b46f3e810fe5afa7d38 (diff)
parent78c361428d27096e376547afba565222d1715a96 (diff)
Merge changes from topic "rupinsi2-messagerouter"6.0.0-ONAPfrankfurt
* changes: fixed code smells removed code smells
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/CambriaPublisherUtility.java14
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/impl/CambriaBaseClient.java6
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaRawStreamReader.java6
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaTextStreamReader.java6
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/service/impl/ApiKeysServiceImpl.java5
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/utils/ConfigurationReader.java15
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/utils/Utils.java7
7 files changed, 40 insertions, 19 deletions
diff --git a/src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/CambriaPublisherUtility.java b/src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/CambriaPublisherUtility.java
index 4f072ac..1572835 100644
--- a/src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/CambriaPublisherUtility.java
+++ b/src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/CambriaPublisherUtility.java
@@ -98,7 +98,10 @@ public class CambriaPublisherUtility
final ArrayList<HttpHost> convertedHosts = new ArrayList<>();
for ( String host : hosts )
{
- if ( host.length () == 0 ) continue;
+ if ( host.length () == 0 ){
+ continue;
+ }
+
convertedHosts.add ( hostForString ( host ) );
}
return convertedHosts;
@@ -115,13 +118,18 @@ public class CambriaPublisherUtility
*/
public static HttpHost hostForString ( String host )
{
- if ( host.length() < 1 ) throw new IllegalArgumentException ( "An empty host entry is invalid." );
+ if ( host.length() < 1 ){
+ throw new IllegalArgumentException ( "An empty host entry is invalid." );
+ }
String hostPart = host;
int port = kStdCambriaServicePort;
final int colon = host.indexOf ( ':' );
- if ( colon == 0 ) throw new IllegalArgumentException ( "Host entry '" + host + "' is invalid." );
+ if ( colon == 0 ){
+ throw new IllegalArgumentException ( "Host entry '" + host + "' is invalid." );
+ }
+
if ( colon > 0 )
{
hostPart = host.substring ( 0, colon ).trim();
diff --git a/src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/impl/CambriaBaseClient.java b/src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/impl/CambriaBaseClient.java
index 6bedd18..050bf29 100644
--- a/src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/impl/CambriaBaseClient.java
+++ b/src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/impl/CambriaBaseClient.java
@@ -69,8 +69,10 @@ public class CambriaBaseClient extends HttpClient implements org.onap.dmaap.dmf.
public Set<String> jsonArrayToSet ( JSONArray a ) throws JSONException
{
- if ( a == null ) return null;
-
+ if ( a == null ){
+ return null;
+ }
+
final TreeSet<String> set = new TreeSet<>();
for ( int i=0; i<a.length (); i++ )
{
diff --git a/src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaRawStreamReader.java b/src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaRawStreamReader.java
index 93baee0..1000f15 100644
--- a/src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaRawStreamReader.java
+++ b/src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaRawStreamReader.java
@@ -63,8 +63,10 @@ public class CambriaRawStreamReader implements reader
*/
public message next () throws CambriaApiException
{
- if ( fClosed ) return null;
-
+ if ( fClosed ){
+ return null;
+ }
+
try
{
final byte[] rawBytes = StreamTools.readBytes ( fStream );
diff --git a/src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaTextStreamReader.java b/src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaTextStreamReader.java
index 67a31bb..bf9e544 100644
--- a/src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaTextStreamReader.java
+++ b/src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaTextStreamReader.java
@@ -66,8 +66,10 @@ public class CambriaTextStreamReader implements reader
try
{
final String line = fReader.readLine ();
- if ( line == null ) return null;
-
+ if ( line == null ) {
+ return null;
+ }
+
return new message ()
{
private LogDetails logDetails;
diff --git a/src/main/java/org/onap/dmaap/dmf/mr/service/impl/ApiKeysServiceImpl.java b/src/main/java/org/onap/dmaap/dmf/mr/service/impl/ApiKeysServiceImpl.java
index d9559bb..d6fd89e 100644
--- a/src/main/java/org/onap/dmaap/dmf/mr/service/impl/ApiKeysServiceImpl.java
+++ b/src/main/java/org/onap/dmaap/dmf/mr/service/impl/ApiKeysServiceImpl.java
@@ -137,8 +137,9 @@ public class ApiKeysServiceImpl implements ApiKeysService {
String contactEmail = nsaApiKey.getEmail();
final boolean emailProvided = contactEmail != null && contactEmail.length() > 0 && contactEmail.indexOf("@") > 1 ;
String kSetting_AllowAnonymousKeys= com.att.ajsc.filemonitor.AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,"apiKeys.allowAnonymous");
- if(null==kSetting_AllowAnonymousKeys) kSetting_AllowAnonymousKeys ="false";
-
+ if(null==kSetting_AllowAnonymousKeys) {
+ kSetting_AllowAnonymousKeys ="false";
+ }
if ( kSetting_AllowAnonymousKeys.equalsIgnoreCase("true") && !emailProvided )
{
diff --git a/src/main/java/org/onap/dmaap/dmf/mr/utils/ConfigurationReader.java b/src/main/java/org/onap/dmaap/dmf/mr/utils/ConfigurationReader.java
index 800bb0f..5688dcc 100644
--- a/src/main/java/org/onap/dmaap/dmf/mr/utils/ConfigurationReader.java
+++ b/src/main/java/org/onap/dmaap/dmf/mr/utils/ConfigurationReader.java
@@ -38,7 +38,6 @@ import org.onap.dmaap.dmf.mr.backends.memory.MemoryMetaBroker;
import org.onap.dmaap.dmf.mr.backends.memory.MemoryQueue;
import org.onap.dmaap.dmf.mr.backends.memory.MemoryQueuePublisher;
import org.onap.dmaap.dmf.mr.beans.DMaaPCambriaLimiter;
-import org.onap.dmaap.dmf.mr.beans.DMaaPKafkaMetaBroker;
import org.onap.dmaap.dmf.mr.beans.DMaaPZkConfigDb;
import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
import org.onap.dmaap.dmf.mr.metabroker.Broker;
@@ -147,8 +146,10 @@ public class ConfigurationReader {
long allowedtimeSkewMs=600000L;
String strallowedTimeSkewM= com.att.ajsc.filemonitor.AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,"authentication.allowedTimeSkewMs");
- if(null!=strallowedTimeSkewM)allowedtimeSkewMs= Long.parseLong(strallowedTimeSkewM);
-
+ if(null!=strallowedTimeSkewM)
+ {
+ allowedtimeSkewMs= Long.parseLong(strallowedTimeSkewM);
+ }
//String strrequireSecureChannel= com.att.ajsc.filemonitor.AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,"aauthentication.requireSecureChannel");
//if(strrequireSecureChannel!=null)requireSecureChannel=Boolean.parseBoolean(strrequireSecureChannel);
@@ -181,7 +182,9 @@ public class ConfigurationReader {
// setup a backend
String type = com.att.ajsc.filemonitor.AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,CambriaConstants.kBrokerType);
- if (type==null) type = CambriaConstants.kBrokerType_Kafka;
+ if (type==null){
+ type = CambriaConstants.kBrokerType_Kafka;
+ }
if (CambriaConstants.kBrokerType_Kafka.equalsIgnoreCase(type)) {
log.info("Broker Type is:" + CambriaConstants.kBrokerType_Kafka);
} else if (CambriaConstants.kBrokerType_Memory.equalsIgnoreCase(type)) {
@@ -454,7 +457,9 @@ public class ConfigurationReader {
String zkServername = com.att.ajsc.filemonitor.AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,CambriaConstants.kSetting_ZkConfigDbServers);
- if (zkServername==null) zkServername=CambriaConstants.kDefault_ZkConfigDbServers;
+ if (zkServername==null){
+ zkServername=CambriaConstants.kDefault_ZkConfigDbServers;
+ }
return zkServername;
}
diff --git a/src/main/java/org/onap/dmaap/dmf/mr/utils/Utils.java b/src/main/java/org/onap/dmaap/dmf/mr/utils/Utils.java
index 40e6840..174d80b 100644
--- a/src/main/java/org/onap/dmaap/dmf/mr/utils/Utils.java
+++ b/src/main/java/org/onap/dmaap/dmf/mr/utils/Utils.java
@@ -33,8 +33,6 @@ import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
-
-import org.onap.dmaap.dmf.mr.backends.kafka.KafkaPublisher;
import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -133,7 +131,10 @@ public class Utils {
*/
public static long getSleepMsForRate ( double ratePerMinute )
{
- if ( ratePerMinute <= 0.0 ) return 0;
+ if ( ratePerMinute <= 0.0 )
+ {
+ return 0;
+ }
return Math.max ( 1000, Math.round ( 60 * 1000 / ratePerMinute ) );
}