Remove major and minor code smells in dr-node
[dmaap/datarouter.git] / datarouter-node / src / main / java / org / onap / dmaap / datarouter / node / DestInfo.java
index 1225331..f5fa6e9 100644 (file)
 package org.onap.dmaap.datarouter.node;
 
 /**
- * Information for a delivery destination that doesn't change from message to message
+ * Information for a delivery destination that doesn't change from message to message.
  */
 public class DestInfo {
+
     private String name;
     private String spool;
     private String subid;
@@ -37,34 +38,54 @@ public class DestInfo {
     private String authentication;
     private boolean metaonly;
     private boolean use100;
+    private boolean privilegedSubscriber;
+    private boolean decompress;
+    private boolean followRedirects;
+
+    /**
+     * Create a destination information object.
+     *
+     * @param destInfoBuilder DestInfo Object Builder
+     */
+    public DestInfo(DestInfoBuilder destInfoBuilder) {
+        this.name = destInfoBuilder.getName();
+        this.spool = destInfoBuilder.getSpool();
+        this.subid = destInfoBuilder.getSubid();
+        this.logdata = destInfoBuilder.getLogdata();
+        this.url = destInfoBuilder.getUrl();
+        this.authuser = destInfoBuilder.getAuthuser();
+        this.authentication = destInfoBuilder.getAuthentication();
+        this.metaonly = destInfoBuilder.isMetaonly();
+        this.use100 = destInfoBuilder.isUse100();
+        this.privilegedSubscriber = destInfoBuilder.isPrivilegedSubscriber();
+        this.followRedirects = destInfoBuilder.isFollowRedirects();
+        this.decompress = destInfoBuilder.isDecompress();
+    }
 
     /**
      * Create a destination information object.
      *
-     * @param    name    n:fqdn or s:subid
-     * @param    spool    The directory where files are spooled.
-     * @param    subid    The subscription ID (if applicable).
-     * @param    logdata    Text to be included in log messages
-     * @param    url    The URL to deliver to.
-     * @param    authuser    The auth user for logging.
-     * @param    authentication    The credentials.
-     * @param    metaonly    Is this a metadata only delivery?
-     * @param    use100    Should I use expect 100-continue?
+     * @param name n:fqdn or s:subid
+     * @param spool The directory where files are spooled.
+     * @param subscription The subscription.
      */
-    public DestInfo(String name, String spool, String subid, String logdata, String url, String authuser, String authentication, boolean metaonly, boolean use100) {
+    public DestInfo(String name, String spool, NodeConfig.ProvSubscription subscription) {
         this.name = name;
         this.spool = spool;
-        this.subid = subid;
-        this.logdata = logdata;
-        this.url = url;
-        this.authuser = authuser;
-        this.authentication = authentication;
-        this.metaonly = metaonly;
-        this.use100 = use100;
+        this.subid = subscription.getSubId();
+        this.logdata = subscription.getFeedId();
+        this.url = subscription.getURL();
+        this.authuser = subscription.getAuthUser();
+        this.authentication = subscription.getCredentials();
+        this.metaonly = subscription.isMetaDataOnly();
+        this.use100 = subscription.isUsing100();
+        this.privilegedSubscriber = subscription.isPrivilegedSubscriber();
+        this.followRedirects = subscription.getFollowRedirect();
+        this.decompress = subscription.isDecompress();
     }
 
-    public boolean equals(Object o) {
-        return ((o instanceof DestInfo) && ((DestInfo) o).spool.equals(spool));
+    public boolean equals(Object object) {
+        return ((object instanceof DestInfo) && ((DestInfo) object).spool.equals(spool));
     }
 
     public int hashCode() {
@@ -72,7 +93,7 @@ public class DestInfo {
     }
 
     /**
-     * Get the name of this destination
+     * Get the name of this destination.
      */
     public String getName() {
         return (name);
@@ -116,7 +137,7 @@ public class DestInfo {
     }
 
     /**
-     * Get the user for authentication
+     * Get the user for authentication.
      *
      * @return The name of the user for logging
      */
@@ -125,7 +146,7 @@ public class DestInfo {
     }
 
     /**
-     * Get the authentication header
+     * Get the authentication header.
      *
      * @return The string to use to authenticate to the recipient.
      */
@@ -134,7 +155,7 @@ public class DestInfo {
     }
 
     /**
-     * Is this a metadata only delivery?
+     * Is this a metadata only delivery.
      *
      * @return True if this is a metadata only delivery
      */
@@ -143,11 +164,38 @@ public class DestInfo {
     }
 
     /**
-     * Should I send expect 100-continue header?
+     * Should I send expect 100-continue header.
      *
      * @return True if I should.
      */
     public boolean isUsing100() {
         return (use100);
     }
+
+    /**
+     * Should we wait to receive a file processed acknowledgement before deleting file.
+     */
+    public boolean isPrivilegedSubscriber() {
+        return (privilegedSubscriber);
+    }
+
+    /**
+     * Should I follow redirects.
+     *
+     * @return True if I should.
+     */
+    public boolean isFollowRedirects() {
+        return (followRedirects);
+    }
+
+    /**
+     * Should i decompress the file before sending it on.
+     *
+     * @return True if I should.
+     */
+    public boolean isDecompress() {
+        return (decompress);
+    }
+
+
 }