1 /*******************************************************************************
\r
2 * ============LICENSE_START==================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
25 package org.onap.dmaap.datarouter.provisioning.beans;
\r
27 import org.apache.log4j.Logger;
\r
28 import org.json.JSONArray;
\r
29 import org.json.JSONObject;
\r
30 import org.onap.dmaap.datarouter.provisioning.utils.DB;
\r
31 import org.onap.dmaap.datarouter.provisioning.utils.JSONUtilities;
\r
32 import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
\r
34 import java.io.InvalidObjectException;
\r
37 import java.util.Date;
\r
40 * The representation of a Feed. Feeds can be retrieved from the DB, or stored/updated in the DB.
\r
42 * @author Robert Eby
\r
43 * @version $Id: Feed.java,v 1.13 2013/10/28 18:06:52 eby Exp $
\r
45 public class Feed extends Syncable {
\r
46 private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");
\r
47 private static int next_feedid = getMaxFeedID() + 1;
\r
50 private int groupid; //New field is added - Groups feature Rally:US708115 - 1610
\r
51 private String name;
\r
52 private String version;
\r
53 private String description;
\r
54 private String business_description; // New field is added - Groups feature Rally:US708102 - 1610
\r
55 private FeedAuthorization authorization;
\r
56 private String publisher;
\r
57 private FeedLinks links;
\r
58 private boolean deleted;
\r
59 private boolean suspended;
\r
60 private Date last_mod;
\r
61 private Date created_date;
\r
64 * Check if a feed ID is valid.
\r
66 * @param id the Feed ID
\r
67 * @return true if it is valid
\r
69 @SuppressWarnings("resource")
\r
70 public static boolean isFeedValid(int id) {
\r
74 Connection conn = db.getConnection();
\r
75 try(Statement stmt = conn.createStatement()) {
\r
76 try(ResultSet rs = stmt.executeQuery("select COUNT(*) from FEEDS where FEEDID = " + id)) {
\r
78 count = rs.getInt(1);
\r
83 } catch (SQLException e) {
\r
84 e.printStackTrace();
\r
90 * Get a specific feed from the DB, based upon its ID.
\r
92 * @param id the Feed ID
\r
93 * @return the Feed object, or null if it does not exist
\r
95 public static Feed getFeedById(int id) {
\r
96 String sql = "select * from FEEDS where FEEDID = " + id;
\r
97 return getFeedBySQL(sql);
\r
101 * Get a specific feed from the DB, based upon its name and version.
\r
103 * @param name the name of the Feed
\r
104 * @param version the version of the Feed
\r
105 * @return the Feed object, or null if it does not exist
\r
107 public static Feed getFeedByNameVersion(String name, String version) {
\r
108 name = name.replaceAll("'", "''");
\r
109 version = version.replaceAll("'", "''");
\r
110 String sql = "select * from FEEDS where NAME = '" + name + "' and VERSION ='" + version + "'";
\r
111 return getFeedBySQL(sql);
\r
115 * Return a count of the number of active feeds in the DB.
\r
117 * @return the count
\r
119 public static int countActiveFeeds() {
\r
123 @SuppressWarnings("resource")
\r
124 Connection conn = db.getConnection();
\r
125 try(Statement stmt = conn.createStatement()) {
\r
126 try (ResultSet rs = stmt.executeQuery("select count(*) from FEEDS where DELETED = 0")) {
\r
128 count = rs.getInt(1);
\r
133 } catch (SQLException e) {
\r
134 intlogger.info("countActiveFeeds: " + e.getMessage());
\r
135 e.printStackTrace();
\r
140 public static int getMaxFeedID() {
\r
144 @SuppressWarnings("resource")
\r
145 Connection conn = db.getConnection();
\r
146 try(Statement stmt = conn.createStatement()) {
\r
147 try (ResultSet rs = stmt.executeQuery("select MAX(feedid) from FEEDS")) {
\r
149 max = rs.getInt(1);
\r
154 } catch (SQLException e) {
\r
155 intlogger.info("getMaxFeedID: " + e.getMessage());
\r
156 e.printStackTrace();
\r
161 public static Collection<Feed> getAllFeeds() {
\r
162 Map<Integer, Feed> map = new HashMap<Integer, Feed>();
\r
165 @SuppressWarnings("resource")
\r
166 Connection conn = db.getConnection();
\r
167 try(Statement stmt = conn.createStatement()) {
\r
168 try(ResultSet rs = stmt.executeQuery("select * from FEEDS")) {
\r
169 while (rs.next()) {
\r
170 Feed feed = new Feed(rs);
\r
171 map.put(feed.getFeedid(), feed);
\r
175 String sql = "select * from FEED_ENDPOINT_IDS";
\r
176 try(ResultSet rs = stmt.executeQuery(sql)){
\r
177 while (rs.next()) {
\r
178 int id = rs.getInt("FEEDID");
\r
179 Feed feed = map.get(id);
\r
180 if (feed != null) {
\r
181 FeedEndpointID epi = new FeedEndpointID(rs);
\r
182 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
188 sql = "select * from FEED_ENDPOINT_ADDRS";
\r
189 try(ResultSet rs = stmt.executeQuery(sql)) {
\r
190 while (rs.next()) {
\r
191 int id = rs.getInt("FEEDID");
\r
192 Feed feed = map.get(id);
\r
193 if (feed != null) {
\r
194 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
195 acoll.add(rs.getString("ADDR"));
\r
201 } catch (SQLException e) {
\r
202 e.printStackTrace();
\r
204 return map.values();
\r
207 public static List<String> getFilteredFeedUrlList(final String name, final String val) {
\r
208 List<String> list = new ArrayList<String>();
\r
209 String sql = "select SELF_LINK from FEEDS where DELETED = 0";
\r
210 if (name.equals("name")) {
\r
211 sql += " and NAME = ?";
\r
212 } else if (name.equals("publ")) {
\r
213 sql += " and PUBLISHER = ?";
\r
214 } else if (name.equals("subs")) {
\r
215 sql = "select distinct FEEDS.SELF_LINK from FEEDS, SUBSCRIPTIONS " +
\r
216 "where DELETED = 0 " +
\r
217 "and FEEDS.FEEDID = SUBSCRIPTIONS.FEEDID " +
\r
218 "and SUBSCRIPTIONS.SUBSCRIBER = ?";
\r
222 @SuppressWarnings("resource")
\r
223 Connection conn = db.getConnection();
\r
224 try(PreparedStatement ps = conn.prepareStatement(sql)) {
\r
225 if (sql.indexOf('?') >= 0)
\r
226 ps.setString(1, val);
\r
227 try(ResultSet rs = ps.executeQuery()) {
\r
228 while (rs.next()) {
\r
229 String t = rs.getString(1);
\r
230 list.add(t.trim());
\r
235 } catch (SQLException e) {
\r
236 e.printStackTrace();
\r
241 @SuppressWarnings("resource")
\r
242 private static Feed getFeedBySQL(String sql) {
\r
246 Connection conn = db.getConnection();
\r
247 try (Statement stmt = conn.createStatement()) {
\r
248 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
250 feed = new Feed(rs);
\r
253 if (feed != null) {
\r
254 sql = "select * from FEED_ENDPOINT_IDS where FEEDID = " + feed.feedid;
\r
255 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
256 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
257 while (rs.next()) {
\r
258 FeedEndpointID epi = new FeedEndpointID(rs);
\r
262 sql = "select * from FEED_ENDPOINT_ADDRS where FEEDID = " + feed.feedid;
\r
263 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
264 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
265 while (rs.next()) {
\r
266 acoll.add(rs.getString("ADDR"));
\r
272 } catch (SQLException e) {
\r
273 e.printStackTrace();
\r
279 this("", "", "", "");
\r
282 public Feed(String name, String version, String desc, String business_description) {
\r
284 this.groupid = -1; //New field is added - Groups feature Rally:US708115 - 1610
\r
286 this.version = version;
\r
287 this.description = desc;
\r
288 this.business_description = business_description; // New field is added - Groups feature Rally:US708102 - 1610
\r
289 this.authorization = new FeedAuthorization();
\r
290 this.publisher = "";
\r
291 this.links = new FeedLinks();
\r
292 this.deleted = false;
\r
293 this.suspended = false;
\r
294 this.last_mod = new Date();
\r
295 this.created_date = new Date();
\r
298 public Feed(ResultSet rs) throws SQLException {
\r
299 this.feedid = rs.getInt("FEEDID");
\r
300 this.groupid = rs.getInt("GROUPID"); //New field is added - Groups feature Rally:US708115 - 1610
\r
301 this.name = rs.getString("NAME");
\r
302 this.version = rs.getString("VERSION");
\r
303 this.description = rs.getString("DESCRIPTION");
\r
304 this.business_description = rs.getString("BUSINESS_DESCRIPTION"); // New field is added - Groups feature Rally:US708102 - 1610
\r
305 this.authorization = new FeedAuthorization();
\r
306 this.authorization.setClassification(rs.getString("AUTH_CLASS"));
\r
307 this.publisher = rs.getString("PUBLISHER");
\r
308 this.links = new FeedLinks();
\r
309 this.links.setSelf(rs.getString("SELF_LINK"));
\r
310 this.links.setPublish(rs.getString("PUBLISH_LINK"));
\r
311 this.links.setSubscribe(rs.getString("SUBSCRIBE_LINK"));
\r
312 this.links.setLog(rs.getString("LOG_LINK"));
\r
313 this.deleted = rs.getBoolean("DELETED");
\r
314 this.suspended = rs.getBoolean("SUSPENDED");
\r
315 this.last_mod = rs.getDate("LAST_MOD");
\r
316 this.created_date = rs.getTimestamp("CREATED_DATE");
\r
319 public Feed(JSONObject jo) throws InvalidObjectException {
\r
320 this("", "", "", "");
\r
322 // The JSONObject is assumed to contain a vnd.att-dr.feed representation
\r
323 this.feedid = jo.optInt("feedid", -1);
\r
324 this.groupid = jo.optInt("groupid"); //New field is added - Groups feature Rally:US708115 - 1610
\r
325 this.name = jo.getString("name");
\r
326 if (name.length() > 255)
\r
327 throw new InvalidObjectException("name field is too long");
\r
328 this.version = jo.getString("version");
\r
329 if (version.length() > 20)
\r
330 throw new InvalidObjectException("version field is too long");
\r
331 this.description = jo.optString("description");
\r
332 this.business_description = jo.optString("business_description"); // New field is added - Groups feature Rally:US708102 - 1610
\r
333 if (description.length() > 1000)
\r
334 throw new InvalidObjectException("technical description field is too long");
\r
336 if (business_description.length() > 1000) // New field is added - Groups feature Rally:US708102 - 1610
\r
337 throw new InvalidObjectException("business description field is too long");
\r
339 this.authorization = new FeedAuthorization();
\r
340 JSONObject jauth = jo.getJSONObject("authorization");
\r
341 this.authorization.setClassification(jauth.getString("classification"));
\r
342 if (this.authorization.getClassification().length() > 32)
\r
343 throw new InvalidObjectException("classification field is too long");
\r
344 JSONArray ja = jauth.getJSONArray("endpoint_ids");
\r
345 for (int i = 0; i < ja.length(); i++) {
\r
346 JSONObject id = ja.getJSONObject(i);
\r
347 FeedEndpointID fid = new FeedEndpointID(id.getString("id"), id.getString("password"));
\r
348 if (fid.getId().length() > 20)
\r
349 throw new InvalidObjectException("id field is too long (" + fid.getId() + ")");
\r
350 if (fid.getPassword().length() > 32)
\r
351 throw new InvalidObjectException("password field is too long (" + fid.getPassword() + ")");
\r
352 this.authorization.getEndpoint_ids().add(fid);
\r
354 if (this.authorization.getEndpoint_ids().size() < 1)
\r
355 throw new InvalidObjectException("need to specify at least one endpoint_id");
\r
356 ja = jauth.getJSONArray("endpoint_addrs");
\r
357 for (int i = 0; i < ja.length(); i++) {
\r
358 String addr = ja.getString(i);
\r
359 if (!JSONUtilities.validIPAddrOrSubnet(addr))
\r
360 throw new InvalidObjectException("bad IP addr or subnet mask: " + addr);
\r
361 this.authorization.getEndpoint_addrs().add(addr);
\r
364 this.publisher = jo.optString("publisher", "");
\r
365 this.deleted = jo.optBoolean("deleted", false);
\r
366 this.suspended = jo.optBoolean("suspend", false);
\r
367 JSONObject jol = jo.optJSONObject("links");
\r
368 this.links = (jol == null) ? (new FeedLinks()) : (new FeedLinks(jol));
\r
369 } catch (InvalidObjectException e) {
\r
371 } catch (Exception e) {
\r
372 throw new InvalidObjectException("invalid JSON: " + e.getMessage());
\r
376 public int getFeedid() {
\r
380 public void setFeedid(int feedid) {
\r
381 this.feedid = feedid;
\r
383 // Create link URLs
\r
384 FeedLinks fl = getLinks();
\r
385 fl.setSelf(URLUtilities.generateFeedURL(feedid));
\r
386 fl.setPublish(URLUtilities.generatePublishURL(feedid));
\r
387 fl.setSubscribe(URLUtilities.generateSubscribeURL(feedid));
\r
388 fl.setLog(URLUtilities.generateFeedLogURL(feedid));
\r
391 //new getter setters for groups- Rally:US708115 - 1610
\r
392 public int getGroupid() {
\r
396 public void setGroupid(int groupid) {
\r
397 this.groupid = groupid;
\r
400 public String getName() {
\r
404 public void setName(String name) {
\r
408 public String getVersion() {
\r
412 public void setVersion(String version) {
\r
413 this.version = version;
\r
416 public String getDescription() {
\r
417 return description;
\r
420 public void setDescription(String description) {
\r
421 this.description = description;
\r
424 // New field is added - Groups feature Rally:US708102 - 1610
\r
425 public String getBusiness_description() {
\r
426 return business_description;
\r
429 public void setBusiness_description(String business_description) {
\r
430 this.business_description = business_description;
\r
433 public FeedAuthorization getAuthorization() {
\r
434 return authorization;
\r
437 public void setAuthorization(FeedAuthorization authorization) {
\r
438 this.authorization = authorization;
\r
441 public String getPublisher() {
\r
445 public void setPublisher(String publisher) {
\r
446 if (publisher != null) {
\r
447 if (publisher.length() > 8)
\r
448 publisher = publisher.substring(0, 8);
\r
449 this.publisher = publisher;
\r
453 public FeedLinks getLinks() {
\r
457 public void setLinks(FeedLinks links) {
\r
458 this.links = links;
\r
461 public boolean isDeleted() {
\r
465 public void setDeleted(boolean deleted) {
\r
466 this.deleted = deleted;
\r
469 public boolean isSuspended() {
\r
473 public void setSuspended(boolean suspended) {
\r
474 this.suspended = suspended;
\r
477 public Date getLast_mod() {
\r
481 public Date getCreated_date() {
\r
482 return created_date;
\r
486 public JSONObject asJSONObject() {
\r
487 JSONObject jo = new JSONObject();
\r
488 jo.put("feedid", feedid);
\r
489 jo.put("groupid", groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
490 jo.put("name", name);
\r
491 jo.put("version", version);
\r
492 jo.put("description", description);
\r
493 jo.put("business_description", business_description); // New field is added - Groups feature Rally:US708102 - 1610
\r
494 jo.put("authorization", authorization.asJSONObject());
\r
495 jo.put("publisher", publisher);
\r
496 jo.put("links", links.asJSONObject());
\r
497 jo.put("deleted", deleted);
\r
498 jo.put("suspend", suspended);
\r
499 jo.put("last_mod", last_mod.getTime());
\r
500 jo.put("created_date", created_date.getTime());
\r
504 public JSONObject asLimitedJSONObject() {
\r
505 JSONObject jo = asJSONObject();
\r
506 jo.remove("deleted");
\r
507 jo.remove("feedid");
\r
508 jo.remove("last_mod");
\r
509 jo.remove("created_date");
\r
513 public JSONObject asJSONObject(boolean hidepasswords) {
\r
514 JSONObject jo = asJSONObject();
\r
515 if (hidepasswords) {
\r
516 jo.remove("feedid"); // we no longer hide passwords, however we do hide these
\r
517 jo.remove("deleted");
\r
518 jo.remove("last_mod");
\r
519 jo.remove("created_date");
\r
525 public boolean doDelete(Connection c) {
\r
527 PreparedStatement ps = null;
\r
529 String sql = "delete from FEEDS where FEEDID = ?";
\r
530 ps = c.prepareStatement(sql);
\r
531 ps.setInt(1, feedid);
\r
533 } catch (SQLException e) {
\r
535 intlogger.warn("PROV0007 doDelete: " + e.getMessage());
\r
536 e.printStackTrace();
\r
542 } catch (SQLException e) {
\r
543 e.printStackTrace();
\r
550 public synchronized boolean doInsert(Connection c) {
\r
553 if (feedid == -1) {
\r
554 setFeedid(next_feedid++);
\r
556 // In case we insert a feed from synchronization
\r
557 if (feedid > next_feedid)
\r
558 next_feedid = feedid + 1;
\r
560 // Create FEED_ENDPOINT_IDS rows
\r
561 FeedAuthorization auth = getAuthorization();
\r
562 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
563 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
564 for (FeedEndpointID fid : auth.getEndpoint_ids()) {
\r
565 ps2.setInt(1, feedid);
\r
566 ps2.setString(2, fid.getId());
\r
567 ps2.setString(3, fid.getPassword());
\r
568 ps2.executeUpdate();
\r
572 // Create FEED_ENDPOINT_ADDRS rows
\r
573 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
574 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
575 for (String t : auth.getEndpoint_addrs()) {
\r
576 ps2.setInt(1, feedid);
\r
577 ps2.setString(2, t);
\r
578 ps2.executeUpdate();
\r
582 // Finally, create the FEEDS row
\r
583 sql = "insert into FEEDS (FEEDID, NAME, VERSION, DESCRIPTION, AUTH_CLASS, PUBLISHER, SELF_LINK, PUBLISH_LINK, SUBSCRIBE_LINK, LOG_LINK, DELETED, SUSPENDED,BUSINESS_DESCRIPTION, GROUPID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?, ?)";
\r
584 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
585 ps2.setInt(1, feedid);
\r
586 ps2.setString(2, getName());
\r
587 ps2.setString(3, getVersion());
\r
588 ps2.setString(4, getDescription());
\r
589 ps2.setString(5, getAuthorization().getClassification());
\r
590 ps2.setString(6, getPublisher());
\r
591 ps2.setString(7, getLinks().getSelf());
\r
592 ps2.setString(8, getLinks().getPublish());
\r
593 ps2.setString(9, getLinks().getSubscribe());
\r
594 ps2.setString(10, getLinks().getLog());
\r
595 ps2.setBoolean(11, isDeleted());
\r
596 ps2.setBoolean(12, isSuspended());
\r
597 ps2.setString(13, getBusiness_description()); // New field is added - Groups feature Rally:US708102 - 1610
\r
598 ps2.setInt(14, groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
599 ps2.executeUpdate();
\r
601 } catch (SQLException e) {
\r
603 intlogger.warn("PROV0005 doInsert: " + e.getMessage());
\r
604 e.printStackTrace();
\r
610 public boolean doUpdate(Connection c) {
\r
612 Feed oldobj = getFeedById(feedid);
\r
613 PreparedStatement ps = null;
\r
615 Set<FeedEndpointID> newset = getAuthorization().getEndpoint_ids();
\r
616 Set<FeedEndpointID> oldset = oldobj.getAuthorization().getEndpoint_ids();
\r
618 // Insert new FEED_ENDPOINT_IDS rows
\r
619 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
620 ps = c.prepareStatement(sql);
\r
621 for (FeedEndpointID fid : newset) {
\r
622 if (!oldset.contains(fid)) {
\r
623 ps.setInt(1, feedid);
\r
624 ps.setString(2, fid.getId());
\r
625 ps.setString(3, fid.getPassword());
\r
626 ps.executeUpdate();
\r
631 // Delete old FEED_ENDPOINT_IDS rows
\r
632 sql = "delete from FEED_ENDPOINT_IDS where FEEDID = ? AND USERID = ? AND PASSWORD = ?";
\r
633 ps = c.prepareStatement(sql);
\r
634 for (FeedEndpointID fid : oldset) {
\r
635 if (!newset.contains(fid)) {
\r
636 ps.setInt(1, feedid);
\r
637 ps.setString(2, fid.getId());
\r
638 ps.setString(3, fid.getPassword());
\r
639 ps.executeUpdate();
\r
644 // Insert new FEED_ENDPOINT_ADDRS rows
\r
645 Set<String> newset2 = getAuthorization().getEndpoint_addrs();
\r
646 Set<String> oldset2 = oldobj.getAuthorization().getEndpoint_addrs();
\r
647 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
648 ps = c.prepareStatement(sql);
\r
649 for (String t : newset2) {
\r
650 if (!oldset2.contains(t)) {
\r
651 ps.setInt(1, feedid);
\r
652 ps.setString(2, t);
\r
653 ps.executeUpdate();
\r
658 // Delete old FEED_ENDPOINT_ADDRS rows
\r
659 sql = "delete from FEED_ENDPOINT_ADDRS where FEEDID = ? AND ADDR = ?";
\r
660 ps = c.prepareStatement(sql);
\r
661 for (String t : oldset2) {
\r
662 if (!newset2.contains(t)) {
\r
663 ps.setInt(1, feedid);
\r
664 ps.setString(2, t);
\r
665 ps.executeUpdate();
\r
670 // Finally, update the FEEDS row
\r
671 sql = "update FEEDS set DESCRIPTION = ?, AUTH_CLASS = ?, DELETED = ?, SUSPENDED = ?, BUSINESS_DESCRIPTION=?, GROUPID=? where FEEDID = ?";
\r
672 ps = c.prepareStatement(sql);
\r
673 ps.setString(1, getDescription());
\r
674 ps.setString(2, getAuthorization().getClassification());
\r
675 ps.setInt(3, deleted ? 1 : 0);
\r
676 ps.setInt(4, suspended ? 1 : 0);
\r
677 ps.setString(5, getBusiness_description()); // New field is added - Groups feature Rally:US708102 - 1610
\r
678 ps.setInt(6, groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
679 ps.setInt(7, feedid);
\r
680 ps.executeUpdate();
\r
682 } catch (SQLException e) {
\r
684 intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
\r
685 e.printStackTrace();
\r
690 } catch (SQLException e) {
\r
691 e.printStackTrace();
\r
699 * Change Ownership of FEED - 1610
\r
701 public boolean changeOwnerShip() {
\r
703 PreparedStatement ps = null;
\r
707 @SuppressWarnings("resource")
\r
708 Connection c = db.getConnection();
\r
709 String sql = "update FEEDS set PUBLISHER = ? where FEEDID = ?";
\r
710 ps = c.prepareStatement(sql);
\r
711 ps.setString(1, this.publisher);
\r
712 ps.setInt(2, feedid);
\r
715 } catch (SQLException e) {
\r
717 intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
\r
718 e.printStackTrace();
\r
724 } catch (SQLException e) {
\r
725 e.printStackTrace();
\r
733 public String getKey() {
\r
734 return "" + getFeedid();
\r
738 public boolean equals(Object obj) {
\r
739 if (!(obj instanceof Feed))
\r
741 Feed of = (Feed) obj;
\r
742 if (feedid != of.feedid)
\r
744 if (groupid != of.groupid) //New field is added - Groups feature Rally:US708115 - 1610
\r
746 if (!name.equals(of.name))
\r
748 if (!version.equals(of.version))
\r
750 if (!description.equals(of.description))
\r
752 if (!business_description.equals(of.business_description)) // New field is added - Groups feature Rally:US708102 - 1610
\r
754 if (!publisher.equals(of.publisher))
\r
756 if (!authorization.equals(of.authorization))
\r
758 if (!links.equals(of.links))
\r
760 if (deleted != of.deleted)
\r
762 if (suspended != of.suspended)
\r
768 public String toString() {
\r
769 return "FEED: feedid=" + feedid + ", name=" + name + ", version=" + version;
\r
773 public int hashCode() {
\r
774 return Objects.hash(feedid, groupid, name, version, description, business_description, authorization, publisher, links, deleted, suspended, last_mod, created_date);
\r