Multiple Sonar Fixes 06/77906/1
authorDriptaroop Das <driptaroop.das@in.ibm.com>
Tue, 5 Feb 2019 19:28:56 +0000 (00:58 +0530)
committerDriptaroop Das <driptaroop.das@in.ibm.com>
Tue, 5 Feb 2019 19:29:17 +0000 (00:59 +0530)
Multiple Sonar Fixes

Issue-ID: DMAAP-1023
Change-Id: Idcc12fda4678841d9510e744780273be89ced3e1
Signed-off-by: Driptaroop Das <driptaroop.das@in.ibm.com>
src/main/java/org/onap/dmaap/dbcapi/client/DrProvConnection.java
src/main/java/org/onap/dmaap/dbcapi/database/DatabaseClass.java
src/main/java/org/onap/dmaap/dbcapi/model/Topic.java
src/main/java/org/onap/dmaap/dbcapi/service/DR_SubService.java

index a8f075c..441596a 100644 (file)
@@ -243,19 +243,10 @@ public class DrProvConnection extends BaseLoggingClass {
 
                try {
                        uc.setRequestMethod("POST");
-//                     uc.setRequestProperty("Content-Type", feedContenType );
-//                     uc.setRequestProperty( "charset", "utf-8");
-//                     uc.setRequestProperty( behalfHeader, postFeed.getOwner() );
-//                     uc.setRequestProperty( "Content-Length", Integer.toString( postData.length ));
-//                     uc.setUseCaches(false);
-//                     uc.setDoOutput(true);   
-                       OutputStream os = null;
-       
-                       
+
+
                        try {
                  uc.connect();
-                 os = uc.getOutputStream();
-
 
             } catch (ProtocolException pe) {
                  // Rcvd error instead of 100-Continue
@@ -264,6 +255,7 @@ public class DrProvConnection extends BaseLoggingClass {
                      // without this, Java will connect multiple times to the server to run the same request
                      uc.setDoOutput(false);
                  } catch (Exception e) {
+                       logger.error(e.getMessage(), e);
                  }
             }
                        rc = uc.getResponseCode();
@@ -278,12 +270,14 @@ public class DrProvConnection extends BaseLoggingClass {
                err.setMessage(responsemessage);
             }
                } catch (Exception e) {
-            System.err.println("Unable to read response  " );
+            logger.error("Unable to read response  " );
             e.printStackTrace();
         }              finally {
                        try {
                                uc.disconnect();
-                       } catch ( Exception e ) {}
+                       } catch ( Exception e ) {
+                               logger.error(e.getMessage(), e);
+                       }
                }
        
                return rc;
@@ -521,8 +515,8 @@ public class DrProvConnection extends BaseLoggingClass {
             err.setCode( 500 );
                err.setMessage("Backend connection refused");
                } catch (Exception e) {
-            System.err.println("Unable to read response  " );
-            e.printStackTrace();
+            logger.error("Unable to read response  " );
+            logger.error(e.getMessage(), e);
         } finally {
                uc.disconnect();
         }
@@ -542,22 +536,13 @@ public class DrProvConnection extends BaseLoggingClass {
                logger.info( "templog:doGetNodes at 12.10.14.11"  );
        
                        uc.setRequestMethod("GET");
-               
-                       //uc.setRequestProperty("Content-Type", subContentType );
-                       //uc.setRequestProperty( "charset", "utf-8");
-                       //uc.setRequestProperty( behalfHeader, "DGL" );
-                       //uc.setRequestProperty( "Content-Length", Integer.toString( postData.length ));
-                       //uc.setUseCaches(false);
-                       //uc.setDoOutput(true);
-                       OutputStream os = null;
                        int rc = -1;
                        
                logger.info( "templog:doGetNodes at 12.10.14.12"  );
                        try {
-                 uc.connect();
-               logger.info( "templog:doGetNodes at 12.10.14.13"  );
-                 //os = uc.getOutputStream();
-                 //os.write( postData );
+                uc.connect();
+                               logger.info( "templog:doGetNodes at 12.10.14.13"  );
+
 
             } catch (ProtocolException pe) {
                logger.info( "templog:doGetNodes at 12.10.14.14"  );
index b404479..e2004bd 100644 (file)
@@ -149,7 +149,7 @@ public class DatabaseClass extends BaseLoggingClass {
                                appLogger.warn("Problem updating DB schema", e);
                        }
                        try {
-                               dmaap = new DBSingleton<Dmaap>(Dmaap.class, "dmaap");
+                               dmaap = new DBSingleton<>(Dmaap.class, "dmaap");
                                dcaeLocations = new DBMap<>(DcaeLocation.class, "dcae_location", "dcae_location_name");
                                dr_nodes = new DBMap<>(DR_Node.class, "dr_node", "fqdn");
                                dr_pubs = new DBMap<>(DR_Pub.class, "dr_pub", "pub_id");
index 7eea5f1..cffe448 100644 (file)
@@ -128,7 +128,7 @@ public class Topic extends DmaapObject  {
 
        public Topic() {
                super();
-               this.clients = new ArrayList<MR_Client>();
+               this.clients = new ArrayList<>();
                this.lastMod = new Date();
                this.replicationCase = ReplicationType.Validator("none");
                this.setLastMod();
@@ -140,7 +140,6 @@ public class Topic extends DmaapObject  {
                this.fqtn = fqtn;
                this.topicName = topicName;
                this.topicDescription = topicDescription;
-               //this.dcaeLocationName = dcaeLocationName;
                this.tnxEnabled = tnxEnabled;
                this.owner = owner;
                this.init();
@@ -178,7 +177,6 @@ public class Topic extends DmaapObject  {
                this.setTopicName( (String) jsonObj.get( "topicName" ) );
                this.setTopicDescription( (String) jsonObj.get( "topicDescription" ));
                this.setOwner( (String) jsonObj.get( "owner" ) );
-               //this.setLastMod();
                this.setStatus( (String) jsonObj.get( "status" ) );
                this.setReplicationCase( ReplicationType.Validator( (String) jsonObj.get( "replicationCase" ) ));
                this.setFqtnStyle( FqtnType.Validator( (String) jsonObj.get( "fqtnStyle" ) ) );
index 2fd75d0..99c8f31 100644 (file)
@@ -65,11 +65,11 @@ public class DR_SubService extends BaseLoggingClass {
                
        public List<DR_Sub> getAllDr_Subs() {
                logger.debug( "enter getAllDR_Subs()");
-               return new ArrayList<DR_Sub>(dr_subs.values());
+               return new ArrayList<>(dr_subs.values());
        }
        
        public ArrayList<DR_Sub> getDr_SubsByFeedId( String pubId ) {
-               ArrayList<DR_Sub> someSubs = new ArrayList<DR_Sub>();
+               ArrayList<DR_Sub> someSubs = new ArrayList<>();
                for( DR_Sub sub : dr_subs.values() ) {
                        if ( pubId.equals(  sub.getFeedId()  )) {
                                someSubs.add( sub );