Code style cleanup for prov authz and beans 80/92480/1
authoregernug <gerard.nugent@est.tech>
Thu, 1 Aug 2019 15:09:35 +0000 (15:09 +0000)
committeregernug <gerard.nugent@est.tech>
Thu, 1 Aug 2019 15:09:35 +0000 (15:09 +0000)
Change-Id: I4ee093658fd602c54378e64d251fb795cbb77b96
Issue-ID: DMAAP-1250
Signed-off-by: egernug <gerard.nugent@est.tech>
32 files changed:
ci_scripts/suppressedFilesForStyleCheck.xml
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponse.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/AuthorizationResponseSupplement.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/Authorizer.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/AuthzResource.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthorizer.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/ProvDataProvider.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecord.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Deleteable.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryExtraRecord.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecord.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EventLogRecord.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/ExpiryRecord.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedEndpointID.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRoute.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Insertable.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Parameters.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PubFailRecord.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecord.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubDelivery.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/SubLinks.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Subscription.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Syncable.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Updateable.java

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