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
52 private int groupid; //New field is added - Groups feature Rally:US708115 - 1610
\r
53 private String name;
\r
54 private String version;
\r
55 private String description;
\r
56 private String business_description; // New field is added - Groups feature Rally:US708102 - 1610
\r
57 private FeedAuthorization authorization;
\r
58 private String publisher;
\r
59 private FeedLinks links;
\r
60 private boolean deleted;
\r
61 private boolean suspended;
\r
62 private Date last_mod;
\r
63 private Date created_date;
\r
64 private String aaf_instance;
\r
67 * Check if a feed ID is valid.
\r
69 * @param id the Feed ID
\r
70 * @return true if it is valid
\r
72 @SuppressWarnings("resource")
\r
73 public static boolean isFeedValid(int id) {
\r
77 Connection conn = db.getConnection();
\r
78 try(PreparedStatement stmt = conn.prepareStatement("select COUNT(*) from FEEDS where FEEDID = ?")) {
\r
80 try(ResultSet rs = stmt.executeQuery()) {
\r
82 count = rs.getInt(1);
\r
87 } catch (SQLException e) {
\r
88 intlogger.warn("PROV0024 Feed.isFeedValid: ", e.getMessage());
\r
94 * Get a specific feed from the DB, based upon its ID.
\r
96 * @param id the Feed ID
\r
97 * @return the Feed object, or null if it does not exist
\r
99 public static Feed getFeedById(int id) {
\r
100 String sql = "select * from FEEDS where FEEDID = " + id;
\r
101 return getFeedBySQL(sql);
\r
105 * 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
119 * Return a count of the number of active feeds in the DB.
\r
121 * @return the count
\r
123 public static int countActiveFeeds() {
\r
127 @SuppressWarnings("resource")
\r
128 Connection conn = db.getConnection();
\r
129 try(Statement stmt = conn.createStatement()) {
\r
130 try (ResultSet rs = stmt.executeQuery("select count(*) from FEEDS where DELETED = 0")) {
\r
132 count = rs.getInt(1);
\r
137 } catch (SQLException e) {
\r
138 intlogger.warn("PROV0025 Feed.countActiveFeeds: ", e.getMessage());
\r
143 public static int getMaxFeedID() {
\r
147 @SuppressWarnings("resource")
\r
148 Connection conn = db.getConnection();
\r
149 try(Statement stmt = conn.createStatement()) {
\r
150 try (ResultSet rs = stmt.executeQuery("select MAX(feedid) from FEEDS")) {
\r
152 max = rs.getInt(1);
\r
157 } catch (SQLException e) {
\r
158 intlogger.warn("PROV0026 Feed.getMaxFeedID: ", e.getMessage());
\r
163 public static Collection<Feed> getAllFeeds() {
\r
164 Map<Integer, Feed> map = new HashMap<Integer, Feed>();
\r
167 @SuppressWarnings("resource")
\r
168 Connection conn = db.getConnection();
\r
169 try(Statement stmt = conn.createStatement()) {
\r
170 try(ResultSet rs = stmt.executeQuery("select * from FEEDS")) {
\r
171 while (rs.next()) {
\r
172 Feed feed = new Feed(rs);
\r
173 map.put(feed.getFeedid(), feed);
\r
177 String sql = "select * from FEED_ENDPOINT_IDS";
\r
178 try(ResultSet rs = stmt.executeQuery(sql)){
\r
179 while (rs.next()) {
\r
180 int id = rs.getInt("FEEDID");
\r
181 Feed feed = map.get(id);
\r
182 if (feed != null) {
\r
183 FeedEndpointID epi = new FeedEndpointID(rs);
\r
184 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
190 sql = "select * from FEED_ENDPOINT_ADDRS";
\r
191 try(ResultSet rs = stmt.executeQuery(sql)) {
\r
192 while (rs.next()) {
\r
193 int id = rs.getInt("FEEDID");
\r
194 Feed feed = map.get(id);
\r
195 if (feed != null) {
\r
196 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
197 acoll.add(rs.getString("ADDR"));
\r
203 } catch (SQLException e) {
\r
204 intlogger.warn("PROV0027 Feed.getAllFeeds: ", e.getMessage());
\r
206 return map.values();
\r
209 public static List<String> getFilteredFeedUrlList(final String name, final String val) {
\r
210 List<String> list = new ArrayList<String>();
\r
211 String sql = "select SELF_LINK from FEEDS where DELETED = 0";
\r
212 if (name.equals("name")) {
\r
213 sql += " and NAME = ?";
\r
214 } else if (name.equals("publ")) {
\r
215 sql += " and PUBLISHER = ?";
\r
216 } else if (name.equals("subs")) {
\r
217 sql = "select distinct FEEDS.SELF_LINK from FEEDS, SUBSCRIPTIONS " +
\r
218 "where DELETED = 0 " +
\r
219 "and FEEDS.FEEDID = SUBSCRIPTIONS.FEEDID " +
\r
220 "and SUBSCRIPTIONS.SUBSCRIBER = ?";
\r
224 @SuppressWarnings("resource")
\r
225 Connection conn = db.getConnection();
\r
226 try(PreparedStatement ps = conn.prepareStatement(sql)) {
\r
227 if (sql.indexOf('?') >= 0)
\r
228 ps.setString(1, val);
\r
229 try(ResultSet rs = ps.executeQuery()) {
\r
230 while (rs.next()) {
\r
231 String t = rs.getString(1);
\r
232 list.add(t.trim());
\r
237 } catch (SQLException e) {
\r
238 intlogger.warn("PROV0028 Feed.getFilteredFeedUrlList: ", e.getMessage());
\r
243 @SuppressWarnings("resource")
\r
244 private static Feed getFeedBySQL(String sql) {
\r
248 Connection conn = db.getConnection();
\r
249 try (Statement stmt = conn.createStatement()) {
\r
250 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
252 feed = new Feed(rs);
\r
255 if (feed != null) {
\r
256 sql = "select * from FEED_ENDPOINT_IDS where FEEDID = " + feed.feedid;
\r
257 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
258 Collection<FeedEndpointID> ecoll = feed.getAuthorization().getEndpoint_ids();
\r
259 while (rs.next()) {
\r
260 FeedEndpointID epi = new FeedEndpointID(rs);
\r
264 sql = "select * from FEED_ENDPOINT_ADDRS where FEEDID = " + feed.feedid;
\r
265 try (ResultSet rs = stmt.executeQuery(sql)) {
\r
266 Collection<String> acoll = feed.getAuthorization().getEndpoint_addrs();
\r
267 while (rs.next()) {
\r
268 acoll.add(rs.getString("ADDR"));
\r
274 } catch (SQLException e) {
\r
275 intlogger.warn("PROV0029 Feed.getFeedBySQL: ", e.getMessage());
\r
281 this("", "", "", "");
\r
284 public Feed(String name, String version, String desc, String business_description) {
\r
286 this.groupid = -1; //New field is added - Groups feature Rally:US708115 - 1610
\r
288 this.version = version;
\r
289 this.description = desc;
\r
290 this.business_description = business_description; // New field is added - Groups feature Rally:US708102 - 1610
\r
291 this.authorization = new FeedAuthorization();
\r
292 this.publisher = "";
\r
293 this.links = new FeedLinks();
\r
294 this.deleted = false;
\r
295 this.suspended = false;
\r
296 this.last_mod = new Date();
\r
297 this.created_date = new Date();
\r
298 this.aaf_instance = "";
\r
301 public Feed(ResultSet rs) throws SQLException {
\r
302 this.feedid = rs.getInt("FEEDID");
\r
303 this.groupid = rs.getInt("GROUPID"); //New field is added - Groups feature Rally:US708115 - 1610
\r
304 this.name = rs.getString("NAME");
\r
305 this.version = rs.getString("VERSION");
\r
306 this.description = rs.getString("DESCRIPTION");
\r
307 this.business_description = rs.getString("BUSINESS_DESCRIPTION"); // New field is added - Groups feature Rally:US708102 - 1610
\r
308 this.authorization = new FeedAuthorization();
\r
309 this.authorization.setClassification(rs.getString("AUTH_CLASS"));
\r
310 this.publisher = rs.getString("PUBLISHER");
\r
311 this.links = new FeedLinks();
\r
312 this.links.setSelf(rs.getString("SELF_LINK"));
\r
313 this.links.setPublish(rs.getString("PUBLISH_LINK"));
\r
314 this.links.setSubscribe(rs.getString("SUBSCRIBE_LINK"));
\r
315 this.links.setLog(rs.getString("LOG_LINK"));
\r
316 this.deleted = rs.getBoolean("DELETED");
\r
317 this.suspended = rs.getBoolean("SUSPENDED");
\r
318 this.last_mod = rs.getDate("LAST_MOD");
\r
319 this.created_date = rs.getTimestamp("CREATED_DATE");
\r
320 this.aaf_instance = rs.getString("AAF_INSTANCE");
\r
323 public Feed(JSONObject jo) throws InvalidObjectException {
\r
324 this("", "", "", "");
\r
326 // The JSONObject is assumed to contain a vnd.dmaap-dr.feed representation
\r
327 this.feedid = jo.optInt("feedid", -1);
\r
328 this.groupid = jo.optInt("groupid");
\r
329 this.name = jo.getString("name");
\r
330 this.aaf_instance = jo.optString("aaf_instance", "legacy");
\r
331 if(!(aaf_instance.equalsIgnoreCase("legacy"))){
\r
332 if (aaf_instance.length() > 255){
\r
333 throw new InvalidObjectException("aaf_instance field is too long");
\r
336 if (name.length() > 255)
\r
337 throw new InvalidObjectException("name field is too long");
\r
339 this.version = jo.getString("version");
\r
340 } catch (JSONException e) {
\r
341 this.version = null;
\r
343 if(version != null && version.length() > 20)
\r
344 throw new InvalidObjectException("version field is too long");
\r
345 this.description = jo.optString("description");
\r
346 this.business_description = jo.optString("business_description");
\r
347 if (description.length() > 1000)
\r
348 throw new InvalidObjectException("technical description field is too long");
\r
349 if (business_description.length() > 1000)
\r
350 throw new InvalidObjectException("business description field is too long");
\r
351 this.authorization = new FeedAuthorization();
\r
352 JSONObject jauth = jo.getJSONObject("authorization");
\r
353 this.authorization.setClassification(jauth.getString("classification"));
\r
354 if (this.authorization.getClassification().length() > 32)
\r
355 throw new InvalidObjectException("classification field is too long");
\r
356 JSONArray endPointIds = jauth.getJSONArray("endpoint_ids");
\r
357 for (int i = 0; i < endPointIds.length(); i++) {
\r
358 JSONObject id = endPointIds.getJSONObject(i);
\r
359 FeedEndpointID fid = new FeedEndpointID(id.getString("id"), id.getString("password"));
\r
360 if (fid.getId().length() > 60)
\r
361 throw new InvalidObjectException("id field is too long (" + fid.getId() + ")");
\r
362 if (fid.getPassword().length() > 32)
\r
363 throw new InvalidObjectException("password field is too long ("+ fid.getPassword()+")"); //Fortify scan fixes - Privacy Violation
\r
364 this.authorization.getEndpoint_ids().add(fid);
\r
366 if (this.authorization.getEndpoint_ids().size() < 1)
\r
367 throw new InvalidObjectException("need to specify at least one endpoint_id");
\r
368 endPointIds = jauth.getJSONArray("endpoint_addrs");
\r
369 for (int i = 0; i < endPointIds.length(); i++) {
\r
370 String addr = endPointIds.getString(i);
\r
371 if (!JSONUtilities.validIPAddrOrSubnet(addr))
\r
372 throw new InvalidObjectException("bad IP addr or subnet mask: " + addr);
\r
373 this.authorization.getEndpoint_addrs().add(addr);
\r
376 this.publisher = jo.optString("publisher", "");
\r
377 this.deleted = jo.optBoolean("deleted", false);
\r
378 this.suspended = jo.optBoolean("suspend", false);
\r
379 JSONObject jol = jo.optJSONObject("links");
\r
380 this.links = (jol == null) ? (new FeedLinks()) : (new FeedLinks(jol));
\r
381 } catch (InvalidObjectException e) {
\r
382 intlogger.warn("PROV0030 Feed.Feed: ", e.getMessage());
\r
384 } catch (Exception e) {
\r
385 intlogger.error("PROV0031 Feed.Feed: invalid JSON: "+e);
\r
386 throw new InvalidObjectException("invalid JSON: " + e.getMessage());
\r
390 public int getFeedid() {
\r
394 public void setFeedid(int feedid) {
\r
395 this.feedid = feedid;
\r
397 // Create link URLs
\r
398 FeedLinks fl = getLinks();
\r
399 fl.setSelf(URLUtilities.generateFeedURL(feedid));
\r
400 fl.setPublish(URLUtilities.generatePublishURL(feedid));
\r
401 fl.setSubscribe(URLUtilities.generateSubscribeURL(feedid));
\r
402 fl.setLog(URLUtilities.generateFeedLogURL(feedid));
\r
405 public String getAafInstance() {
\r
406 return aaf_instance;
\r
409 public void setAaf_instance(String aaf_instance) {
\r
410 this.aaf_instance = aaf_instance;
\r
413 //new getter setters for groups- Rally:US708115 - 1610
\r
414 public int getGroupid() {
\r
418 public void setGroupid(int groupid) {
\r
419 this.groupid = groupid;
\r
422 public String getName() {
\r
426 public void setName(String name) {
\r
430 public String getVersion() {
\r
434 public void setVersion(String version) {
\r
435 this.version = version;
\r
438 public String getDescription() {
\r
439 return description;
\r
442 public void setDescription(String description) {
\r
443 this.description = description;
\r
446 // New field is added - Groups feature Rally:US708102 - 1610
\r
447 public String getBusiness_description() {
\r
448 return business_description;
\r
451 public void setBusiness_description(String business_description) {
\r
452 this.business_description = business_description;
\r
455 public FeedAuthorization getAuthorization() {
\r
456 return authorization;
\r
459 public void setAuthorization(FeedAuthorization authorization) {
\r
460 this.authorization = authorization;
\r
463 public String getPublisher() {
\r
467 public void setPublisher(String publisher) {
\r
468 if (publisher != null) {
\r
469 if (publisher.length() > 8)
\r
470 publisher = publisher.substring(0, 8);
\r
471 this.publisher = publisher;
\r
475 public FeedLinks getLinks() {
\r
479 public void setLinks(FeedLinks links) {
\r
480 this.links = links;
\r
483 public boolean isDeleted() {
\r
487 public void setDeleted(boolean deleted) {
\r
488 this.deleted = deleted;
\r
491 public boolean isSuspended() {
\r
495 public void setSuspended(boolean suspended) {
\r
496 this.suspended = suspended;
\r
499 public Date getLast_mod() {
\r
503 public Date getCreated_date() {
\r
504 return created_date;
\r
508 public JSONObject asJSONObject() {
\r
509 JSONObject jo = new JSONObject();
\r
510 jo.put("feedid", feedid);
\r
511 jo.put("groupid", groupid); //New field is added - Groups feature Rally:US708115 - 1610
\r
512 jo.put("name", name);
\r
513 jo.put("version", version);
\r
514 jo.put("description", description);
\r
515 jo.put("business_description", business_description); // New field is added - Groups feature Rally:US708102 - 1610
\r
516 jo.put("authorization", authorization.asJSONObject());
\r
517 jo.put("publisher", publisher);
\r
518 jo.put("links", links.asJSONObject());
\r
519 jo.put("deleted", deleted);
\r
520 jo.put("suspend", suspended);
\r
521 jo.put("last_mod", last_mod.getTime());
\r
522 jo.put("created_date", created_date.getTime());
\r
523 jo.put("aaf_instance", aaf_instance);
\r
527 public JSONObject asLimitedJSONObject() {
\r
528 JSONObject jo = asJSONObject();
\r
529 jo.remove("deleted");
\r
530 jo.remove("feedid");
\r
531 jo.remove("last_mod");
\r
532 jo.remove("created_date");
\r
536 public JSONObject asJSONObject(boolean hidepasswords) {
\r
537 JSONObject jo = asJSONObject();
\r
538 if (hidepasswords) {
\r
539 jo.remove("feedid"); // we no longer hide passwords, however we do hide these
\r
540 jo.remove("deleted");
\r
541 jo.remove("last_mod");
\r
542 jo.remove("created_date");
\r
548 public boolean doDelete(Connection c) {
\r
550 PreparedStatement ps = null;
\r
552 String sql = "delete from FEEDS where FEEDID = ?";
\r
553 ps = c.prepareStatement(sql);
\r
554 ps.setInt(1, feedid);
\r
556 } catch (SQLException e) {
\r
558 intlogger.warn("PROV0007 doDelete: " + e.getMessage());
\r
559 intlogger.error("SQLException " + e.getMessage());
\r
565 } catch (SQLException e) {
\r
566 intlogger.error("SQLException " + e.getMessage());
\r
573 public synchronized boolean doInsert(Connection c) {
\r
576 if (feedid == -1) {
\r
577 setFeedid(next_feedid++);
\r
579 // In case we insert a feed from synchronization
\r
580 if (feedid > next_feedid)
\r
581 next_feedid = feedid + 1;
\r
583 // Create FEED_ENDPOINT_IDS rows
\r
584 FeedAuthorization auth = getAuthorization();
\r
585 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
586 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
587 for (FeedEndpointID fid : auth.getEndpoint_ids()) {
\r
588 ps2.setInt(1, feedid);
\r
589 ps2.setString(2, fid.getId());
\r
590 ps2.setString(3, fid.getPassword());
\r
591 ps2.executeUpdate();
\r
595 // Create FEED_ENDPOINT_ADDRS rows
\r
596 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
597 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
598 for (String t : auth.getEndpoint_addrs()) {
\r
599 ps2.setInt(1, feedid);
\r
600 ps2.setString(2, t);
\r
601 ps2.executeUpdate();
\r
605 // Finally, create the FEEDS row
\r
606 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
607 try(PreparedStatement ps2 = c.prepareStatement(sql)) {
\r
608 ps2.setInt(1, feedid);
\r
609 ps2.setString(2, getName());
\r
610 ps2.setString(3, getVersion());
\r
611 ps2.setString(4, getDescription());
\r
612 ps2.setString(5, getAuthorization().getClassification());
\r
613 ps2.setString(6, getPublisher());
\r
614 ps2.setString(7, getLinks().getSelf());
\r
615 ps2.setString(8, getLinks().getPublish());
\r
616 ps2.setString(9, getLinks().getSubscribe());
\r
617 ps2.setString(10, getLinks().getLog());
\r
618 ps2.setBoolean(11, isDeleted());
\r
619 ps2.setBoolean(12, isSuspended());
\r
620 ps2.setString(13, getBusiness_description());
\r
621 ps2.setInt(14, groupid);
\r
622 ps2.setString(15, getAafInstance());
\r
623 ps2.executeUpdate();
\r
625 } catch (SQLException e) {
\r
627 intlogger.warn("PROV0005 doInsert: " + e.getMessage());
\r
628 intlogger.error("SQLException " + e.getMessage());
\r
634 public boolean doUpdate(Connection c) {
\r
636 Feed oldobj = getFeedById(feedid);
\r
637 PreparedStatement ps = null;
\r
639 Set<FeedEndpointID> newset = getAuthorization().getEndpoint_ids();
\r
640 Set<FeedEndpointID> oldset = oldobj.getAuthorization().getEndpoint_ids();
\r
642 // Insert new FEED_ENDPOINT_IDS rows
\r
643 String sql = "insert into FEED_ENDPOINT_IDS values (?, ?, ?)";
\r
644 ps = c.prepareStatement(sql);
\r
645 for (FeedEndpointID fid : newset) {
\r
646 if (!oldset.contains(fid)) {
\r
647 ps.setInt(1, feedid);
\r
648 ps.setString(2, fid.getId());
\r
649 ps.setString(3, fid.getPassword());
\r
650 ps.executeUpdate();
\r
655 // Delete old FEED_ENDPOINT_IDS rows
\r
656 sql = "delete from FEED_ENDPOINT_IDS where FEEDID = ? AND USERID = ? AND PASSWORD = ?";
\r
657 ps = c.prepareStatement(sql);
\r
658 for (FeedEndpointID fid : oldset) {
\r
659 if (!newset.contains(fid)) {
\r
660 ps.setInt(1, feedid);
\r
661 ps.setString(2, fid.getId());
\r
662 ps.setString(3, fid.getPassword());
\r
663 ps.executeUpdate();
\r
668 // Insert new FEED_ENDPOINT_ADDRS rows
\r
669 Set<String> newset2 = getAuthorization().getEndpoint_addrs();
\r
670 Set<String> oldset2 = oldobj.getAuthorization().getEndpoint_addrs();
\r
671 sql = "insert into FEED_ENDPOINT_ADDRS values (?, ?)";
\r
672 ps = c.prepareStatement(sql);
\r
673 for (String t : newset2) {
\r
674 if (!oldset2.contains(t)) {
\r
675 ps.setInt(1, feedid);
\r
676 ps.setString(2, t);
\r
677 ps.executeUpdate();
\r
682 // Delete old FEED_ENDPOINT_ADDRS rows
\r
683 sql = "delete from FEED_ENDPOINT_ADDRS where FEEDID = ? AND ADDR = ?";
\r
684 ps = c.prepareStatement(sql);
\r
685 for (String t : oldset2) {
\r
686 if (!newset2.contains(t)) {
\r
687 ps.setInt(1, feedid);
\r
688 ps.setString(2, t);
\r
689 ps.executeUpdate();
\r
694 // Finally, update the FEEDS row
\r
695 sql = "update FEEDS set DESCRIPTION = ?, AUTH_CLASS = ?, DELETED = ?, SUSPENDED = ?, BUSINESS_DESCRIPTION=?, GROUPID=? where FEEDID = ?";
\r
696 ps = c.prepareStatement(sql);
\r
697 ps.setString(1, getDescription());
\r
698 ps.setString(2, getAuthorization().getClassification());
\r
699 ps.setInt(3, deleted ? 1 : 0);
\r
700 ps.setInt(4, suspended ? 1 : 0);
\r
701 ps.setString(5, getBusiness_description());
\r
702 ps.setInt(6, groupid);
\r
703 ps.setInt(7, feedid);
\r
704 ps.executeUpdate();
\r
706 } catch (SQLException e) {
\r
708 intlogger.warn("PROV0006 doUpdate: " + e.getMessage());
\r
713 } catch (SQLException e) {
\r
714 intlogger.error("SQLException " + e.getMessage());
\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
746 } catch (SQLException e) {
\r
747 intlogger.error("SQLException " + e.getMessage());
\r
755 public String getKey() {
\r
756 return "" + getFeedid();
\r
760 public boolean equals(Object obj) {
\r
761 if (!(obj instanceof Feed))
\r
763 Feed of = (Feed) obj;
\r
764 if (feedid != of.feedid)
\r
766 if (groupid != of.groupid) //New field is added - Groups feature Rally:US708115 - 1610
\r
768 if (!name.equals(of.name))
\r
770 if (!version.equals(of.version))
\r
772 if (!description.equals(of.description))
\r
774 if (!business_description.equals(of.business_description)) // New field is added - Groups feature Rally:US708102 - 1610
\r
776 if (!publisher.equals(of.publisher))
\r
778 if (!authorization.equals(of.authorization))
\r
780 if (!links.equals(of.links))
\r
782 if (deleted != of.deleted)
\r
784 if (suspended != of.suspended)
\r
786 if (!aaf_instance.equals(of.aaf_instance))
\r
792 public String toString() {
\r
793 return "FEED: feedid=" + feedid + ", name=" + name + ", version=" + version;
\r
797 public int hashCode() {
\r
798 return super.hashCode();
\r