<suppressions>
<suppress files=".*Test\.java" checks="[a-zA-Z0-9]*"/>
+ <suppress files="." checks="JavadocTagContinuationIndentation"/>
</suppressions>
\ No newline at end of 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
/**\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
/** 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
* 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
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
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
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?
*
}
/**
- * 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.
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);
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);
* * 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
*/\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
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
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
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
}\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
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
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
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
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
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
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
* @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
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
} 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
}\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
}\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
}\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
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
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
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
jo.put("expiryReason", reason);\r
jo.put("attempts", attempts);\r
\r
- return this.reOrderObject(jo);\r
+ return reOrderObject(jo);\r
}\r
\r
@Override\r
\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
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
* @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
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
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
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
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
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
}\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
}\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
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
} 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
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
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
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
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
}\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
\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
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
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
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
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
}\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
\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
}\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
}\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
\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
\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
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
\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
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
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
}\r
\r
/**\r
- * Rally US708115\r
+ * Rally US708115.\r
* Change Ownership of FEED - 1610\r
*/\r
public boolean changeOwnerShip() {\r
\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
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
\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
* @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
}\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
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
\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
* *\r
******************************************************************************/\r
\r
-\r
package org.onap.dmaap.datarouter.provisioning.beans;\r
\r
import java.sql.ResultSet;\r
\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
* @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
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
\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
* @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
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
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
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
}\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
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
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
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
}\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
}\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
}\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
\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
* @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
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
}\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
* @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
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
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
* @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
}\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
* @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
}\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
}\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
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
* @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
\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
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
*\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
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
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
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
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
+ result + "|"\r
+ attempts + "|"\r
+ reason + "|"\r
- + record_id + "|"\r
+ + recordId + "|"\r
+ clength2\r
+ "\n";\r
}\r
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
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
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
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
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
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
}\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
}\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
}\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
}\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
* @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
}\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
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
} 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
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
* @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
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
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
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
/**\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
}\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
}\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
}\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
* @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
* @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
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
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
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
return new LOGJSONObject(logrecordObj);\r
}\r
\r
+\r
@Override\r
public LOGJSONObject asJSONObject() {\r
LOGJSONObject jo = super.asJSONObject();\r
* @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
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
\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
* @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
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
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
\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
* @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
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
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
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
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
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
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
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
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
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
}\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
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
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
SubLinks sl = getLinks();\r
sl.setFeed(URLUtilities.generateFeedURL(feedid));\r
}\r
+\r
public String getAafInstance() {\r
return aafInstance;\r
}\r
private boolean isFollowRedirect() {\r
return followRedirect;\r
}\r
+\r
public void setFollowRedirect(boolean followRedirect) {\r
this.followRedirect = followRedirect;\r
}\r
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
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
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
}\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
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
}\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
\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
\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
\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
* @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
* @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