- public Subscription() {\r
- this("", "", "");\r
- }\r
-\r
- public Subscription(String url, String user, String password) {\r
- this.subid = -1;\r
- this.feedid = -1;\r
- this.groupid = -1; //New field is added - Groups feature Rally:US708115 - 1610\r
- this.delivery = new SubDelivery(url, user, password, false);\r
- this.metadataOnly = false;\r
- this.subscriber = "";\r
- this.links = new SubLinks();\r
- this.suspended = false;\r
- this.lastMod = new Date();\r
- this.createdDate = new Date();\r
- }\r
-\r
- public Subscription(ResultSet rs) throws SQLException {\r
- this.subid = rs.getInt(SUBID_COL);\r
- this.feedid = rs.getInt("FEEDID");\r
- this.groupid = rs.getInt("GROUPID"); //New field is added - Groups feature Rally:US708115 - 1610\r
- this.delivery = new SubDelivery(rs);\r
- this.metadataOnly = rs.getBoolean("METADATA_ONLY");\r
- this.subscriber = rs.getString("SUBSCRIBER");\r
- this.links = new SubLinks(rs.getString("SELF_LINK"), URLUtilities.generateFeedURL(feedid),\r
- rs.getString("LOG_LINK"));\r
- this.suspended = rs.getBoolean("SUSPENDED");\r
- this.lastMod = rs.getDate("LAST_MOD");\r
- this.createdDate = rs.getDate("CREATED_DATE");\r
- }\r
-\r
- public Subscription(JSONObject jo) throws InvalidObjectException {\r
- this("", "", "");\r
- try {\r
- // The JSONObject is assumed to contain a vnd.dmaap-dr.subscription representation\r
- this.subid = jo.optInt(SUBID_KEY, -1);\r
- this.feedid = jo.optInt(FEEDID_KEY, -1);\r
- this.groupid = jo.optInt(GROUPID_KEY, -1); //New field is added - Groups feature Rally:US708115 - 1610\r
-\r
- JSONObject jdeli = jo.getJSONObject("delivery");\r
- String url = jdeli.getString("url");\r
- String user = jdeli.getString("user");\r
- String password = jdeli.getString("password");\r
- boolean use100 = jdeli.getBoolean("use100");\r
-\r
- //Data Router Subscriber HTTPS Relaxation feature USERSTORYID:US674047.\r
- Properties p = (new DB()).getProperties();\r
- if (!url.startsWith("https://") && isHttpsRelaxationFalseAndHasSyncKey(jo, p)) {\r
- throw new InvalidObjectException("delivery URL is not HTTPS");\r
- }\r
-\r
- if (url.length() > 256) {\r
- throw new InvalidObjectException("delivery url field is too long");\r
- }\r
- if (user.length() > 20) {\r
- throw new InvalidObjectException("delivery user field is too long");\r
- }\r
- if (password.length() > 32) {\r
- throw new InvalidObjectException("delivery password field is too long");\r
- }\r
- this.delivery = new SubDelivery(url, user, password, use100);\r
-\r
- this.metadataOnly = jo.getBoolean("metadataOnly");\r
- this.suspended = jo.optBoolean("suspend", false);\r
-\r
- this.subscriber = jo.optString("subscriber", "");\r
- JSONObject jol = jo.optJSONObject("links");\r
- this.links = (jol == null) ? (new SubLinks()) : (new SubLinks(jol));\r
- } catch (InvalidObjectException e) {\r
- throw e;\r
- } catch (Exception e) {\r
- throw new InvalidObjectException("invalid JSON: " + e.getMessage());\r
- }\r
- }\r
-\r
- private boolean isHttpsRelaxationFalseAndHasSyncKey(JSONObject jo, Properties p) {\r
- return p.get("org.onap.dmaap.datarouter.provserver.https.relaxation").toString().equals("false") && !jo\r