Merge "Added new fields to dr_sub API"
authorvarun gudisena <varuneshwar.gudisena@att.com>
Thu, 21 Feb 2019 17:37:40 +0000 (17:37 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 21 Feb 2019 17:37:40 +0000 (17:37 +0000)
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/MirrorMaker.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 e693afe..ab183d6 100644 (file)
 
 package org.onap.dmaap.dbcapi.model;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum;
 import org.onap.dmaap.dbcapi.service.MirrorMakerService;
 
+import java.util.ArrayList;
+
 public class MirrorMaker extends DmaapObject {
 
 
@@ -58,7 +54,7 @@ public class MirrorMaker extends DmaapObject {
                sourceCluster = source;
                targetCluster = target;
                mmName = genKey(source, target);
-               topics = new ArrayList<String>();
+               topics = new ArrayList<>();
 
        }
        
@@ -89,12 +85,10 @@ public class MirrorMaker extends DmaapObject {
                str.append( " \"name\": \"" + this.getMmName() + "\", \"whitelist\": \"" );
                int numTargets = 0;
 
-               //for (ReplicationVector rv: vectors) {
                for (String rv: topics) {
                        if ( numTargets > 0 ) {
                                str.append( ",");
                        }
-                       //str.append(  rv.getFqtn() );
                        str.append( rv );
                        numTargets++;
                }
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 );