aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'datarouter-prov/src/main/java')
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponse.java15
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponseSupplement.java6
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/Authorizer.java10
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/AuthzResource.java8
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java13
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvDataProvider.java12
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecord.java77
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Deleteable.java6
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryExtraRecord.java7
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java22
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java27
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EventLogRecord.java10
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java23
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java309
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java42
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedEndpointID.java4
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java20
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java68
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java87
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Insertable.java5
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java53
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java45
-rwxr-xr-xdatarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java49
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Parameters.java39
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PubFailRecord.java6
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java31
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubDelivery.java28
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java23
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java136
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Syncable.java11
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Updateable.java7
31 files changed, 816 insertions, 383 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponse.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponse.java
index e6e8802f..5e21f229 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponse.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponse.java
@@ -20,19 +20,22 @@
* * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* *
******************************************************************************/
+
package org.onap.dmaap.datarouter.authz;
import java.util.List;
/**
* The <code>AuthorizationResponse</code> interface gives the caller access to information about an authorization
- * decision. This information includes the permit/deny decision itself, along with supplementary information in the form of
- * advice and obligations. (The advice and obligations will not be used in Data Router R1.)
+ * decision. This information includes the permit/deny decision itself,
+ * along with supplementary information in the form of advice and obligations.
+ * (The advice and obligations will not be used in Data Router R1.)
*
* @author J. F. Lucas
*
*/
public interface AuthorizationResponse {
+
/**
* Indicates whether the request is authorized or not.
*
@@ -43,16 +46,16 @@ public interface AuthorizationResponse {
/**
* Returns any advice elements that were included in the authorization response.
*
- * @return A list of objects implementing the <code>AuthorizationResponseSupplement</code> interface, with each object representing an
- * advice element from the authorization response.
+ * @return A list of objects implementing the <code>AuthorizationResponseSupplement</code> interface,
+ * each representing an advice element from the authorization response.
*/
public List<AuthorizationResponseSupplement> getAdvice();
/**
* Returns any obligation elements that were included in the authorization response.
*
- * @return A list of objects implementing the <code>AuthorizationResponseSupplement</code> interface, with each object representing an
- * obligation element from the authorization response.
+ * @return A list of objects implementing the <code>AuthorizationResponseSupplement</code> interface,
+ * each representing an obligation element from the authorization response.
*/
public List<AuthorizationResponseSupplement> getObligations();
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponseSupplement.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponseSupplement.java
index 6e956334..2bf0d517 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponseSupplement.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponseSupplement.java
@@ -29,14 +29,16 @@ import java.util.Map;
/** An object that meets the <code>AuthorizationResponseSupplement</code> interface carries supplementary
* information for an authorization response. In a XACML-based system, a response to an authorization request
* carries not just the permit/deny decision but, optionally, supplemental information in the form of advice and
- * obligation elements. The structure of a XACML advice element and a XACML obligation element are similar: each has an identifier and
- * a set of attributes (name-value) pairs. (The difference between a XACML advice element and a XACML obligation element is in
+ * obligation elements. The structure of a XACML advice element and a XACML obligation element are similar:
+ * each has an identifier and a set of attributes (name-value) pairs.
+ * (The difference between a XACML advice element and a XACML obligation element is in
* how the recipient of the response--the Policy Enforcement Point, in XACML terminology--handles the element.)
*
* @author J. F. Lucas
*
*/
public interface AuthorizationResponseSupplement {
+
/** Return the identifier for the supplementary information element.
*
* @return a <code>String</code> containing the identifier.
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/Authorizer.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/Authorizer.java
index d6944e56..c932f915 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/Authorizer.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/Authorizer.java
@@ -31,7 +31,7 @@ import javax.servlet.http.HttpServletRequest;
* A Data Router API that requires authorization of incoming requests creates an instance of a class that implements
* the <code>Authorizer</code> interface. The class implements all of the logic necessary to determine if an API
* request is permitted. In Data Router R1, the classes that implement the <code>Authorizer</code> interface will have
- * local logic that makes the authorization decision. After R1, these classes will instead have logic that creates XACML
+ * local logic that makes the authorization decision. After R1,these classes will instead have logic that creates XACML
* authorization requests, sends these requests to a Policy Decision Point (PDP), and parses the XACML responses.
*
* @author J. F. Lucas
@@ -49,14 +49,14 @@ public interface Authorizer {
public AuthorizationResponse decide(HttpServletRequest request);
/**
- * Determine if the API request carried in the <code>request</code> parameter, with additional attributes provided in
+ * Determine if the API request carried in the <code>request</code> parameter,with additional attributes provided in
* the <code>additionalAttrs</code> parameter, is permitted.
*
* @param request the HTTP request for which an authorization decision is needed
- * @param additionalAttrs additional attributes that the <code>Authorizer</code> can in making an authorization decision
+ * @param additionalAttrs additional attributes that the <code>Authorizer</code> can in making a decision
* @return an object implementing the <code>AuthorizationResponse</code> interface. This object includes the
- * permit/deny decision for the request and (after R1) supplemental information related to the response in the form
- * of advice and obligations.
+ * permit/deny decision for the request and (after R1) supplemental information related to the response
+ * in the form of advice and obligations.
*/
public AuthorizationResponse decide(HttpServletRequest request, Map<String,String> additionalAttrs);
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/AuthzResource.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/AuthzResource.java
index c248468f..45c2286a 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/AuthzResource.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/AuthzResource.java
@@ -55,11 +55,11 @@ public class AuthzResource {
AuthzResource(String requestUri) {
if (requestUri != null) {
for (ResourceType t : ResourceType.values()) {
- Matcher m = t.getPattern().matcher(requestUri);
- if (m.find(0)) {
+ Matcher match = t.getPattern().matcher(requestUri);
+ if (match.find(0)) {
this.type = t;
- if (m.group("id") != null) {
- this.id = m.group("id");
+ if (match.group("id") != null) {
+ this.id = match.group("id");
}
break;
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java
index 595b626c..761df097 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java
@@ -42,7 +42,8 @@ public class ProvAuthorizer implements Authorizer {
private ProvDataProvider provData;
private static final String SUBJECT_HEADER = "X-DMAAP-DR-ON-BEHALF-OF"; // HTTP header carrying requester identity
- private static final String SUBJECT_HEADER_GROUP = "X-DMAAP-DR-ON-BEHALF-OF-GROUP"; // HTTP header carrying requester identity by group Rally : US708115
+ // HTTP header carrying requester identity by group Rally : US708115
+ private static final String SUBJECT_HEADER_GROUP = "X-DMAAP-DR-ON-BEHALF-OF-GROUP";
/** Constructor. For the moment, do nothing special. Make it a singleton?
*
@@ -66,11 +67,11 @@ public class ProvAuthorizer implements Authorizer {
}
/**
- * Determine if the API request carried in the <code>request</code> parameter, with additional attributes provided in
+ * Determine if the API request carried in the <code>request</code> parameter,with additional attributes provided in
* the <code>additionalAttrs</code> parameter, is permitted. <code>additionalAttrs</code> isn't used in R1.
*
* @param request the HTTP request for which an authorization decision is needed
- * @param additionalAttrs additional attributes that the <code>Authorizer</code> can in making an authorization decision
+ * @param additionalAttrs additional attributes that the <code>Authorizer</code> can in making a decision
* @return an object implementing the <code>AuthorizationResponse</code> interface. This object includes the
* permit/deny decision for the request and (after R1) supplemental information related to the response in the form
* of advice and obligations.
@@ -128,7 +129,8 @@ public class ProvAuthorizer implements Authorizer {
private boolean allowFeedAccess(AuthzResource resource, String method, String subject, String subjectgroup) {
boolean decision = false;
// Allow GET, PUT, or DELETE if requester (subject) is the owner (publisher) of the feed
- if ( method != null && ("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method) || "DELETE".equalsIgnoreCase(method))) {
+ if ( method != null && ("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method)
+ || "DELETE".equalsIgnoreCase(method))) {
String owner = provData.getFeedOwner(resource.getId());
decision = (owner != null) && owner.equals(subject);
@@ -145,7 +147,8 @@ public class ProvAuthorizer implements Authorizer {
boolean decision = false;
// Allow GET, PUT, or DELETE if requester (subject) is the owner of the subscription (subscriber)
- if (method != null && ("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method) || "DELETE".equalsIgnoreCase(method) || "POST".equalsIgnoreCase(method))) {
+ if (method != null && ("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method)
+ || "DELETE".equalsIgnoreCase(method) || "POST".equalsIgnoreCase(method))) {
String owner = provData.getSubscriptionOwner(resource.getId());
decision = (owner != null) && owner.equals(subject);
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvDataProvider.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvDataProvider.java
index dca348a0..0e8e2066 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvDataProvider.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvDataProvider.java
@@ -20,6 +20,7 @@
* * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* *
******************************************************************************/
+
package org.onap.dmaap.datarouter.authz.impl;
/** Interface to access data about subscriptions and feeds. A software component that
@@ -43,23 +44,24 @@ public interface ProvDataProvider {
*/
public String getFeedClassification(String feedId);
- /** Get the identity of the owner of a feed
+ /** Get the identity of the owner of a feed.
*
* @param subId the ID of the subscripition whose owner is being looked up.
* @return the subscription owner's identity.
*/
public String getSubscriptionOwner(String subId);
- /** Get the identity of the owner of a feed by group id - Rally : US708115
+ /** Get the identity of the owner of a feed by group id - Rally : US708115.
*
- * @param feedId, user the ID of the feed whose owner is being looked up.
+ * @param feedId user the ID of the feed whose owner is being looked up.
* @return the feed owner's identity by group.
*/
public String getGroupByFeedGroupId(String owner, String feedId);
- /** Get the identity of the owner of a sub by group id Rally : US708115
+ /** Get the identity of the owner of a sub by group id Rally : US708115.
+ *
+ * @param subId user the ID of the feed whose owner is being looked up.
*
- * @param subId, user the ID of the feed whose owner is being looked up.
* @return the feed owner's identity by group.
*/
public String getGroupBySubGroupId(String owner, String subId);
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecord.java
index 8534bc03..8cb4c153 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecord.java
@@ -53,13 +53,9 @@ public class BaseLogRecord implements LOGJSONable, Loadable {
private long contentLength;
protected BaseLogRecord(String[] pp) throws ParseException {
-// This throws exceptions occasionally - don't know why.
-// Date d = null;
-// synchronized (sdf) {
-// d = sdf.parse(pp[0]);
-// }
- Date d = parseDate(pp[0]);
- this.eventTime = d.getTime();
+
+ Date dt = parseDate(pp[0]);
+ this.eventTime = dt.getTime();
this.publishId = pp[2];
this.feedid = Integer.parseInt(pp[3]);
if (pp[1].equals("DLX")) {
@@ -79,6 +75,7 @@ public class BaseLogRecord implements LOGJSONable, Loadable {
this.contentLength = Long.parseLong(pp[8]);
}
}
+
protected BaseLogRecord(ResultSet rs) throws SQLException {
this.eventTime = rs.getLong("EVENT_TIME");
this.publishId = rs.getString("PUBLISH_ID");
@@ -88,81 +85,99 @@ public class BaseLogRecord implements LOGJSONable, Loadable {
this.contentType = rs.getString("CONTENT_TYPE");
this.contentLength = rs.getLong("CONTENT_LENGTH");
}
- protected Date parseDate(final String s) throws ParseException {
- int[] n = new int[7];
- int p = 0;
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c < '0' || c > '9') {
- p++;
+
+ protected Date parseDate(final String str) throws ParseException {
+ int[] num = new int[7];
+ int place = 0;
+ for (int i = 0; i < str.length(); i++) {
+ char chr = str.charAt(i);
+ if (chr < '0' || chr > '9') {
+ place++;
} else {
- if (p > n.length)
+ if (place > num.length) {
throw new ParseException("parseDate()", 0);
- n[p] = (n[p] * 10) + (c - '0');
+ }
+ num[place] = (num[place] * 10) + (chr - '0');
}
}
- if (p != 7)
+ if (place != 7) {
throw new ParseException("parseDate()", 1);
+ }
Calendar cal = new GregorianCalendar();
- cal.set(Calendar.YEAR, n[0]);
- cal.set(Calendar.MONTH, n[1]-1);
- cal.set(Calendar.DAY_OF_MONTH, n[2]);
- cal.set(Calendar.HOUR_OF_DAY, n[3]);
- cal.set(Calendar.MINUTE, n[4]);
- cal.set(Calendar.SECOND, n[5]);
- cal.set(Calendar.MILLISECOND, n[6]);
+ cal.set(Calendar.YEAR, num[0]);
+ cal.set(Calendar.MONTH, num[1] - 1);
+ cal.set(Calendar.DAY_OF_MONTH, num[2]);
+ cal.set(Calendar.HOUR_OF_DAY, num[3]);
+ cal.set(Calendar.MINUTE, num[4]);
+ cal.set(Calendar.SECOND, num[5]);
+ cal.set(Calendar.MILLISECOND, num[6]);
return cal.getTime();
}
+
public long getEventTime() {
return eventTime;
}
+
public void setEventTime(long eventTime) {
this.eventTime = eventTime;
}
+
public String getPublishId() {
return publishId;
}
+
public void setPublishId(String publishId) {
this.publishId = publishId;
}
+
public int getFeedid() {
return feedid;
}
+
public void setFeedid(int feedid) {
this.feedid = feedid;
}
+
public String getRequestUri() {
return requestUri;
}
+
public void setRequestUri(String requestUri) {
this.requestUri = requestUri;
}
+
public String getMethod() {
return method;
}
+
public void setMethod(String method) {
this.method = method;
}
+
public String getContentType() {
return contentType;
}
+
public void setContentType(String contentType) {
this.contentType = contentType;
}
+
public long getContentLength() {
return contentLength;
}
+
public void setContentLength(long contentLength) {
this.contentLength = contentLength;
}
+
@Override
public LOGJSONObject asJSONObject() {
LOGJSONObject jo = new LOGJSONObject();
- String t = "";
+ String str = "";
synchronized (sdf) {
- t = sdf.format(eventTime);
+ str = sdf.format(eventTime);
}
- jo.put("date", t);
+ jo.put("date", str);
jo.put("publishId", publishId);
jo.put("requestURI", requestUri);
jo.put("method", method);
@@ -172,14 +187,16 @@ public class BaseLogRecord implements LOGJSONable, Loadable {
}
return jo;
}
+
@Override
public void load(PreparedStatement ps) throws SQLException {
- ps.setLong (2, getEventTime());
+ ps.setLong(2, getEventTime());
ps.setString(3, getPublishId());
- ps.setInt (4, getFeedid());
+ ps.setInt(4, getFeedid());
ps.setString(5, getRequestUri());
ps.setString(6, getMethod());
ps.setString(7, getContentType());
- ps.setLong (8, getContentLength());
+ ps.setLong(8, getContentLength());
}
}
+
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Deleteable.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Deleteable.java
index a485312c..6910e0d7 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Deleteable.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Deleteable.java
@@ -25,17 +25,17 @@
package org.onap.dmaap.datarouter.provisioning.beans;
import java.sql.Connection;
-
/**
* An object that can be DELETE-ed from the database.
* @author Robert Eby
* @version $Id: Deleteable.java,v 1.2 2013/05/29 14:44:36 eby Exp $
*/
+
public interface Deleteable {
/**
* Delete this object in the DB.
- * @param c the JDBC Connection to use
+ * @param conn the JDBC Connection to use
* @return true if the DELETE succeeded, false otherwise
*/
- public boolean doDelete(Connection c);
+ public boolean doDelete(Connection conn);
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryExtraRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryExtraRecord.java
index 0a5258e2..4a26a9f6 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryExtraRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryExtraRecord.java
@@ -38,6 +38,11 @@ public class DeliveryExtraRecord extends BaseLogRecord {
private int subid;
private long contentLength2;
+ /**
+ * DLX constructor.
+ * @param pp string array of DXL attributes
+ * @throws ParseException in case of parse error
+ */
public DeliveryExtraRecord(String[] pp) throws ParseException {
super(pp);
this.subid = Integer.parseInt(pp[4]);
@@ -52,7 +57,7 @@ public class DeliveryExtraRecord extends BaseLogRecord {
ps.setNull(10, Types.VARCHAR);
ps.setNull(11, Types.VARCHAR);
ps.setNull(12, Types.INTEGER);
- ps.setInt (13, subid);
+ ps.setInt(13, subid);
ps.setNull(14, Types.VARCHAR);
ps.setNull(15, Types.INTEGER);
ps.setNull(16, Types.INTEGER);
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 07fe7372..0bce4910 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
@@ -46,19 +46,31 @@ public class DeliveryRecord extends BaseLogRecord {
private int result;
private String user;
+ /**
+ * Constructor for DeliverRecord.
+ * @param pp string array of DeliverRecord attributes
+ * @throws ParseException in case of parse error
+ */
public DeliveryRecord(String[] pp) throws ParseException {
super(pp);
String fileid = pp[5];
- if (fileid.lastIndexOf('/') >= 0)
+ if (fileid.lastIndexOf('/') >= 0) {
fileid = fileid.substring(fileid.lastIndexOf('/') + 1);
+ }
this.subid = Integer.parseInt(pp[4]);
this.fileid = fileid;
this.result = Integer.parseInt(pp[10]);
this.user = pp[9];
- if (this.user != null && this.user.length() > 50)
+ if (this.user != null && this.user.length() > 50) {
this.user = this.user.substring(0, 50);
+ }
}
+ /**
+ * DeliverRecord constructor from ResultSet.
+ * @param rs ResultSet
+ * @throws SQLException in case of get error from SQL statement
+ */
public DeliveryRecord(ResultSet rs) throws SQLException {
super(rs);
this.subid = rs.getInt("DELIVERY_SUBID");
@@ -99,7 +111,11 @@ public class DeliveryRecord extends BaseLogRecord {
this.user = user;
}
-
+ /**
+ * Method to reorder LOGJSONObject.
+ * @param jo LOGJSONObject
+ * @return new LOGJSONObject
+ */
public LOGJSONObject reOrderObject(LOGJSONObject jo) {
LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java
index a78a9c18..54d5b39f 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java
@@ -49,6 +49,11 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
private final int subid;
private final int nodeid;
+ /**
+ * EgressRoute constructor.
+ * @param subid subscription id
+ * @param nodeid node id
+ */
public EgressRoute(int subid, int nodeid) {
this.subid = subid;
this.nodeid = nodeid;
@@ -101,7 +106,7 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
* @return an EgressRoute, or null if there is no route for this subscription
*/
public static EgressRoute getEgressRoute(int sub) {
- EgressRoute v = null;
+ EgressRoute er = null;
DB db = new DB();
String sql = "select NODEID from EGRESS_ROUTES where SUBID = ?";
try (Connection conn = db.getConnection();
@@ -110,7 +115,7 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
int node = rs.getInt("NODEID");
- v = new EgressRoute(sub, node);
+ er = new EgressRoute(sub, node);
}
} finally {
db.release(conn);
@@ -118,14 +123,14 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
} catch (SQLException e) {
intlogger.error("PROV0009 EgressRoute.getEgressRoute: " + e.getMessage(), e);
}
- return v;
+ return er;
}
@Override
- public boolean doDelete(Connection c) {
+ public boolean doDelete(Connection conn) {
boolean rv = true;
String sql = "delete from EGRESS_ROUTES where SUBID = ?";
- try (PreparedStatement ps = c.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, subid);
ps.execute();
} catch (SQLException e) {
@@ -136,10 +141,10 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
}
@Override
- public boolean doInsert(Connection c) {
+ public boolean doInsert(Connection conn) {
boolean rv = false;
String sql = "insert into EGRESS_ROUTES (SUBID, NODEID) values (?, ?)";
- try (PreparedStatement ps = c.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
// Create the NETWORK_ROUTES row
ps.setInt(1, this.subid);
ps.setInt(2, this.nodeid);
@@ -153,10 +158,10 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
}
@Override
- public boolean doUpdate(Connection c) {
+ public boolean doUpdate(Connection conn) {
boolean rv = true;
String sql = "update EGRESS_ROUTES set NODEID = ? where SUBID = ?";
- try (PreparedStatement ps = c.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, nodeid);
ps.setInt(2, subid);
ps.executeUpdate();
@@ -189,8 +194,8 @@ public class EgressRoute extends NodeClass implements Comparable<EgressRoute> {
}
@Override
- public int compareTo(EgressRoute o) {
- return this.subid - o.subid;
+ public int compareTo(EgressRoute er) {
+ return this.subid - er.subid;
}
@Override
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EventLogRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EventLogRecord.java
index ce03f59a..cfdda917 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EventLogRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EventLogRecord.java
@@ -49,12 +49,16 @@ public class EventLogRecord {
private int result; // How
private String message;
+ /**
+ * EventLogRecord constructor.
+ * @param request HTTP Request
+ */
public EventLogRecord(HttpServletRequest request) {
// Who is making the request
this.ipaddr = request.getRemoteAddr();
- String s = request.getHeader(BaseServlet.BEHALF_HEADER);
- this.behalfof = (s != null) ? s : "";
- X509Certificate certs[] = (X509Certificate[]) request.getAttribute(BaseServlet.CERT_ATTRIBUTE);
+ String str = request.getHeader(BaseServlet.BEHALF_HEADER);
+ this.behalfof = (str != null) ? str : "";
+ X509Certificate [] certs = (X509Certificate[]) request.getAttribute(BaseServlet.CERT_ATTRIBUTE);
this.clientSubject = (certs != null && certs.length > 0)
? certs[0].getSubjectX500Principal().getName() : "";
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 8e841e68..d812036a 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
@@ -46,19 +46,31 @@ public class ExpiryRecord extends BaseLogRecord {
private int attempts;
private String reason;
+ /**
+ * ExpiryRecord constructor.
+ * @param pp string array of ExpiryRecord attributes
+ * @throws ParseException in case of parse error
+ */
public ExpiryRecord(String[] pp) throws ParseException {
super(pp);
String fileid = pp[5];
- if (fileid.lastIndexOf('/') >= 0)
+ if (fileid.lastIndexOf('/') >= 0) {
fileid = fileid.substring(fileid.lastIndexOf('/') + 1);
+ }
this.subid = Integer.parseInt(pp[4]);
this.fileid = fileid;
this.attempts = Integer.parseInt(pp[10]);
this.reason = pp[9];
- if (!reason.equals("notRetryable") && !reason.equals("retriesExhausted") && !reason.equals("diskFull"))
+ if (!reason.equals("notRetryable") && !reason.equals("retriesExhausted") && !reason.equals("diskFull")) {
this.reason = "other";
+ }
}
+ /**
+ * ExpiryRecord constructor from ResultSet.
+ * @param rs ResultSet of ExpiryREcord attributes
+ * @throws SQLException in case of error with SQL statement
+ */
public ExpiryRecord(ResultSet rs) throws SQLException {
super(rs);
this.subid = rs.getInt("DELIVERY_SUBID");
@@ -99,6 +111,11 @@ public class ExpiryRecord extends BaseLogRecord {
this.reason = reason;
}
+ /**
+ * Method to reorder LOGJSONObject.
+ * @param jo LOGJSONObject
+ * @return LOGJSONObject
+ */
public LOGJSONObject reOrderObject(LOGJSONObject jo) {
LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();
@@ -122,7 +139,7 @@ public class ExpiryRecord extends BaseLogRecord {
jo.put("expiryReason", reason);
jo.put("attempts", attempts);
- return this.reOrderObject(jo);
+ return 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 3462e234..a8be6b3f 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
@@ -26,6 +26,19 @@ package org.onap.dmaap.datarouter.provisioning.beans;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import java.io.InvalidObjectException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -33,10 +46,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.onap.dmaap.datarouter.provisioning.utils.JSONUtilities;
import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
-import java.io.InvalidObjectException;
-import java.sql.*;
-import java.util.Date;
-import java.util.*;
+
/**
* The representation of a Feed. Feeds can be retrieved from the DB, or stored/updated in the DB.
@@ -45,6 +55,7 @@ import java.util.*;
* @version $Id: Feed.java,v 1.13 2013/10/28 18:06:52 eby Exp $
*/
public class Feed extends Syncable {
+
private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog");
private static int next_feedid = getMaxFeedID() + 1;
private static final String SQLEXCEPTION = "SQLException: ";
@@ -54,15 +65,15 @@ public class Feed extends Syncable {
private String name;
private String version;
private String description;
- private String business_description; // New field is added - Groups feature Rally:US708102 - 1610
+ private String businessDescription; // New field is added - Groups feature Rally:US708102 - 1610
private FeedAuthorization authorization;
private String publisher;
private FeedLinks links;
private boolean deleted;
private boolean suspended;
- private Date last_mod;
- private Date created_date;
- private String aaf_instance;
+ private Date lastMod;
+ private Date createdDate;
+ private String aafInstance;
/**
* Check if a feed ID is valid.
@@ -76,9 +87,9 @@ public class Feed extends Syncable {
try {
DB db = new DB();
Connection conn = db.getConnection();
- try(PreparedStatement stmt = conn.prepareStatement("select COUNT(*) from FEEDS where FEEDID = ?")) {
+ try (PreparedStatement stmt = conn.prepareStatement("select COUNT(*) from FEEDS where FEEDID = ?")) {
stmt.setInt(1, id);
- try(ResultSet rs = stmt.executeQuery()) {
+ try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
count = rs.getInt(1);
}
@@ -125,9 +136,8 @@ public class Feed extends Syncable {
int count = 0;
try {
DB db = new DB();
- @SuppressWarnings("resource")
- Connection conn = db.getConnection();
- try(Statement stmt = conn.createStatement()) {
+ @SuppressWarnings("resource") Connection conn = db.getConnection();
+ try (Statement stmt = conn.createStatement()) {
try (ResultSet rs = stmt.executeQuery("select count(*) from FEEDS where DELETED = 0")) {
if (rs.next()) {
count = rs.getInt(1);
@@ -141,13 +151,17 @@ public class Feed extends Syncable {
return count;
}
+ /**
+ * Method to get max feed id.
+ * @return int max feed id
+ */
public static int getMaxFeedID() {
int max = 0;
try {
DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try(Statement stmt = conn.createStatement()) {
+ try (Statement stmt = conn.createStatement()) {
try (ResultSet rs = stmt.executeQuery("select MAX(feedid) from FEEDS")) {
if (rs.next()) {
max = rs.getInt(1);
@@ -161,14 +175,18 @@ public class Feed extends Syncable {
return max;
}
+ /**
+ * Gets all feeds.
+ * @return Collection of feeds
+ */
public static Collection<Feed> getAllFeeds() {
Map<Integer, Feed> map = new HashMap<>();
try {
DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try(Statement stmt = conn.createStatement()) {
- try(ResultSet rs = stmt.executeQuery("select * from FEEDS")) {
+ try (Statement stmt = conn.createStatement()) {
+ try (ResultSet rs = stmt.executeQuery("select * from FEEDS")) {
while (rs.next()) {
Feed feed = new Feed(rs);
map.put(feed.getFeedid(), feed);
@@ -176,7 +194,7 @@ public class Feed extends Syncable {
}
String sql = "select * from FEED_ENDPOINT_IDS";
- try(ResultSet rs = stmt.executeQuery(sql)){
+ try (ResultSet rs = stmt.executeQuery(sql)) {
while (rs.next()) {
int id = rs.getInt("FEEDID");
Feed feed = map.get(id);
@@ -189,7 +207,7 @@ public class Feed extends Syncable {
}
sql = "select * from FEED_ENDPOINT_ADDRS";
- try(ResultSet rs = stmt.executeQuery(sql)) {
+ try (ResultSet rs = stmt.executeQuery(sql)) {
while (rs.next()) {
int id = rs.getInt("FEEDID");
Feed feed = map.get(id);
@@ -207,6 +225,12 @@ public class Feed extends Syncable {
return map.values();
}
+ /**
+ * Get Feed URL list.
+ * @param name of Feed
+ * @param val of feed
+ * @return List of feed names
+ */
public static List<String> getFilteredFeedUrlList(final String name, final String val) {
List<String> list = new ArrayList<>();
String sql = "select SELF_LINK from FEEDS where DELETED = 0";
@@ -215,22 +239,23 @@ public class Feed extends Syncable {
} else if (name.equals("publ")) {
sql += " and PUBLISHER = ?";
} else if (name.equals("subs")) {
- sql = "select distinct FEEDS.SELF_LINK from FEEDS, SUBSCRIPTIONS " +
- "where DELETED = 0 " +
- "and FEEDS.FEEDID = SUBSCRIPTIONS.FEEDID " +
- "and SUBSCRIPTIONS.SUBSCRIBER = ?";
+ sql = "select distinct FEEDS.SELF_LINK from FEEDS, SUBSCRIPTIONS "
+ + "where DELETED = 0 "
+ + "and FEEDS.FEEDID = SUBSCRIPTIONS.FEEDID "
+ + "and SUBSCRIPTIONS.SUBSCRIBER = ?";
}
try {
DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
- try(PreparedStatement ps = conn.prepareStatement(sql)) {
- if (sql.indexOf('?') >= 0)
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
+ if (sql.indexOf('?') >= 0) {
ps.setString(1, val);
- try(ResultSet rs = ps.executeQuery()) {
+ }
+ try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
- String t = rs.getString(1);
- list.add(t.trim());
+ String str = rs.getString(1);
+ list.add(str.trim());
}
}
}
@@ -282,30 +307,44 @@ public class Feed extends Syncable {
this("", "", "", "");
}
- public Feed(String name, String version, String desc, String business_description) {
+ /**
+ * Feed constructor.
+ * @param name feed name
+ * @param version feed version
+ * @param desc feed description
+ * @param businessDescription feed business description
+ */
+ public Feed(String name, String version, String desc, String businessDescription) {
this.feedid = -1;
this.groupid = -1; //New field is added - Groups feature Rally:US708115 - 1610
this.name = name;
this.version = version;
this.description = desc;
- this.business_description = business_description; // New field is added - Groups feature Rally:US708102 - 1610
+ this.businessDescription = businessDescription; // New field is added - Groups feature Rally:US708102 - 1610
this.authorization = new FeedAuthorization();
this.publisher = "";
this.links = new FeedLinks();
this.deleted = false;
this.suspended = false;
- this.last_mod = new Date();
- this.created_date = new Date();
- this.aaf_instance = "";
+ this.lastMod = new Date();
+ this.createdDate = new Date();
+ this.aafInstance = "";
}
+ /**
+ * Feed Constructor from ResultSet.
+ * @param rs ResultSet
+ * @throws SQLException in case of SQL statement error
+ */
public Feed(ResultSet rs) throws SQLException {
this.feedid = rs.getInt("FEEDID");
- this.groupid = rs.getInt("GROUPID"); //New field is added - Groups feature Rally:US708115 - 1610
+ //New field is added - Groups feature Rally:US708115 - 1610
+ this.groupid = rs.getInt("GROUPID");
this.name = rs.getString("NAME");
this.version = rs.getString("VERSION");
this.description = rs.getString("DESCRIPTION");
- this.business_description = rs.getString("BUSINESS_DESCRIPTION"); // New field is added - Groups feature Rally:US708102 - 1610
+ // New field is added - Groups feature Rally:US708102 - 1610
+ this.businessDescription = rs.getString("BUSINESS_DESCRIPTION");
this.authorization = new FeedAuthorization();
this.authorization.setClassification(rs.getString("AUTH_CLASS"));
this.publisher = rs.getString("PUBLISHER");
@@ -316,11 +355,16 @@ public class Feed extends Syncable {
this.links.setLog(rs.getString("LOG_LINK"));
this.deleted = rs.getBoolean("DELETED");
this.suspended = rs.getBoolean("SUSPENDED");
- this.last_mod = rs.getDate("LAST_MOD");
- this.created_date = rs.getTimestamp("CREATED_DATE");
- this.aaf_instance = rs.getString("AAF_INSTANCE");
+ this.lastMod = rs.getDate("LAST_MOD");
+ this.createdDate = rs.getTimestamp("CREATED_DATE");
+ this.aafInstance = rs.getString("AAF_INSTANCE");
}
+ /**
+ * Feed constructor from JSONObject.
+ * @param jo JSONObject
+ * @throws InvalidObjectException in case of JSON error
+ */
public Feed(JSONObject jo) throws InvalidObjectException {
this("", "", "", "");
try {
@@ -328,48 +372,58 @@ public class Feed extends Syncable {
this.feedid = jo.optInt("feedid", -1);
this.groupid = jo.optInt("groupid");
this.name = jo.getString("name");
- this.aaf_instance = jo.optString("aaf_instance", "legacy");
- if(!(aaf_instance.equalsIgnoreCase("legacy")) && aaf_instance.length() > 255){
- throw new InvalidObjectException("aaf_instance field is too long");
+ this.aafInstance = jo.optString("aaf_instance", "legacy");
+ if (!(aafInstance.equalsIgnoreCase("legacy")) && aafInstance.length() > 255) {
+ throw new InvalidObjectException("aaf_instance field is too long");
}
- if (name.length() > 255)
+ if (name.length() > 255) {
throw new InvalidObjectException("name field is too long");
+ }
try {
this.version = jo.getString("version");
} catch (JSONException e) {
intlogger.warn("PROV0023 Feed.Feed: " + e.getMessage(), e);
this.version = null;
}
- if(version != null && version.length() > 20)
+ if (version != null && version.length() > 20) {
throw new InvalidObjectException("version field is too long");
+ }
this.description = jo.optString("description");
- this.business_description = jo.optString("business_description");
- if (description.length() > 1000)
+ this.businessDescription = jo.optString("business_description");
+ if (description.length() > 1000) {
throw new InvalidObjectException("technical description field is too long");
- if (business_description.length() > 1000)
+ }
+ if (businessDescription.length() > 1000) {
throw new InvalidObjectException("business description field is too long");
+ }
this.authorization = new FeedAuthorization();
JSONObject jauth = jo.getJSONObject("authorization");
this.authorization.setClassification(jauth.getString("classification"));
- if (this.authorization.getClassification().length() > 32)
+ if (this.authorization.getClassification().length() > 32) {
throw new InvalidObjectException("classification field is too long");
+ }
JSONArray endPointIds = jauth.getJSONArray("endpoint_ids");
for (int i = 0; i < endPointIds.length(); i++) {
JSONObject id = endPointIds.getJSONObject(i);
FeedEndpointID fid = new FeedEndpointID(id.getString("id"), id.getString("password"));
- if (fid.getId().length() > 60)
+ if (fid.getId().length() > 60) {
throw new InvalidObjectException("id field is too long (" + fid.getId() + ")");
- if (fid.getPassword().length() > 32)
- throw new InvalidObjectException("password field is too long ("+ fid.getPassword()+")"); //Fortify scan fixes - Privacy Violation
+ }
+ if (fid.getPassword().length() > 32) {
+ //Fortify scan fixes - Privacy Violation
+ throw new InvalidObjectException("password field is too long (" + fid.getPassword() + ")");
+ }
this.authorization.getEndpoint_ids().add(fid);
}
- if (this.authorization.getEndpoint_ids().isEmpty())
+ 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++) {
String addr = endPointIds.getString(i);
- if (!JSONUtilities.validIPAddrOrSubnet(addr))
+ if (!JSONUtilities.validIPAddrOrSubnet(addr)) {
throw new InvalidObjectException("bad IP addr or subnet mask: " + addr);
+ }
this.authorization.getEndpoint_addrs().add(addr);
}
@@ -390,6 +444,10 @@ public class Feed extends Syncable {
return feedid;
}
+ /**
+ * Set feedid with FeedLinks.
+ * @param feedid Feedid to set to
+ */
public void setFeedid(int feedid) {
this.feedid = feedid;
@@ -402,11 +460,11 @@ public class Feed extends Syncable {
}
public String getAafInstance() {
- return aaf_instance;
+ return aafInstance;
}
- public void setAaf_instance(String aaf_instance) {
- this.aaf_instance = aaf_instance;
+ public void setAaf_instance(String aafInstance) {
+ this.aafInstance = aafInstance;
}
//new getter setters for groups- Rally:US708115 - 1610
@@ -444,11 +502,11 @@ public class Feed extends Syncable {
// New field is added - Groups feature Rally:US708102 - 1610
public String getBusiness_description() {
- return business_description;
+ return businessDescription;
}
- public void setBusiness_description(String business_description) {
- this.business_description = business_description;
+ public void setBusiness_description(String businessDescription) {
+ this.businessDescription = businessDescription;
}
public FeedAuthorization getAuthorization() {
@@ -463,10 +521,15 @@ public class Feed extends Syncable {
return publisher;
}
+ /**
+ * Set publisher.
+ * @param publisher Publisher name
+ */
public void setPublisher(String publisher) {
if (publisher != null) {
- if (publisher.length() > 8)
+ if (publisher.length() > 8) {
publisher = publisher.substring(0, 8);
+ }
this.publisher = publisher;
}
}
@@ -499,31 +562,29 @@ public class Feed extends Syncable {
public JSONObject asJSONObject() {
JSONObject jo = new JSONObject();
jo.put("feedid", feedid);
- jo.put("groupid", groupid); //New field is added - Groups feature Rally:US708115 - 1610
+ //New field is added - Groups feature Rally:US708115 - 1610
+ jo.put("groupid", groupid);
jo.put("name", name);
jo.put("version", version);
jo.put("description", description);
- jo.put("business_description", business_description); // New field is added - Groups feature Rally:US708102 - 1610
+ // New field is added - Groups feature Rally:US708102 - 1610
+ jo.put("business_description", businessDescription);
jo.put("authorization", authorization.asJSONObject());
jo.put("publisher", publisher);
jo.put("links", links.asJSONObject());
jo.put("deleted", deleted);
jo.put("suspend", suspended);
- jo.put("last_mod", last_mod.getTime());
- jo.put("created_date", created_date.getTime());
- jo.put("aaf_instance", aaf_instance);
- return jo;
- }
-
- public JSONObject asLimitedJSONObject() {
- JSONObject jo = asJSONObject();
- jo.remove("deleted");
- jo.remove("feedid");
- jo.remove("last_mod");
- jo.remove("created_date");
+ jo.put("last_mod", lastMod.getTime());
+ jo.put("created_date", createdDate.getTime());
+ jo.put("aaf_instance", aafInstance);
return jo;
}
+ /**
+ * Method to hide some attributes.
+ * @param hidepasswords true/false
+ * @return JSONObject
+ */
public JSONObject asJSONObject(boolean hidepasswords) {
JSONObject jo = asJSONObject();
if (hidepasswords) {
@@ -535,13 +596,28 @@ public class Feed extends Syncable {
return jo;
}
+ /**
+ * Method to limit JSONObject.
+ * @return JSONObject
+ */
+ public JSONObject asLimitedJSONObject() {
+ JSONObject jo = asJSONObject();
+ jo.remove("deleted");
+ jo.remove("feedid");
+ jo.remove("last_mod");
+ jo.remove("created_date");
+ return jo;
+ }
+
+
+
@Override
- public boolean doDelete(Connection c) {
+ public boolean doDelete(Connection conn) {
boolean rv = true;
PreparedStatement ps = null;
try {
String sql = "delete from FEEDS where FEEDID = ?";
- ps = c.prepareStatement(sql);
+ ps = conn.prepareStatement(sql);
ps.setInt(1, feedid);
ps.execute();
} catch (SQLException e) {
@@ -549,7 +625,7 @@ public class Feed extends Syncable {
intlogger.error("PROV0007 doDelete: " + e.getMessage(), e);
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -560,20 +636,21 @@ public class Feed extends Syncable {
}
@Override
- public synchronized boolean doInsert(Connection c) {
+ public synchronized boolean doInsert(Connection conn) {
boolean rv = true;
try {
if (feedid == -1) {
setFeedid(next_feedid++);
}
// In case we insert a feed from synchronization
- if (feedid > next_feedid)
+ if (feedid > next_feedid) {
next_feedid = feedid + 1;
+ }
// Create FEED_ENDPOINT_IDS rows
FeedAuthorization auth = getAuthorization();
String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
- try(PreparedStatement ps2 = c.prepareStatement(sql)) {
+ try (PreparedStatement ps2 = conn.prepareStatement(sql)) {
for (FeedEndpointID fid : auth.getEndpoint_ids()) {
ps2.setInt(1, feedid);
ps2.setString(2, fid.getId());
@@ -584,7 +661,7 @@ public class Feed extends Syncable {
// Create FEED_ENDPOINT_ADDRS rows
sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
- try(PreparedStatement ps2 = c.prepareStatement(sql)) {
+ try (PreparedStatement ps2 = conn.prepareStatement(sql)) {
for (String t : auth.getEndpoint_addrs()) {
ps2.setInt(1, feedid);
ps2.setString(2, t);
@@ -593,8 +670,11 @@ public class Feed extends Syncable {
}
// Finally, create the FEEDS row
- sql = "insert into FEEDS (FEEDID, NAME, VERSION, DESCRIPTION, AUTH_CLASS, PUBLISHER, SELF_LINK, PUBLISH_LINK, SUBSCRIBE_LINK, LOG_LINK, DELETED, SUSPENDED,BUSINESS_DESCRIPTION, GROUPID, AAF_INSTANCE) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
- try(PreparedStatement ps2 = c.prepareStatement(sql)) {
+ sql = "insert into FEEDS (FEEDID, NAME, VERSION, DESCRIPTION, AUTH_CLASS, PUBLISHER, SELF_LINK, "
+ + "PUBLISH_LINK, SUBSCRIBE_LINK, LOG_LINK, DELETED, SUSPENDED,"
+ + "BUSINESS_DESCRIPTION, GROUPID, AAF_INSTANCE) "
+ + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ try (PreparedStatement ps2 = conn.prepareStatement(sql)) {
ps2.setInt(1, feedid);
ps2.setString(2, getName());
ps2.setString(3, getVersion());
@@ -620,7 +700,7 @@ public class Feed extends Syncable {
}
@Override
- public boolean doUpdate(Connection c) {
+ public boolean doUpdate(Connection conn) {
boolean rv = true;
Feed oldobj = getFeedById(feedid);
PreparedStatement ps = null;
@@ -630,7 +710,7 @@ public class Feed extends Syncable {
// Insert new FEED_ENDPOINT_IDS rows
String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
- ps = c.prepareStatement(sql);
+ ps = conn.prepareStatement(sql);
for (FeedEndpointID fid : newset) {
if (!oldset.contains(fid)) {
ps.setInt(1, feedid);
@@ -643,7 +723,7 @@ public class Feed extends Syncable {
// Delete old FEED_ENDPOINT_IDS rows
sql = "delete from FEED_ENDPOINT_IDS where FEEDID = ? AND USERID = ? AND PASSWORD = ?";
- ps = c.prepareStatement(sql);
+ ps = conn.prepareStatement(sql);
for (FeedEndpointID fid : oldset) {
if (!newset.contains(fid)) {
ps.setInt(1, feedid);
@@ -658,7 +738,7 @@ public class Feed extends Syncable {
Set<String> newset2 = getAuthorization().getEndpoint_addrs();
Set<String> oldset2 = oldobj.getAuthorization().getEndpoint_addrs();
sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
- ps = c.prepareStatement(sql);
+ ps = conn.prepareStatement(sql);
for (String t : newset2) {
if (!oldset2.contains(t)) {
ps.setInt(1, feedid);
@@ -670,7 +750,7 @@ public class Feed extends Syncable {
// Delete old FEED_ENDPOINT_ADDRS rows
sql = "delete from FEED_ENDPOINT_ADDRS where FEEDID = ? AND ADDR = ?";
- ps = c.prepareStatement(sql);
+ ps = conn.prepareStatement(sql);
for (String t : oldset2) {
if (!newset2.contains(t)) {
ps.setInt(1, feedid);
@@ -681,8 +761,9 @@ public class Feed extends Syncable {
ps.close();
// Finally, update the FEEDS row
- sql = "update FEEDS set DESCRIPTION = ?, AUTH_CLASS = ?, DELETED = ?, SUSPENDED = ?, BUSINESS_DESCRIPTION=?, GROUPID=? where FEEDID = ?";
- ps = c.prepareStatement(sql);
+ sql = "update FEEDS set DESCRIPTION = ?, AUTH_CLASS = ?, DELETED = ?, SUSPENDED = ?, "
+ + "BUSINESS_DESCRIPTION=?, GROUPID=? where FEEDID = ?";
+ ps = conn.prepareStatement(sql);
ps.setString(1, getDescription());
ps.setString(2, getAuthorization().getClassification());
ps.setInt(3, deleted ? 1 : 0);
@@ -697,8 +778,9 @@ public class Feed extends Syncable {
intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e);
} finally {
try {
- if (ps != null)
+ if (ps != null) {
ps.close();
+ }
} catch (SQLException e) {
intlogger.error(SQLEXCEPTION + e.getMessage(), e);
}
@@ -707,7 +789,7 @@ public class Feed extends Syncable {
}
/**
- * Rally US708115
+ * Rally US708115.
* Change Ownership of FEED - 1610
*/
public boolean changeOwnerShip() {
@@ -717,9 +799,9 @@ public class Feed extends Syncable {
DB db = new DB();
@SuppressWarnings("resource")
- Connection c = db.getConnection();
+ Connection conn = db.getConnection();
String sql = "update FEEDS set PUBLISHER = ? where FEEDID = ?";
- ps = c.prepareStatement(sql);
+ ps = conn.prepareStatement(sql);
ps.setString(1, this.publisher);
ps.setInt(2, feedid);
ps.execute();
@@ -729,7 +811,7 @@ public class Feed extends Syncable {
intlogger.warn("PROV0008 changeOwnerShip: " + e.getMessage(), e);
} finally {
try {
- if(ps!=null) {
+ if (ps != null) {
ps.close();
}
} catch (SQLException e) {
@@ -747,33 +829,48 @@ public class Feed extends Syncable {
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof Feed))
+ if (!(obj instanceof Feed)) {
return false;
+ }
Feed of = (Feed) obj;
- if (feedid != of.feedid)
+ if (feedid != of.feedid) {
return false;
- if (groupid != of.groupid) //New field is added - Groups feature Rally:US708115 - 1610
+ }
+ if (groupid != of.groupid) {
+ //New field is added - Groups feature Rally:US708115 - 1610
return false;
- if (!name.equals(of.name))
+ }
+ if (!name.equals(of.name)) {
return false;
- if (!version.equals(of.version))
+ }
+ if (!version.equals(of.version)) {
return false;
- if (!description.equals(of.description))
+ }
+ if (!description.equals(of.description)) {
return false;
- if (!business_description.equals(of.business_description)) // New field is added - Groups feature Rally:US708102 - 1610
+ }
+ if (!businessDescription.equals(of.businessDescription)) {
+ // New field is added - Groups feature Rally:US708102 - 1610
return false;
- if (!publisher.equals(of.publisher))
+ }
+ if (!publisher.equals(of.publisher)) {
return false;
- if (!authorization.equals(of.authorization))
+ }
+ if (!authorization.equals(of.authorization)) {
return false;
- if (!links.equals(of.links))
+ }
+ if (!links.equals(of.links)) {
return false;
- if (deleted != of.deleted)
+ }
+ if (deleted != of.deleted) {
return false;
- if (suspended != of.suspended)
+ }
+ if (suspended != of.suspended) {
return false;
- if (!aaf_instance.equals(of.aaf_instance))
+ }
+ if (!aafInstance.equals(of.aafInstance)) {
return false;
+ }
return true;
}
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 4d901633..ff08f594 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
@@ -38,14 +38,18 @@ import org.json.JSONObject;
* @version $Id: FeedAuthorization.java,v 1.2 2013/06/20 14:11:05 eby Exp $
*/
public class FeedAuthorization implements JSONable {
+
private String classification;
- private Set<FeedEndpointID> endpoint_ids;
- private Set<String> endpoint_addrs;
+ private Set<FeedEndpointID> endpointIds;
+ private Set<String> endpointAddrs;
+ /**
+ * FeedAuthoization constructor.
+ */
public FeedAuthorization() {
this.classification = "";
- this.endpoint_ids = new HashSet<>();
- this.endpoint_addrs = new HashSet<>();
+ this.endpointIds = new HashSet<>();
+ this.endpointAddrs = new HashSet<>();
}
public String getClassification() {
@@ -57,19 +61,19 @@ public class FeedAuthorization implements JSONable {
}
public Set<FeedEndpointID> getEndpoint_ids() {
- return endpoint_ids;
+ return endpointIds;
}
- public void setEndpoint_ids(Set<FeedEndpointID> endpoint_ids) {
- this.endpoint_ids = endpoint_ids;
+ public void setEndpoint_ids(Set<FeedEndpointID> endpointIds) {
+ this.endpointIds = endpointIds;
}
public Set<String> getEndpoint_addrs() {
- return endpoint_addrs;
+ return endpointAddrs;
}
- public void setEndpoint_addrs(Set<String> endpoint_addrs) {
- this.endpoint_addrs = endpoint_addrs;
+ public void setEndpoint_addrs(Set<String> endpointAddrs) {
+ this.endpointAddrs = endpointAddrs;
}
@Override
@@ -77,12 +81,12 @@ public class FeedAuthorization implements JSONable {
JSONObject jo = new JSONObject();
jo.put("classification", classification);
JSONArray ja = new JSONArray();
- for (FeedEndpointID eid : endpoint_ids) {
+ for (FeedEndpointID eid : endpointIds) {
ja.put(eid.asJSONObject());
}
jo.put("endpoint_ids", ja);
ja = new JSONArray();
- for (String t : endpoint_addrs) {
+ for (String t : endpointAddrs) {
ja.put(t);
}
jo.put("endpoint_addrs", ja);
@@ -91,20 +95,24 @@ public class FeedAuthorization implements JSONable {
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof FeedAuthorization))
+ if (!(obj instanceof FeedAuthorization)) {
return false;
+ }
FeedAuthorization of = (FeedAuthorization) obj;
- if (!classification.equals(of.classification))
+ if (!classification.equals(of.classification)) {
return false;
- if (!endpoint_ids.equals(of.endpoint_ids))
+ }
+ if (!endpointIds.equals(of.endpointIds)) {
return false;
- if (!endpoint_addrs.equals(of.endpoint_addrs))
+ }
+ if (!endpointAddrs.equals(of.endpointAddrs)) {
return false;
+ }
return true;
}
@Override
public int hashCode() {
- return Objects.hash(classification, endpoint_ids, endpoint_addrs);
+ return Objects.hash(classification, endpointIds, endpointAddrs);
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedEndpointID.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedEndpointID.java
index 384d9f64..41c5cad9 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedEndpointID.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedEndpointID.java
@@ -21,7 +21,6 @@
* *
******************************************************************************/
-
package org.onap.dmaap.datarouter.provisioning.beans;
import java.sql.ResultSet;
@@ -75,8 +74,9 @@ public class FeedEndpointID implements JSONable {
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof FeedEndpointID))
+ if (!(obj instanceof FeedEndpointID)) {
return false;
+ }
FeedEndpointID f2 = (FeedEndpointID) obj;
return id.equals(f2.id) && password.equals(f2.password);
}
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 0e885e5f..779bffa8 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
@@ -35,6 +35,7 @@ import org.json.JSONObject;
* @author Robert Eby
* @version $Id: FeedLinks.java,v 1.3 2013/07/05 13:48:05 eby Exp $
*/
+
public class FeedLinks implements JSONable {
private String self;
private String publish;
@@ -45,6 +46,10 @@ public class FeedLinks implements JSONable {
self = publish = subscribe = log = null;
}
+ /**
+ * FeedLinks constructor.
+ * @param jo JSONObject
+ */
public FeedLinks(JSONObject jo) {
this();
self = jo.getString("self");
@@ -97,17 +102,22 @@ public class FeedLinks implements JSONable {
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof FeedLinks))
+ if (!(obj instanceof FeedLinks)) {
return false;
+ }
FeedLinks of = (FeedLinks) obj;
- if (!self.equals(of.self))
+ if (!self.equals(of.self)) {
return false;
- if (!publish.equals(of.publish))
+ }
+ if (!publish.equals(of.publish)) {
return false;
- if (!subscribe.equals(of.subscribe))
+ }
+ if (!subscribe.equals(of.subscribe)) {
return false;
- if (!log.equals(of.log))
+ }
+ if (!log.equals(of.log)) {
return false;
+ }
return true;
}
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 d05e3e6b..e0756f9f 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
@@ -45,6 +45,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
* @author vikram
* @version $Id: Group.java,v 1.0 2016/07/19
*/
+
public class Group extends Syncable {
private static final String GROUP_ID_CONST = "groupid";
@@ -58,12 +59,18 @@ public class Group extends Syncable {
private String description;
private String classification;
private String members;
- private Date last_mod;
+ private Date lastMod;
public Group() {
this("", "", "");
}
+ /**
+ * Group constructor.
+ * @param name group name
+ * @param desc group description
+ * @param members group members
+ */
public Group(String name, String desc, String members) {
this.groupid = -1;
this.authid = "";
@@ -71,10 +78,15 @@ public class Group extends Syncable {
this.description = desc;
this.members = members;
this.classification = "";
- this.last_mod = new Date();
+ this.lastMod = new Date();
}
+ /**
+ * Group constructor from ResultSet.
+ * @param rs ResultSet
+ * @throws SQLException in case of SQL statement error
+ */
public Group(ResultSet rs) throws SQLException {
this.groupid = rs.getInt("GROUPID");
this.authid = rs.getString("AUTHID");
@@ -82,10 +94,14 @@ public class Group extends Syncable {
this.description = rs.getString("DESCRIPTION");
this.classification = rs.getString("CLASSIFICATION");
this.members = rs.getString("MEMBERS");
- this.last_mod = rs.getDate("LAST_MOD");
+ this.lastMod = rs.getDate("LAST_MOD");
}
-
+ /**
+ * Group constructor for JSONObject.
+ * @param jo JSONObject
+ * @throws InvalidObjectException in case of JSON error
+ */
public Group(JSONObject jo) throws InvalidObjectException {
this("", "", "");
try {
@@ -114,7 +130,11 @@ public class Group extends Syncable {
}
}
-
+ /**
+ * Get a group frpm DB.
+ * @param gup group object
+ * @return Group object
+ */
public static Group getGroupMatching(Group gup) {
String sql = String.format(
"select * from GROUPS where NAME='%s'",
@@ -124,6 +144,12 @@ public class Group extends Syncable {
return !list.isEmpty() ? list.get(0) : null;
}
+ /**
+ * Get a group from DB using name and groupid.
+ * @param gup group object
+ * @param groupid id of group
+ * @return group object
+ */
public static Group getGroupMatching(Group gup, int groupid) {
String sql = String.format(
"select * from GROUPS where NAME = '%s' and GROUPID != %d ",
@@ -134,12 +160,22 @@ public class Group extends Syncable {
return !list.isEmpty() ? list.get(0) : null;
}
+ /**
+ * Get group from DB using groupid only.
+ * @param id id of group
+ * @return group object
+ */
public static Group getGroupById(int id) {
String sql = "select * from GROUPS where GROUPID = " + id;
List<Group> list = getGroupsForSQL(sql);
return !list.isEmpty() ? list.get(0) : null;
}
+ /**
+ * Get group from DB using AUTHID.
+ * @param id AUTHID
+ * @return group object
+ */
static Group getGroupByAuthId(String id) {
String sql = "select * from GROUPS where AUTHID = '" + id + "'";
List<Group> list = getGroupsForSQL(sql);
@@ -252,12 +288,12 @@ public class Group extends Syncable {
jo.put("description", description);
jo.put("classification", classification);
jo.put("members", members);
- jo.put("last_mod", last_mod.getTime());
+ jo.put("last_mod", lastMod.getTime());
return jo;
}
@Override
- public boolean doInsert(Connection c) {
+ public boolean doInsert(Connection conn) {
boolean rv = true;
PreparedStatement ps = null;
try {
@@ -271,8 +307,9 @@ public class Group extends Syncable {
}
// Create the GROUPS row
- String sql = "insert into GROUPS (GROUPID, AUTHID, NAME, DESCRIPTION, CLASSIFICATION, MEMBERS) values (?, ?, ?, ?, ?, ?)";
- ps = c.prepareStatement(sql, new String[]{"GROUPID"});
+ String sql = "insert into GROUPS (GROUPID, AUTHID, NAME, DESCRIPTION, CLASSIFICATION, MEMBERS) "
+ + "values (?, ?, ?, ?, ?, ?)";
+ ps = conn.prepareStatement(sql, new String[]{"GROUPID"});
ps.setInt(1, groupid);
ps.setString(2, authid);
ps.setString(3, name);
@@ -297,12 +334,13 @@ public class Group extends Syncable {
}
@Override
- public boolean doUpdate(Connection c) {
+ public boolean doUpdate(Connection conn) {
boolean rv = true;
PreparedStatement ps = null;
try {
- String sql = "update GROUPS set AUTHID = ?, NAME = ?, DESCRIPTION = ?, CLASSIFICATION = ? , MEMBERS = ? where GROUPID = ?";
- ps = c.prepareStatement(sql);
+ String sql = "update GROUPS set AUTHID = ?, NAME = ?, DESCRIPTION = ?, CLASSIFICATION = ? , MEMBERS = ? "
+ + "where GROUPID = ?";
+ ps = conn.prepareStatement(sql);
ps.setString(1, authid);
ps.setString(2, name);
ps.setString(3, description);
@@ -326,12 +364,12 @@ public class Group extends Syncable {
}
@Override
- public boolean doDelete(Connection c) {
+ public boolean doDelete(Connection conn) {
boolean rv = true;
PreparedStatement ps = null;
try {
String sql = "delete from GROUPS where GROUPID = ?";
- ps = c.prepareStatement(sql);
+ ps = conn.prepareStatement(sql);
ps.setInt(1, groupid);
ps.execute();
} catch (SQLException e) {
@@ -389,6 +427,6 @@ public class Group extends Syncable {
@Override
public int hashCode() {
- return Objects.hash(groupid, authid, name, description, classification, members, last_mod);
+ return Objects.hash(groupid, authid, name, description, classification, members, lastMod);
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java
index 1df093df..f1fa54c7 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java
@@ -49,6 +49,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
* @author Robert P. Eby
* @version $Id: IngressRoute.java,v 1.3 2013/12/16 20:30:23 eby Exp $
*/
+
public class IngressRoute extends NodeClass implements Comparable<IngressRoute> {
private static final String NODESET = "NODESET";
@@ -61,6 +62,14 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
private int nodelist;
private SortedSet<String> nodes;
+ /**
+ * Ingress route constructor.
+ * @param seq squence number
+ * @param feedid id for feed
+ * @param user user name
+ * @param subnet subnet string
+ * @param nodes collection of nodes
+ */
public IngressRoute(int seq, int feedid, String user, String subnet, Collection<String> nodes) {
this(seq, feedid, user, subnet);
this.nodelist = -1;
@@ -91,13 +100,17 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
}
}
+ /**
+ * Ingress route constructor.
+ * @param jo JSONObject
+ */
public IngressRoute(JSONObject jo) {
this.seq = jo.optInt("seq");
this.feedid = jo.optInt("feedid");
- String t = jo.optString("user");
- this.userid = "".equals(t) ? "-" : t;
- t = jo.optString("subnet");
- this.subnet = "".equals(t) ? "-" : t;
+ String user = jo.optString("user");
+ this.userid = "".equals(user) ? "-" : user;
+ user = jo.optString("subnet");
+ this.subnet = "".equals(user) ? "-" : user;
this.nodelist = -1;
this.nodes = new TreeSet<>();
JSONArray ja = jo.getJSONArray("node");
@@ -200,7 +213,7 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
* @return the Ingress Route, or null of there is none
*/
public static IngressRoute getIngressRoute(int feedid, String user, String subnet) {
- IngressRoute v = null;
+ IngressRoute ir = null;
DB db = new DB();
String sql = "select SEQUENCE, NODESET from INGRESS_ROUTES where FEEDID = ? AND USERID = ? and SUBNET = ?";
try (Connection conn = db.getConnection();
@@ -212,14 +225,14 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
if (rs.next()) {
int seq = rs.getInt("SEQUENCE");
int nodeset = rs.getInt(NODESET);
- v = new IngressRoute(seq, feedid, user, subnet, nodeset);
+ ir = new IngressRoute(seq, feedid, user, subnet, nodeset);
}
}
db.release(conn);
} catch (SQLException e) {
intlogger.error("PROV0003 getIngressRoute: " + e.getMessage(), e);
}
- return v;
+ return ir;
}
/**
@@ -243,12 +256,12 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
if (credentials == null || !credentials.startsWith("Basic ")) {
return false;
}
- String t = new String(Base64.decodeBase64(credentials.substring(6)));
- int ix = t.indexOf(':');
+ String cred = new String(Base64.decodeBase64(credentials.substring(6)));
+ int ix = cred.indexOf(':');
if (ix >= 0) {
- t = t.substring(0, ix);
+ cred = cred.substring(0, ix);
}
- if (!t.equals(this.userid)) {
+ if (!cred.equals(this.userid)) {
return false;
}
}
@@ -283,8 +296,8 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
* @param subnet The CIDR to match
*/
public SubnetMatcher(String subnet) {
- int i = subnet.lastIndexOf('/');
- if (i == -1) {
+ int index = subnet.lastIndexOf('/');
+ if (index == -1) {
try {
sn = InetAddress.getByName(subnet).getAddress();
len = sn.length;
@@ -296,16 +309,16 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
}
mask = 0;
} else {
- int n = Integer.parseInt(subnet.substring(i + 1));
+ int num = Integer.parseInt(subnet.substring(index + 1));
try {
- sn = InetAddress.getByName(subnet.substring(0, i)).getAddress();
+ sn = InetAddress.getByName(subnet.substring(0, index)).getAddress();
valid = true;
} catch (UnknownHostException e) {
intlogger.error("PROV0008 SubnetMatcher: " + e.getMessage(), e);
valid = false;
}
- len = n / 8;
- mask = ((0xff00) >> (n % 8)) & 0xff;
+ len = num / 8;
+ mask = ((0xff00) >> (num % 8)) & 0xff;
}
}
@@ -375,11 +388,11 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
* @return true if the delete succeeded
*/
@Override
- public boolean doDelete(Connection c) {
+ public boolean doDelete(Connection conn) {
boolean rv = true;
- try (PreparedStatement ps = c.prepareStatement(
+ try (PreparedStatement ps = conn.prepareStatement(
"delete from INGRESS_ROUTES where FEEDID = ? and USERID = ? and SUBNET = ?");
- PreparedStatement ps2 = c.prepareStatement("delete from NODESETS where SETID = ?")) {
+ PreparedStatement ps2 = conn.prepareStatement("delete from NODESETS where SETID = ?")) {
// Delete the Ingress Route
ps.setInt(1, feedid);
ps.setString(2, userid);
@@ -397,10 +410,10 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
}
@Override
- public boolean doInsert(Connection c) {
+ public boolean doInsert(Connection conn) {
boolean rv = false;
- try (PreparedStatement ps = c.prepareStatement("insert into NODESETS (SETID, NODEID) values (?,?)");
- PreparedStatement ps2 = c.prepareStatement("insert into INGRESS_ROUTES (SEQUENCE, FEEDID, USERID,"
+ try (PreparedStatement ps = conn.prepareStatement("insert into NODESETS (SETID, NODEID) values (?,?)");
+ PreparedStatement ps2 = conn.prepareStatement("insert into INGRESS_ROUTES (SEQUENCE, FEEDID, USERID,"
+ " SUBNET, NODESET) values (?, ?, ?, ?, ?)")) {
// Create the NODESETS rows & set nodelist
this.nodelist = getMaxNodeSetID() + 1;
@@ -425,8 +438,8 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
}
@Override
- public boolean doUpdate(Connection c) {
- return doDelete(c) && doInsert(c);
+ public boolean doUpdate(Connection conn) {
+ return doDelete(conn) && doInsert(conn);
}
@Override
@@ -469,21 +482,21 @@ public class IngressRoute extends NodeClass implements Comparable<IngressRoute>
if (in == null) {
throw new NullPointerException();
}
- int n = this.feedid - in.feedid;
- if (n != 0) {
- return n;
+ int num = this.feedid - in.feedid;
+ if (num != 0) {
+ return num;
}
- n = this.seq - in.seq;
- if (n != 0) {
- return n;
+ num = this.seq - in.seq;
+ if (num != 0) {
+ return num;
}
- n = this.userid.compareTo(in.userid);
- if (n != 0) {
- return n;
+ num = this.userid.compareTo(in.userid);
+ if (num != 0) {
+ return num;
}
- n = this.subnet.compareTo(in.subnet);
- if (n != 0) {
- return n;
+ num = this.subnet.compareTo(in.subnet);
+ if (num != 0) {
+ return num;
}
return this.nodes.equals(in.nodes) ? 0 : 1;
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Insertable.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Insertable.java
index ed0815e8..135c079d 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Insertable.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Insertable.java
@@ -32,13 +32,14 @@ import java.sql.Connection;
* @author Robert Eby
* @version $Id: Insertable.java,v 1.2 2013/05/29 14:44:36 eby Exp $
*/
+
@FunctionalInterface
public interface Insertable {
/**
* Insert this object into the DB.
*
- * @param c the JDBC Connection to use
+ * @param conn the JDBC Connection to use
* @return true if the INSERT succeeded, false otherwise
*/
- boolean doInsert(Connection c);
+ boolean doInsert(Connection conn);
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java
index cbddbf43..51c162ef 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java
@@ -24,6 +24,8 @@
package org.onap.dmaap.datarouter.provisioning.beans;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.Connection;
@@ -34,11 +36,10 @@ import java.sql.Types;
import java.text.ParseException;
import java.util.Iterator;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
+
/**
* The representation of a Log Record, as retrieved from the DB. Since this record format is only used to replicate
* between provisioning servers, it is very bare-bones; e.g. there are no field setters and only 1 getter.
@@ -53,10 +54,16 @@ public class LogRecord extends BaseLogRecord {
*
* @param os the {@link OutputStream} to print the records on
* @param bs the {@link RLEBitSet} listing the record IDs to print
- * @throws IOException
+ * @throws IOException in case of I/O error
*/
private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog");
+ /**
+ * Get Log Records.
+ * @param os outputstream
+ * @param bs RLEBitSet object
+ * @throws IOException in case of I/O error
+ */
public static void printLogRecords(OutputStream os, RLEBitSet bs) throws IOException {
final String sql = "select * from LOG_RECORDS where RECORD_ID >= ? AND RECORD_ID <= ?";
DB db = new DB();
@@ -64,9 +71,9 @@ public class LogRecord extends BaseLogRecord {
Iterator<Long[]> iter = bs.getRangeIterator();
try (PreparedStatement ps = conn.prepareStatement(sql)) {
while (iter.hasNext()) {
- Long[] n = iter.next();
- ps.setLong(1, n[0]);
- ps.setLong(2, n[1]);
+ Long[] nxt = iter.next();
+ ps.setLong(1, nxt[0]);
+ ps.setLong(2, nxt[1]);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
LogRecord lr = new LogRecord(rs);
@@ -91,10 +98,15 @@ public class LogRecord extends BaseLogRecord {
private final int result;
private final int attempts;
private final String reason;
- private final long record_id;
+ private final long recordId;
private final long clength2;
private final String fileName;
+ /**
+ * LogRecord constructor.
+ * @param rs ResultSet from SQL statement
+ * @throws SQLException in case of SQL error
+ */
public LogRecord(ResultSet rs) throws SQLException {
super(rs);
this.type = rs.getString("TYPE");
@@ -110,11 +122,16 @@ public class LogRecord extends BaseLogRecord {
this.attempts = rs.getInt("ATTEMPTS");
this.reason = rs.getString("REASON");
- this.record_id = rs.getLong("RECORD_ID");
+ this.recordId = rs.getLong("RECORD_ID");
this.clength2 = rs.getLong("CONTENT_LENGTH_2");
this.fileName = rs.getString("FILENAME");
}
+ /**
+ * LogRecord Constructor from string array.
+ * @param pp string array of LogRecord attributes
+ * @throws ParseException in case of parse error
+ */
public LogRecord(String[] pp) throws ParseException {
super(pp);
this.type = pp[8];
@@ -130,13 +147,13 @@ public class LogRecord extends BaseLogRecord {
this.attempts = Integer.parseInt(pp[16]);
this.reason = pp[17];
- this.record_id = Long.parseLong(pp[18]);
+ this.recordId = Long.parseLong(pp[18]);
this.clength2 = (pp.length == 21) ? Long.parseLong(pp[19]) : 0;
this.fileName = pp[20];
}
public long getRecordId() {
- return record_id;
+ return recordId;
}
@Override
@@ -160,7 +177,7 @@ public class LogRecord extends BaseLogRecord {
+ result + "|"
+ attempts + "|"
+ reason + "|"
- + record_id + "|"
+ + recordId + "|"
+ clength2
+ "\n";
}
@@ -179,7 +196,7 @@ public class LogRecord extends BaseLogRecord {
ps.setNull(15, Types.INTEGER);
ps.setNull(16, Types.INTEGER);
ps.setNull(17, Types.VARCHAR);
- ps.setLong(18, record_id);
+ ps.setLong(18, recordId);
ps.setNull(19, Types.BIGINT);
ps.setString(20, fileName);
} else if (type.equals("del")) {
@@ -192,7 +209,7 @@ public class LogRecord extends BaseLogRecord {
ps.setInt(15, result);
ps.setNull(16, Types.INTEGER);
ps.setNull(17, Types.VARCHAR);
- ps.setLong(18, record_id);
+ ps.setLong(18, recordId);
ps.setNull(19, Types.BIGINT);
ps.setString(20, fileName);
} else if (type.equals("exp")) {
@@ -205,7 +222,7 @@ public class LogRecord extends BaseLogRecord {
ps.setNull(15, Types.INTEGER);
ps.setInt(16, attempts);
ps.setString(17, reason);
- ps.setLong(18, record_id);
+ ps.setLong(18, recordId);
ps.setNull(19, Types.BIGINT);
ps.setString(20, fileName);
} else if (type.equals("pbf")) {
@@ -218,7 +235,7 @@ public class LogRecord extends BaseLogRecord {
ps.setNull(15, Types.INTEGER);
ps.setNull(16, Types.INTEGER);
ps.setNull(17, Types.VARCHAR);
- ps.setLong(18, record_id);
+ ps.setLong(18, recordId);
ps.setLong(19, clength2);
ps.setString(20, fileName);
} else if (type.equals("dlx")) {
@@ -231,13 +248,13 @@ public class LogRecord extends BaseLogRecord {
ps.setNull(15, Types.INTEGER);
ps.setNull(16, Types.INTEGER);
ps.setNull(17, Types.VARCHAR);
- ps.setLong(18, record_id);
+ ps.setLong(18, recordId);
ps.setLong(19, clength2);
ps.setString(20, fileName);
}
}
- public static void main(String[] a) throws IOException {
- LogRecord.printLogRecords(System.out, new RLEBitSet(a[0]));
+ public static void main(String[] args) throws IOException {
+ LogRecord.printLogRecords(System.out, new RLEBitSet(args[0]));
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java
index fa3d4e0e..dd9a624e 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java
@@ -51,24 +51,45 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
private final int tonode;
private final int vianode;
+ /**
+ * NetworkRoute Constructor.
+ * @param fromnode node source
+ * @param tonode node destination
+ */
public NetworkRoute(String fromnode, String tonode) {
this.fromnode = lookupNodeName(fromnode);
this.tonode = lookupNodeName(tonode);
this.vianode = -1;
}
+ /**
+ * NetworkRoute Constructor.
+ * @param fromnode node source
+ * @param tonode node destination
+ * @param vianode via node
+ */
public NetworkRoute(String fromnode, String tonode, String vianode) {
this.fromnode = lookupNodeName(fromnode);
this.tonode = lookupNodeName(tonode);
this.vianode = lookupNodeName(vianode);
}
+ /**
+ * NetworkRoute Constructor.
+ * @param jo JSONObject of attributes
+ */
public NetworkRoute(JSONObject jo) {
this.fromnode = lookupNodeName(jo.getString("from"));
this.tonode = lookupNodeName(jo.getString("to"));
this.vianode = lookupNodeName(jo.getString("via"));
}
+ /**
+ * NetworkRoute Constructor.
+ * @param fromnode integer source node
+ * @param tonode integer destination node
+ * @param vianode integer via node
+ */
private NetworkRoute(int fromnode, int tonode, int vianode) {
this.fromnode = fromnode;
this.tonode = tonode;
@@ -122,10 +143,10 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
}
@Override
- public boolean doDelete(Connection c) {
+ public boolean doDelete(Connection conn) {
boolean rv = true;
String sql = "delete from NETWORK_ROUTES where FROMNODE = ? AND TONODE = ?";
- try (PreparedStatement ps = c.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, fromnode);
ps.setInt(2, tonode);
ps.execute();
@@ -137,11 +158,11 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
}
@Override
- public boolean doInsert(Connection c) {
+ public boolean doInsert(Connection conn) {
boolean rv = false;
String sql = "insert into NETWORK_ROUTES (FROMNODE, TONODE, VIANODE) values (?, ?, ?)";
if (this.vianode >= 0) {
- try (PreparedStatement ps = c.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
// Create the NETWORK_ROUTES row
ps.setInt(1, this.fromnode);
ps.setInt(2, this.tonode);
@@ -156,10 +177,10 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
}
@Override
- public boolean doUpdate(Connection c) {
+ public boolean doUpdate(Connection conn) {
boolean rv = true;
String sql = "update NETWORK_ROUTES set VIANODE = ? where FROMNODE = ? and TONODE = ?";
- try (PreparedStatement ps = c.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, vianode);
ps.setInt(2, fromnode);
ps.setInt(3, tonode);
@@ -200,14 +221,14 @@ public class NetworkRoute extends NodeClass implements Comparable<NetworkRoute>
}
@Override
- public int compareTo(NetworkRoute o) {
- if (this.fromnode == o.fromnode) {
- if (this.tonode == o.tonode) {
- return this.vianode - o.vianode;
+ public int compareTo(NetworkRoute nr) {
+ if (this.fromnode == nr.fromnode) {
+ if (this.tonode == nr.tonode) {
+ return this.vianode - nr.vianode;
}
- return this.tonode - o.tonode;
+ return this.tonode - nr.tonode;
}
- return this.fromnode - o.fromnode;
+ return this.fromnode - nr.fromnode;
}
@Override
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
index d11c20fb..ef491cab 100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
@@ -42,6 +42,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
* @author Robert P. Eby
* @version $Id: NodeClass.java,v 1.2 2014/01/15 16:08:43 eby Exp $
*/
+
public abstract class NodeClass extends Syncable {
private static final String PROV_0005_DO_INSERT = "PROV0005 doInsert: ";
@@ -101,7 +102,7 @@ public abstract class NodeClass extends Syncable {
}
private static void reload() {
- Map<String, Integer> m = new HashMap<>();
+ Map<String, Integer> hmap = new HashMap<>();
String sql = "select NODEID, NAME from NODES";
DB db = new DB();
try (Connection conn = db.getConnection();
@@ -110,7 +111,7 @@ public abstract class NodeClass extends Syncable {
while (rs.next()) {
int id = rs.getInt("NODEID");
String name = rs.getString("NAME");
- m.put(name, id);
+ hmap.put(name, id);
}
} finally {
db.release(conn);
@@ -118,17 +119,22 @@ public abstract class NodeClass extends Syncable {
} catch (SQLException e) {
intLogger.error(PROV_0005_DO_INSERT + e.getMessage(),e);
}
- map = m;
+ map = hmap;
}
static Integer lookupNodeName(final String name) {
- Integer n = map.get(name);
- if (n == null) {
+ Integer nodeName = map.get(name);
+ if (nodeName == null) {
throw new IllegalArgumentException("Invalid node name: " + name);
}
- return n;
+ return nodeName;
}
+ /**
+ * Get node names.
+ * @param patt pattern to search
+ * @return collection of node names
+ */
public static Collection<String> lookupNodeNames(String patt) {
Collection<String> coll = new TreeSet<>();
final Set<String> keyset = map.keySet();
@@ -146,32 +152,37 @@ public abstract class NodeClass extends Syncable {
return coll;
}
- private static void addNodeToCollection(Collection<String> coll, Set<String> keyset, String s) {
- s = s.substring(0, s.length() - 1);
+ private static void addNodeToCollection(Collection<String> coll, Set<String> keyset, String str) {
+ str = str.substring(0, str.length() - 1);
for (String s2 : keyset) {
- if (s2.startsWith(s)) {
+ if (s2.startsWith(str)) {
coll.add(s2);
}
}
}
- public static String normalizeNodename(String s) {
- if (s != null && s.indexOf('.') <= 0) {
- Parameters p = Parameters.getParameter(Parameters.PROV_DOMAIN);
- if (p != null) {
- String domain = p.getValue();
- s += "." + domain;
+ /**
+ * Method to add domain name.
+ * @param str nde name string
+ * @return normalized node name
+ */
+ public static String normalizeNodename(String str) {
+ if (str != null && str.indexOf('.') <= 0) {
+ Parameters param = Parameters.getParameter(Parameters.PROV_DOMAIN);
+ if (param != null) {
+ String domain = param.getValue();
+ str += "." + domain;
}
- return s.toLowerCase();
+ return str.toLowerCase();
} else {
- return s;
+ return str;
}
}
- String lookupNodeID(int n) {
+ String lookupNodeID(int node) {
for (Map.Entry<String, Integer> entry : map.entrySet()) {
- if (entry.getValue() == n) {
+ if (entry.getValue() == node) {
return entry.getKey();
}
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Parameters.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Parameters.java
index 78ed96dd..e89cfd47 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Parameters.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Parameters.java
@@ -45,6 +45,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
* @author Robert Eby
* @version $Id: Parameters.java,v 1.11 2014/03/12 19:45:41 eby Exp $
*/
+
public class Parameters extends Syncable {
public static final String PROV_REQUIRE_SECURE = "PROV_REQUIRE_SECURE";
@@ -78,9 +79,9 @@ public class Parameters extends Syncable {
private String keyname;
private String value;
- public Parameters(String k, String v) {
- this.keyname = k;
- this.value = v;
+ public Parameters(String key, String val) {
+ this.keyname = key;
+ this.value = val;
}
public Parameters(ResultSet rs) throws SQLException {
@@ -101,6 +102,10 @@ public class Parameters extends Syncable {
return props;
}
+ /**
+ * Method to get parameters.
+ * @return collection of parameters
+ */
public static Collection<Parameters> getParameterCollection() {
Collection<Parameters> coll = new ArrayList<>();
DB db = new DB();
@@ -109,8 +114,8 @@ public class Parameters extends Syncable {
Statement stmt = conn.createStatement()) {
try (ResultSet rs = stmt.executeQuery(sql)) {
while (rs.next()) {
- Parameters p = new Parameters(rs);
- coll.add(p);
+ Parameters param = new Parameters(rs);
+ coll.add(param);
}
}
db.release(conn);
@@ -123,26 +128,26 @@ public class Parameters extends Syncable {
/**
* Get a specific parameter value from the DB.
*
- * @param k the key to lookup
+ * @param key the key to lookup
* @return the value, or null if non-existant
*/
- public static Parameters getParameter(String k) {
- Parameters v = null;
+ public static Parameters getParameter(String key) {
+ Parameters val = null;
DB db = new DB();
String sql = "select KEYNAME, VALUE from PARAMETERS where KEYNAME = ?";
try (Connection conn = db.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
- stmt.setString(1, k);
+ stmt.setString(1, key);
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
- v = new Parameters(rs);
+ val = new Parameters(rs);
}
}
db.release(conn);
} catch (SQLException e) {
intlogger.error(SQLEXCEPTION + e.getMessage(), e);
}
- return v;
+ return val;
}
public String getKeyname() {
@@ -166,10 +171,10 @@ public class Parameters extends Syncable {
}
@Override
- public boolean doInsert(Connection c) {
+ public boolean doInsert(Connection conn) {
boolean rv = true;
String sql = "insert into PARAMETERS values (?, ?)";
- try (PreparedStatement ps = c.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setString(1, getKeyname());
ps.setString(2, getValue());
ps.execute();
@@ -181,10 +186,10 @@ public class Parameters extends Syncable {
}
@Override
- public boolean doUpdate(Connection c) {
+ public boolean doUpdate(Connection conn) {
boolean rv = true;
String sql = "update PARAMETERS set VALUE = ? where KEYNAME = ?";
- try (PreparedStatement ps = c.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setString(1, getValue());
ps.setString(2, getKeyname());
ps.executeUpdate();
@@ -196,10 +201,10 @@ public class Parameters extends Syncable {
}
@Override
- public boolean doDelete(Connection c) {
+ public boolean doDelete(Connection conn) {
boolean rv = true;
String sql = "delete from PARAMETERS where KEYNAME = ?";
- try (PreparedStatement ps = c.prepareStatement(sql)) {
+ try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setString(1, getKeyname());
ps.execute();
} catch (SQLException e) {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PubFailRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PubFailRecord.java
index a38d8bd2..719b44fe 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PubFailRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PubFailRecord.java
@@ -34,12 +34,18 @@ import java.text.ParseException;
* @author Robert Eby
* @version $Id: PubFailRecord.java,v 1.1 2013/10/28 18:06:53 eby Exp $
*/
+
public class PubFailRecord extends BaseLogRecord {
private long contentLengthReceived;
private String sourceIP;
private String user;
private String error;
+ /**
+ * PBF record constructor.
+ * @param pp string array of PBF attributes
+ * @throws ParseException in case of parse error
+ */
public PubFailRecord(String[] pp) throws ParseException {
super(pp);
this.contentLengthReceived = Long.parseLong(pp[8]);
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 72ad8af0..4afb61cd 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
@@ -40,6 +40,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;
* @author Robert Eby
* @version $Id: PublishRecord.java,v 1.6 2013/10/28 18:06:53 eby Exp $
*/
+
public class PublishRecord extends BaseLogRecord {
private String feedFileid;
private String remoteAddr;
@@ -47,14 +48,21 @@ public class PublishRecord extends BaseLogRecord {
private int status;
private String fileName;
+ /**
+ * Publish record constructor.
+ * @param pp string array of attributes
+ * @throws ParseException in case of parse error
+ */
public PublishRecord(String[] pp) throws ParseException {
super(pp);
int ix = pp[4].indexOf("/publish/");
- if (ix < 0)
+ if (ix < 0) {
throw new ParseException("bad pattern", 0);
+ }
ix = pp[4].indexOf('/', ix + 9);
- if (ix < 0)
+ if (ix < 0) {
throw new ParseException("bad pattern", 0);
+ }
this.feedFileid = pp[4].substring(ix + 1);
this.remoteAddr = pp[8];
this.user = pp[9];
@@ -62,6 +70,11 @@ public class PublishRecord extends BaseLogRecord {
this.fileName = StringUtils.substringAfterLast(this.getRequestUri(), "/");
}
+ /**
+ * Publish record constructor.
+ * @param rs ResultSet from DB
+ * @throws SQLException in case of SQL error
+ */
public PublishRecord(ResultSet rs) throws SQLException {
super(rs);
this.feedFileid = rs.getString("FEED_FILEID");
@@ -103,11 +116,20 @@ public class PublishRecord extends BaseLogRecord {
this.status = status;
}
- public String getFileName() { return fileName;}
+ public String getFileName() {
+ return fileName;
+ }
- public void setFileName(String fileName) { this.fileName = fileName; }
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+ /**
+ * Method to reorder json object.
+ * @param jo LOGJSONObject
+ * @return LOGJSONObject
+ */
public LOGJSONObject reOrderObject(LOGJSONObject jo) {
LinkedHashMap<String, Object> logrecordObj = new LinkedHashMap<>();
@@ -127,6 +149,7 @@ public class PublishRecord extends BaseLogRecord {
return new LOGJSONObject(logrecordObj);
}
+
@Override
public LOGJSONObject asJSONObject() {
LOGJSONObject jo = super.asJSONObject();
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubDelivery.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubDelivery.java
index 5a3457b9..e3a0dc0c 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubDelivery.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubDelivery.java
@@ -37,12 +37,20 @@ import org.json.JSONObject;
* @author Robert Eby
* @version $Id: SubDelivery.java,v 1.2 2013/06/20 14:11:05 eby Exp $
*/
+
public class SubDelivery implements JSONable {
private String url;
private String user;
private String password;
private boolean use100;
+ /**
+ * SubDelivery constructor.
+ * @param url url string
+ * @param user user string
+ * @param password password string
+ * @param use100 use100 string
+ */
public SubDelivery(String url, String user, String password, boolean use100) {
this.url = url;
this.user = user;
@@ -50,6 +58,11 @@ public class SubDelivery implements JSONable {
this.use100 = use100;
}
+ /**
+ * SubDelivery constructor.
+ * @param rs resultset from DB
+ * @throws SQLException in cse of SQL error
+ */
public SubDelivery(ResultSet rs) throws SQLException {
this.url = rs.getString("DELIVERY_URL");
this.user = rs.getString("DELIVERY_USER");
@@ -98,17 +111,22 @@ public class SubDelivery implements JSONable {
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof SubDelivery))
+ if (!(obj instanceof SubDelivery)) {
return false;
+ }
SubDelivery os = (SubDelivery) obj;
- if (!url.equals(os.url))
+ if (!url.equals(os.url)) {
return false;
- if (!user.equals(os.user))
+ }
+ if (!user.equals(os.user)) {
return false;
- if (!password.equals(os.password))
+ }
+ if (!password.equals(os.password)) {
return false;
- if (use100 != os.use100)
+ }
+ if (use100 != os.use100) {
return false;
+ }
return true;
}
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 e8ef8393..9c10fb3d 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
@@ -35,6 +35,7 @@ import org.json.JSONObject;
* @author Robert Eby
* @version $Id: SubLinks.java,v 1.3 2013/07/05 13:48:05 eby Exp $
*/
+
public class SubLinks implements JSONable {
private String self;
private String feed;
@@ -44,6 +45,10 @@ public class SubLinks implements JSONable {
self = feed = log = null;
}
+ /**
+ * Sublinks constructor.
+ * @param jo JSONObject
+ */
public SubLinks(JSONObject jo) {
this();
self = jo.getString("self");
@@ -51,6 +56,12 @@ public class SubLinks implements JSONable {
log = jo.getString("log");
}
+ /**
+ * Sublinks constructor.
+ * @param self string for self
+ * @param feed string for feed
+ * @param log string for log
+ */
public SubLinks(String self, String feed, String log) {
this.self = self;
this.feed = feed;
@@ -92,15 +103,19 @@ public class SubLinks implements JSONable {
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof SubLinks))
+ if (!(obj instanceof SubLinks)) {
return false;
+ }
SubLinks os = (SubLinks) obj;
- if (!self.equals(os.self))
+ if (!self.equals(os.self)) {
return false;
- if (!feed.equals(os.feed))
+ }
+ if (!feed.equals(os.feed)) {
return false;
- if (!log.equals(os.log))
+ }
+ if (!log.equals(os.log)) {
return false;
+ }
return true;
}
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 0b07a5d9..95f0a706 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
@@ -47,6 +47,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
* @author Robert Eby
* @version $Id: Subscription.java,v 1.9 2013/10/28 18:06:53 eby Exp $
*/
+
public class Subscription extends Syncable {
private static final String SQLEXCEPTION = "SQLException: ";
@@ -74,22 +75,34 @@ public class Subscription extends Syncable {
private String aafInstance;
private boolean decompress;
+ /**
+ * Get specific subscription.
+ * @param sub subscription object
+ * @return subscription
+ */
public static Subscription getSubscriptionMatching(Subscription sub) {
SubDelivery deli = sub.getDelivery();
String sql = String.format(
- "select * from SUBSCRIPTIONS where FEEDID = %d and DELIVERY_URL = \"%s\" and DELIVERY_USER = \"%s\" and DELIVERY_PASSWORD = \"%s\" and DELIVERY_USE100 = %d and METADATA_ONLY = %d and FOLLOW_REDIRECTS = %d",
+ "select * from SUBSCRIPTIONS where FEEDID = %d and DELIVERY_URL = \"%s\" and DELIVERY_USER = \"%s\" "
+ + "and DELIVERY_PASSWORD = \"%s\" and DELIVERY_USE100 = %d and METADATA_ONLY = %d "
+ + "and FOLLOW_REDIRECTS = %d",
sub.getFeedid(),
deli.getUrl(),
deli.getUser(),
deli.getPassword(),
deli.isUse100() ? 1 : 0,
sub.isMetadataOnly() ? 1 : 0,
- sub.isFollowRedirect() ? 1 :0
+ sub.isFollowRedirect() ? 1 : 0
);
List<Subscription> list = getSubscriptionsForSQL(sql);
return !list.isEmpty() ? list.get(0) : null;
}
+ /**
+ * Get subscription by id.
+ * @param id subscription id string
+ * @return subscription
+ */
public static Subscription getSubscriptionById(int id) {
String sql = "select * from SUBSCRIPTIONS where SUBID = " + id;
List<Subscription> list = getSubscriptionsForSQL(sql);
@@ -100,6 +113,11 @@ public class Subscription extends Syncable {
return getSubscriptionsForSQL("select * from SUBSCRIPTIONS");
}
+ /**
+ * Get subscriptions from SQL.
+ * @param sql SQL statement
+ * @return List of subscriptions
+ */
private static List<Subscription> getSubscriptionsForSQL(String sql) {
List<Subscription> list = new ArrayList<>();
try {
@@ -121,6 +139,10 @@ public class Subscription extends Syncable {
return list;
}
+ /**
+ * Get max subid.
+ * @return subid int
+ */
public static int getMaxSubID() {
int max = 0;
try {
@@ -141,6 +163,11 @@ public class Subscription extends Syncable {
return max;
}
+ /**
+ * Get subscription URL list.
+ * @param feedid feedid int
+ * @return collection of subscription URL
+ */
public static Collection<String> getSubscriptionUrlList(int feedid) {
List<String> list = new ArrayList<>();
String sql = "select SUBID from SUBSCRIPTIONS where FEEDID = ?";
@@ -194,6 +221,12 @@ public class Subscription extends Syncable {
this("", "", "");
}
+ /**
+ * Subscription constructor.
+ * @param url url string
+ * @param user user string
+ * @param password password string
+ */
public Subscription(String url, String user, String password) {
this.subid = -1;
this.feedid = -1;
@@ -211,6 +244,11 @@ public class Subscription extends Syncable {
this.decompress = false;
}
+ /**
+ * Subscription constructor.
+ * @param rs resultset from SQL
+ * @throws SQLException in case of SQL error
+ */
public Subscription(ResultSet rs) throws SQLException {
this.subid = rs.getInt(SUBID_COL);
this.feedid = rs.getInt("FEEDID");
@@ -219,7 +257,8 @@ public class Subscription extends Syncable {
this.metadataOnly = rs.getBoolean("METADATA_ONLY");
this.followRedirect = rs.getBoolean("FOLLOW_REDIRECTS");
this.subscriber = rs.getString("SUBSCRIBER");
- this.links = new SubLinks(rs.getString("SELF_LINK"), URLUtilities.generateFeedURL(feedid), rs.getString("LOG_LINK"));
+ this.links = new SubLinks(rs.getString("SELF_LINK"), URLUtilities.generateFeedURL(feedid),
+ rs.getString("LOG_LINK"));
this.suspended = rs.getBoolean("SUSPENDED");
this.lastMod = rs.getDate("LAST_MOD");
this.createdDate = rs.getDate("CREATED_DATE");
@@ -228,6 +267,11 @@ public class Subscription extends Syncable {
this.decompress = rs.getBoolean("DECOMPRESS");
}
+ /**
+ * Subscription constructor.
+ * @param jo JSONObject
+ * @throws InvalidObjectException in case of object error
+ */
public Subscription(JSONObject jo) throws InvalidObjectException {
this("", "", "");
try {
@@ -236,18 +280,18 @@ 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")) && aafInstance.length() > 255) {
- throw new InvalidObjectException("aaf_instance field is too long");
+ if (!(aafInstance.equalsIgnoreCase("legacy")) && aafInstance.length() > 255) {
+ throw new InvalidObjectException("aaf_instance field is too long");
}
JSONObject jdeli = jo.getJSONObject("delivery");
String url = jdeli.getString("url");
String user = jdeli.getString("user");
- String password = jdeli.getString("password");
- boolean use100 = jdeli.getBoolean("use100");
+ final String password = jdeli.getString("password");
+ final boolean use100 = jdeli.getBoolean("use100");
//Data Router Subscriber HTTPS Relaxation feature USERSTORYID:US674047.
- Properties p = (new DB()).getProperties();
- if (!url.startsWith("https://") && isHttpsRelaxationFalseAndHasSyncKey(jo, p)) {
+ Properties prop = (new DB()).getProperties();
+ if (!url.startsWith("https://") && isHttpsRelaxationFalseAndHasSyncKey(jo, prop)) {
throw new InvalidObjectException("delivery URL is not HTTPS");
}
@@ -277,8 +321,8 @@ public class Subscription extends Syncable {
}
}
- private boolean isHttpsRelaxationFalseAndHasSyncKey(JSONObject jo, Properties p) {
- return p.get("org.onap.dmaap.datarouter.provserver.https.relaxation").toString().equals("false") && !jo
+ private boolean isHttpsRelaxationFalseAndHasSyncKey(JSONObject jo, Properties prop) {
+ return prop.get("org.onap.dmaap.datarouter.provserver.https.relaxation").toString().equals("false") && !jo
.has("sync");
}
@@ -286,6 +330,10 @@ public class Subscription extends Syncable {
return subid;
}
+ /**
+ * Subid setter.
+ * @param subid subid string
+ */
public void setSubid(int subid) {
this.subid = subid;
@@ -299,6 +347,10 @@ public class Subscription extends Syncable {
return feedid;
}
+ /**
+ * feedid setter.
+ * @param feedid feedid string
+ */
public void setFeedid(int feedid) {
this.feedid = feedid;
@@ -306,6 +358,7 @@ public class Subscription extends Syncable {
SubLinks sl = getLinks();
sl.setFeed(URLUtilities.generateFeedURL(feedid));
}
+
public String getAafInstance() {
return aafInstance;
}
@@ -342,6 +395,7 @@ public class Subscription extends Syncable {
private boolean isFollowRedirect() {
return followRedirect;
}
+
public void setFollowRedirect(boolean followRedirect) {
this.followRedirect = followRedirect;
}
@@ -366,6 +420,10 @@ public class Subscription extends Syncable {
return subscriber;
}
+ /**
+ * Subscriber setter.
+ * @param subscriber subscriber string
+ */
public void setSubscriber(String subscriber) {
if (subscriber != null) {
if (subscriber.length() > 8) {
@@ -411,14 +469,11 @@ public class Subscription extends Syncable {
return jo;
}
- public JSONObject asLimitedJSONObject() {
- JSONObject jo = asJSONObject();
- jo.remove(SUBID_KEY);
- jo.remove(FEEDID_KEY);
- jo.remove(LAST_MOD_KEY);
- return jo;
- }
-
+ /**
+ * Method to hide attributes.
+ * @param hidepasswords true/false
+ * @return JSONObject
+ */
public JSONObject asJSONObject(boolean hidepasswords) {
JSONObject jo = asJSONObject();
if (hidepasswords) {
@@ -430,8 +485,21 @@ public class Subscription extends Syncable {
return jo;
}
+ /**
+ * Method to remove some attributes from JSON.
+ * @ JSONObject
+ */
+ public JSONObject asLimitedJSONObject() {
+ JSONObject jo = asJSONObject();
+ jo.remove(SUBID_KEY);
+ jo.remove(FEEDID_KEY);
+ jo.remove(LAST_MOD_KEY);
+ return jo;
+ }
+
+
@Override
- public boolean doInsert(Connection c) {
+ public boolean doInsert(Connection conn) {
boolean rv = true;
PreparedStatement ps = null;
try {
@@ -445,8 +513,11 @@ 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, FOLLOW_REDIRECTS, DECOMPRESS, AAF_INSTANCE) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
- ps = c.prepareStatement(sql, new String[]{SUBID_COL});
+ String sql = "insert into SUBSCRIPTIONS (SUBID, FEEDID, DELIVERY_URL, DELIVERY_USER, DELIVERY_PASSWORD, "
+ + "DELIVERY_USE100, METADATA_ONLY, SUBSCRIBER, SUSPENDED, GROUPID, "
+ + "PRIVILEGED_SUBSCRIBER, FOLLOW_REDIRECTS, DECOMPRESS, AAF_INSTANCE) "
+ + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ ps = conn.prepareStatement(sql, new String[]{SUBID_COL});
ps.setInt(1, subid);
ps.setInt(2, feedid);
ps.setString(3, getDelivery().getUrl());
@@ -465,7 +536,7 @@ public class Subscription extends Syncable {
ps.close();
// Update the row to set the URLs
sql = "update SUBSCRIPTIONS set SELF_LINK = ?, LOG_LINK = ? where SUBID = ?";
- ps = c.prepareStatement(sql);
+ ps = conn.prepareStatement(sql);
ps.setString(1, getLinks().getSelf());
ps.setString(2, getLinks().getLog());
ps.setInt(3, subid);
@@ -487,12 +558,15 @@ public class Subscription extends Syncable {
}
@Override
- public boolean doUpdate(Connection c) {
+ public boolean doUpdate(Connection conn) {
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 = ?, FOLLOW_REDIRECTS = ?, DECOMPRESS = ? where SUBID = ?";
- ps = c.prepareStatement(sql);
+ String sql = "update SUBSCRIPTIONS set DELIVERY_URL = ?, DELIVERY_USER = ?, DELIVERY_PASSWORD = ?, "
+ + "DELIVERY_USE100 = ?, METADATA_ONLY = ?, " + "SUSPENDED = ?, GROUPID = ?, "
+ + "PRIVILEGED_SUBSCRIBER = ?, "
+ + "FOLLOW_REDIRECTS = ?, DECOMPRESS = ? where SUBID = ?";
+ ps = conn.prepareStatement(sql);
ps.setString(1, delivery.getUrl());
ps.setString(2, delivery.getUser());
ps.setString(3, delivery.getPassword());
@@ -522,7 +596,7 @@ public class Subscription extends Syncable {
/**
- * Rally US708115 Change Ownership of Subscription - 1610
+ * Rally US708115 Change Ownership of Subscription - 1610.
*/
public boolean changeOwnerShip() {
boolean rv = true;
@@ -531,9 +605,9 @@ public class Subscription extends Syncable {
DB db = new DB();
@SuppressWarnings("resource")
- Connection c = db.getConnection();
+ Connection conn = db.getConnection();
String sql = "update SUBSCRIPTIONS set SUBSCRIBER = ? where SUBID = ?";
- ps = c.prepareStatement(sql);
+ ps = conn.prepareStatement(sql);
ps.setString(1, this.subscriber);
ps.setInt(2, subid);
ps.execute();
@@ -555,12 +629,12 @@ public class Subscription extends Syncable {
@Override
- public boolean doDelete(Connection c) {
+ public boolean doDelete(Connection conn) {
boolean rv = true;
PreparedStatement ps = null;
try {
String sql = "delete from SUBSCRIPTIONS where SUBID = ?";
- ps = c.prepareStatement(sql);
+ ps = conn.prepareStatement(sql);
ps.setInt(1, subid);
ps.execute();
} catch (SQLException e) {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Syncable.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Syncable.java
index 6b9eb42a..5f9235b2 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Syncable.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Syncable.java
@@ -36,23 +36,24 @@ import org.json.JSONObject;
* @author Robert Eby
* @version $Id: Syncable.java,v 1.1 2013/07/05 13:48:05 eby Exp $
*/
+
public abstract class Syncable implements Deleteable, Insertable, Updateable, JSONable {
@Override
- abstract public JSONObject asJSONObject();
+ public abstract JSONObject asJSONObject();
@Override
- abstract public boolean doUpdate(Connection c);
+ public abstract boolean doUpdate(Connection conn);
@Override
- abstract public boolean doInsert(Connection c);
+ public abstract boolean doInsert(Connection conn);
@Override
- abstract public boolean doDelete(Connection c);
+ public abstract boolean doDelete(Connection conn);
/**
* Get the "natural key" for this object type, as a String.
*
* @return the key
*/
- abstract public String getKey();
+ public abstract String getKey();
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Updateable.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Updateable.java
index 60af748d..18a42d72 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Updateable.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Updateable.java
@@ -31,12 +31,13 @@ import java.sql.Connection;
* @author Robert Eby
* @version $Id: Updateable.java,v 1.2 2013/05/29 14:44:36 eby Exp $
*/
+
public interface Updateable {
/**
- * Update this object in the DB.
+ * * Update this object in the DB.
*
- * @param c the JDBC Connection to use
+ * @param conn the JDBC Connection to use
* @return true if the UPDATE succeeded, false otherwise
*/
- public boolean doUpdate(Connection c);
+ boolean doUpdate(Connection conn);
}