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 com.att.research.datarouter.provisioning.beans;
\r
27 import java.io.InvalidObjectException;
\r
28 import java.sql.Connection;
\r
29 import java.sql.PreparedStatement;
\r
30 import java.sql.ResultSet;
\r
31 import java.sql.SQLException;
\r
32 import java.sql.Statement;
\r
33 import java.util.ArrayList;
\r
34 import java.util.Collection;
\r
35 import java.util.Date;
\r
36 import java.util.HashMap;
\r
37 import java.util.List;
\r
38 import java.util.Map;
\r
39 import java.util.Set;
\r
41 import org.apache.log4j.Logger;
\r
42 import org.json.JSONArray;
\r
43 import org.json.JSONObject;
\r
45 import com.att.research.datarouter.provisioning.utils.DB;
\r
46 import com.att.research.datarouter.provisioning.utils.JSONUtilities;
\r
47 import com.att.research.datarouter.provisioning.utils.URLUtilities;
\r
50 * The representation of a Feed. Feeds can be retrieved from the DB, or stored/updated in the DB.
\r
51 * @author Robert Eby
\r
52 * @version $Id: Feed.java,v 1.13 2013/10/28 18:06:52 eby Exp $
\r
54 public class Feed extends Syncable {
\r
55 private static Logger intlogger = Logger.getLogger("com.att.research.datarouter.provisioning.internal");
\r
56 private static int next_feedid = getMaxFeedID() + 1;
\r
59 private int groupid; //New field is added - Groups feature Rally:US708115 - 1610
\r
60 private String name;
\r
61 private String version;
\r
62 private String description;
\r
63 private String business_description; // New field is added - Groups feature Rally:US708102 - 1610
\r
64 private FeedAuthorization authorization;
\r
65 private String publisher;
\r
66 private FeedLinks links;
\r
67 private boolean deleted;
\r
68 private boolean suspended;
\r
69 private Date last_mod;
\r
70 private Date created_date;
\r
73 * Check if a feed ID is valid.
\r
74 * @param id the Feed ID
\r
75 * @return true if it is valid
\r
77 @SuppressWarnings("resource")
\r
78 public static boolean isFeedValid(int id) {
\r
82 Connection conn = db.getConnection();
\r
83 Statement stmt = conn.createStatement();
\r
84 ResultSet rs = stmt.executeQuery("select COUNT(*) from FEEDS where FEEDID = " + id);
\r
86 count = rs.getInt(1);
\r
91 } catch (SQLException e) {
\r
92 e.printStackTrace();
\r
97 * Get a specific feed from the DB, based upon its ID.
\r
98 * @param id the Feed ID
\r
99 * @return the Feed object, or null if it does not exist
\r
101 public static Feed getFeedById(int id) {
\r
102 String sql = "select * from FEEDS where FEEDID = " + id;
\r
103 return getFeedBySQL(sql);
\r
106 * Get a specific feed from the DB, based upon its name and version.
\r
107 * @param name the name of the Feed
\r
108 * @param version the version of the Feed
\r
109 * @return the Feed object, or null if it does not exist
\r
111 public static Feed getFeedByNameVersion(String name, String version) {
\r
112 name = name.replaceAll("'", "''");
\r
113 version = version.replaceAll("'", "''");
\r
114 String sql = "select * from FEEDS where NAME = '" + name + "' and VERSION ='" + version + "'";
\r
115 return getFeedBySQL(sql);
\r
118 * Return a count of the number of active feeds in the DB.
\r
119 * @return the count
\r
121 public static int countActiveFeeds() {
\r
125 @SuppressWarnings("resource")
\r
126 Connection conn = db.getConnection();
\r
127 Statement stmt = conn.createStatement();
\r
128 ResultSet rs = stmt.executeQuery("select count(*) from FEEDS where DELETED = 0");
\r
130 count = rs.getInt(1);
\r
135 } catch (SQLException e) {
\r
136 intlogger.info("countActiveFeeds: "+e.getMessage());
\r
137 e.printStackTrace();
\r
141 public static int getMaxFeedID() {
\r
145 @SuppressWarnings("resource")
\r
146 Connection conn = db.getConnection();
\r
147 Statement stmt = conn.createStatement();
\r
148 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
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 Statement stmt = conn.createStatement();
\r
168 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 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 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
202 } catch (SQLException e) {
\r
203 e.printStackTrace();
\r
205 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 PreparedStatement ps = conn.prepareStatement(sql);
\r
225 if (sql.indexOf('?') >= 0)
\r
226 ps.setString(1, val);
\r
227 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
240 @SuppressWarnings("resource")
\r
241 private static Feed getFeedBySQL(String sql) {
\r
245 Connection conn = db.getConnection();
\r
246 Statement stmt = conn.createStatement();
\r
247 ResultSet rs = stmt.executeQuery(sql);
\r
249 feed = new Feed(rs);
\r
252 sql = "select * from FEED_ENDPOINT_IDS where FEEDID = " + feed.feedid;
\r
253 rs = stmt.executeQuery(sql);
\r
254 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
255 while (rs.next()) {
\r
256 FeedEndpointID epi = new FeedEndpointID(rs);
\r
261 sql = "select * from FEED_ENDPOINT_ADDRS where FEEDID = " + feed.feedid;
\r
262 rs = stmt.executeQuery(sql);
\r
263 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
264 while (rs.next()) {
\r
265 acoll.add(rs.getString("ADDR"));
\r
271 } catch (SQLException e) {
\r
272 e.printStackTrace();
\r
278 this("", "", "","");
\r
281 public Feed(String name, String version, String desc,String business_description) {
\r
283 this.groupid = -1; //New field is added - Groups feature Rally:US708115 - 1610
\r
285 this.version = version;
\r
286 this.description = desc;
\r
287 this.business_description=business_description; // New field is added - Groups feature Rally:US708102 - 1610
\r
288 this.authorization = new FeedAuthorization();
\r
289 this.publisher = "";
\r
290 this.links = new FeedLinks();
\r
291 this.deleted = false;
\r
292 this.suspended = false;
\r
293 this.last_mod = new Date();
\r
294 this.created_date = new Date();
\r
296 public Feed(ResultSet rs) throws SQLException {
\r
297 this.feedid = rs.getInt("FEEDID");
\r
298 this.groupid = rs.getInt("GROUPID"); //New field is added - Groups feature Rally:US708115 - 1610
\r
299 this.name = rs.getString("NAME");
\r
300 this.version = rs.getString("VERSION");
\r
301 this.description = rs.getString("DESCRIPTION");
\r
302 this.business_description=rs.getString("BUSINESS_DESCRIPTION"); // New field is added - Groups feature Rally:US708102 - 1610
\r
303 this.authorization = new FeedAuthorization();
\r
304 this.authorization.setClassification(rs.getString("AUTH_CLASS"));
\r
305 this.publisher = rs.getString("PUBLISHER");
\r
306 this.links = new FeedLinks();
\r
307 this.links.setSelf(rs.getString("SELF_LINK"));
\r
308 this.links.setPublish(rs.getString("PUBLISH_LINK"));
\r
309 this.links.setSubscribe(rs.getString("SUBSCRIBE_LINK"));
\r
310 this.links.setLog(rs.getString("LOG_LINK"));
\r
311 this.deleted = rs.getBoolean("DELETED");
\r
312 this.suspended = rs.getBoolean("SUSPENDED");
\r
313 this.last_mod = rs.getDate("LAST_MOD");
\r
314 this.created_date = rs.getTimestamp("CREATED_DATE");
\r
316 public Feed(JSONObject jo) throws InvalidObjectException {
\r
317 this("", "", "","");
\r
319 // The JSONObject is assumed to contain a vnd.att-dr.feed representation
\r
320 this.feedid = jo.optInt("feedid", -1);
\r
321 this.groupid = jo.optInt("groupid"); //New field is added - Groups feature Rally:US708115 - 1610
\r
322 this.name = jo.getString("name");
\r
323 if (name.length() > 255)
\r
324 throw new InvalidObjectException("name field is too long");
\r
325 this.version = jo.getString("version");
\r
326 if (version.length() > 20)
\r
327 throw new InvalidObjectException("version field is too long");
\r
328 this.description = jo.optString("description");
\r
329 this.business_description = jo.optString("business_description"); // New field is added - Groups feature Rally:US708102 - 1610
\r
330 if (description.length() > 1000)
\r
331 throw new InvalidObjectException("technical description field is too long");
\r
333 if (business_description.length() > 1000) // New field is added - Groups feature Rally:US708102 - 1610
\r
334 throw new InvalidObjectException("business description field is too long");
\r
336 this.authorization = new FeedAuthorization();
\r
337 JSONObject jauth = jo.getJSONObject("authorization");
\r
338 this.authorization.setClassification(jauth.getString("classification"));
\r
339 if (this.authorization.getClassification().length() > 32)
\r
340 throw new InvalidObjectException("classification field is too long");
\r
341 JSONArray ja = jauth.getJSONArray("endpoint_ids");
\r
342 for (int i = 0; i < ja.length(); i++) {
\r
343 JSONObject id = ja.getJSONObject(i);
\r
344 FeedEndpointID fid = new FeedEndpointID(id.getString("id"), id.getString("password"));
\r
345 if (fid.getId().length() > 20)
\r
346 throw new InvalidObjectException("id field is too long ("+fid.getId()+")");
\r
347 if (fid.getPassword().length() > 32)
\r
348 throw new InvalidObjectException("password field is too long ("+fid.getPassword()+")");
\r
349 this.authorization.getEndpoint_ids().add(fid);
\r
351 if (this.authorization.getEndpoint_ids().size() < 1)
\r
352 throw new InvalidObjectException("need to specify at least one endpoint_id");
\r
353 ja = jauth.getJSONArray("endpoint_addrs");
\r
354 for (int i = 0; i < ja.length(); i++) {
\r
355 String addr = ja.getString(i);
\r
356 if (!JSONUtilities.validIPAddrOrSubnet(addr))
\r
357 throw new InvalidObjectException("bad IP addr or subnet mask: "+addr);
\r
358 this.authorization.getEndpoint_addrs().add(addr);
\r
361 this.publisher = jo.optString("publisher", "");
\r
362 this.deleted = jo.optBoolean("deleted", false);
\r
363 this.suspended = jo.optBoolean("suspend", false);
\r
364 JSONObject jol = jo.optJSONObject("links");
\r
365 this.links = (jol == null) ? (new FeedLinks()) : (new FeedLinks(jol));
\r
366 } catch (InvalidObjectException e) {
\r
368 } catch (Exception e) {
\r
369 throw new InvalidObjectException("invalid JSON: "+e.getMessage());
\r
372 public int getFeedid() {
\r
375 public void setFeedid(int feedid) {
\r
376 this.feedid = feedid;
\r
378 // Create link URLs
\r
379 FeedLinks fl = getLinks();
\r
380 fl.setSelf(URLUtilities.generateFeedURL(feedid));
\r
381 fl.setPublish(URLUtilities.generatePublishURL(feedid));
\r
382 fl.setSubscribe(URLUtilities.generateSubscribeURL(feedid));
\r
383 fl.setLog(URLUtilities.generateFeedLogURL(feedid));
\r
386 //new getter setters for groups- Rally:US708115 - 1610
\r
387 public int getGroupid() {
\r
391 public void setGroupid(int groupid) {
\r
392 this.groupid = groupid;
\r
395 public String getName() {
\r
398 public void setName(String name) {
\r
401 public String getVersion() {
\r
404 public void setVersion(String version) {
\r
405 this.version = version;
\r
407 public String getDescription() {
\r
408 return description;
\r
410 public void setDescription(String description) {
\r
411 this.description = description;
\r
413 // New field is added - Groups feature Rally:US708102 - 1610
\r
414 public String getBusiness_description() {
\r
415 return business_description;
\r
418 public void setBusiness_description(String business_description) {
\r
419 this.business_description = business_description;
\r
422 public FeedAuthorization getAuthorization() {
\r
423 return authorization;
\r
425 public void setAuthorization(FeedAuthorization authorization) {
\r
426 this.authorization = authorization;
\r
428 public String getPublisher() {
\r
431 public void setPublisher(String publisher) {
\r
432 if (publisher != null) {
\r
433 if (publisher.length() > 8)
\r
434 publisher = publisher.substring(0, 8);
\r
435 this.publisher = publisher;
\r
438 public FeedLinks getLinks() {
\r
441 public void setLinks(FeedLinks links) {
\r
442 this.links = links;
\r
445 public boolean isDeleted() {
\r
449 public void setDeleted(boolean deleted) {
\r
450 this.deleted = deleted;
\r
453 public boolean isSuspended() {
\r
457 public void setSuspended(boolean suspended) {
\r
458 this.suspended = suspended;
\r
461 public Date getLast_mod() {
\r
465 public Date getCreated_date() {
\r
466 return created_date;
\r
470 public JSONObject asJSONObject() {
\r
471 JSONObject jo = new JSONObject();
\r
472 jo.put("feedid", feedid);
\r
473 jo.put("groupid", groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
474 jo.put("name", name);
\r
475 jo.put("version", version);
\r
476 jo.put("description", description);
\r
477 jo.put("business_description", business_description); // New field is added - Groups feature Rally:US708102 - 1610
\r
478 jo.put("authorization", authorization.asJSONObject());
\r
479 jo.put("publisher", publisher);
\r
480 jo.put("links", links.asJSONObject());
\r
481 jo.put("deleted", deleted);
\r
482 jo.put("suspend", suspended);
\r
483 jo.put("last_mod", last_mod.getTime());
\r
484 jo.put("created_date", created_date.getTime());
\r
487 public JSONObject asLimitedJSONObject() {
\r
488 JSONObject jo = asJSONObject();
\r
489 jo.remove("deleted");
\r
490 jo.remove("feedid");
\r
491 jo.remove("last_mod");
\r
492 jo.remove("created_date");
\r
495 public JSONObject asJSONObject(boolean hidepasswords) {
\r
496 JSONObject jo = asJSONObject();
\r
497 if (hidepasswords) {
\r
498 jo.remove("feedid"); // we no longer hide passwords, however we do hide these
\r
499 jo.remove("deleted");
\r
500 jo.remove("last_mod");
\r
501 jo.remove("created_date");
\r
506 public boolean doDelete(Connection c) {
\r
508 PreparedStatement ps = null;
\r
510 String sql = "delete from FEEDS where FEEDID = ?";
\r
511 ps = c.prepareStatement(sql);
\r
512 ps.setInt(1, feedid);
\r
514 } catch (SQLException e) {
\r
516 intlogger.warn("PROV0007 doDelete: "+e.getMessage());
\r
517 e.printStackTrace();
\r
521 } catch (SQLException e) {
\r
522 e.printStackTrace();
\r
528 public synchronized boolean doInsert(Connection c) {
\r
530 // PreparedStatement ps = null;
\r
532 if (feedid == -1) {
\r
533 // // Get the next feedid
\r
534 // String sql = "insert into FEEDS_UNIQUEID (FEEDID) values (0)";
\r
535 // ps = c.prepareStatement(sql, new String[] { "FEEDID" });
\r
537 // ResultSet rs = ps.getGeneratedKeys();
\r
539 // setFeedid(rs.getInt(1));
\r
540 // No feed ID assigned yet, so assign the next available one
\r
541 setFeedid(next_feedid++);
\r
543 // In case we insert a feed from synchronization
\r
544 if (feedid > next_feedid)
\r
545 next_feedid = feedid+1;
\r
547 // Create FEED_ENDPOINT_IDS rows
\r
548 FeedAuthorization auth = getAuthorization();
\r
549 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
550 PreparedStatement ps2 = c.prepareStatement(sql);
\r
551 for (FeedEndpointID fid : auth.getEndpoint_ids()) {
\r
552 ps2.setInt(1, feedid);
\r
553 ps2.setString(2, fid.getId());
\r
554 ps2.setString(3, fid.getPassword());
\r
555 ps2.executeUpdate();
\r
559 // Create FEED_ENDPOINT_ADDRS rows
\r
560 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
561 ps2 = c.prepareStatement(sql);
\r
562 for (String t : auth.getEndpoint_addrs()) {
\r
563 ps2.setInt(1, feedid);
\r
564 ps2.setString(2, t);
\r
565 ps2.executeUpdate();
\r
569 // Finally, create the FEEDS row
\r
570 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
571 ps2 = c.prepareStatement(sql);
\r
572 ps2.setInt(1, feedid);
\r
573 ps2.setString(2, getName());
\r
574 ps2.setString(3, getVersion());
\r
575 ps2.setString(4, getDescription());
\r
576 ps2.setString(5, getAuthorization().getClassification());
\r
577 ps2.setString(6, getPublisher());
\r
578 ps2.setString(7, getLinks().getSelf());
\r
579 ps2.setString(8, getLinks().getPublish());
\r
580 ps2.setString(9, getLinks().getSubscribe());
\r
581 ps2.setString(10, getLinks().getLog());
\r
582 ps2.setBoolean(11, isDeleted());
\r
583 ps2.setBoolean(12, isSuspended());
\r
584 ps2.setString(13,getBusiness_description()); // New field is added - Groups feature Rally:US708102 - 1610
\r
585 ps2.setInt(14,groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
586 ps2.executeUpdate();
\r
588 } catch (SQLException e) {
\r
590 intlogger.warn("PROV0005 doInsert: "+e.getMessage());
\r
591 e.printStackTrace();
\r
595 // } catch (SQLException e) {
\r
596 // e.printStackTrace();
\r
602 public boolean doUpdate(Connection c) {
\r
604 Feed oldobj = getFeedById(feedid);
\r
605 PreparedStatement ps = null;
\r
607 Set<FeedEndpointID> newset = getAuthorization().getEndpoint_ids();
\r
608 Set<FeedEndpointID> oldset = oldobj.getAuthorization().getEndpoint_ids();
\r
610 // Insert new FEED_ENDPOINT_IDS rows
\r
611 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
612 ps = c.prepareStatement(sql);
\r
613 for (FeedEndpointID fid : newset) {
\r
614 if (!oldset.contains(fid)) {
\r
615 ps.setInt(1, feedid);
\r
616 ps.setString(2, fid.getId());
\r
617 ps.setString(3, fid.getPassword());
\r
618 ps.executeUpdate();
\r
623 // Delete old FEED_ENDPOINT_IDS rows
\r
624 sql = "delete from FEED_ENDPOINT_IDS where FEEDID = ? AND USERID = ? AND PASSWORD = ?";
\r
625 ps = c.prepareStatement(sql);
\r
626 for (FeedEndpointID fid : oldset) {
\r
627 if (!newset.contains(fid)) {
\r
628 ps.setInt(1, feedid);
\r
629 ps.setString(2, fid.getId());
\r
630 ps.setString(3, fid.getPassword());
\r
631 ps.executeUpdate();
\r
636 // Insert new FEED_ENDPOINT_ADDRS rows
\r
637 Set<String> newset2 = getAuthorization().getEndpoint_addrs();
\r
638 Set<String> oldset2 = oldobj.getAuthorization().getEndpoint_addrs();
\r
639 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
640 ps = c.prepareStatement(sql);
\r
641 for (String t : newset2) {
\r
642 if (!oldset2.contains(t)) {
\r
643 ps.setInt(1, feedid);
\r
644 ps.setString(2, t);
\r
645 ps.executeUpdate();
\r
650 // Delete old FEED_ENDPOINT_ADDRS rows
\r
651 sql = "delete from FEED_ENDPOINT_ADDRS where FEEDID = ? AND ADDR = ?";
\r
652 ps = c.prepareStatement(sql);
\r
653 for (String t : oldset2) {
\r
654 if (!newset2.contains(t)) {
\r
655 ps.setInt(1, feedid);
\r
656 ps.setString(2, t);
\r
657 ps.executeUpdate();
\r
662 // Finally, update the FEEDS row
\r
663 sql = "update FEEDS set DESCRIPTION = ?, AUTH_CLASS = ?, DELETED = ?, SUSPENDED = ?, BUSINESS_DESCRIPTION=?, GROUPID=? where FEEDID = ?";
\r
664 ps = c.prepareStatement(sql);
\r
665 ps.setString(1, getDescription());
\r
666 ps.setString(2, getAuthorization().getClassification());
\r
667 ps.setInt(3, deleted ? 1 : 0);
\r
668 ps.setInt(4, suspended ? 1 : 0);
\r
669 ps.setString(5, getBusiness_description()); // New field is added - Groups feature Rally:US708102 - 1610
\r
670 ps.setInt(6, groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
671 ps.setInt(7, feedid);
\r
672 ps.executeUpdate();
\r
674 } catch (SQLException e) {
\r
676 intlogger.warn("PROV0006 doUpdate: "+e.getMessage());
\r
677 e.printStackTrace();
\r
682 } catch (SQLException e) {
\r
683 e.printStackTrace();
\r
690 * Change Ownership of FEED - 1610
\r
692 public boolean changeOwnerShip() {
\r
694 PreparedStatement ps = null;
\r
698 @SuppressWarnings("resource")
\r
699 Connection c = db.getConnection();
\r
700 String sql = "update FEEDS set PUBLISHER = ? where FEEDID = ?";
\r
701 ps = c.prepareStatement(sql);
\r
702 ps.setString(1, this.publisher);
\r
703 ps.setInt(2, feedid);
\r
706 } catch (SQLException e) {
\r
708 intlogger.warn("PROV0006 doUpdate: "+e.getMessage());
\r
709 e.printStackTrace();
\r
713 } catch (SQLException e) {
\r
714 e.printStackTrace();
\r
722 public String getKey() {
\r
723 return ""+getFeedid();
\r
727 public boolean equals(Object obj) {
\r
728 if (!(obj instanceof Feed))
\r
730 Feed of = (Feed) obj;
\r
731 if (feedid != of.feedid)
\r
733 if (groupid != of.groupid) //New field is added - Groups feature Rally:US708115 - 1610
\r
735 if (!name.equals(of.name))
\r
737 if (!version.equals(of.version))
\r
739 if (!description.equals(of.description))
\r
741 if (!business_description.equals(of.business_description)) // New field is added - Groups feature Rally:US708102 - 1610
\r
743 if (!publisher.equals(of.publisher))
\r
745 if (!authorization.equals(of.authorization))
\r
747 if (!links.equals(of.links))
\r
749 if (deleted != of.deleted)
\r
751 if (suspended != of.suspended)
\r
757 public String toString() {
\r
758 return "FEED: feedid=" + feedid + ", name=" + name + ", version=" + version;
\r