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 230df75..0c0c546 100644 (file)
@@ -69,6 +69,7 @@ public class Subscription extends Syncable {
     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
@@ -202,6 +203,7 @@ public class Subscription extends Syncable {
         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
@@ -217,6 +219,7 @@ public class Subscription extends Syncable {
         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
@@ -253,6 +256,7 @@ public class Subscription extends Syncable {
             this.metadataOnly = jo.getBoolean("metadataOnly");\r
             this.suspended = jo.optBoolean("suspend", false);\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
@@ -355,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
@@ -369,6 +381,7 @@ public class Subscription extends Syncable {
         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
@@ -406,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, PRIVILEGED_SUBSCRIBER) 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
@@ -419,6 +432,7 @@ public class Subscription extends Syncable {
             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
@@ -449,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 = ?, PRIVILEGED_SUBSCRIBER = ? 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
@@ -459,7 +473,8 @@ public class Subscription extends Syncable {
             ps.setInt(6, suspended ? 1 : 0);\r
             ps.setInt(7, groupid); //New field is added - Groups feature Rally:US708115 - 1610\r
             ps.setInt(8, privilegedSubscriber ? 1 : 0);\r
-            ps.setInt(9, subid);\r
+            ps.setInt(9, decompress ? 1 : 0);\r
+            ps.setInt(10, subid);\r
             ps.executeUpdate();\r
         } catch (SQLException e) {\r
             rv = false;\r