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 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
44 import org.onap.dmaap.datarouter.provisioning.utils.DB;
\r
45 import org.onap.dmaap.datarouter.provisioning.utils.JSONUtilities;
\r
46 import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
\r
49 * 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("org.onap.dmaap.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
75 * @param id the Feed ID
\r
76 * @return true if it is valid
\r
78 @SuppressWarnings("resource")
\r
79 public static boolean isFeedValid(int id) {
\r
83 Connection conn = db.getConnection();
\r
84 Statement stmt = conn.createStatement();
\r
85 ResultSet rs = stmt.executeQuery("select COUNT(*) from FEEDS where FEEDID = " + id);
\r
87 count = rs.getInt(1);
\r
92 } catch (SQLException e) {
\r
93 e.printStackTrace();
\r
99 * Get a specific feed from the DB, based upon its ID.
\r
101 * @param id the Feed ID
\r
102 * @return the Feed object, or null if it does not exist
\r
104 public static Feed getFeedById(int id) {
\r
105 String sql = "select * from FEEDS where FEEDID = " + id;
\r
106 return getFeedBySQL(sql);
\r
110 * Get a specific feed from the DB, based upon its name and version.
\r
112 * @param name the name of the Feed
\r
113 * @param version the version of the Feed
\r
114 * @return the Feed object, or null if it does not exist
\r
116 public static Feed getFeedByNameVersion(String name, String version) {
\r
117 name = name.replaceAll("'", "''");
\r
118 version = version.replaceAll("'", "''");
\r
119 String sql = "select * from FEEDS where NAME = '" + name + "' and VERSION ='" + version + "'";
\r
120 return getFeedBySQL(sql);
\r
124 * Return a count of the number of active feeds in the DB.
\r
126 * @return the count
\r
128 public static int countActiveFeeds() {
\r
132 @SuppressWarnings("resource")
\r
133 Connection conn = db.getConnection();
\r
134 Statement stmt = conn.createStatement();
\r
135 ResultSet rs = stmt.executeQuery("select count(*) from FEEDS where DELETED = 0");
\r
137 count = rs.getInt(1);
\r
142 } catch (SQLException e) {
\r
143 intlogger.info("countActiveFeeds: " + e.getMessage());
\r
144 e.printStackTrace();
\r
149 public static int getMaxFeedID() {
\r
153 @SuppressWarnings("resource")
\r
154 Connection conn = db.getConnection();
\r
155 Statement stmt = conn.createStatement();
\r
156 ResultSet rs = stmt.executeQuery("select MAX(feedid) from FEEDS");
\r
158 max = rs.getInt(1);
\r
163 } catch (SQLException e) {
\r
164 intlogger.info("getMaxFeedID: " + e.getMessage());
\r
165 e.printStackTrace();
\r
170 public static Collection<Feed> getAllFeeds() {
\r
171 Map<Integer, Feed> map = new HashMap<Integer, Feed>();
\r
174 @SuppressWarnings("resource")
\r
175 Connection conn = db.getConnection();
\r
176 Statement stmt = conn.createStatement();
\r
177 ResultSet rs = stmt.executeQuery("select * from FEEDS");
\r
178 while (rs.next()) {
\r
179 Feed feed = new Feed(rs);
\r
180 map.put(feed.getFeedid(), feed);
\r
184 String sql = "select * from FEED_ENDPOINT_IDS";
\r
185 rs = stmt.executeQuery(sql);
\r
186 while (rs.next()) {
\r
187 int id = rs.getInt("FEEDID");
\r
188 Feed feed = map.get(id);
\r
189 if (feed != null) {
\r
190 FeedEndpointID epi = new FeedEndpointID(rs);
\r
191 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
197 sql = "select * from FEED_ENDPOINT_ADDRS";
\r
198 rs = stmt.executeQuery(sql);
\r
199 while (rs.next()) {
\r
200 int id = rs.getInt("FEEDID");
\r
201 Feed feed = map.get(id);
\r
202 if (feed != null) {
\r
203 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
204 acoll.add(rs.getString("ADDR"));
\r
211 } catch (SQLException e) {
\r
212 e.printStackTrace();
\r
214 return map.values();
\r
217 public static List<String> getFilteredFeedUrlList(final String name, final String val) {
\r
218 List<String> list = new ArrayList<String>();
\r
219 String sql = "select SELF_LINK from FEEDS where DELETED = 0";
\r
220 if (name.equals("name")) {
\r
221 sql += " and NAME = ?";
\r
222 } else if (name.equals("publ")) {
\r
223 sql += " and PUBLISHER = ?";
\r
224 } else if (name.equals("subs")) {
\r
225 sql = "select distinct FEEDS.SELF_LINK from FEEDS, SUBSCRIPTIONS " +
\r
226 "where DELETED = 0 " +
\r
227 "and FEEDS.FEEDID = SUBSCRIPTIONS.FEEDID " +
\r
228 "and SUBSCRIPTIONS.SUBSCRIBER = ?";
\r
232 @SuppressWarnings("resource")
\r
233 Connection conn = db.getConnection();
\r
234 PreparedStatement ps = conn.prepareStatement(sql);
\r
235 if (sql.indexOf('?') >= 0)
\r
236 ps.setString(1, val);
\r
237 ResultSet rs = ps.executeQuery();
\r
238 while (rs.next()) {
\r
239 String t = rs.getString(1);
\r
240 list.add(t.trim());
\r
245 } catch (SQLException e) {
\r
246 e.printStackTrace();
\r
251 @SuppressWarnings("resource")
\r
252 private static Feed getFeedBySQL(String sql) {
\r
256 Connection conn = db.getConnection();
\r
257 Statement stmt = conn.createStatement();
\r
258 ResultSet rs = stmt.executeQuery(sql);
\r
260 feed = new Feed(rs);
\r
263 sql = "select * from FEED_ENDPOINT_IDS where FEEDID = " + feed.feedid;
\r
264 rs = stmt.executeQuery(sql);
\r
265 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
266 while (rs.next()) {
\r
267 FeedEndpointID epi = new FeedEndpointID(rs);
\r
272 sql = "select * from FEED_ENDPOINT_ADDRS where FEEDID = " + feed.feedid;
\r
273 rs = stmt.executeQuery(sql);
\r
274 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
275 while (rs.next()) {
\r
276 acoll.add(rs.getString("ADDR"));
\r
282 } catch (SQLException e) {
\r
283 e.printStackTrace();
\r
289 this("", "", "", "");
\r
292 public Feed(String name, String version, String desc, String business_description) {
\r
294 this.groupid = -1; //New field is added - Groups feature Rally:US708115 - 1610
\r
296 this.version = version;
\r
297 this.description = desc;
\r
298 this.business_description = business_description; // New field is added - Groups feature Rally:US708102 - 1610
\r
299 this.authorization = new FeedAuthorization();
\r
300 this.publisher = "";
\r
301 this.links = new FeedLinks();
\r
302 this.deleted = false;
\r
303 this.suspended = false;
\r
304 this.last_mod = new Date();
\r
305 this.created_date = new Date();
\r
308 public Feed(ResultSet rs) throws SQLException {
\r
309 this.feedid = rs.getInt("FEEDID");
\r
310 this.groupid = rs.getInt("GROUPID"); //New field is added - Groups feature Rally:US708115 - 1610
\r
311 this.name = rs.getString("NAME");
\r
312 this.version = rs.getString("VERSION");
\r
313 this.description = rs.getString("DESCRIPTION");
\r
314 this.business_description = rs.getString("BUSINESS_DESCRIPTION"); // New field is added - Groups feature Rally:US708102 - 1610
\r
315 this.authorization = new FeedAuthorization();
\r
316 this.authorization.setClassification(rs.getString("AUTH_CLASS"));
\r
317 this.publisher = rs.getString("PUBLISHER");
\r
318 this.links = new FeedLinks();
\r
319 this.links.setSelf(rs.getString("SELF_LINK"));
\r
320 this.links.setPublish(rs.getString("PUBLISH_LINK"));
\r
321 this.links.setSubscribe(rs.getString("SUBSCRIBE_LINK"));
\r
322 this.links.setLog(rs.getString("LOG_LINK"));
\r
323 this.deleted = rs.getBoolean("DELETED");
\r
324 this.suspended = rs.getBoolean("SUSPENDED");
\r
325 this.last_mod = rs.getDate("LAST_MOD");
\r
326 this.created_date = rs.getTimestamp("CREATED_DATE");
\r
329 public Feed(JSONObject jo) throws InvalidObjectException {
\r
330 this("", "", "", "");
\r
332 // The JSONObject is assumed to contain a vnd.att-dr.feed representation
\r
333 this.feedid = jo.optInt("feedid", -1);
\r
334 this.groupid = jo.optInt("groupid"); //New field is added - Groups feature Rally:US708115 - 1610
\r
335 this.name = jo.getString("name");
\r
336 if (name.length() > 255)
\r
337 throw new InvalidObjectException("name field is too long");
\r
338 this.version = jo.getString("version");
\r
339 if (version.length() > 20)
\r
340 throw new InvalidObjectException("version field is too long");
\r
341 this.description = jo.optString("description");
\r
342 this.business_description = jo.optString("business_description"); // New field is added - Groups feature Rally:US708102 - 1610
\r
343 if (description.length() > 1000)
\r
344 throw new InvalidObjectException("technical description field is too long");
\r
346 if (business_description.length() > 1000) // New field is added - Groups feature Rally:US708102 - 1610
\r
347 throw new InvalidObjectException("business description field is too long");
\r
349 this.authorization = new FeedAuthorization();
\r
350 JSONObject jauth = jo.getJSONObject("authorization");
\r
351 this.authorization.setClassification(jauth.getString("classification"));
\r
352 if (this.authorization.getClassification().length() > 32)
\r
353 throw new InvalidObjectException("classification field is too long");
\r
354 JSONArray ja = jauth.getJSONArray("endpoint_ids");
\r
355 for (int i = 0; i < ja.length(); i++) {
\r
356 JSONObject id = ja.getJSONObject(i);
\r
357 FeedEndpointID fid = new FeedEndpointID(id.getString("id"), id.getString("password"));
\r
358 if (fid.getId().length() > 20)
\r
359 throw new InvalidObjectException("id field is too long (" + fid.getId() + ")");
\r
360 if (fid.getPassword().length() > 32)
\r
361 throw new InvalidObjectException("password field is too long (" + fid.getPassword() + ")");
\r
362 this.authorization.getEndpoint_ids().add(fid);
\r
364 if (this.authorization.getEndpoint_ids().size() < 1)
\r
365 throw new InvalidObjectException("need to specify at least one endpoint_id");
\r
366 ja = jauth.getJSONArray("endpoint_addrs");
\r
367 for (int i = 0; i < ja.length(); i++) {
\r
368 String addr = ja.getString(i);
\r
369 if (!JSONUtilities.validIPAddrOrSubnet(addr))
\r
370 throw new InvalidObjectException("bad IP addr or subnet mask: " + addr);
\r
371 this.authorization.getEndpoint_addrs().add(addr);
\r
374 this.publisher = jo.optString("publisher", "");
\r
375 this.deleted = jo.optBoolean("deleted", false);
\r
376 this.suspended = jo.optBoolean("suspend", false);
\r
377 JSONObject jol = jo.optJSONObject("links");
\r
378 this.links = (jol == null) ? (new FeedLinks()) : (new FeedLinks(jol));
\r
379 } catch (InvalidObjectException e) {
\r
381 } catch (Exception e) {
\r
382 throw new InvalidObjectException("invalid JSON: " + e.getMessage());
\r
386 public int getFeedid() {
\r
390 public void setFeedid(int feedid) {
\r
391 this.feedid = feedid;
\r
393 // Create link URLs
\r
394 FeedLinks fl = getLinks();
\r
395 fl.setSelf(URLUtilities.generateFeedURL(feedid));
\r
396 fl.setPublish(URLUtilities.generatePublishURL(feedid));
\r
397 fl.setSubscribe(URLUtilities.generateSubscribeURL(feedid));
\r
398 fl.setLog(URLUtilities.generateFeedLogURL(feedid));
\r
401 //new getter setters for groups- Rally:US708115 - 1610
\r
402 public int getGroupid() {
\r
406 public void setGroupid(int groupid) {
\r
407 this.groupid = groupid;
\r
410 public String getName() {
\r
414 public void setName(String name) {
\r
418 public String getVersion() {
\r
422 public void setVersion(String version) {
\r
423 this.version = version;
\r
426 public String getDescription() {
\r
427 return description;
\r
430 public void setDescription(String description) {
\r
431 this.description = description;
\r
434 // New field is added - Groups feature Rally:US708102 - 1610
\r
435 public String getBusiness_description() {
\r
436 return business_description;
\r
439 public void setBusiness_description(String business_description) {
\r
440 this.business_description = business_description;
\r
443 public FeedAuthorization getAuthorization() {
\r
444 return authorization;
\r
447 public void setAuthorization(FeedAuthorization authorization) {
\r
448 this.authorization = authorization;
\r
451 public String getPublisher() {
\r
455 public void setPublisher(String publisher) {
\r
456 if (publisher != null) {
\r
457 if (publisher.length() > 8)
\r
458 publisher = publisher.substring(0, 8);
\r
459 this.publisher = publisher;
\r
463 public FeedLinks getLinks() {
\r
467 public void setLinks(FeedLinks links) {
\r
468 this.links = links;
\r
471 public boolean isDeleted() {
\r
475 public void setDeleted(boolean deleted) {
\r
476 this.deleted = deleted;
\r
479 public boolean isSuspended() {
\r
483 public void setSuspended(boolean suspended) {
\r
484 this.suspended = suspended;
\r
487 public Date getLast_mod() {
\r
491 public Date getCreated_date() {
\r
492 return created_date;
\r
496 public JSONObject asJSONObject() {
\r
497 JSONObject jo = new JSONObject();
\r
498 jo.put("feedid", feedid);
\r
499 jo.put("groupid", groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
500 jo.put("name", name);
\r
501 jo.put("version", version);
\r
502 jo.put("description", description);
\r
503 jo.put("business_description", business_description); // New field is added - Groups feature Rally:US708102 - 1610
\r
504 jo.put("authorization", authorization.asJSONObject());
\r
505 jo.put("publisher", publisher);
\r
506 jo.put("links", links.asJSONObject());
\r
507 jo.put("deleted", deleted);
\r
508 jo.put("suspend", suspended);
\r
509 jo.put("last_mod", last_mod.getTime());
\r
510 jo.put("created_date", created_date.getTime());
\r
514 public JSONObject asLimitedJSONObject() {
\r
515 JSONObject jo = asJSONObject();
\r
516 jo.remove("deleted");
\r
517 jo.remove("feedid");
\r
518 jo.remove("last_mod");
\r
519 jo.remove("created_date");
\r
523 public JSONObject asJSONObject(boolean hidepasswords) {
\r
524 JSONObject jo = asJSONObject();
\r
525 if (hidepasswords) {
\r
526 jo.remove("feedid"); // we no longer hide passwords, however we do hide these
\r
527 jo.remove("deleted");
\r
528 jo.remove("last_mod");
\r
529 jo.remove("created_date");
\r
535 public boolean doDelete(Connection c) {
\r
537 PreparedStatement ps = null;
\r
539 String sql = "delete from FEEDS where FEEDID = ?";
\r
540 ps = c.prepareStatement(sql);
\r
541 ps.setInt(1, feedid);
\r
543 } catch (SQLException e) {
\r
545 intlogger.warn("PROV0007 doDelete: " + e.getMessage());
\r
546 e.printStackTrace();
\r
550 } catch (SQLException e) {
\r
551 e.printStackTrace();
\r
558 public synchronized boolean doInsert(Connection c) {
\r
560 // PreparedStatement ps = null;
\r
562 if (feedid == -1) {
\r
563 // // Get the next feedid
\r
564 // String sql = "insert into FEEDS_UNIQUEID (FEEDID) values (0)";
\r
565 // ps = c.prepareStatement(sql, new String[] { "FEEDID" });
\r
567 // ResultSet rs = ps.getGeneratedKeys();
\r
569 // setFeedid(rs.getInt(1));
\r
570 // No feed ID assigned yet, so assign the next available one
\r
571 setFeedid(next_feedid++);
\r
573 // In case we insert a feed from synchronization
\r
574 if (feedid > next_feedid)
\r
575 next_feedid = feedid + 1;
\r
577 // Create FEED_ENDPOINT_IDS rows
\r
578 FeedAuthorization auth = getAuthorization();
\r
579 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
580 PreparedStatement ps2 = c.prepareStatement(sql);
\r
581 for (FeedEndpointID fid : auth.getEndpoint_ids()) {
\r
582 ps2.setInt(1, feedid);
\r
583 ps2.setString(2, fid.getId());
\r
584 ps2.setString(3, fid.getPassword());
\r
585 ps2.executeUpdate();
\r
589 // Create FEED_ENDPOINT_ADDRS rows
\r
590 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
591 ps2 = c.prepareStatement(sql);
\r
592 for (String t : auth.getEndpoint_addrs()) {
\r
593 ps2.setInt(1, feedid);
\r
594 ps2.setString(2, t);
\r
595 ps2.executeUpdate();
\r
599 // Finally, create the FEEDS row
\r
600 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
601 ps2 = c.prepareStatement(sql);
\r
602 ps2.setInt(1, feedid);
\r
603 ps2.setString(2, getName());
\r
604 ps2.setString(3, getVersion());
\r
605 ps2.setString(4, getDescription());
\r
606 ps2.setString(5, getAuthorization().getClassification());
\r
607 ps2.setString(6, getPublisher());
\r
608 ps2.setString(7, getLinks().getSelf());
\r
609 ps2.setString(8, getLinks().getPublish());
\r
610 ps2.setString(9, getLinks().getSubscribe());
\r
611 ps2.setString(10, getLinks().getLog());
\r
612 ps2.setBoolean(11, isDeleted());
\r
613 ps2.setBoolean(12, isSuspended());
\r
614 ps2.setString(13, getBusiness_description()); // New field is added - Groups feature Rally:US708102 - 1610
\r
615 ps2.setInt(14, groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
616 ps2.executeUpdate();
\r
618 } catch (SQLException e) {
\r
620 intlogger.warn("PROV0005 doInsert: " + e.getMessage());
\r
621 e.printStackTrace();
\r
625 // } catch (SQLException e) {
\r
626 // e.printStackTrace();
\r
633 public boolean doUpdate(Connection c) {
\r
635 Feed oldobj = getFeedById(feedid);
\r
636 PreparedStatement ps = null;
\r
638 Set<FeedEndpointID> newset = getAuthorization().getEndpoint_ids();
\r
639 Set<FeedEndpointID> oldset = oldobj.getAuthorization().getEndpoint_ids();
\r
641 // Insert new FEED_ENDPOINT_IDS rows
\r
642 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
643 ps = c.prepareStatement(sql);
\r
644 for (FeedEndpointID fid : newset) {
\r
645 if (!oldset.contains(fid)) {
\r
646 ps.setInt(1, feedid);
\r
647 ps.setString(2, fid.getId());
\r
648 ps.setString(3, fid.getPassword());
\r
649 ps.executeUpdate();
\r
654 // Delete old FEED_ENDPOINT_IDS rows
\r
655 sql = "delete from FEED_ENDPOINT_IDS where FEEDID = ? AND USERID = ? AND PASSWORD = ?";
\r
656 ps = c.prepareStatement(sql);
\r
657 for (FeedEndpointID fid : oldset) {
\r
658 if (!newset.contains(fid)) {
\r
659 ps.setInt(1, feedid);
\r
660 ps.setString(2, fid.getId());
\r
661 ps.setString(3, fid.getPassword());
\r
662 ps.executeUpdate();
\r
667 // Insert new FEED_ENDPOINT_ADDRS rows
\r
668 Set<String> newset2 = getAuthorization().getEndpoint_addrs();
\r
669 Set<String> oldset2 = oldobj.getAuthorization().getEndpoint_addrs();
\r
670 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
671 ps = c.prepareStatement(sql);
\r
672 for (String t : newset2) {
\r
673 if (!oldset2.contains(t)) {
\r
674 ps.setInt(1, feedid);
\r
675 ps.setString(2, t);
\r
676 ps.executeUpdate();
\r
681 // Delete old FEED_ENDPOINT_ADDRS rows
\r
682 sql = "delete from FEED_ENDPOINT_ADDRS where FEEDID = ? AND ADDR = ?";
\r
683 ps = c.prepareStatement(sql);
\r
684 for (String t : oldset2) {
\r
685 if (!newset2.contains(t)) {
\r
686 ps.setInt(1, feedid);
\r
687 ps.setString(2, t);
\r
688 ps.executeUpdate();
\r
693 // Finally, update the FEEDS row
\r
694 sql = "update FEEDS set DESCRIPTION = ?, AUTH_CLASS = ?, DELETED = ?, SUSPENDED = ?, BUSINESS_DESCRIPTION=?, GROUPID=? where FEEDID = ?";
\r
695 ps = c.prepareStatement(sql);
\r
696 ps.setString(1, getDescription());
\r
697 ps.setString(2, getAuthorization().getClassification());
\r
698 ps.setInt(3, deleted ? 1 : 0);
\r
699 ps.setInt(4, suspended ? 1 : 0);
\r
700 ps.setString(5, getBusiness_description()); // New field is added - Groups feature Rally:US708102 - 1610
\r
701 ps.setInt(6, groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
702 ps.setInt(7, feedid);
\r
703 ps.executeUpdate();
\r
705 } catch (SQLException e) {
\r
707 intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
\r
708 e.printStackTrace();
\r
713 } catch (SQLException e) {
\r
714 e.printStackTrace();
\r
722 * Change Ownership of FEED - 1610
\r
724 public boolean changeOwnerShip() {
\r
726 PreparedStatement ps = null;
\r
730 @SuppressWarnings("resource")
\r
731 Connection c = db.getConnection();
\r
732 String sql = "update FEEDS set PUBLISHER = ? where FEEDID = ?";
\r
733 ps = c.prepareStatement(sql);
\r
734 ps.setString(1, this.publisher);
\r
735 ps.setInt(2, feedid);
\r
738 } catch (SQLException e) {
\r
740 intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
\r
741 e.printStackTrace();
\r
745 } catch (SQLException e) {
\r
746 e.printStackTrace();
\r
754 public String getKey() {
\r
755 return "" + getFeedid();
\r
759 public boolean equals(Object obj) {
\r
760 if (!(obj instanceof Feed))
\r
762 Feed of = (Feed) obj;
\r
763 if (feedid != of.feedid)
\r
765 if (groupid != of.groupid) //New field is added - Groups feature Rally:US708115 - 1610
\r
767 if (!name.equals(of.name))
\r
769 if (!version.equals(of.version))
\r
771 if (!description.equals(of.description))
\r
773 if (!business_description.equals(of.business_description)) // New field is added - Groups feature Rally:US708102 - 1610
\r
775 if (!publisher.equals(of.publisher))
\r
777 if (!authorization.equals(of.authorization))
\r
779 if (!links.equals(of.links))
\r
781 if (deleted != of.deleted)
\r
783 if (suspended != of.suspended)
\r
789 public String toString() {
\r
790 return "FEED: feedid=" + feedid + ", name=" + name + ", version=" + version;
\r