Merge changes from topic "rupinsi2-messagerouter" frankfurt 6.0.0-ONAP
authorMandar Sawant <ms5838@att.com>
Thu, 9 Apr 2020 21:09:55 +0000 (21:09 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 9 Apr 2020 21:09:55 +0000 (21:09 +0000)
* changes:
  fixed code smells
  removed code smells

src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/CambriaPublisherUtility.java
src/main/java/org/onap/dmaap/dmf/mr/metrics/publisher/impl/CambriaBaseClient.java
src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaRawStreamReader.java
src/main/java/org/onap/dmaap/dmf/mr/resources/streamReaders/CambriaTextStreamReader.java
src/main/java/org/onap/dmaap/dmf/mr/service/impl/ApiKeysServiceImpl.java
src/main/java/org/onap/dmaap/dmf/mr/utils/ConfigurationReader.java
src/main/java/org/onap/dmaap/dmf/mr/utils/Utils.java

index 4f072ac..1572835 100644 (file)
@@ -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();
index 6bedd18..050bf29 100644 (file)
@@ -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++ )
                {
index 93baee0..1000f15 100644 (file)
@@ -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 );
index 67a31bb..bf9e544 100644 (file)
@@ -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;
index d9559bb..d6fd89e 100644 (file)
@@ -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   )
              {
index 800bb0f..5688dcc 100644 (file)
@@ -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;
        }
 
index 40e6840..174d80b 100644 (file)
@@ -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 ) );
        }