+ 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(FEED_ID_SQL);\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(FEED_ID, -1);\r
+ this.groupid = jo.optInt("groupid");\r
+ this.name = jo.getString("name");\r
+ this.aafInstance = jo.optString("aaf_instance", "legacy");\r
+ if (!("legacy".equalsIgnoreCase(aafInstance)) && 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(DEL, 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