- public static Collection<String> getGroupsByClassfication(String classfication) {\r
- List<String> list = new ArrayList<>();\r
- String sql = "select * from GROUPS where classification = ?";\r
- try {\r
- DB db = new DB();\r
- @SuppressWarnings("resource")\r
- Connection conn = db.getConnection();\r
- try (PreparedStatement stmt = conn.prepareStatement(sql)) {\r
- stmt.setString(1, classfication);\r
- try (ResultSet rs = stmt.executeQuery()) {\r
- while (rs.next()) {\r
- int groupid = rs.getInt("groupid");\r
-\r
- }\r
- }\r
- }\r
- db.release(conn);\r
- } catch (SQLException e) {\r
- intlogger.error("SQLException " + e.getMessage());\r
- }\r
- return list;\r
- }\r
-\r
- /**\r
- * Return a count of the number of active subscriptions in the DB.\r
- *\r
- * @return the count\r
- */\r
- public static int countActiveSubscriptions() {\r
- 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
- try (ResultSet rs = stmt.executeQuery("select count(*) from SUBSCRIPTIONS")) {\r
- if (rs.next()) {\r
- count = rs.getInt(1);\r
- }\r
- }\r
- }\r
- db.release(conn);\r
- } catch (SQLException e) {\r
- intlogger.warn("PROV0008 countActiveSubscriptions: " + e.getMessage());\r
- }\r
- return count;\r
- }\r
-\r
- 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.att-dr.group representation\r
- this.groupid = jo.optInt("groupid", -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
- throw new InvalidObjectException("invalid JSON: " + e.getMessage());\r
- }\r
- }\r
-\r