Adding decompression option for user to a feed.
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / beans / Subscription.java
index f427525..0c0c546 100644 (file)
@@ -68,6 +68,8 @@ public class Subscription extends Syncable {
     private boolean suspended;\r
     private Date lastMod;\r
     private Date createdDate;\r
+    private boolean privilegedSubscriber;\r
+    private boolean decompress;\r
 \r
     public static Subscription getSubscriptionMatching(Subscription sub) {\r
         SubDelivery deli = sub.getDelivery();\r
@@ -200,6 +202,8 @@ public class Subscription extends Syncable {
         this.suspended = false;\r
         this.lastMod = new Date();\r
         this.createdDate = new Date();\r
+        this.privilegedSubscriber = false;\r
+        this.decompress = false;\r
     }\r
 \r
     public Subscription(ResultSet rs) throws SQLException {\r
@@ -214,12 +218,14 @@ public class Subscription extends Syncable {
         this.suspended = rs.getBoolean("SUSPENDED");\r
         this.lastMod = rs.getDate("LAST_MOD");\r
         this.createdDate = rs.getDate("CREATED_DATE");\r
+        this.privilegedSubscriber = rs.getBoolean("PRIVILEGED_SUBSCRIBER");\r
+        this.decompress  = rs.getBoolean("DECOMPRESS");\r
     }\r
 \r
     public Subscription(JSONObject jo) throws InvalidObjectException {\r
         this("", "", "");\r
         try {\r
-            // The JSONObject is assumed to contain a vnd.att-dr.subscription representation\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
@@ -249,7 +255,8 @@ public class Subscription extends Syncable {
 \r
             this.metadataOnly = jo.getBoolean("metadataOnly");\r
             this.suspended = jo.optBoolean("suspend", false);\r
-\r
+            this.privilegedSubscriber = jo.optBoolean("privilegedSubscriber", false);\r
+            this.decompress = jo.optBoolean("decompress", false);\r
             this.subscriber = jo.optString("subscriber", "");\r
             JSONObject jol = jo.optJSONObject("links");\r
             this.links = (jol == null) ? (new SubLinks()) : (new SubLinks(jol));\r
@@ -323,6 +330,14 @@ public class Subscription extends Syncable {
         this.suspended = suspended;\r
     }\r
 \r
+    public boolean isPrivilegedSubscriber() {\r
+        return privilegedSubscriber;\r
+    }\r
+\r
+    public void setPrivilegedSubscriber(boolean privilegedSubscriber) {\r
+        this.privilegedSubscriber = privilegedSubscriber;\r
+    }\r
+\r
     public String getSubscriber() {\r
         return subscriber;\r
     }\r
@@ -344,6 +359,14 @@ public class Subscription extends Syncable {
         this.links = links;\r
     }\r
 \r
+    public boolean isDecompress() {\r
+        return decompress;\r
+    }\r
+\r
+    public void setDecompress(boolean decompress) {\r
+        this.decompress = decompress;\r
+    }\r
+\r
     @Override\r
     public JSONObject asJSONObject() {\r
         JSONObject jo = new JSONObject();\r
@@ -357,6 +380,8 @@ public class Subscription extends Syncable {
         jo.put("suspend", suspended);\r
         jo.put(LAST_MOD_KEY, lastMod.getTime());\r
         jo.put(CREATED_DATE, createdDate.getTime());\r
+        jo.put("privilegedSubscriber", privilegedSubscriber);\r
+        jo.put("decompress", decompress);\r
         return jo;\r
     }\r
 \r
@@ -394,7 +419,7 @@ public class Subscription extends Syncable {
             }\r
 \r
             // Create the SUBSCRIPTIONS row\r
-            String sql = "insert into SUBSCRIPTIONS (SUBID, FEEDID, DELIVERY_URL, DELIVERY_USER, DELIVERY_PASSWORD, DELIVERY_USE100, METADATA_ONLY, SUBSCRIBER, SUSPENDED, GROUPID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";\r
+            String sql = "insert into SUBSCRIPTIONS (SUBID, FEEDID, DELIVERY_URL, DELIVERY_USER, DELIVERY_PASSWORD, DELIVERY_USE100, METADATA_ONLY, SUBSCRIBER, SUSPENDED, GROUPID, PRIVILEGED_SUBSCRIBER, DECOMPRESS) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";\r
             ps = c.prepareStatement(sql, new String[]{SUBID_COL});\r
             ps.setInt(1, subid);\r
             ps.setInt(2, feedid);\r
@@ -406,6 +431,8 @@ public class Subscription extends Syncable {
             ps.setString(8, getSubscriber());\r
             ps.setBoolean(9, isSuspended());\r
             ps.setInt(10, groupid); //New field is added - Groups feature Rally:US708115 - 1610\r
+            ps.setBoolean(11, isPrivilegedSubscriber());\r
+            ps.setBoolean(12, isDecompress());\r
             ps.execute();\r
             ps.close();\r
             // Update the row to set the URLs\r
@@ -436,7 +463,7 @@ public class Subscription extends Syncable {
         boolean rv = true;\r
         PreparedStatement ps = null;\r
         try {\r
-            String sql = "update SUBSCRIPTIONS set DELIVERY_URL = ?, DELIVERY_USER = ?, DELIVERY_PASSWORD = ?, DELIVERY_USE100 = ?, METADATA_ONLY = ?, SUSPENDED = ?, GROUPID = ? where SUBID = ?";\r
+            String sql = "update SUBSCRIPTIONS set DELIVERY_URL = ?, DELIVERY_USER = ?, DELIVERY_PASSWORD = ?, DELIVERY_USE100 = ?, METADATA_ONLY = ?, SUSPENDED = ?, GROUPID = ?, PRIVILEGED_SUBSCRIBER = ?, DECOMPRESS = ? where SUBID = ?";\r
             ps = c.prepareStatement(sql);\r
             ps.setString(1, delivery.getUrl());\r
             ps.setString(2, delivery.getUser());\r
@@ -445,7 +472,9 @@ public class Subscription extends Syncable {
             ps.setInt(5, isMetadataOnly() ? 1 : 0);\r
             ps.setInt(6, suspended ? 1 : 0);\r
             ps.setInt(7, groupid); //New field is added - Groups feature Rally:US708115 - 1610\r
-            ps.setInt(8, subid);\r
+            ps.setInt(8, privilegedSubscriber ? 1 : 0);\r
+            ps.setInt(9, decompress ? 1 : 0);\r
+            ps.setInt(10, subid);\r
             ps.executeUpdate();\r
         } catch (SQLException e) {\r
             rv = false;\r