+ public Group() {\r
+ this("", "", "");\r
+ }\r
+\r
+ public Group(String name, String desc, String members) {\r
+ this.groupid = -1;\r
+ this.authid = "";\r
+ this.name = name;\r
+ this.description = desc;\r
+ this.members = members;\r
+ this.classification = "";\r
+ this.last_mod = new Date();\r
+ }\r
+\r
+\r
+ public Group(ResultSet rs) throws SQLException {\r
+ this.groupid = rs.getInt("GROUPID");\r
+ this.authid = rs.getString("AUTHID");\r
+ this.name = rs.getString("NAME");\r
+ this.description = rs.getString("DESCRIPTION");\r
+ this.classification = rs.getString("CLASSIFICATION");\r
+ this.members = rs.getString("MEMBERS");\r
+ this.last_mod = rs.getDate("LAST_MOD");\r
+ }\r
+\r
+\r
+ public Group(JSONObject jo) throws InvalidObjectException {\r
+ this("", "", "");\r
+ try {\r
+ // The JSONObject is assumed to contain a vnd.dmaap-dr.group representation\r
+ this.groupid = jo.optInt(GROUP_ID_CONST, -1);\r
+ String gname = jo.getString("name");\r
+ String gdescription = jo.getString("description");\r
+\r
+ this.authid = jo.getString("authid");\r
+ this.name = gname;\r
+ this.description = gdescription;\r
+ this.classification = jo.getString("classification");\r
+ this.members = jo.getString("members");\r
+\r
+ if (gname.length() > 50) {\r
+ throw new InvalidObjectException("Group name is too long");\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
+ intlogger.warn("Invalid JSON: " + e.getMessage(), e);\r
+ throw new InvalidObjectException("Invalid JSON: " + e.getMessage());\r
+ }\r
+ }\r
+\r