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(PreparedStatement stmt = conn.prepareStatement("select COUNT(*) from FEEDS where FEEDID = ?")) {
\r
77 try(ResultSet rs = stmt.executeQuery()) {
\r
79 count = rs.getInt(1);
\r
84 } catch (SQLException e) {
\r
85 e.printStackTrace();
\r
91 * Get a specific feed from the DB, based upon its ID.
\r
93 * @param id the Feed ID
\r
94 * @return the Feed object, or null if it does not exist
\r
96 public static Feed getFeedById(int id) {
\r
97 String sql = "select * from FEEDS where FEEDID = " + id;
\r
98 return getFeedBySQL(sql);
\r
102 * Get a specific feed from the DB, based upon its name and version.
\r
104 * @param name the name of the Feed
\r
105 * @param version the version of the Feed
\r
106 * @return the Feed object, or null if it does not exist
\r
108 public static Feed getFeedByNameVersion(String name, String version) {
\r
109 name = name.replaceAll("'", "''");
\r
110 version = version.replaceAll("'", "''");
\r
111 String sql = "select * from FEEDS where NAME = '" + name + "' and VERSION ='" + version + "'";
\r
112 return getFeedBySQL(sql);
\r
116 * Return a count of the number of active feeds in the DB.
\r
118 * @return the count
\r
120 public static int countActiveFeeds() {
\r
124 @SuppressWarnings("resource")
\r
125 Connection conn = db.getConnection();
\r
126 try(Statement stmt = conn.createStatement()) {
\r
127 try (ResultSet rs = stmt.executeQuery("select count(*) from FEEDS where DELETED = 0")) {
\r
129 count = rs.getInt(1);
\r
134 } catch (SQLException e) {
\r
135 intlogger.info("countActiveFeeds: " + e.getMessage());
\r
136 e.printStackTrace();
\r
141 public static int getMaxFeedID() {
\r
145 @SuppressWarnings("resource")
\r
146 Connection conn = db.getConnection();
\r
147 try(Statement stmt = conn.createStatement()) {
\r
148 try (ResultSet rs = stmt.executeQuery("select MAX(feedid) from FEEDS")) {
\r
150 max = rs.getInt(1);
\r
155 } catch (SQLException e) {
\r
156 intlogger.info("getMaxFeedID: " + e.getMessage());
\r
157 e.printStackTrace();
\r
162 public static Collection<Feed> getAllFeeds() {
\r
163 Map<Integer, Feed> map = new HashMap<Integer, Feed>();
\r
166 @SuppressWarnings("resource")
\r
167 Connection conn = db.getConnection();
\r
168 try(Statement stmt = conn.createStatement()) {
\r
169 try(ResultSet rs = stmt.executeQuery("select * from FEEDS")) {
\r
170 while (rs.next()) {
\r
171 Feed feed = new Feed(rs);
\r
172 map.put(feed.getFeedid(), feed);
\r
176 String sql = "select * from FEED_ENDPOINT_IDS";
\r
177 try(ResultSet rs = stmt.executeQuery(sql)){
\r
178 while (rs.next()) {
\r
179 int id = rs.getInt("FEEDID");
\r
180 Feed feed = map.get(id);
\r
181 if (feed != null) {
\r
182 FeedEndpointID epi = new FeedEndpointID(rs);
\r
183 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
189 sql = "select * from FEED_ENDPOINT_ADDRS";
\r
190 try(ResultSet rs = stmt.executeQuery(sql)) {
\r
191 while (rs.next()) {
\r
192 int id = rs.getInt("FEEDID");
\r
193 Feed feed = map.get(id);
\r
194 if (feed != null) {
\r
195 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
196 acoll.add(rs.getString("ADDR"));
\r
202 } catch (SQLException e) {
\r
203 e.printStackTrace();
\r
205 return map.values();
\r
208 public static List<String> getFilteredFeedUrlList(final String name, final String val) {
\r
209 List<String> list = new ArrayList<String>();
\r
210 String sql = "select SELF_LINK from FEEDS where DELETED = 0";
\r
211 if (name.equals("name")) {
\r
212 sql += " and NAME = ?";
\r
213 } else if (name.equals("publ")) {
\r
214 sql += " and PUBLISHER = ?";
\r
215 } else if (name.equals("subs")) {
\r
216 sql = "select distinct FEEDS.SELF_LINK from FEEDS, SUBSCRIPTIONS " +
\r
217 "where DELETED = 0 " +
\r
218 "and FEEDS.FEEDID = SUBSCRIPTIONS.FEEDID " +
\r
219 "and SUBSCRIPTIONS.SUBSCRIBER = ?";
\r
223 @SuppressWarnings("resource")
\r
224 Connection conn = db.getConnection();
\r
225 try(PreparedStatement ps = conn.prepareStatement(sql)) {
\r
226 if (sql.indexOf('?') >= 0)
\r
227 ps.setString(1, val);
\r
228 try(ResultSet rs = ps.executeQuery()) {
\r
229 while (rs.next()) {
\r
230 String t = rs.getString(1);
\r
231 list.add(t.trim());
\r
236 } catch (SQLException e) {
\r
237 e.printStackTrace();
\r
242 @SuppressWarnings("resource")
\r
243 private static Feed getFeedBySQL(String sql) {
\r
247 Connection conn = db.getConnection();
\r
248 try (Statement stmt = conn.createStatement()) {
\r
249 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
251 feed = new Feed(rs);
\r
254 if (feed != null) {
\r
255 sql = "select * from FEED_ENDPOINT_IDS where FEEDID = " + feed.feedid;
\r
256 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
257 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
258 while (rs.next()) {
\r
259 FeedEndpointID epi = new FeedEndpointID(rs);
\r
263 sql = "select * from FEED_ENDPOINT_ADDRS where FEEDID = " + feed.feedid;
\r
264 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
265 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
266 while (rs.next()) {
\r
267 acoll.add(rs.getString("ADDR"));
\r
273 } catch (SQLException e) {
\r
274 e.printStackTrace();
\r
280 this("", "", "", "");
\r
283 public Feed(String name, String version, String desc, String business_description) {
\r
285 this.groupid = -1; //New field is added - Groups feature Rally:US708115 - 1610
\r
287 this.version = version;
\r
288 this.description = desc;
\r
289 this.business_description = business_description; // New field is added - Groups feature Rally:US708102 - 1610
\r
290 this.authorization = new FeedAuthorization();
\r
291 this.publisher = "";
\r
292 this.links = new FeedLinks();
\r
293 this.deleted = false;
\r
294 this.suspended = false;
\r
295 this.last_mod = new Date();
\r
296 this.created_date = new Date();
\r
299 public Feed(ResultSet rs) throws SQLException {
\r
300 this.feedid = rs.getInt("FEEDID");
\r
301 this.groupid = rs.getInt("GROUPID"); //New field is added - Groups feature Rally:US708115 - 1610
\r
302 this.name = rs.getString("NAME");
\r
303 this.version = rs.getString("VERSION");
\r
304 this.description = rs.getString("DESCRIPTION");
\r
305 this.business_description = rs.getString("BUSINESS_DESCRIPTION"); // New field is added - Groups feature Rally:US708102 - 1610
\r
306 this.authorization = new FeedAuthorization();
\r
307 this.authorization.setClassification(rs.getString("AUTH_CLASS"));
\r
308 this.publisher = rs.getString("PUBLISHER");
\r
309 this.links = new FeedLinks();
\r
310 this.links.setSelf(rs.getString("SELF_LINK"));
\r
311 this.links.setPublish(rs.getString("PUBLISH_LINK"));
\r
312 this.links.setSubscribe(rs.getString("SUBSCRIBE_LINK"));
\r
313 this.links.setLog(rs.getString("LOG_LINK"));
\r
314 this.deleted = rs.getBoolean("DELETED");
\r
315 this.suspended = rs.getBoolean("SUSPENDED");
\r
316 this.last_mod = rs.getDate("LAST_MOD");
\r
317 this.created_date = rs.getTimestamp("CREATED_DATE");
\r
320 public Feed(JSONObject jo) throws InvalidObjectException {
\r
321 this("", "", "", "");
\r
323 // The JSONObject is assumed to contain a vnd.att-dr.feed representation
\r
324 this.feedid = jo.optInt("feedid", -1);
\r
325 this.groupid = jo.optInt("groupid"); //New field is added - Groups feature Rally:US708115 - 1610
\r
326 this.name = jo.getString("name");
\r
327 if (name.length() > 255)
\r
328 throw new InvalidObjectException("name field is too long");
\r
329 this.version = jo.getString("version");
\r
330 if (version.length() > 20)
\r
331 throw new InvalidObjectException("version field is too long");
\r
332 this.description = jo.optString("description");
\r
333 this.business_description = jo.optString("business_description"); // New field is added - Groups feature Rally:US708102 - 1610
\r
334 if (description.length() > 1000)
\r
335 throw new InvalidObjectException("technical description field is too long");
\r
337 if (business_description.length() > 1000) // New field is added - Groups feature Rally:US708102 - 1610
\r
338 throw new InvalidObjectException("business description field is too long");
\r
340 this.authorization = new FeedAuthorization();
\r
341 JSONObject jauth = jo.getJSONObject("authorization");
\r
342 this.authorization.setClassification(jauth.getString("classification"));
\r
343 if (this.authorization.getClassification().length() > 32)
\r
344 throw new InvalidObjectException("classification field is too long");
\r
345 JSONArray ja = jauth.getJSONArray("endpoint_ids");
\r
346 for (int i = 0; i < ja.length(); i++) {
\r
347 JSONObject id = ja.getJSONObject(i);
\r
348 FeedEndpointID fid = new FeedEndpointID(id.getString("id"), id.getString("password"));
\r
349 if (fid.getId().length() > 20)
\r
350 throw new InvalidObjectException("id field is too long (" + fid.getId() + ")");
\r
351 if (fid.getPassword().length() > 32)
\r
352 throw new InvalidObjectException("password field is too long (" + fid.getPassword() + ")");
\r
353 this.authorization.getEndpoint_ids().add(fid);
\r
355 if (this.authorization.getEndpoint_ids().size() < 1)
\r
356 throw new InvalidObjectException("need to specify at least one endpoint_id");
\r
357 ja = jauth.getJSONArray("endpoint_addrs");
\r
358 for (int i = 0; i < ja.length(); i++) {
\r
359 String addr = ja.getString(i);
\r
360 if (!JSONUtilities.validIPAddrOrSubnet(addr))
\r
361 throw new InvalidObjectException("bad IP addr or subnet mask: " + addr);
\r
362 this.authorization.getEndpoint_addrs().add(addr);
\r
365 this.publisher = jo.optString("publisher", "");
\r
366 this.deleted = jo.optBoolean("deleted", false);
\r
367 this.suspended = jo.optBoolean("suspend", false);
\r
368 JSONObject jol = jo.optJSONObject("links");
\r
369 this.links = (jol == null) ? (new FeedLinks()) : (new FeedLinks(jol));
\r
370 } catch (InvalidObjectException e) {
\r
372 } catch (Exception e) {
\r
373 throw new InvalidObjectException("invalid JSON: " + e.getMessage());
\r
377 public int getFeedid() {
\r
381 public void setFeedid(int feedid) {
\r
382 this.feedid = feedid;
\r
384 // Create link URLs
\r
385 FeedLinks fl = getLinks();
\r
386 fl.setSelf(URLUtilities.generateFeedURL(feedid));
\r
387 fl.setPublish(URLUtilities.generatePublishURL(feedid));
\r
388 fl.setSubscribe(URLUtilities.generateSubscribeURL(feedid));
\r
389 fl.setLog(URLUtilities.generateFeedLogURL(feedid));
\r
392 //new getter setters for groups- Rally:US708115 - 1610
\r
393 public int getGroupid() {
\r
397 public void setGroupid(int groupid) {
\r
398 this.groupid = groupid;
\r
401 public String getName() {
\r
405 public void setName(String name) {
\r
409 public String getVersion() {
\r
413 public void setVersion(String version) {
\r
414 this.version = version;
\r
417 public String getDescription() {
\r
418 return description;
\r
421 public void setDescription(String description) {
\r
422 this.description = description;
\r
425 // New field is added - Groups feature Rally:US708102 - 1610
\r
426 public String getBusiness_description() {
\r
427 return business_description;
\r
430 public void setBusiness_description(String business_description) {
\r
431 this.business_description = business_description;
\r
434 public FeedAuthorization getAuthorization() {
\r
435 return authorization;
\r
438 public void setAuthorization(FeedAuthorization authorization) {
\r
439 this.authorization = authorization;
\r
442 public String getPublisher() {
\r
446 public void setPublisher(String publisher) {
\r
447 if (publisher != null) {
\r
448 if (publisher.length() > 8)
\r
449 publisher = publisher.substring(0, 8);
\r
450 this.publisher = publisher;
\r
454 public FeedLinks getLinks() {
\r
458 public void setLinks(FeedLinks links) {
\r
459 this.links = links;
\r
462 public boolean isDeleted() {
\r
466 public void setDeleted(boolean deleted) {
\r
467 this.deleted = deleted;
\r
470 public boolean isSuspended() {
\r
474 public void setSuspended(boolean suspended) {
\r
475 this.suspended = suspended;
\r
478 public Date getLast_mod() {
\r
482 public Date getCreated_date() {
\r
483 return created_date;
\r
487 public JSONObject asJSONObject() {
\r
488 JSONObject jo = new JSONObject();
\r
489 jo.put("feedid", feedid);
\r
490 jo.put("groupid", groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
491 jo.put("name", name);
\r
492 jo.put("version", version);
\r
493 jo.put("description", description);
\r
494 jo.put("business_description", business_description); // New field is added - Groups feature Rally:US708102 - 1610
\r
495 jo.put("authorization", authorization.asJSONObject());
\r
496 jo.put("publisher", publisher);
\r
497 jo.put("links", links.asJSONObject());
\r
498 jo.put("deleted", deleted);
\r
499 jo.put("suspend", suspended);
\r
500 jo.put("last_mod", last_mod.getTime());
\r
501 jo.put("created_date", created_date.getTime());
\r
505 public JSONObject asLimitedJSONObject() {
\r
506 JSONObject jo = asJSONObject();
\r
507 jo.remove("deleted");
\r
508 jo.remove("feedid");
\r
509 jo.remove("last_mod");
\r
510 jo.remove("created_date");
\r
514 public JSONObject asJSONObject(boolean hidepasswords) {
\r
515 JSONObject jo = asJSONObject();
\r
516 if (hidepasswords) {
\r
517 jo.remove("feedid"); // we no longer hide passwords, however we do hide these
\r
518 jo.remove("deleted");
\r
519 jo.remove("last_mod");
\r
520 jo.remove("created_date");
\r
526 public boolean doDelete(Connection c) {
\r
528 PreparedStatement ps = null;
\r
530 String sql = "delete from FEEDS where FEEDID = ?";
\r
531 ps = c.prepareStatement(sql);
\r
532 ps.setInt(1, feedid);
\r
534 } catch (SQLException e) {
\r
536 intlogger.warn("PROV0007 doDelete: " + e.getMessage());
\r
537 e.printStackTrace();
\r
543 } catch (SQLException e) {
\r
544 e.printStackTrace();
\r
551 public synchronized boolean doInsert(Connection c) {
\r
554 if (feedid == -1) {
\r
555 setFeedid(next_feedid++);
\r
557 // In case we insert a feed from synchronization
\r
558 if (feedid > next_feedid)
\r
559 next_feedid = feedid + 1;
\r
561 // Create FEED_ENDPOINT_IDS rows
\r
562 FeedAuthorization auth = getAuthorization();
\r
563 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
564 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
565 for (FeedEndpointID fid : auth.getEndpoint_ids()) {
\r
566 ps2.setInt(1, feedid);
\r
567 ps2.setString(2, fid.getId());
\r
568 ps2.setString(3, fid.getPassword());
\r
569 ps2.executeUpdate();
\r
573 // Create FEED_ENDPOINT_ADDRS rows
\r
574 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
575 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
576 for (String t : auth.getEndpoint_addrs()) {
\r
577 ps2.setInt(1, feedid);
\r
578 ps2.setString(2, t);
\r
579 ps2.executeUpdate();
\r
583 // Finally, create the FEEDS row
\r
584 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
585 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
586 ps2.setInt(1, feedid);
\r
587 ps2.setString(2, getName());
\r
588 ps2.setString(3, getVersion());
\r
589 ps2.setString(4, getDescription());
\r
590 ps2.setString(5, getAuthorization().getClassification());
\r
591 ps2.setString(6, getPublisher());
\r
592 ps2.setString(7, getLinks().getSelf());
\r
593 ps2.setString(8, getLinks().getPublish());
\r
594 ps2.setString(9, getLinks().getSubscribe());
\r
595 ps2.setString(10, getLinks().getLog());
\r
596 ps2.setBoolean(11, isDeleted());
\r
597 ps2.setBoolean(12, isSuspended());
\r
598 ps2.setString(13, getBusiness_description()); // New field is added - Groups feature Rally:US708102 - 1610
\r
599 ps2.setInt(14, groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
600 ps2.executeUpdate();
\r
602 } catch (SQLException e) {
\r
604 intlogger.warn("PROV0005 doInsert: " + e.getMessage());
\r
605 e.printStackTrace();
\r
611 public boolean doUpdate(Connection c) {
\r
613 Feed oldobj = getFeedById(feedid);
\r
614 PreparedStatement ps = null;
\r
616 Set<FeedEndpointID> newset = getAuthorization().getEndpoint_ids();
\r
617 Set<FeedEndpointID> oldset = oldobj.getAuthorization().getEndpoint_ids();
\r
619 // Insert new FEED_ENDPOINT_IDS rows
\r
620 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
621 ps = c.prepareStatement(sql);
\r
622 for (FeedEndpointID fid : newset) {
\r
623 if (!oldset.contains(fid)) {
\r
624 ps.setInt(1, feedid);
\r
625 ps.setString(2, fid.getId());
\r
626 ps.setString(3, fid.getPassword());
\r
627 ps.executeUpdate();
\r
632 // Delete old FEED_ENDPOINT_IDS rows
\r
633 sql = "delete from FEED_ENDPOINT_IDS where FEEDID = ? AND USERID = ? AND PASSWORD = ?";
\r
634 ps = c.prepareStatement(sql);
\r
635 for (FeedEndpointID fid : oldset) {
\r
636 if (!newset.contains(fid)) {
\r
637 ps.setInt(1, feedid);
\r
638 ps.setString(2, fid.getId());
\r
639 ps.setString(3, fid.getPassword());
\r
640 ps.executeUpdate();
\r
645 // Insert new FEED_ENDPOINT_ADDRS rows
\r
646 Set<String> newset2 = getAuthorization().getEndpoint_addrs();
\r
647 Set<String> oldset2 = oldobj.getAuthorization().getEndpoint_addrs();
\r
648 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
649 ps = c.prepareStatement(sql);
\r
650 for (String t : newset2) {
\r
651 if (!oldset2.contains(t)) {
\r
652 ps.setInt(1, feedid);
\r
653 ps.setString(2, t);
\r
654 ps.executeUpdate();
\r
659 // Delete old FEED_ENDPOINT_ADDRS rows
\r
660 sql = "delete from FEED_ENDPOINT_ADDRS where FEEDID = ? AND ADDR = ?";
\r
661 ps = c.prepareStatement(sql);
\r
662 for (String t : oldset2) {
\r
663 if (!newset2.contains(t)) {
\r
664 ps.setInt(1, feedid);
\r
665 ps.setString(2, t);
\r
666 ps.executeUpdate();
\r
671 // Finally, update the FEEDS row
\r
672 sql = "update FEEDS set DESCRIPTION = ?, AUTH_CLASS = ?, DELETED = ?, SUSPENDED = ?, BUSINESS_DESCRIPTION=?, GROUPID=? where FEEDID = ?";
\r
673 ps = c.prepareStatement(sql);
\r
674 ps.setString(1, getDescription());
\r
675 ps.setString(2, getAuthorization().getClassification());
\r
676 ps.setInt(3, deleted ? 1 : 0);
\r
677 ps.setInt(4, suspended ? 1 : 0);
\r
678 ps.setString(5, getBusiness_description()); // New field is added - Groups feature Rally:US708102 - 1610
\r
679 ps.setInt(6, groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
680 ps.setInt(7, feedid);
\r
681 ps.executeUpdate();
\r
683 } catch (SQLException e) {
\r
685 intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
\r
686 e.printStackTrace();
\r
691 } catch (SQLException e) {
\r
692 e.printStackTrace();
\r
700 * Change Ownership of FEED - 1610
\r
702 public boolean changeOwnerShip() {
\r
704 PreparedStatement ps = null;
\r
708 @SuppressWarnings("resource")
\r
709 Connection c = db.getConnection();
\r
710 String sql = "update FEEDS set PUBLISHER = ? where FEEDID = ?";
\r
711 ps = c.prepareStatement(sql);
\r
712 ps.setString(1, this.publisher);
\r
713 ps.setInt(2, feedid);
\r
716 } catch (SQLException e) {
\r
718 intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
\r
719 e.printStackTrace();
\r
725 } catch (SQLException e) {
\r
726 e.printStackTrace();
\r
734 public String getKey() {
\r
735 return "" + getFeedid();
\r
739 public boolean equals(Object obj) {
\r
740 if (!(obj instanceof Feed))
\r
742 Feed of = (Feed) obj;
\r
743 if (feedid != of.feedid)
\r
745 if (groupid != of.groupid) //New field is added - Groups feature Rally:US708115 - 1610
\r
747 if (!name.equals(of.name))
\r
749 if (!version.equals(of.version))
\r
751 if (!description.equals(of.description))
\r
753 if (!business_description.equals(of.business_description)) // New field is added - Groups feature Rally:US708102 - 1610
\r
755 if (!publisher.equals(of.publisher))
\r
757 if (!authorization.equals(of.authorization))
\r
759 if (!links.equals(of.links))
\r
761 if (deleted != of.deleted)
\r
763 if (suspended != of.suspended)
\r
769 public String toString() {
\r
770 return "FEED: feedid=" + feedid + ", name=" + name + ", version=" + version;
\r
774 public int hashCode() {
\r
775 return Objects.hash(feedid, groupid, name, version, description, business_description, authorization, publisher, links, deleted, suspended, last_mod, created_date);
\r