DMAAP-1195 [DR] Remove DR code smells
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / beans / Feed.java
index a2076b0..76b9e4b 100644 (file)
 \r
 package org.onap.dmaap.datarouter.provisioning.beans;\r
 \r
-import org.apache.log4j.Logger;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+import java.io.InvalidObjectException;\r
+import java.sql.Connection;\r
+import java.sql.PreparedStatement;\r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+import java.sql.Statement;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Date;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
 import org.json.JSONArray;\r
+import org.json.JSONException;\r
 import org.json.JSONObject;\r
 import org.onap.dmaap.datarouter.provisioning.utils.DB;\r
 import org.onap.dmaap.datarouter.provisioning.utils.JSONUtilities;\r
 import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;\r
 \r
-import java.io.InvalidObjectException;\r
-import java.sql.*;\r
-import java.util.*;\r
-import java.util.Date;\r
+\r
 \r
 /**\r
  * The representation of a Feed.  Feeds can be retrieved from the DB, or stored/updated in the DB.\r
@@ -43,22 +55,167 @@ import java.util.Date;
  * @version $Id: Feed.java,v 1.13 2013/10/28 18:06:52 eby Exp $\r
  */\r
 public class Feed extends Syncable {\r
-    private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");\r
-    private static int next_feedid = getMaxFeedID() + 1;\r
+\r
+    private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog");\r
+    private static int nextFeedID = getMaxFeedID() + 1;\r
+    private static final String SQLEXCEPTION = "SQLException: ";\r
+    private static final String FEEDID = "FEEDID";\r
+    private static final String feedIDStr = "feedid";\r
+    private static final String deletedStr = "deleted";\r
+    private static final String lastModStr = "last_mod";\r
+    private static final String createdDateStr ="created_date";\r
 \r
     private int feedid;\r
     private int groupid; //New field is added - Groups feature Rally:US708115 - 1610\r
     private String name;\r
     private String version;\r
     private String description;\r
-    private String business_description; // New field is added - Groups feature Rally:US708102 - 1610\r
+    private String businessDescription; // New field is added - Groups feature Rally:US708102 - 1610\r
     private FeedAuthorization authorization;\r
     private String publisher;\r
     private FeedLinks links;\r
     private boolean deleted;\r
     private boolean suspended;\r
-    private Date last_mod;\r
-    private Date created_date;\r
+    private Date lastMod;\r
+    private Date createdDate;\r
+    private String aafInstance;\r
+\r
+    public Feed() {\r
+        this("", "", "", "");\r
+    }\r
+\r
+    /**\r
+     * Feed constructor.\r
+     * @param name feed name\r
+     * @param version feed version\r
+     * @param desc feed description\r
+     * @param businessDescription feed business description\r
+     */\r
+    public Feed(String name, String version, String desc, String businessDescription) {\r
+        this.feedid = -1;\r
+        this.groupid = -1; //New field is added - Groups feature Rally:US708115 - 1610\r
+        this.name = name;\r
+        this.version = version;\r
+        this.description = desc;\r
+        this.businessDescription = businessDescription; // New field is added - Groups feature Rally:US708102 - 1610\r
+        this.authorization = new FeedAuthorization();\r
+        this.publisher = "";\r
+        this.links = new FeedLinks();\r
+        this.deleted = false;\r
+        this.suspended = false;\r
+        this.lastMod = new Date();\r
+        this.createdDate = new Date();\r
+        this.aafInstance = "";\r
+    }\r
+\r
+    /**\r
+     * Feed Constructor from ResultSet.\r
+     * @param rs ResultSet\r
+     * @throws SQLException in case of SQL statement error\r
+     */\r
+    public Feed(ResultSet rs) throws SQLException {\r
+        this.feedid = rs.getInt(FEEDID);\r
+        //New field is added - Groups feature Rally:US708115 - 1610\r
+        this.groupid = rs.getInt("GROUPID");\r
+        this.name = rs.getString("NAME");\r
+        this.version = rs.getString("VERSION");\r
+        this.description = rs.getString("DESCRIPTION");\r
+        // New field is added - Groups feature Rally:US708102 - 1610\r
+        this.businessDescription = rs.getString("BUSINESS_DESCRIPTION");\r
+        this.authorization = new FeedAuthorization();\r
+        this.authorization.setClassification(rs.getString("AUTH_CLASS"));\r
+        this.publisher = rs.getString("PUBLISHER");\r
+        this.links = new FeedLinks();\r
+        this.links.setSelf(rs.getString("SELF_LINK"));\r
+        this.links.setPublish(rs.getString("PUBLISH_LINK"));\r
+        this.links.setSubscribe(rs.getString("SUBSCRIBE_LINK"));\r
+        this.links.setLog(rs.getString("LOG_LINK"));\r
+        this.deleted = rs.getBoolean("DELETED");\r
+        this.suspended = rs.getBoolean("SUSPENDED");\r
+        this.lastMod = rs.getDate("LAST_MOD");\r
+        this.createdDate = rs.getTimestamp("CREATED_DATE");\r
+        this.aafInstance = rs.getString("AAF_INSTANCE");\r
+    }\r
+\r
+    /**\r
+     * Feed constructor from JSONObject.\r
+     * @param jo JSONObject\r
+     * @throws InvalidObjectException in case of JSON error\r
+     */\r
+    public Feed(JSONObject jo) throws InvalidObjectException {\r
+        this("", "", "", "");\r
+        try {\r
+            // The JSONObject is assumed to contain a vnd.dmaap-dr.feed representation\r
+            this.feedid = jo.optInt(feedIDStr, -1);\r
+            this.groupid = jo.optInt("groupid");\r
+            this.name = jo.getString("name");\r
+            this.aafInstance = jo.optString("aaf_instance", "legacy");\r
+            if (!(aafInstance.equalsIgnoreCase("legacy")) && aafInstance.length() > 255) {\r
+                throw new InvalidObjectException("aaf_instance field is too long");\r
+            }\r
+            if (name.length() > 255) {\r
+                throw new InvalidObjectException("name field is too long");\r
+            }\r
+            try {\r
+                this.version = jo.getString("version");\r
+            } catch (JSONException e) {\r
+                intlogger.warn("PROV0023 Feed.Feed: " + e.getMessage(), e);\r
+                this.version = null;\r
+            }\r
+            if (version != null && version.length() > 20) {\r
+                throw new InvalidObjectException("version field is too long");\r
+            }\r
+            this.description = jo.optString("description");\r
+            this.businessDescription = jo.optString("business_description");\r
+            if (description.length() > 1000) {\r
+                throw new InvalidObjectException("technical description field is too long");\r
+            }\r
+            if (businessDescription.length() > 1000) {\r
+                throw new InvalidObjectException("business description field is too long");\r
+            }\r
+            this.authorization = new FeedAuthorization();\r
+            JSONObject jauth = jo.getJSONObject("authorization");\r
+            this.authorization.setClassification(jauth.getString("classification"));\r
+            if (this.authorization.getClassification().length() > 32) {\r
+                throw new InvalidObjectException("classification field is too long");\r
+            }\r
+            JSONArray endPointIds = jauth.getJSONArray("endpoint_ids");\r
+            for (int i = 0; i < endPointIds.length(); i++) {\r
+                JSONObject id = endPointIds.getJSONObject(i);\r
+                FeedEndpointID fid = new FeedEndpointID(id.getString("id"), id.getString("password"));\r
+                if (fid.getId().length() > 60) {\r
+                    throw new InvalidObjectException("id field is too long (" + fid.getId() + ")");\r
+                }\r
+                if (fid.getPassword().length() > 32) {\r
+                    //Fortify scan fixes - Privacy Violation\r
+                    throw new InvalidObjectException("password field is too long (" + fid.getPassword() + ")");\r
+                }\r
+                this.authorization.getEndpointIDS().add(fid);\r
+            }\r
+            if (this.authorization.getEndpointIDS().isEmpty()) {\r
+                throw new InvalidObjectException("need to specify at least one endpoint_id");\r
+            }\r
+            endPointIds = jauth.getJSONArray("endpoint_addrs");\r
+            for (int i = 0; i < endPointIds.length(); i++) {\r
+                String addr = endPointIds.getString(i);\r
+                if (!JSONUtilities.validIPAddrOrSubnet(addr)) {\r
+                    throw new InvalidObjectException("bad IP addr or subnet mask: " + addr);\r
+                }\r
+                this.authorization.getEndpointAddrs().add(addr);\r
+            }\r
+\r
+            this.publisher = jo.optString("publisher", "");\r
+            this.deleted = jo.optBoolean(deletedStr, false);\r
+            this.suspended = jo.optBoolean("suspend", false);\r
+            JSONObject jol = jo.optJSONObject("links");\r
+            this.links = (jol == null) ? (new FeedLinks()) : (new FeedLinks(jol));\r
+        } catch (InvalidObjectException e) {\r
+            throw e;\r
+        } catch (Exception e) {\r
+            intlogger.warn("Invalid JSON: " + e.getMessage(), e);\r
+            throw new InvalidObjectException("Invalid JSON: " + e.getMessage());\r
+        }\r
+    }\r
 \r
     /**\r
      * Check if a feed ID is valid.\r
@@ -72,9 +229,9 @@ public class Feed extends Syncable {
         try {\r
             DB db = new DB();\r
             Connection conn = db.getConnection();\r
-            try(PreparedStatement stmt = conn.prepareStatement("select COUNT(*) from FEEDS where FEEDID = ?")) {\r
+            try (PreparedStatement stmt = conn.prepareStatement("select COUNT(*) from FEEDS where FEEDID = ?")) {\r
                 stmt.setInt(1, id);\r
-                try(ResultSet rs = stmt.executeQuery()) {\r
+                try (ResultSet rs = stmt.executeQuery()) {\r
                     if (rs.next()) {\r
                         count = rs.getInt(1);\r
                     }\r
@@ -82,7 +239,7 @@ public class Feed extends Syncable {
             }\r
             db.release(conn);\r
         } catch (SQLException e) {\r
-            intlogger.error("SQLException " + e.getMessage());\r
+            intlogger.warn("PROV0024 Feed.isFeedValid: " + e.getMessage(), e);\r
         }\r
         return count != 0;\r
     }\r
@@ -121,9 +278,8 @@ public class Feed extends Syncable {
         int count = 0;\r
         try {\r
             DB db = new DB();\r
-            @SuppressWarnings("resource")\r
-            Connection conn = db.getConnection();\r
-            try(Statement stmt = conn.createStatement()) {\r
+            @SuppressWarnings("resource") Connection conn = db.getConnection();\r
+            try (Statement stmt = conn.createStatement()) {\r
                 try (ResultSet rs = stmt.executeQuery("select count(*) from FEEDS where DELETED = 0")) {\r
                     if (rs.next()) {\r
                         count = rs.getInt(1);\r
@@ -132,19 +288,22 @@ public class Feed extends Syncable {
             }\r
             db.release(conn);\r
         } catch (SQLException e) {\r
-            intlogger.info("countActiveFeeds: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
+            intlogger.warn("PROV0025 Feed.countActiveFeeds: " + e.getMessage(), e);\r
         }\r
         return count;\r
     }\r
 \r
+    /**\r
+     * Method to get max feed id.\r
+     * @return int max feed id\r
+     */\r
     public static int getMaxFeedID() {\r
         int max = 0;\r
         try {\r
             DB db = new DB();\r
             @SuppressWarnings("resource")\r
             Connection conn = db.getConnection();\r
-            try(Statement stmt = conn.createStatement()) {\r
+            try (Statement stmt = conn.createStatement()) {\r
                 try (ResultSet rs = stmt.executeQuery("select MAX(feedid) from FEEDS")) {\r
                     if (rs.next()) {\r
                         max = rs.getInt(1);\r
@@ -153,20 +312,23 @@ public class Feed extends Syncable {
             }\r
             db.release(conn);\r
         } catch (SQLException e) {\r
-            intlogger.info("getMaxFeedID: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
+            intlogger.warn("PROV0026 Feed.getMaxFeedID: " + e.getMessage(), e);\r
         }\r
         return max;\r
     }\r
 \r
+    /**\r
+     * Gets all feeds.\r
+     * @return Collection of feeds\r
+     */\r
     public static Collection<Feed> getAllFeeds() {\r
-        Map<Integer, Feed> map = new HashMap<Integer, Feed>();\r
+        Map<Integer, Feed> map = new HashMap<>();\r
         try {\r
             DB db = new DB();\r
             @SuppressWarnings("resource")\r
             Connection conn = db.getConnection();\r
-            try(Statement stmt = conn.createStatement()) {\r
-                try(ResultSet rs = stmt.executeQuery("select * from FEEDS")) {\r
+            try (Statement stmt = conn.createStatement()) {\r
+                try (ResultSet rs = stmt.executeQuery("select * from FEEDS")) {\r
                     while (rs.next()) {\r
                         Feed feed = new Feed(rs);\r
                         map.put(feed.getFeedid(), feed);\r
@@ -174,25 +336,25 @@ public class Feed extends Syncable {
                 }\r
 \r
                 String sql = "select * from FEED_ENDPOINT_IDS";\r
-                try(ResultSet rs = stmt.executeQuery(sql)){\r
+                try (ResultSet rs = stmt.executeQuery(sql)) {\r
                     while (rs.next()) {\r
-                        int id = rs.getInt("FEEDID");\r
+                        int id = rs.getInt(FEEDID);\r
                         Feed feed = map.get(id);\r
                         if (feed != null) {\r
                             FeedEndpointID epi = new FeedEndpointID(rs);\r
-                            Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();\r
+                            Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpointIDS();\r
                             ecoll.add(epi);\r
                         }\r
                     }\r
                 }\r
 \r
                 sql = "select * from FEED_ENDPOINT_ADDRS";\r
-                try(ResultSet rs = stmt.executeQuery(sql)) {\r
+                try (ResultSet rs = stmt.executeQuery(sql)) {\r
                     while (rs.next()) {\r
-                        int id = rs.getInt("FEEDID");\r
+                        int id = rs.getInt(FEEDID);\r
                         Feed feed = map.get(id);\r
                         if (feed != null) {\r
-                            Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();\r
+                            Collection<String> acoll = feed.getAuthorization().getEndpointAddrs();\r
                             acoll.add(rs.getString("ADDR"));\r
                         }\r
                     }\r
@@ -200,41 +362,48 @@ public class Feed extends Syncable {
             }\r
             db.release(conn);\r
         } catch (SQLException e) {\r
-            intlogger.error("SQLException " + e.getMessage());\r
+            intlogger.warn("PROV0027 Feed.getAllFeeds: " + e.getMessage(), e);\r
         }\r
         return map.values();\r
     }\r
 \r
+    /**\r
+     * Get Feed URL list.\r
+     * @param name of Feed\r
+     * @param val of feed\r
+     * @return List of feed names\r
+     */\r
     public static List<String> getFilteredFeedUrlList(final String name, final String val) {\r
-        List<String> list = new ArrayList<String>();\r
+        List<String> list = new ArrayList<>();\r
         String sql = "select SELF_LINK from FEEDS where DELETED = 0";\r
         if (name.equals("name")) {\r
             sql += " and NAME = ?";\r
         } else if (name.equals("publ")) {\r
             sql += " and PUBLISHER = ?";\r
         } else if (name.equals("subs")) {\r
-            sql = "select distinct FEEDS.SELF_LINK from FEEDS, SUBSCRIPTIONS " +\r
-                    "where DELETED = 0 " +\r
-                    "and FEEDS.FEEDID = SUBSCRIPTIONS.FEEDID " +\r
-                    "and SUBSCRIPTIONS.SUBSCRIBER = ?";\r
+            sql = "select distinct FEEDS.SELF_LINK from FEEDS, SUBSCRIPTIONS "\r
+                          + "where DELETED = 0 "\r
+                          + "and FEEDS.FEEDID = SUBSCRIPTIONS.FEEDID "\r
+                          + "and SUBSCRIPTIONS.SUBSCRIBER = ?";\r
         }\r
         try {\r
             DB db = new DB();\r
             @SuppressWarnings("resource")\r
             Connection conn = db.getConnection();\r
-            try(PreparedStatement ps = conn.prepareStatement(sql)) {\r
-                if (sql.indexOf('?') >= 0)\r
+            try (PreparedStatement ps = conn.prepareStatement(sql)) {\r
+                if (sql.indexOf('?') >= 0) {\r
                     ps.setString(1, val);\r
-                try(ResultSet rs = ps.executeQuery()) {\r
+                }\r
+                try (ResultSet rs = ps.executeQuery()) {\r
                     while (rs.next()) {\r
-                        String t = rs.getString(1);\r
-                        list.add(t.trim());\r
+                        String str = rs.getString(1);\r
+                        list.add(str.trim());\r
                     }\r
                 }\r
             }\r
             db.release(conn);\r
         } catch (SQLException e) {\r
-            intlogger.error("SQLException " + e.getMessage());\r
+            intlogger.warn("PROV0028 Feed.getFilteredFeedUrlList: " + e.getMessage(), e);\r
         }\r
         return list;\r
     }\r
@@ -254,7 +423,7 @@ public class Feed extends Syncable {
                 if (feed != null) {\r
                     sql = "select * from FEED_ENDPOINT_IDS where FEEDID = " + feed.feedid;\r
                     try (ResultSet rs = stmt.executeQuery(sql)) {\r
-                        Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();\r
+                        Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpointIDS();\r
                         while (rs.next()) {\r
                             FeedEndpointID epi = new FeedEndpointID(rs);\r
                             ecoll.add(epi);\r
@@ -262,7 +431,7 @@ public class Feed extends Syncable {
                     }\r
                     sql = "select * from FEED_ENDPOINT_ADDRS where FEEDID = " + feed.feedid;\r
                     try (ResultSet rs = stmt.executeQuery(sql)) {\r
-                        Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();\r
+                        Collection<String> acoll = feed.getAuthorization().getEndpointAddrs();\r
                         while (rs.next()) {\r
                             acoll.add(rs.getString("ADDR"));\r
                         }\r
@@ -271,113 +440,21 @@ public class Feed extends Syncable {
             }\r
             db.release(conn);\r
         } catch (SQLException e) {\r
-            intlogger.error("SQLException " + e.getMessage());\r
+            intlogger.warn("PROV0029 Feed.getFeedBySQL: " + e.getMessage(), e);\r
         }\r
         return feed;\r
     }\r
 \r
-    public Feed() {\r
-        this("", "", "", "");\r
-    }\r
-\r
-    public Feed(String name, String version, String desc, String business_description) {\r
-        this.feedid = -1;\r
-        this.groupid = -1; //New field is added - Groups feature Rally:US708115 - 1610\r
-        this.name = name;\r
-        this.version = version;\r
-        this.description = desc;\r
-        this.business_description = business_description; // New field is added - Groups feature Rally:US708102 - 1610\r
-        this.authorization = new FeedAuthorization();\r
-        this.publisher = "";\r
-        this.links = new FeedLinks();\r
-        this.deleted = false;\r
-        this.suspended = false;\r
-        this.last_mod = new Date();\r
-        this.created_date = new Date();\r
-    }\r
 \r
-    public Feed(ResultSet rs) throws SQLException {\r
-        this.feedid = rs.getInt("FEEDID");\r
-        this.groupid = rs.getInt("GROUPID"); //New field is added - Groups feature Rally:US708115 - 1610\r
-        this.name = rs.getString("NAME");\r
-        this.version = rs.getString("VERSION");\r
-        this.description = rs.getString("DESCRIPTION");\r
-        this.business_description = rs.getString("BUSINESS_DESCRIPTION"); // New field is added - Groups feature Rally:US708102 - 1610\r
-        this.authorization = new FeedAuthorization();\r
-        this.authorization.setClassification(rs.getString("AUTH_CLASS"));\r
-        this.publisher = rs.getString("PUBLISHER");\r
-        this.links = new FeedLinks();\r
-        this.links.setSelf(rs.getString("SELF_LINK"));\r
-        this.links.setPublish(rs.getString("PUBLISH_LINK"));\r
-        this.links.setSubscribe(rs.getString("SUBSCRIBE_LINK"));\r
-        this.links.setLog(rs.getString("LOG_LINK"));\r
-        this.deleted = rs.getBoolean("DELETED");\r
-        this.suspended = rs.getBoolean("SUSPENDED");\r
-        this.last_mod = rs.getDate("LAST_MOD");\r
-        this.created_date = rs.getTimestamp("CREATED_DATE");\r
-    }\r
-\r
-    public Feed(JSONObject jo) throws InvalidObjectException {\r
-        this("", "", "", "");\r
-        try {\r
-            // The JSONObject is assumed to contain a vnd.dmaap-dr.feed representation\r
-            this.feedid = jo.optInt("feedid", -1);\r
-            this.groupid = jo.optInt("groupid"); //New field is added - Groups feature Rally:US708115 - 1610\r
-            this.name = jo.getString("name");\r
-            if (name.length() > 255)\r
-                throw new InvalidObjectException("name field is too long");\r
-            this.version = jo.getString("version");\r
-            if (version.length() > 20)\r
-                throw new InvalidObjectException("version field is too long");\r
-            this.description = jo.optString("description");\r
-            this.business_description = jo.optString("business_description"); // New field is added - Groups feature Rally:US708102 - 1610\r
-            if (description.length() > 1000)\r
-                throw new InvalidObjectException("technical description field is too long");\r
-\r
-            if (business_description.length() > 1000) // New field is added - Groups feature Rally:US708102 - 1610\r
-                throw new InvalidObjectException("business description field is too long");\r
-\r
-            this.authorization = new FeedAuthorization();\r
-            JSONObject jauth = jo.getJSONObject("authorization");\r
-            this.authorization.setClassification(jauth.getString("classification"));\r
-            if (this.authorization.getClassification().length() > 32)\r
-                throw new InvalidObjectException("classification field is too long");\r
-            JSONArray ja = jauth.getJSONArray("endpoint_ids");\r
-            for (int i = 0; i < ja.length(); i++) {\r
-                JSONObject id = ja.getJSONObject(i);\r
-                FeedEndpointID fid = new FeedEndpointID(id.getString("id"), id.getString("password"));\r
-                if (fid.getId().length() > 20)\r
-                    throw new InvalidObjectException("id field is too long (" + fid.getId() + ")");\r
-                if (fid.getPassword().length() > 32)\r
-                    throw new InvalidObjectException("password field is too long (" + fid.getPassword() + ")");\r
-                this.authorization.getEndpoint_ids().add(fid);\r
-            }\r
-            if (this.authorization.getEndpoint_ids().size() < 1)\r
-                throw new InvalidObjectException("need to specify at least one endpoint_id");\r
-            ja = jauth.getJSONArray("endpoint_addrs");\r
-            for (int i = 0; i < ja.length(); i++) {\r
-                String addr = ja.getString(i);\r
-                if (!JSONUtilities.validIPAddrOrSubnet(addr))\r
-                    throw new InvalidObjectException("bad IP addr or subnet mask: " + addr);\r
-                this.authorization.getEndpoint_addrs().add(addr);\r
-            }\r
-\r
-            this.publisher = jo.optString("publisher", "");\r
-            this.deleted = jo.optBoolean("deleted", false);\r
-            this.suspended = jo.optBoolean("suspend", false);\r
-            JSONObject jol = jo.optJSONObject("links");\r
-            this.links = (jol == null) ? (new FeedLinks()) : (new FeedLinks(jol));\r
-        } catch (InvalidObjectException e) {\r
-            throw e;\r
-        } catch (Exception e) {\r
-            throw new InvalidObjectException("invalid JSON: " + e.getMessage());\r
-        }\r
-    }\r
 \r
     public int getFeedid() {\r
         return feedid;\r
     }\r
 \r
+    /**\r
+     *  Set feedid with FeedLinks.\r
+      * @param feedid Feedid to set to\r
+     */\r
     public void setFeedid(int feedid) {\r
         this.feedid = feedid;\r
 \r
@@ -389,6 +466,14 @@ public class Feed extends Syncable {
         fl.setLog(URLUtilities.generateFeedLogURL(feedid));\r
     }\r
 \r
+    public String getAafInstance() {\r
+        return aafInstance;\r
+    }\r
+\r
+    public void setAafInstance(String aafInstance) {\r
+        this.aafInstance = aafInstance;\r
+    }\r
+\r
     //new getter setters for groups- Rally:US708115 - 1610\r
     public int getGroupid() {\r
         return groupid;\r
@@ -423,12 +508,12 @@ public class Feed extends Syncable {
     }\r
 \r
     // New field is added - Groups feature Rally:US708102 - 1610\r
-    public String getBusiness_description() {\r
-        return business_description;\r
+    public String getBusinessDescription() {\r
+        return businessDescription;\r
     }\r
 \r
-    public void setBusiness_description(String business_description) {\r
-        this.business_description = business_description;\r
+    public void setBusinessDescription(String businessDescription) {\r
+        this.businessDescription = businessDescription;\r
     }\r
 \r
     public FeedAuthorization getAuthorization() {\r
@@ -443,10 +528,15 @@ public class Feed extends Syncable {
         return publisher;\r
     }\r
 \r
+    /**\r
+     * Set publisher.\r
+     * @param publisher Publisher name\r
+     */\r
     public void setPublisher(String publisher) {\r
         if (publisher != null) {\r
-            if (publisher.length() > 8)\r
+            if (publisher.length() > 8) {\r
                 publisher = publisher.substring(0, 8);\r
+            }\r
             this.publisher = publisher;\r
         }\r
     }\r
@@ -475,94 +565,100 @@ public class Feed extends Syncable {
         this.suspended = suspended;\r
     }\r
 \r
-    public Date getLast_mod() {\r
-        return last_mod;\r
-    }\r
-\r
-    public Date getCreated_date() {\r
-        return created_date;\r
-    }\r
-\r
     @Override\r
     public JSONObject asJSONObject() {\r
         JSONObject jo = new JSONObject();\r
-        jo.put("feedid", feedid);\r
-        jo.put("groupid", groupid); //New field is added - Groups feature Rally:US708115 - 1610\r
+        jo.put(feedIDStr, feedid);\r
+        //New field is added - Groups feature Rally:US708115 - 1610\r
+        jo.put("groupid", groupid);\r
         jo.put("name", name);\r
         jo.put("version", version);\r
         jo.put("description", description);\r
-        jo.put("business_description", business_description); // New field is added - Groups feature Rally:US708102 - 1610\r
+        // New field is added - Groups feature Rally:US708102 - 1610\r
+        jo.put("business_description", businessDescription);\r
         jo.put("authorization", authorization.asJSONObject());\r
         jo.put("publisher", publisher);\r
         jo.put("links", links.asJSONObject());\r
-        jo.put("deleted", deleted);\r
+        jo.put(deletedStr, deleted);\r
         jo.put("suspend", suspended);\r
-        jo.put("last_mod", last_mod.getTime());\r
-        jo.put("created_date", created_date.getTime());\r
+        jo.put(lastModStr, lastMod.getTime());\r
+        jo.put(createdDateStr, createdDate.getTime());\r
+        jo.put("aaf_instance", aafInstance);\r
         return jo;\r
     }\r
 \r
-    public JSONObject asLimitedJSONObject() {\r
+    /**\r
+     * Method to hide some attributes.\r
+     * @param hidepasswords true/false\r
+     * @return JSONObject\r
+     */\r
+    public JSONObject asJSONObject(boolean hidepasswords) {\r
         JSONObject jo = asJSONObject();\r
-        jo.remove("deleted");\r
-        jo.remove("feedid");\r
-        jo.remove("last_mod");\r
-        jo.remove("created_date");\r
+        if (hidepasswords) {\r
+            jo.remove(feedIDStr);    // we no longer hide passwords, however we do hide these\r
+            jo.remove(deletedStr);\r
+            jo.remove(lastModStr);\r
+            jo.remove(createdDateStr);\r
+        }\r
         return jo;\r
     }\r
 \r
-    public JSONObject asJSONObject(boolean hidepasswords) {\r
+    /**\r
+     * Method to limit JSONObject.\r
+     * @return JSONObject\r
+     */\r
+    public JSONObject asLimitedJSONObject() {\r
         JSONObject jo = asJSONObject();\r
-        if (hidepasswords) {\r
-            jo.remove("feedid");    // we no longer hide passwords, however we do hide these\r
-            jo.remove("deleted");\r
-            jo.remove("last_mod");\r
-            jo.remove("created_date");\r
-        }\r
+        jo.remove(deletedStr);\r
+        jo.remove(feedIDStr);\r
+        jo.remove(lastModStr);\r
+        jo.remove(createdDateStr);\r
         return jo;\r
     }\r
 \r
+\r
+\r
     @Override\r
-    public boolean doDelete(Connection c) {\r
+    public boolean doDelete(Connection conn) {\r
         boolean rv = true;\r
         PreparedStatement ps = null;\r
         try {\r
             String sql = "delete from FEEDS where FEEDID = ?";\r
-            ps = c.prepareStatement(sql);\r
+            ps = conn.prepareStatement(sql);\r
             ps.setInt(1, feedid);\r
             ps.execute();\r
         } catch (SQLException e) {\r
             rv = false;\r
-            intlogger.warn("PROV0007 doDelete: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
+            intlogger.error("PROV0007 doDelete: " + e.getMessage(), e);\r
         } finally {\r
             try {\r
-                if(ps!=null) {\r
+                if (ps != null) {\r
                     ps.close();\r
                 }\r
             } catch (SQLException e) {\r
-                intlogger.error("SQLException " + e.getMessage());\r
+                intlogger.error(SQLEXCEPTION + e.getMessage(), e);\r
             }\r
         }\r
         return rv;\r
     }\r
 \r
     @Override\r
-    public synchronized boolean doInsert(Connection c) {\r
+    public synchronized boolean doInsert(Connection conn) {\r
         boolean rv = true;\r
         try {\r
             if (feedid == -1) {\r
-                setFeedid(next_feedid++);\r
+                setFeedid(nextFeedID++);\r
             }\r
             // In case we insert a feed from synchronization\r
-            if (feedid > next_feedid)\r
-                next_feedid = feedid + 1;\r
+            if (feedid > nextFeedID) {\r
+                nextFeedID = feedid + 1;\r
+            }\r
 \r
             // Create FEED_ENDPOINT_IDS rows\r
             FeedAuthorization auth = getAuthorization();\r
             String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";\r
-            try(PreparedStatement ps2 = c.prepareStatement(sql)) {\r
-                for (FeedEndpointID fid : auth.getEndpoint_ids()) {\r
+            try (PreparedStatement ps2 = conn.prepareStatement(sql)) {\r
+                for (FeedEndpointID fid : auth.getEndpointIDS()) {\r
                     ps2.setInt(1, feedid);\r
                     ps2.setString(2, fid.getId());\r
                     ps2.setString(3, fid.getPassword());\r
@@ -572,8 +668,8 @@ public class Feed extends Syncable {
 \r
             // Create FEED_ENDPOINT_ADDRS rows\r
             sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";\r
-            try(PreparedStatement ps2 = c.prepareStatement(sql)) {\r
-                for (String t : auth.getEndpoint_addrs()) {\r
+            try (PreparedStatement ps2 = conn.prepareStatement(sql)) {\r
+                for (String t : auth.getEndpointAddrs()) {\r
                     ps2.setInt(1, feedid);\r
                     ps2.setString(2, t);\r
                     ps2.executeUpdate();\r
@@ -581,8 +677,11 @@ public class Feed extends Syncable {
             }\r
 \r
             // Finally, create the FEEDS row\r
-            sql = "insert into FEEDS (FEEDID, NAME, VERSION, DESCRIPTION, AUTH_CLASS, PUBLISHER, SELF_LINK, PUBLISH_LINK, SUBSCRIBE_LINK, LOG_LINK, DELETED, SUSPENDED,BUSINESS_DESCRIPTION, GROUPID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?, ?)";\r
-            try(PreparedStatement ps2 = c.prepareStatement(sql)) {\r
+            sql = "insert into FEEDS (FEEDID, NAME, VERSION, DESCRIPTION, AUTH_CLASS, PUBLISHER, SELF_LINK, "\r
+                          + "PUBLISH_LINK, SUBSCRIBE_LINK, LOG_LINK, DELETED, SUSPENDED,"\r
+                          + "BUSINESS_DESCRIPTION, GROUPID, AAF_INSTANCE) "\r
+                          + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";\r
+            try (PreparedStatement ps2 = conn.prepareStatement(sql)) {\r
                 ps2.setInt(1, feedid);\r
                 ps2.setString(2, getName());\r
                 ps2.setString(3, getVersion());\r
@@ -595,30 +694,30 @@ public class Feed extends Syncable {
                 ps2.setString(10, getLinks().getLog());\r
                 ps2.setBoolean(11, isDeleted());\r
                 ps2.setBoolean(12, isSuspended());\r
-                ps2.setString(13, getBusiness_description()); // New field is added - Groups feature Rally:US708102 - 1610\r
-                ps2.setInt(14, groupid); //New field is added - Groups feature Rally:US708115 - 1610\r
+                ps2.setString(13, getBusinessDescription());\r
+                ps2.setInt(14, groupid);\r
+                ps2.setString(15, getAafInstance());\r
                 ps2.executeUpdate();\r
             }\r
         } catch (SQLException e) {\r
             rv = false;\r
-            intlogger.warn("PROV0005 doInsert: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
+            intlogger.error("PROV0005 doInsert: " + e.getMessage(), e);\r
         }\r
         return rv;\r
     }\r
 \r
     @Override\r
-    public boolean doUpdate(Connection c) {\r
+    public boolean doUpdate(Connection conn) {\r
         boolean rv = true;\r
         Feed oldobj = getFeedById(feedid);\r
         PreparedStatement ps = null;\r
         try {\r
-            Set<FeedEndpointID> newset = getAuthorization().getEndpoint_ids();\r
-            Set<FeedEndpointID> oldset = oldobj.getAuthorization().getEndpoint_ids();\r
+            Set<FeedEndpointID> newset = getAuthorization().getEndpointIDS();\r
+            Set<FeedEndpointID> oldset = oldobj.getAuthorization().getEndpointIDS();\r
 \r
             // Insert new FEED_ENDPOINT_IDS rows\r
             String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";\r
-            ps = c.prepareStatement(sql);\r
+            ps = conn.prepareStatement(sql);\r
             for (FeedEndpointID fid : newset) {\r
                 if (!oldset.contains(fid)) {\r
                     ps.setInt(1, feedid);\r
@@ -631,7 +730,7 @@ public class Feed extends Syncable {
 \r
             // Delete old FEED_ENDPOINT_IDS rows\r
             sql = "delete from FEED_ENDPOINT_IDS where FEEDID = ? AND USERID = ? AND PASSWORD = ?";\r
-            ps = c.prepareStatement(sql);\r
+            ps = conn.prepareStatement(sql);\r
             for (FeedEndpointID fid : oldset) {\r
                 if (!newset.contains(fid)) {\r
                     ps.setInt(1, feedid);\r
@@ -643,10 +742,10 @@ public class Feed extends Syncable {
             ps.close();\r
 \r
             // Insert new FEED_ENDPOINT_ADDRS rows\r
-            Set<String> newset2 = getAuthorization().getEndpoint_addrs();\r
-            Set<String> oldset2 = oldobj.getAuthorization().getEndpoint_addrs();\r
+            Set<String> newset2 = getAuthorization().getEndpointAddrs();\r
+            Set<String> oldset2 = oldobj.getAuthorization().getEndpointAddrs();\r
             sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";\r
-            ps = c.prepareStatement(sql);\r
+            ps = conn.prepareStatement(sql);\r
             for (String t : newset2) {\r
                 if (!oldset2.contains(t)) {\r
                     ps.setInt(1, feedid);\r
@@ -658,7 +757,7 @@ public class Feed extends Syncable {
 \r
             // Delete old FEED_ENDPOINT_ADDRS rows\r
             sql = "delete from FEED_ENDPOINT_ADDRS where FEEDID = ? AND ADDR = ?";\r
-            ps = c.prepareStatement(sql);\r
+            ps = conn.prepareStatement(sql);\r
             for (String t : oldset2) {\r
                 if (!newset2.contains(t)) {\r
                     ps.setInt(1, feedid);\r
@@ -669,33 +768,35 @@ public class Feed extends Syncable {
             ps.close();\r
 \r
             // Finally, update the FEEDS row\r
-            sql = "update FEEDS set DESCRIPTION = ?, AUTH_CLASS = ?, DELETED = ?, SUSPENDED = ?, BUSINESS_DESCRIPTION=?, GROUPID=? where FEEDID = ?";\r
-            ps = c.prepareStatement(sql);\r
+            sql = "update FEEDS set DESCRIPTION = ?, AUTH_CLASS = ?, DELETED = ?, SUSPENDED = ?, "\r
+                          + "BUSINESS_DESCRIPTION=?, GROUPID=? where FEEDID = ?";\r
+            ps = conn.prepareStatement(sql);\r
             ps.setString(1, getDescription());\r
             ps.setString(2, getAuthorization().getClassification());\r
             ps.setInt(3, deleted ? 1 : 0);\r
             ps.setInt(4, suspended ? 1 : 0);\r
-            ps.setString(5, getBusiness_description()); // New field is added - Groups feature Rally:US708102 - 1610\r
-            ps.setInt(6, groupid); //New field is added - Groups feature Rally:US708115 - 1610\r
+            ps.setString(5, getBusinessDescription());\r
+            ps.setInt(6, groupid);\r
             ps.setInt(7, feedid);\r
             ps.executeUpdate();\r
             ps.close();\r
         } catch (SQLException e) {\r
             rv = false;\r
-            intlogger.warn("PROV0006 doUpdate: " + e.getMessage());\r
+            intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e);\r
         } finally {\r
             try {\r
-                if (ps != null)\r
+                if (ps != null) {\r
                     ps.close();\r
+                }\r
             } catch (SQLException e) {\r
-                intlogger.error("SQLException " + e.getMessage());\r
+                intlogger.error(SQLEXCEPTION + e.getMessage(), e);\r
             }\r
         }\r
         return rv;\r
     }\r
 \r
     /**\r
-     * Rally US708115\r
+     * Rally US708115.\r
      * Change Ownership of FEED - 1610\r
      */\r
     public boolean changeOwnerShip() {\r
@@ -705,23 +806,23 @@ public class Feed extends Syncable {
 \r
             DB db = new DB();\r
             @SuppressWarnings("resource")\r
-            Connection c = db.getConnection();\r
+            Connection conn = db.getConnection();\r
             String sql = "update FEEDS set PUBLISHER = ? where FEEDID = ?";\r
-            ps = c.prepareStatement(sql);\r
+            ps = conn.prepareStatement(sql);\r
             ps.setString(1, this.publisher);\r
             ps.setInt(2, feedid);\r
             ps.execute();\r
             ps.close();\r
         } catch (SQLException e) {\r
             rv = false;\r
-            intlogger.warn("PROV0006 doUpdate: " + e.getMessage());\r
+            intlogger.warn("PROV0008 changeOwnerShip: " + e.getMessage(), e);\r
         } finally {\r
             try {\r
-                if(ps!=null) {\r
+                if (ps != null) {\r
                     ps.close();\r
                 }\r
             } catch (SQLException e) {\r
-                intlogger.error("SQLException " + e.getMessage());\r
+                intlogger.error(SQLEXCEPTION + e.getMessage(), e);\r
             }\r
         }\r
         return rv;\r
@@ -735,31 +836,48 @@ public class Feed extends Syncable {
 \r
     @Override\r
     public boolean equals(Object obj) {\r
-        if (!(obj instanceof Feed))\r
+        if (!(obj instanceof Feed)) {\r
             return false;\r
+        }\r
         Feed of = (Feed) obj;\r
-        if (feedid != of.feedid)\r
+        if (feedid != of.feedid) {\r
             return false;\r
-        if (groupid != of.groupid) //New field is added - Groups feature Rally:US708115 - 1610\r
+        }\r
+        if (groupid != of.groupid) {\r
+            //New field is added - Groups feature Rally:US708115 - 1610\r
             return false;\r
-        if (!name.equals(of.name))\r
+        }\r
+        if (!name.equals(of.name)) {\r
             return false;\r
-        if (!version.equals(of.version))\r
+        }\r
+        if (!version.equals(of.version)) {\r
             return false;\r
-        if (!description.equals(of.description))\r
+        }\r
+        if (!description.equals(of.description)) {\r
             return false;\r
-        if (!business_description.equals(of.business_description)) // New field is added - Groups feature Rally:US708102 - 1610\r
+        }\r
+        if (!businessDescription.equals(of.businessDescription)) {\r
+            // New field is added - Groups feature Rally:US708102 - 1610\r
             return false;\r
-        if (!publisher.equals(of.publisher))\r
+        }\r
+        if (!publisher.equals(of.publisher)) {\r
             return false;\r
-        if (!authorization.equals(of.authorization))\r
+        }\r
+        if (!authorization.equals(of.authorization)) {\r
             return false;\r
-        if (!links.equals(of.links))\r
+        }\r
+        if (!links.equals(of.links)) {\r
+            return false;\r
+        }\r
+        if (deleted != of.deleted) {\r
             return false;\r
-        if (deleted != of.deleted)\r
+        }\r
+        if (suspended != of.suspended) {\r
             return false;\r
-        if (suspended != of.suspended)\r
+        }\r
+        if (!aafInstance.equals(of.aafInstance)) {\r
             return false;\r
+        }\r
         return true;\r
     }\r
 \r
@@ -770,6 +888,6 @@ public class Feed extends Syncable {
 \r
     @Override\r
     public int hashCode() {\r
-        return Objects.hash(feedid, groupid, name, version, description, business_description, authorization, publisher, links, deleted, suspended, last_mod, created_date);\r
+        return super.hashCode();\r
     }\r
-}\r
+}
\ No newline at end of file