aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'datarouter-prov/src/main')
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedServlet.java4
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java8
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java8
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java10
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java4
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java2
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java8
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java9
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java2
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java3
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSet.java8
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilter.java14
12 files changed, 33 insertions, 47 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedServlet.java
index e1938cd8..de90fdee 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/FeedServlet.java
@@ -338,15 +338,13 @@ public class FeedServlet extends ProxyServlet {
return;
}
// US DSCDR-19 for DCAE if version is not null, version can't be changed
- if ((oldFeed.getVersion() != null) && (feed.getVersion() != null)) {
- if (!oldFeed.getVersion().equals(feed.getVersion())) {
+ if ((oldFeed.getVersion() != null) && (feed.getVersion() != null) && !oldFeed.getVersion().equals(feed.getVersion())) {
message = "The version of the feed may not be updated.";
elr.setMessage(message);
elr.setResult(HttpServletResponse.SC_BAD_REQUEST);
eventlogger.error(elr.toString());
sendResponseError(resp, HttpServletResponse.SC_BAD_REQUEST, message, eventlogger);
return;
- }
}
/*
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java
index 929c6f90..07fe7372 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java
@@ -101,7 +101,7 @@ public class DeliveryRecord extends BaseLogRecord {
public LOGJSONObject reOrderObject(LOGJSONObject jo) {
- LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();
logrecordObj.put("statusCode", jo.get("statusCode"));
logrecordObj.put("deliveryId", jo.get("deliveryId"));
@@ -116,8 +116,7 @@ public class DeliveryRecord extends BaseLogRecord {
logrecordObj.put("contentLength", jo.get("contentLength"));
- LOGJSONObject newjo = new LOGJSONObject(logrecordObj);
- return newjo;
+ return new LOGJSONObject(logrecordObj);
}
@Override
@@ -127,8 +126,7 @@ public class DeliveryRecord extends BaseLogRecord {
jo.put("deliveryId", user);
jo.put("statusCode", result);
- LOGJSONObject newjo = this.reOrderObject(jo);
- return newjo;
+ return this.reOrderObject(jo);
}
@Override
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java
index 9e6987a5..8e841e68 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java
@@ -100,7 +100,7 @@ public class ExpiryRecord extends BaseLogRecord {
}
public LOGJSONObject reOrderObject(LOGJSONObject jo) {
- LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();
logrecordObj.put("expiryReason", jo.get("expiryReason"));
logrecordObj.put("publishId", jo.get("publishId"));
@@ -112,8 +112,7 @@ public class ExpiryRecord extends BaseLogRecord {
logrecordObj.put("date", jo.get("date"));
logrecordObj.put("contentLength", jo.get("contentLength"));
- LOGJSONObject newjo = new LOGJSONObject(logrecordObj);
- return newjo;
+ return new LOGJSONObject(logrecordObj);
}
@Override
@@ -123,8 +122,7 @@ public class ExpiryRecord extends BaseLogRecord {
jo.put("expiryReason", reason);
jo.put("attempts", attempts);
- LOGJSONObject newjo = this.reOrderObject(jo);
- return newjo;
+ return this.reOrderObject(jo);
}
@Override
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java
index 1cfd0f6b..3462e234 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java
@@ -162,7 +162,7 @@ public class Feed extends Syncable {
}
public static Collection<Feed> getAllFeeds() {
- Map<Integer, Feed> map = new HashMap<Integer, Feed>();
+ Map<Integer, Feed> map = new HashMap<>();
try {
DB db = new DB();
@SuppressWarnings("resource")
@@ -208,7 +208,7 @@ public class Feed extends Syncable {
}
public static List<String> getFilteredFeedUrlList(final String name, final String val) {
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
String sql = "select SELF_LINK from FEEDS where DELETED = 0";
if (name.equals("name")) {
sql += " and NAME = ?";
@@ -329,10 +329,8 @@ public class Feed extends Syncable {
this.groupid = jo.optInt("groupid");
this.name = jo.getString("name");
this.aaf_instance = jo.optString("aaf_instance", "legacy");
- if(!(aaf_instance.equalsIgnoreCase("legacy"))){
- if (aaf_instance.length() > 255){
+ if(!(aaf_instance.equalsIgnoreCase("legacy")) && aaf_instance.length() > 255){
throw new InvalidObjectException("aaf_instance field is too long");
- }
}
if (name.length() > 255)
throw new InvalidObjectException("name field is too long");
@@ -365,7 +363,7 @@ public class Feed extends Syncable {
throw new InvalidObjectException("password field is too long ("+ fid.getPassword()+")"); //Fortify scan fixes - Privacy Violation
this.authorization.getEndpoint_ids().add(fid);
}
- if (this.authorization.getEndpoint_ids().size() < 1)
+ if (this.authorization.getEndpoint_ids().isEmpty())
throw new InvalidObjectException("need to specify at least one endpoint_id");
endPointIds = jauth.getJSONArray("endpoint_addrs");
for (int i = 0; i < endPointIds.length(); i++) {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
index a7213e09..4d901633 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
@@ -44,8 +44,8 @@ public class FeedAuthorization implements JSONable {
public FeedAuthorization() {
this.classification = "";
- this.endpoint_ids = new HashSet<FeedEndpointID>();
- this.endpoint_addrs = new HashSet<String>();
+ this.endpoint_ids = new HashSet<>();
+ this.endpoint_addrs = new HashSet<>();
}
public String getClassification() {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java
index 77726bb4..0e885e5f 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java
@@ -45,7 +45,7 @@ public class FeedLinks implements JSONable {
self = publish = subscribe = log = null;
}
- public FeedLinks(JSONObject jo) throws InvalidObjectException {
+ public FeedLinks(JSONObject jo) {
this();
self = jo.getString("self");
publish = jo.getString("publish");
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java
index 4d6b0ee2..d05e3e6b 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java
@@ -121,7 +121,7 @@ public class Group extends Syncable {
gup.getName()
);
List<Group> list = getGroupsForSQL(sql);
- return list.size() > 0 ? list.get(0) : null;
+ return !list.isEmpty() ? list.get(0) : null;
}
public static Group getGroupMatching(Group gup, int groupid) {
@@ -131,19 +131,19 @@ public class Group extends Syncable {
gup.getGroupid()
);
List<Group> list = getGroupsForSQL(sql);
- return list.size() > 0 ? list.get(0) : null;
+ return !list.isEmpty() ? list.get(0) : null;
}
public static Group getGroupById(int id) {
String sql = "select * from GROUPS where GROUPID = " + id;
List<Group> list = getGroupsForSQL(sql);
- return list.size() > 0 ? list.get(0) : null;
+ return !list.isEmpty() ? list.get(0) : null;
}
static Group getGroupByAuthId(String id) {
String sql = "select * from GROUPS where AUTHID = '" + id + "'";
List<Group> list = getGroupsForSQL(sql);
- return list.size() > 0 ? list.get(0) : null;
+ return !list.isEmpty() ? list.get(0) : null;
}
public static Collection<Group> getAllgroups() {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java
index 5e16bac8..72ad8af0 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java
@@ -109,7 +109,7 @@ public class PublishRecord extends BaseLogRecord {
public LOGJSONObject reOrderObject(LOGJSONObject jo) {
- LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();
logrecordObj.put("statusCode", jo.get("statusCode"));
@@ -124,8 +124,7 @@ public class PublishRecord extends BaseLogRecord {
logrecordObj.put("contentLength", jo.get("contentLength"));
logrecordObj.put("fileName", jo.get("fileName"));
- LOGJSONObject newjo = new LOGJSONObject(logrecordObj);
- return newjo;
+ return new LOGJSONObject(logrecordObj);
}
@Override
@@ -140,9 +139,7 @@ public class PublishRecord extends BaseLogRecord {
jo.put("statusCode", status);
jo.put("fileName", fileName);
- LOGJSONObject newjo = this.reOrderObject(jo);
-
- return newjo;
+ return this.reOrderObject(jo);
}
@Override
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java
index d3f82e6e..e8ef8393 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java
@@ -44,7 +44,7 @@ public class SubLinks implements JSONable {
self = feed = log = null;
}
- public SubLinks(JSONObject jo) throws InvalidObjectException {
+ public SubLinks(JSONObject jo) {
this();
self = jo.getString("self");
feed = jo.getString("feed");
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 1cb1f2bb..0b07a5d9 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
@@ -236,8 +236,7 @@ public class Subscription extends Syncable {
this.feedid = jo.optInt(FEEDID_KEY, -1);
this.groupid = jo.optInt(GROUPID_KEY, -1); //New field is added - Groups feature Rally:US708115 - 1610
this.aafInstance = jo.optString("aaf_instance", "legacy");
- if(!(aafInstance.equalsIgnoreCase("legacy"))){
- if (aafInstance.length() > 255)
+ if(!(aafInstance.equalsIgnoreCase("legacy")) && aafInstance.length() > 255) {
throw new InvalidObjectException("aaf_instance field is too long");
}
JSONObject jdeli = jo.getJSONObject("delivery");
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSet.java
index bc1919f7..7914c81d 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSet.java
@@ -144,7 +144,7 @@ public class RLEBitSet {
* Creates a new bit set. All bits are initially <code>false</code>.
*/
public RLEBitSet() {
- bitsets = new TreeSet<RLE>();
+ bitsets = new TreeSet<>();
}
/**
@@ -153,7 +153,7 @@ public class RLEBitSet {
* @param s the initialization String
*/
public RLEBitSet(String s) {
- bitsets = new TreeSet<RLE>();
+ bitsets = new TreeSet<>();
set(s);
}
@@ -196,7 +196,7 @@ public class RLEBitSet {
* @throws NumberFormatException - if a number is incorrectly formatted
* @throws IndexOutOfBoundsException - if an index is negative
*/
- public void set(String s) throws NumberFormatException {
+ public void set(String s) {
s = s.trim();
if (!s.isEmpty()) {
for (String s2 : s.split("[, \n]+")) {
@@ -280,7 +280,7 @@ public class RLEBitSet {
public void clear(long from, long to) {
checkRange(from, to);
RLE newbits = new RLE(from, to - from);
- List<RLE> newranges = new ArrayList<RLE>();
+ List<RLE> newranges = new ArrayList<>();
synchronized (bitsets) {
for (RLE bs : bitsets) {
if (bs.intersects(newbits)) {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilter.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilter.java
index 5c1fd560..b0fd4f40 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilter.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilter.java
@@ -103,7 +103,7 @@ public class ThrottleFilter extends TimerTask implements Filter {
private static int action = ACTION_DROP; // action to take (throttle or drop)
private static EELFLogger logger = EELFManager.getInstance().getLogger("InternalLog");
- private static Map<String, Counter> map = new HashMap<String, Counter>();
+ private static Map<String, Counter> map = new HashMap<>();
private static final Timer rolex = new Timer();
@Override
@@ -214,13 +214,13 @@ public class ThrottleFilter extends TimerTask implements Filter {
}
}
- private Map<String, List<Continuation>> suspended_requests = new HashMap<String, List<Continuation>>();
+ private Map<String, List<Continuation>> suspended_requests = new HashMap<>();
private void register(String id, Continuation continuation) {
synchronized (suspended_requests) {
List<Continuation> list = suspended_requests.get(id);
if (list == null) {
- list = new ArrayList<Continuation>();
+ list = new ArrayList<>();
suspended_requests.put(id, list);
}
list.add(continuation);
@@ -258,13 +258,12 @@ public class ThrottleFilter extends TimerTask implements Filter {
cnt = new Counter();
map.put(key, cnt);
}
- int n = cnt.getRequestRate();
- return n;
+ return cnt.getRequestRate();
}
}
public class Counter {
- private List<Long> times = new Vector<Long>(); // a record of request times
+ private List<Long> times = new Vector<>(); // a record of request times
public int prune() {
try {
@@ -302,8 +301,7 @@ public class ThrottleFilter extends TimerTask implements Filter {
if (ix < 0 || ix == path.length() - 1)
return -2;
try {
- int feedid = Integer.parseInt(path.substring(0, ix));
- return feedid;
+ return Integer.parseInt(path.substring(0, ix));
} catch (NumberFormatException e) {
return -1;
}