Fix logging and formatting for Group 75/69275/1
authoresobmar <mariusz.sobucki@ericsson.com>
Thu, 27 Sep 2018 10:39:39 +0000 (11:39 +0100)
committeresobmar <mariusz.sobucki@ericsson.com>
Thu, 27 Sep 2018 10:39:48 +0000 (11:39 +0100)
Change-Id: Ide80703b07d8d80875e52ad234bd0dd2f0ee77e0
Signed-off-by: Mariusz Sobucki <mariusz.sobucki@ericsson.com>
Issue-ID: DMAAP-775

datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java

index 3536309..3f5f7c7 100644 (file)
@@ -43,6 +43,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
  * @version $Id: Group.java,v 1.0 2016/07/19\r
  */\r
 public class Group extends Syncable {\r
+\r
     private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");\r
     private static int next_groupid = getMaxGroupID() + 1;\r
 \r
@@ -96,8 +97,8 @@ public class Group extends Syncable {
             DB db = new DB();\r
             @SuppressWarnings("resource")\r
             Connection conn = db.getConnection();\r
-            try(Statement stmt = conn.createStatement()) {\r
-                try(ResultSet rs = stmt.executeQuery(sql)) {\r
+            try (Statement stmt = conn.createStatement()) {\r
+                try (ResultSet rs = stmt.executeQuery(sql)) {\r
                     while (rs.next()) {\r
                         Group group = new Group(rs);\r
                         list.add(group);\r
@@ -117,8 +118,8 @@ public class Group extends Syncable {
             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 MAX(groupid) from GROUPS")) {\r
+            try (Statement stmt = conn.createStatement()) {\r
+                try (ResultSet rs = stmt.executeQuery("select MAX(groupid) from GROUPS")) {\r
                     if (rs.next()) {\r
                         max = rs.getInt(1);\r
                     }\r
@@ -127,7 +128,6 @@ public class Group extends Syncable {
             db.release(conn);\r
         } catch (SQLException e) {\r
             intlogger.info("getMaxSubID: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
         }\r
         return max;\r
     }\r
@@ -139,9 +139,9 @@ public class Group extends Syncable {
             DB db = new DB();\r
             @SuppressWarnings("resource")\r
             Connection conn = db.getConnection();\r
-            try(PreparedStatement stmt = conn.prepareStatement(sql)) {\r
+            try (PreparedStatement stmt = conn.prepareStatement(sql)) {\r
                 stmt.setString(1, classfication);\r
-                try(ResultSet rs = stmt.executeQuery()) {\r
+                try (ResultSet rs = stmt.executeQuery()) {\r
                     while (rs.next()) {\r
                         int groupid = rs.getInt("groupid");\r
 \r
@@ -166,8 +166,8 @@ public class Group extends Syncable {
             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 count(*) from SUBSCRIPTIONS")) {\r
+            try (Statement stmt = conn.createStatement()) {\r
+                try (ResultSet rs = stmt.executeQuery("select count(*) from SUBSCRIPTIONS")) {\r
                     if (rs.next()) {\r
                         count = rs.getInt(1);\r
                     }\r
@@ -176,7 +176,6 @@ public class Group extends Syncable {
             db.release(conn);\r
         } catch (SQLException e) {\r
             intlogger.warn("PROV0008 countActiveSubscriptions: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
         }\r
         return count;\r
     }\r
@@ -221,10 +220,12 @@ public class Group extends Syncable {
             this.classification = jo.getString("classification");\r
             this.members = jo.getString("members");\r
 \r
-            if (gname.length() > 50)\r
+            if (gname.length() > 50) {\r
                 throw new InvalidObjectException("Group name is too long");\r
-            if (gdescription.length() > 256)\r
+            }\r
+            if (gdescription.length() > 256) {\r
                 throw new InvalidObjectException("Group Description is too long");\r
+            }\r
         } catch (InvalidObjectException e) {\r
             throw e;\r
         } catch (Exception e) {\r
@@ -328,9 +329,9 @@ public class Group extends Syncable {
                 setGroupid(next_groupid++);\r
             }\r
             // In case we insert a gropup from synchronization\r
-            if (groupid > next_groupid)\r
+            if (groupid > next_groupid) {\r
                 next_groupid = groupid + 1;\r
-\r
+            }\r
 \r
             // Create the GROUPS row\r
             String sql = "insert into GROUPS (GROUPID, AUTHID, NAME, DESCRIPTION, CLASSIFICATION, MEMBERS) values (?, ?, ?, ?, ?, ?)";\r
@@ -346,10 +347,9 @@ public class Group extends Syncable {
         } catch (SQLException e) {\r
             rv = false;\r
             intlogger.warn("PROV0005 doInsert: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
         } finally {\r
             try {\r
-                if(ps!=null) {\r
+                if (ps != null) {\r
                     ps.close();\r
                 }\r
             } catch (SQLException e) {\r
@@ -376,10 +376,9 @@ public class Group extends Syncable {
         } catch (SQLException e) {\r
             rv = false;\r
             intlogger.warn("PROV0006 doUpdate: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
         } finally {\r
             try {\r
-                if(ps!=null) {\r
+                if (ps != null) {\r
                     ps.close();\r
                 }\r
             } catch (SQLException e) {\r
@@ -401,10 +400,9 @@ public class Group extends Syncable {
         } catch (SQLException e) {\r
             rv = false;\r
             intlogger.warn("PROV0007 doDelete: " + e.getMessage());\r
-            intlogger.error("SQLException " + e.getMessage());\r
         } finally {\r
             try {\r
-                if(ps!=null) {\r
+                if (ps != null) {\r
                     ps.close();\r
                 }\r
             } catch (SQLException e) {\r
@@ -421,21 +419,28 @@ public class Group extends Syncable {
 \r
     @Override\r
     public boolean equals(Object obj) {\r
-        if (!(obj instanceof Group))\r
+        if (!(obj instanceof Group)) {\r
             return false;\r
+        }\r
         Group os = (Group) obj;\r
-        if (groupid != os.groupid)\r
+        if (groupid != os.groupid) {\r
             return false;\r
-        if (authid != os.authid)\r
+        }\r
+        if (authid != os.authid) {\r
             return false;\r
-        if (!name.equals(os.name))\r
+        }\r
+        if (!name.equals(os.name)) {\r
             return false;\r
-        if (description != os.description)\r
+        }\r
+        if (description != os.description) {\r
             return false;\r
-        if (!classification.equals(os.classification))\r
+        }\r
+        if (!classification.equals(os.classification)) {\r
             return false;\r
-        if (!members.equals(os.members))\r
+        }\r
+        if (!members.equals(os.members)) {\r
             return false;\r
+        }\r
 \r
         return true;\r
     }\r