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 com.att.eelf.configuration.EELFLogger;
\r
28 import com.att.eelf.configuration.EELFManager;
\r
29 import org.json.JSONArray;
\r
30 import org.json.JSONException;
\r
31 import org.json.JSONObject;
\r
32 import org.onap.dmaap.datarouter.provisioning.utils.DB;
\r
33 import org.onap.dmaap.datarouter.provisioning.utils.JSONUtilities;
\r
34 import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
\r
36 import java.io.InvalidObjectException;
\r
38 import java.util.Date;
\r
42 * The representation of a Feed. Feeds can be retrieved from the DB, or stored/updated in the DB.
\r
44 * @author Robert Eby
\r
45 * @version $Id: Feed.java,v 1.13 2013/10/28 18:06:52 eby Exp $
\r
47 public class Feed extends Syncable {
\r
48 private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog");
\r
49 private static int next_feedid = getMaxFeedID() + 1;
\r
50 private static final String SQLEXCEPTION = "SQLException: ";
\r
53 private int groupid; //New field is added - Groups feature Rally:US708115 - 1610
\r
54 private String name;
\r
55 private String version;
\r
56 private String description;
\r
57 private String business_description; // New field is added - Groups feature Rally:US708102 - 1610
\r
58 private FeedAuthorization authorization;
\r
59 private String publisher;
\r
60 private FeedLinks links;
\r
61 private boolean deleted;
\r
62 private boolean suspended;
\r
63 private Date last_mod;
\r
64 private Date created_date;
\r
65 private String aaf_instance;
\r
68 * Check if a feed ID is valid.
\r
70 * @param id the Feed ID
\r
71 * @return true if it is valid
\r
73 @SuppressWarnings("resource")
\r
74 public static boolean isFeedValid(int id) {
\r
78 Connection conn = db.getConnection();
\r
79 try(PreparedStatement stmt = conn.prepareStatement("select COUNT(*) from FEEDS where FEEDID = ?")) {
\r
81 try(ResultSet rs = stmt.executeQuery()) {
\r
83 count = rs.getInt(1);
\r
88 } catch (SQLException e) {
\r
89 intlogger.warn("PROV0024 Feed.isFeedValid: " + e.getMessage(), e);
\r
95 * Get a specific feed from the DB, based upon its ID.
\r
97 * @param id the Feed ID
\r
98 * @return the Feed object, or null if it does not exist
\r
100 public static Feed getFeedById(int id) {
\r
101 String sql = "select * from FEEDS where FEEDID = " + id;
\r
102 return getFeedBySQL(sql);
\r
106 * Get a specific feed from the DB, based upon its name and version.
\r
108 * @param name the name of the Feed
\r
109 * @param version the version of the Feed
\r
110 * @return the Feed object, or null if it does not exist
\r
112 public static Feed getFeedByNameVersion(String name, String version) {
\r
113 name = name.replaceAll("'", "''");
\r
114 version = version.replaceAll("'", "''");
\r
115 String sql = "select * from FEEDS where NAME = '" + name + "' and VERSION ='" + version + "'";
\r
116 return getFeedBySQL(sql);
\r
120 * Return a count of the number of active feeds in the DB.
\r
122 * @return the count
\r
124 public static int countActiveFeeds() {
\r
128 @SuppressWarnings("resource")
\r
129 Connection conn = db.getConnection();
\r
130 try(Statement stmt = conn.createStatement()) {
\r
131 try (ResultSet rs = stmt.executeQuery("select count(*) from FEEDS where DELETED = 0")) {
\r
133 count = rs.getInt(1);
\r
138 } catch (SQLException e) {
\r
139 intlogger.warn("PROV0025 Feed.countActiveFeeds: " + e.getMessage(), e);
\r
144 public static int getMaxFeedID() {
\r
148 @SuppressWarnings("resource")
\r
149 Connection conn = db.getConnection();
\r
150 try(Statement stmt = conn.createStatement()) {
\r
151 try (ResultSet rs = stmt.executeQuery("select MAX(feedid) from FEEDS")) {
\r
153 max = rs.getInt(1);
\r
158 } catch (SQLException e) {
\r
159 intlogger.warn("PROV0026 Feed.getMaxFeedID: " + e.getMessage(), e);
\r
164 public static Collection<Feed> getAllFeeds() {
\r
165 Map<Integer, Feed> map = new HashMap<Integer, Feed>();
\r
168 @SuppressWarnings("resource")
\r
169 Connection conn = db.getConnection();
\r
170 try(Statement stmt = conn.createStatement()) {
\r
171 try(ResultSet rs = stmt.executeQuery("select * from FEEDS")) {
\r
172 while (rs.next()) {
\r
173 Feed feed = new Feed(rs);
\r
174 map.put(feed.getFeedid(), feed);
\r
178 String sql = "select * from FEED_ENDPOINT_IDS";
\r
179 try(ResultSet rs = stmt.executeQuery(sql)){
\r
180 while (rs.next()) {
\r
181 int id = rs.getInt("FEEDID");
\r
182 Feed feed = map.get(id);
\r
183 if (feed != null) {
\r
184 FeedEndpointID epi = new FeedEndpointID(rs);
\r
185 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
191 sql = "select * from FEED_ENDPOINT_ADDRS";
\r
192 try(ResultSet rs = stmt.executeQuery(sql)) {
\r
193 while (rs.next()) {
\r
194 int id = rs.getInt("FEEDID");
\r
195 Feed feed = map.get(id);
\r
196 if (feed != null) {
\r
197 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
198 acoll.add(rs.getString("ADDR"));
\r
204 } catch (SQLException e) {
\r
205 intlogger.warn("PROV0027 Feed.getAllFeeds: " + e.getMessage(), e);
\r
207 return map.values();
\r
210 public static List<String> getFilteredFeedUrlList(final String name, final String val) {
\r
211 List<String> list = new ArrayList<String>();
\r
212 String sql = "select SELF_LINK from FEEDS where DELETED = 0";
\r
213 if (name.equals("name")) {
\r
214 sql += " and NAME = ?";
\r
215 } else if (name.equals("publ")) {
\r
216 sql += " and PUBLISHER = ?";
\r
217 } else if (name.equals("subs")) {
\r
218 sql = "select distinct FEEDS.SELF_LINK from FEEDS, SUBSCRIPTIONS " +
\r
219 "where DELETED = 0 " +
\r
220 "and FEEDS.FEEDID = SUBSCRIPTIONS.FEEDID " +
\r
221 "and SUBSCRIPTIONS.SUBSCRIBER = ?";
\r
225 @SuppressWarnings("resource")
\r
226 Connection conn = db.getConnection();
\r
227 try(PreparedStatement ps = conn.prepareStatement(sql)) {
\r
228 if (sql.indexOf('?') >= 0)
\r
229 ps.setString(1, val);
\r
230 try(ResultSet rs = ps.executeQuery()) {
\r
231 while (rs.next()) {
\r
232 String t = rs.getString(1);
\r
233 list.add(t.trim());
\r
238 } catch (SQLException e) {
\r
239 intlogger.warn("PROV0028 Feed.getFilteredFeedUrlList: " + e.getMessage(), e);
\r
244 @SuppressWarnings("resource")
\r
245 private static Feed getFeedBySQL(String sql) {
\r
249 Connection conn = db.getConnection();
\r
250 try (Statement stmt = conn.createStatement()) {
\r
251 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
253 feed = new Feed(rs);
\r
256 if (feed != null) {
\r
257 sql = "select * from FEED_ENDPOINT_IDS where FEEDID = " + feed.feedid;
\r
258 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
259 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
260 while (rs.next()) {
\r
261 FeedEndpointID epi = new FeedEndpointID(rs);
\r
265 sql = "select * from FEED_ENDPOINT_ADDRS where FEEDID = " + feed.feedid;
\r
266 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
267 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
268 while (rs.next()) {
\r
269 acoll.add(rs.getString("ADDR"));
\r
275 } catch (SQLException e) {
\r
276 intlogger.warn("PROV0029 Feed.getFeedBySQL: " + e.getMessage(), e);
\r
282 this("", "", "", "");
\r
285 public Feed(String name, String version, String desc, String business_description) {
\r
287 this.groupid = -1; //New field is added - Groups feature Rally:US708115 - 1610
\r
289 this.version = version;
\r
290 this.description = desc;
\r
291 this.business_description = business_description; // New field is added - Groups feature Rally:US708102 - 1610
\r
292 this.authorization = new FeedAuthorization();
\r
293 this.publisher = "";
\r
294 this.links = new FeedLinks();
\r
295 this.deleted = false;
\r
296 this.suspended = false;
\r
297 this.last_mod = new Date();
\r
298 this.created_date = new Date();
\r
299 this.aaf_instance = "";
\r
302 public Feed(ResultSet rs) throws SQLException {
\r
303 this.feedid = rs.getInt("FEEDID");
\r
304 this.groupid = rs.getInt("GROUPID"); //New field is added - Groups feature Rally:US708115 - 1610
\r
305 this.name = rs.getString("NAME");
\r
306 this.version = rs.getString("VERSION");
\r
307 this.description = rs.getString("DESCRIPTION");
\r
308 this.business_description = rs.getString("BUSINESS_DESCRIPTION"); // New field is added - Groups feature Rally:US708102 - 1610
\r
309 this.authorization = new FeedAuthorization();
\r
310 this.authorization.setClassification(rs.getString("AUTH_CLASS"));
\r
311 this.publisher = rs.getString("PUBLISHER");
\r
312 this.links = new FeedLinks();
\r
313 this.links.setSelf(rs.getString("SELF_LINK"));
\r
314 this.links.setPublish(rs.getString("PUBLISH_LINK"));
\r
315 this.links.setSubscribe(rs.getString("SUBSCRIBE_LINK"));
\r
316 this.links.setLog(rs.getString("LOG_LINK"));
\r
317 this.deleted = rs.getBoolean("DELETED");
\r
318 this.suspended = rs.getBoolean("SUSPENDED");
\r
319 this.last_mod = rs.getDate("LAST_MOD");
\r
320 this.created_date = rs.getTimestamp("CREATED_DATE");
\r
321 this.aaf_instance = rs.getString("AAF_INSTANCE");
\r
324 public Feed(JSONObject jo) throws InvalidObjectException {
\r
325 this("", "", "", "");
\r
327 // The JSONObject is assumed to contain a vnd.dmaap-dr.feed representation
\r
328 this.feedid = jo.optInt("feedid", -1);
\r
329 this.groupid = jo.optInt("groupid");
\r
330 this.name = jo.getString("name");
\r
331 this.aaf_instance = jo.optString("aaf_instance", "legacy");
\r
332 if(!(aaf_instance.equalsIgnoreCase("legacy"))){
\r
333 if (aaf_instance.length() > 255){
\r
334 throw new InvalidObjectException("aaf_instance field is too long");
\r
337 if (name.length() > 255)
\r
338 throw new InvalidObjectException("name field is too long");
\r
340 this.version = jo.getString("version");
\r
341 } catch (JSONException e) {
\r
342 intlogger.warn("PROV0023 Feed.Feed: " + e.getMessage(), e);
\r
343 this.version = null;
\r
345 if(version != null && version.length() > 20)
\r
346 throw new InvalidObjectException("version field is too long");
\r
347 this.description = jo.optString("description");
\r
348 this.business_description = jo.optString("business_description");
\r
349 if (description.length() > 1000)
\r
350 throw new InvalidObjectException("technical description field is too long");
\r
351 if (business_description.length() > 1000)
\r
352 throw new InvalidObjectException("business description field is too long");
\r
353 this.authorization = new FeedAuthorization();
\r
354 JSONObject jauth = jo.getJSONObject("authorization");
\r
355 this.authorization.setClassification(jauth.getString("classification"));
\r
356 if (this.authorization.getClassification().length() > 32)
\r
357 throw new InvalidObjectException("classification field is too long");
\r
358 JSONArray endPointIds = jauth.getJSONArray("endpoint_ids");
\r
359 for (int i = 0; i < endPointIds.length(); i++) {
\r
360 JSONObject id = endPointIds.getJSONObject(i);
\r
361 FeedEndpointID fid = new FeedEndpointID(id.getString("id"), id.getString("password"));
\r
362 if (fid.getId().length() > 60)
\r
363 throw new InvalidObjectException("id field is too long (" + fid.getId() + ")");
\r
364 if (fid.getPassword().length() > 32)
\r
365 throw new InvalidObjectException("password field is too long ("+ fid.getPassword()+")"); //Fortify scan fixes - Privacy Violation
\r
366 this.authorization.getEndpoint_ids().add(fid);
\r
368 if (this.authorization.getEndpoint_ids().size() < 1)
\r
369 throw new InvalidObjectException("need to specify at least one endpoint_id");
\r
370 endPointIds = jauth.getJSONArray("endpoint_addrs");
\r
371 for (int i = 0; i < endPointIds.length(); i++) {
\r
372 String addr = endPointIds.getString(i);
\r
373 if (!JSONUtilities.validIPAddrOrSubnet(addr))
\r
374 throw new InvalidObjectException("bad IP addr or subnet mask: " + addr);
\r
375 this.authorization.getEndpoint_addrs().add(addr);
\r
378 this.publisher = jo.optString("publisher", "");
\r
379 this.deleted = jo.optBoolean("deleted", false);
\r
380 this.suspended = jo.optBoolean("suspend", false);
\r
381 JSONObject jol = jo.optJSONObject("links");
\r
382 this.links = (jol == null) ? (new FeedLinks()) : (new FeedLinks(jol));
\r
383 } catch (InvalidObjectException e) {
\r
385 } catch (Exception e) {
\r
386 intlogger.warn("Invalid JSON: " + e.getMessage(), e);
\r
387 throw new InvalidObjectException("Invalid JSON: " + e.getMessage());
\r
391 public int getFeedid() {
\r
395 public void setFeedid(int feedid) {
\r
396 this.feedid = feedid;
\r
398 // Create link URLs
\r
399 FeedLinks fl = getLinks();
\r
400 fl.setSelf(URLUtilities.generateFeedURL(feedid));
\r
401 fl.setPublish(URLUtilities.generatePublishURL(feedid));
\r
402 fl.setSubscribe(URLUtilities.generateSubscribeURL(feedid));
\r
403 fl.setLog(URLUtilities.generateFeedLogURL(feedid));
\r
406 public String getAafInstance() {
\r
407 return aaf_instance;
\r
410 public void setAaf_instance(String aaf_instance) {
\r
411 this.aaf_instance = aaf_instance;
\r
414 //new getter setters for groups- Rally:US708115 - 1610
\r
415 public int getGroupid() {
\r
419 public void setGroupid(int groupid) {
\r
420 this.groupid = groupid;
\r
423 public String getName() {
\r
427 public void setName(String name) {
\r
431 public String getVersion() {
\r
435 public void setVersion(String version) {
\r
436 this.version = version;
\r
439 public String getDescription() {
\r
440 return description;
\r
443 public void setDescription(String description) {
\r
444 this.description = description;
\r
447 // New field is added - Groups feature Rally:US708102 - 1610
\r
448 public String getBusiness_description() {
\r
449 return business_description;
\r
452 public void setBusiness_description(String business_description) {
\r
453 this.business_description = business_description;
\r
456 public FeedAuthorization getAuthorization() {
\r
457 return authorization;
\r
460 public void setAuthorization(FeedAuthorization authorization) {
\r
461 this.authorization = authorization;
\r
464 public String getPublisher() {
\r
468 public void setPublisher(String publisher) {
\r
469 if (publisher != null) {
\r
470 if (publisher.length() > 8)
\r
471 publisher = publisher.substring(0, 8);
\r
472 this.publisher = publisher;
\r
476 public FeedLinks getLinks() {
\r
480 public void setLinks(FeedLinks links) {
\r
481 this.links = links;
\r
484 public boolean isDeleted() {
\r
488 public void setDeleted(boolean deleted) {
\r
489 this.deleted = deleted;
\r
492 public boolean isSuspended() {
\r
496 public void setSuspended(boolean suspended) {
\r
497 this.suspended = suspended;
\r
501 public JSONObject asJSONObject() {
\r
502 JSONObject jo = new JSONObject();
\r
503 jo.put("feedid", feedid);
\r
504 jo.put("groupid", groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
505 jo.put("name", name);
\r
506 jo.put("version", version);
\r
507 jo.put("description", description);
\r
508 jo.put("business_description", business_description); // New field is added - Groups feature Rally:US708102 - 1610
\r
509 jo.put("authorization", authorization.asJSONObject());
\r
510 jo.put("publisher", publisher);
\r
511 jo.put("links", links.asJSONObject());
\r
512 jo.put("deleted", deleted);
\r
513 jo.put("suspend", suspended);
\r
514 jo.put("last_mod", last_mod.getTime());
\r
515 jo.put("created_date", created_date.getTime());
\r
516 jo.put("aaf_instance", aaf_instance);
\r
520 public JSONObject asLimitedJSONObject() {
\r
521 JSONObject jo = asJSONObject();
\r
522 jo.remove("deleted");
\r
523 jo.remove("feedid");
\r
524 jo.remove("last_mod");
\r
525 jo.remove("created_date");
\r
529 public JSONObject asJSONObject(boolean hidepasswords) {
\r
530 JSONObject jo = asJSONObject();
\r
531 if (hidepasswords) {
\r
532 jo.remove("feedid"); // we no longer hide passwords, however we do hide these
\r
533 jo.remove("deleted");
\r
534 jo.remove("last_mod");
\r
535 jo.remove("created_date");
\r
541 public boolean doDelete(Connection c) {
\r
543 PreparedStatement ps = null;
\r
545 String sql = "delete from FEEDS where FEEDID = ?";
\r
546 ps = c.prepareStatement(sql);
\r
547 ps.setInt(1, feedid);
\r
549 } catch (SQLException e) {
\r
551 intlogger.error("PROV0007 doDelete: " + e.getMessage(), e);
\r
557 } catch (SQLException e) {
\r
558 intlogger.error(SQLEXCEPTION + e.getMessage(), e);
\r
565 public synchronized boolean doInsert(Connection c) {
\r
568 if (feedid == -1) {
\r
569 setFeedid(next_feedid++);
\r
571 // In case we insert a feed from synchronization
\r
572 if (feedid > next_feedid)
\r
573 next_feedid = feedid + 1;
\r
575 // Create FEED_ENDPOINT_IDS rows
\r
576 FeedAuthorization auth = getAuthorization();
\r
577 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
578 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
579 for (FeedEndpointID fid : auth.getEndpoint_ids()) {
\r
580 ps2.setInt(1, feedid);
\r
581 ps2.setString(2, fid.getId());
\r
582 ps2.setString(3, fid.getPassword());
\r
583 ps2.executeUpdate();
\r
587 // Create FEED_ENDPOINT_ADDRS rows
\r
588 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
589 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
590 for (String t : auth.getEndpoint_addrs()) {
\r
591 ps2.setInt(1, feedid);
\r
592 ps2.setString(2, t);
\r
593 ps2.executeUpdate();
\r
597 // Finally, create the FEEDS row
\r
598 sql = "insert into FEEDS (FEEDID, NAME, VERSION, DESCRIPTION, AUTH_CLASS, PUBLISHER, SELF_LINK, PUBLISH_LINK, SUBSCRIBE_LINK, LOG_LINK, DELETED, SUSPENDED,BUSINESS_DESCRIPTION, GROUPID, AAF_INSTANCE) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
\r
599 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
600 ps2.setInt(1, feedid);
\r
601 ps2.setString(2, getName());
\r
602 ps2.setString(3, getVersion());
\r
603 ps2.setString(4, getDescription());
\r
604 ps2.setString(5, getAuthorization().getClassification());
\r
605 ps2.setString(6, getPublisher());
\r
606 ps2.setString(7, getLinks().getSelf());
\r
607 ps2.setString(8, getLinks().getPublish());
\r
608 ps2.setString(9, getLinks().getSubscribe());
\r
609 ps2.setString(10, getLinks().getLog());
\r
610 ps2.setBoolean(11, isDeleted());
\r
611 ps2.setBoolean(12, isSuspended());
\r
612 ps2.setString(13, getBusiness_description());
\r
613 ps2.setInt(14, groupid);
\r
614 ps2.setString(15, getAafInstance());
\r
615 ps2.executeUpdate();
\r
617 } catch (SQLException e) {
\r
619 intlogger.error("PROV0005 doInsert: " + e.getMessage(), e);
\r
625 public boolean doUpdate(Connection c) {
\r
627 Feed oldobj = getFeedById(feedid);
\r
628 PreparedStatement ps = null;
\r
630 Set<FeedEndpointID> newset = getAuthorization().getEndpoint_ids();
\r
631 Set<FeedEndpointID> oldset = oldobj.getAuthorization().getEndpoint_ids();
\r
633 // Insert new FEED_ENDPOINT_IDS rows
\r
634 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
635 ps = c.prepareStatement(sql);
\r
636 for (FeedEndpointID fid : newset) {
\r
637 if (!oldset.contains(fid)) {
\r
638 ps.setInt(1, feedid);
\r
639 ps.setString(2, fid.getId());
\r
640 ps.setString(3, fid.getPassword());
\r
641 ps.executeUpdate();
\r
646 // Delete old FEED_ENDPOINT_IDS rows
\r
647 sql = "delete from FEED_ENDPOINT_IDS where FEEDID = ? AND USERID = ? AND PASSWORD = ?";
\r
648 ps = c.prepareStatement(sql);
\r
649 for (FeedEndpointID fid : oldset) {
\r
650 if (!newset.contains(fid)) {
\r
651 ps.setInt(1, feedid);
\r
652 ps.setString(2, fid.getId());
\r
653 ps.setString(3, fid.getPassword());
\r
654 ps.executeUpdate();
\r
659 // Insert new FEED_ENDPOINT_ADDRS rows
\r
660 Set<String> newset2 = getAuthorization().getEndpoint_addrs();
\r
661 Set<String> oldset2 = oldobj.getAuthorization().getEndpoint_addrs();
\r
662 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
663 ps = c.prepareStatement(sql);
\r
664 for (String t : newset2) {
\r
665 if (!oldset2.contains(t)) {
\r
666 ps.setInt(1, feedid);
\r
667 ps.setString(2, t);
\r
668 ps.executeUpdate();
\r
673 // Delete old FEED_ENDPOINT_ADDRS rows
\r
674 sql = "delete from FEED_ENDPOINT_ADDRS where FEEDID = ? AND ADDR = ?";
\r
675 ps = c.prepareStatement(sql);
\r
676 for (String t : oldset2) {
\r
677 if (!newset2.contains(t)) {
\r
678 ps.setInt(1, feedid);
\r
679 ps.setString(2, t);
\r
680 ps.executeUpdate();
\r
685 // Finally, update the FEEDS row
\r
686 sql = "update FEEDS set DESCRIPTION = ?, AUTH_CLASS = ?, DELETED = ?, SUSPENDED = ?, BUSINESS_DESCRIPTION=?, GROUPID=? where FEEDID = ?";
\r
687 ps = c.prepareStatement(sql);
\r
688 ps.setString(1, getDescription());
\r
689 ps.setString(2, getAuthorization().getClassification());
\r
690 ps.setInt(3, deleted ? 1 : 0);
\r
691 ps.setInt(4, suspended ? 1 : 0);
\r
692 ps.setString(5, getBusiness_description());
\r
693 ps.setInt(6, groupid);
\r
694 ps.setInt(7, feedid);
\r
695 ps.executeUpdate();
\r
697 } catch (SQLException e) {
\r
699 intlogger.warn("PROV0006 doUpdate: " + e.getMessage(), e);
\r
704 } catch (SQLException e) {
\r
705 intlogger.error(SQLEXCEPTION + e.getMessage(), e);
\r
713 * Change Ownership of FEED - 1610
\r
715 public boolean changeOwnerShip() {
\r
717 PreparedStatement ps = null;
\r
721 @SuppressWarnings("resource")
\r
722 Connection c = db.getConnection();
\r
723 String sql = "update FEEDS set PUBLISHER = ? where FEEDID = ?";
\r
724 ps = c.prepareStatement(sql);
\r
725 ps.setString(1, this.publisher);
\r
726 ps.setInt(2, feedid);
\r
729 } catch (SQLException e) {
\r
731 intlogger.warn("PROV0008 changeOwnerShip: " + e.getMessage(), e);
\r
737 } catch (SQLException e) {
\r
738 intlogger.error(SQLEXCEPTION + e.getMessage(), e);
\r
746 public String getKey() {
\r
747 return "" + getFeedid();
\r
751 public boolean equals(Object obj) {
\r
752 if (!(obj instanceof Feed))
\r
754 Feed of = (Feed) obj;
\r
755 if (feedid != of.feedid)
\r
757 if (groupid != of.groupid) //New field is added - Groups feature Rally:US708115 - 1610
\r
759 if (!name.equals(of.name))
\r
761 if (!version.equals(of.version))
\r
763 if (!description.equals(of.description))
\r
765 if (!business_description.equals(of.business_description)) // New field is added - Groups feature Rally:US708102 - 1610
\r
767 if (!publisher.equals(of.publisher))
\r
769 if (!authorization.equals(of.authorization))
\r
771 if (!links.equals(of.links))
\r
773 if (deleted != of.deleted)
\r
775 if (suspended != of.suspended)
\r
777 if (!aaf_instance.equals(of.aaf_instance))
\r
783 public String toString() {
\r
784 return "FEED: feedid=" + feedid + ", name=" + name + ", version=" + version;
\r
788 public int hashCode() {
\r
789 return super.hashCode();
\r