aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src
diff options
context:
space:
mode:
authoredepaul <paul.p.dennehy@est.tech>2019-03-13 11:54:41 +0000
committeredepaul <paul.p.dennehy@est.tech>2019-03-13 11:54:41 +0000
commit58553dd3f01290e5b8acac7cfcb63016d7a037da (patch)
tree4253295c8b1931658707a0ae580d8eb0a7258b70 /datarouter-prov/src
parent7744ccb9eb0a755c1dad8fc8ec42e4ad645d20d6 (diff)
Adding decompression option for user to a feed.
Change-Id: I2276d109fd65052cc043cdc2c7b4eb10655a0ac3 Issue-ID: DMAAP-1043 Signed-off-by: edepaul <paul.p.dennehy@est.tech>
Diffstat (limited to 'datarouter-prov/src')
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java21
-rwxr-xr-xdatarouter-prov/src/main/resources/misc/sql_init_01.sql1
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java7
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/SubscriptionTest.java2
-rwxr-xr-xdatarouter-prov/src/test/resources/create.sql5
5 files changed, 31 insertions, 5 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java
index 230df756..0c0c5461 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java
@@ -69,6 +69,7 @@ public class Subscription extends Syncable {
private Date lastMod;
private Date createdDate;
private boolean privilegedSubscriber;
+ private boolean decompress;
public static Subscription getSubscriptionMatching(Subscription sub) {
SubDelivery deli = sub.getDelivery();
@@ -202,6 +203,7 @@ public class Subscription extends Syncable {
this.lastMod = new Date();
this.createdDate = new Date();
this.privilegedSubscriber = false;
+ this.decompress = false;
}
public Subscription(ResultSet rs) throws SQLException {
@@ -217,6 +219,7 @@ public class Subscription extends Syncable {
this.lastMod = rs.getDate("LAST_MOD");
this.createdDate = rs.getDate("CREATED_DATE");
this.privilegedSubscriber = rs.getBoolean("PRIVILEGED_SUBSCRIBER");
+ this.decompress = rs.getBoolean("DECOMPRESS");
}
public Subscription(JSONObject jo) throws InvalidObjectException {
@@ -253,6 +256,7 @@ public class Subscription extends Syncable {
this.metadataOnly = jo.getBoolean("metadataOnly");
this.suspended = jo.optBoolean("suspend", false);
this.privilegedSubscriber = jo.optBoolean("privilegedSubscriber", false);
+ this.decompress = jo.optBoolean("decompress", false);
this.subscriber = jo.optString("subscriber", "");
JSONObject jol = jo.optJSONObject("links");
this.links = (jol == null) ? (new SubLinks()) : (new SubLinks(jol));
@@ -355,6 +359,14 @@ public class Subscription extends Syncable {
this.links = links;
}
+ public boolean isDecompress() {
+ return decompress;
+ }
+
+ public void setDecompress(boolean decompress) {
+ this.decompress = decompress;
+ }
+
@Override
public JSONObject asJSONObject() {
JSONObject jo = new JSONObject();
@@ -369,6 +381,7 @@ public class Subscription extends Syncable {
jo.put(LAST_MOD_KEY, lastMod.getTime());
jo.put(CREATED_DATE, createdDate.getTime());
jo.put("privilegedSubscriber", privilegedSubscriber);
+ jo.put("decompress", decompress);
return jo;
}
@@ -406,7 +419,7 @@ public class Subscription extends Syncable {
}
// Create the SUBSCRIPTIONS row
- String sql = "insert into SUBSCRIPTIONS (SUBID, FEEDID, DELIVERY_URL, DELIVERY_USER, DELIVERY_PASSWORD, DELIVERY_USE100, METADATA_ONLY, SUBSCRIBER, SUSPENDED, GROUPID, PRIVILEGED_SUBSCRIBER) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ String sql = "insert into SUBSCRIPTIONS (SUBID, FEEDID, DELIVERY_URL, DELIVERY_USER, DELIVERY_PASSWORD, DELIVERY_USE100, METADATA_ONLY, SUBSCRIBER, SUSPENDED, GROUPID, PRIVILEGED_SUBSCRIBER, DECOMPRESS) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
ps = c.prepareStatement(sql, new String[]{SUBID_COL});
ps.setInt(1, subid);
ps.setInt(2, feedid);
@@ -419,6 +432,7 @@ public class Subscription extends Syncable {
ps.setBoolean(9, isSuspended());
ps.setInt(10, groupid); //New field is added - Groups feature Rally:US708115 - 1610
ps.setBoolean(11, isPrivilegedSubscriber());
+ ps.setBoolean(12, isDecompress());
ps.execute();
ps.close();
// Update the row to set the URLs
@@ -449,7 +463,7 @@ public class Subscription extends Syncable {
boolean rv = true;
PreparedStatement ps = null;
try {
- String sql = "update SUBSCRIPTIONS set DELIVERY_URL = ?, DELIVERY_USER = ?, DELIVERY_PASSWORD = ?, DELIVERY_USE100 = ?, METADATA_ONLY = ?, SUSPENDED = ?, GROUPID = ?, PRIVILEGED_SUBSCRIBER = ? where SUBID = ?";
+ String sql = "update SUBSCRIPTIONS set DELIVERY_URL = ?, DELIVERY_USER = ?, DELIVERY_PASSWORD = ?, DELIVERY_USE100 = ?, METADATA_ONLY = ?, SUSPENDED = ?, GROUPID = ?, PRIVILEGED_SUBSCRIBER = ?, DECOMPRESS = ? where SUBID = ?";
ps = c.prepareStatement(sql);
ps.setString(1, delivery.getUrl());
ps.setString(2, delivery.getUser());
@@ -459,7 +473,8 @@ public class Subscription extends Syncable {
ps.setInt(6, suspended ? 1 : 0);
ps.setInt(7, groupid); //New field is added - Groups feature Rally:US708115 - 1610
ps.setInt(8, privilegedSubscriber ? 1 : 0);
- ps.setInt(9, subid);
+ ps.setInt(9, decompress ? 1 : 0);
+ ps.setInt(10, subid);
ps.executeUpdate();
} catch (SQLException e) {
rv = false;
diff --git a/datarouter-prov/src/main/resources/misc/sql_init_01.sql b/datarouter-prov/src/main/resources/misc/sql_init_01.sql
index 60b638a0..14c59a65 100755
--- a/datarouter-prov/src/main/resources/misc/sql_init_01.sql
+++ b/datarouter-prov/src/main/resources/misc/sql_init_01.sql
@@ -45,6 +45,7 @@ CREATE TABLE SUBSCRIPTIONS (
LAST_MOD TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
SUSPENDED BOOLEAN DEFAULT FALSE,
PRIVILEGED_SUBSCRIBER BOOLEAN DEFAULT FALSE,
+ DECOMPRESS BOOLEAN DEFAULT FALSE,
CREATED_DATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
index 43973d56..aede69cf 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
@@ -279,6 +279,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
jo.put("metadataOnly", true);
jo.put("suspend", true);
jo.put("privilegedSubscriber", true);
+ jo.put("decompress", true);
jo.put("delivery", JSObject);
jo.put("subscriber", "differentSubscriber");
jo.put("sync", true);
@@ -303,6 +304,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
jo.put("suspend", true);
jo.put("privilegedSubscriber", true);
jo.put("delivery", JSObject);
+ jo.put("decompress", true);
jo.put("sync", true);
return jo;
}
@@ -331,6 +333,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
jo.put("metadataOnly", true);
jo.put("suspend", true);
jo.put("privilegedSubscriber", true);
+ jo.put("decompress", true);
jo.put("delivery", JSObject);
jo.put("sync", true);
jo.put("changeowner", true);
@@ -431,6 +434,8 @@ public class SubscriptionServletTest extends DrServletTestBase {
jo.put("metadataOnly", true);
jo.put("suspend", true);
jo.put("delivery", JSObject);
+ jo.put("privilegedSubscriber", false);
+ jo.put("decompress", false);
jo.put("failed", false);
return jo;
}
@@ -504,6 +509,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
subscription.setMetadataOnly(false);
subscription.setSuspended(false);
subscription.setPrivilegedSubscriber(false);
+ subscription.setDecompress(false);
subscription.doInsert(db.getConnection());
}
@@ -518,6 +524,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
subscription.setMetadataOnly(false);
subscription.setSuspended(false);
subscription.setPrivilegedSubscriber(false);
+ subscription.setDecompress(false);
subscription.changeOwnerShip();
subscription.doUpdate(db.getConnection());
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/SubscriptionTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/SubscriptionTest.java
index 3e6aed07..d859e082 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/SubscriptionTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/SubscriptionTest.java
@@ -64,6 +64,7 @@ public class SubscriptionTest {
subscription.setSuspended(false);
subscription.setPrivilegedSubscriber(false);
subscription.setLinks(subLinks);
+ subscription.setDecompress(false);
Assert.assertEquals(2, subscription.getGroupid());
Assert.assertEquals(subDelivery, subscription.getDelivery());
@@ -71,5 +72,6 @@ public class SubscriptionTest {
Assert.assertFalse(subscription.isMetadataOnly());
Assert.assertFalse(subscription.isSuspended());
Assert.assertFalse(subscription.isPrivilegedSubscriber());
+ Assert.assertFalse(subscription.isDecompress());
}
} \ No newline at end of file
diff --git a/datarouter-prov/src/test/resources/create.sql b/datarouter-prov/src/test/resources/create.sql
index d29e5891..887b06a3 100755
--- a/datarouter-prov/src/test/resources/create.sql
+++ b/datarouter-prov/src/test/resources/create.sql
@@ -43,6 +43,7 @@ CREATE TABLE SUBSCRIPTIONS (
LAST_MOD TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
SUSPENDED BOOLEAN DEFAULT FALSE,
PRIVILEGED_SUBSCRIBER BOOLEAN DEFAULT FALSE,
+ DECOMPRESS BOOLEAN DEFAULT FALSE,
CREATED_DATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
@@ -148,8 +149,8 @@ INSERT INTO PARAMETERS VALUES
INSERT INTO GROUPS(GROUPID, AUTHID, NAME, DESCRIPTION, CLASSIFICATION, MEMBERS)
VALUES (1, 'Basic dXNlcjE6cGFzc3dvcmQx', 'Group1', 'First Group for testing', 'Class1', 'Member1');
-INSERT INTO SUBSCRIPTIONS(SUBID, FEEDID, DELIVERY_URL, DELIVERY_USER, DELIVERY_PASSWORD, DELIVERY_USE100, METADATA_ONLY, SUBSCRIBER, SUSPENDED, GROUPID, PRIVILEGED_SUBSCRIBER)
-VALUES (1, 1, 'https://172.100.0.5:8080', 'user1', 'password1', true, false, 'user1', false, 1, false);
+INSERT INTO SUBSCRIPTIONS(SUBID, FEEDID, DELIVERY_URL, DELIVERY_USER, DELIVERY_PASSWORD, DELIVERY_USE100, METADATA_ONLY, SUBSCRIBER, SUSPENDED, GROUPID, PRIVILEGED_SUBSCRIBER, DECOMPRESS)
+VALUES (1, 1, 'https://172.100.0.5:8080', 'user1', 'password1', true, false, 'user1', false, 1, false, false);
INSERT INTO SUBSCRIPTIONS(SUBID, FEEDID, DELIVERY_URL, DELIVERY_USER, DELIVERY_PASSWORD, SUBSCRIBER, SELF_LINK, LOG_LINK)
VALUES (23, 1, 'http://delivery_url', 'user1', 'somepassword', 'sub123', 'selflink', 'loglink');