Remove blog as well when removing RSS feed

This also adds a confirmation dialog to the removal process.
This commit is contained in:
Torsten Grote
2017-04-10 13:39:28 -03:00
parent c7ff1ba974
commit 17de785c12
6 changed files with 51 additions and 27 deletions

View File

@@ -224,6 +224,11 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
}
}
@Override
public void removeBlog(Transaction txn, Blog b) throws DbException {
removeBlog(txn, b, false);
}
private void removeBlog(Transaction txn, Blog b, boolean forced)
throws DbException {
if (!forced && !canBeRemoved(txn, b.getId()))

View File

@@ -203,22 +203,20 @@ class FeedManagerImpl implements FeedManager, Client, EventListener {
}
@Override
public void removeFeed(String url) throws DbException {
public void removeFeed(Feed feed) throws DbException {
LOG.info("Removing RSS feed...");
Transaction txn = db.startTransaction(false);
try {
List<Feed> feeds = getFeeds(txn);
Feed feed = null;
for (Feed f : feeds) {
if (f.getUrl().equals(url)) {
if (f.getBlogId().equals(feed.getBlogId())) {
feed = f;
feeds.remove(f);
break;
}
}
if (feed == null) throw new DbException();
storeFeeds(txn, feeds);
// TODO blogManager.removeBlog(txn, feed.getBlog());
blogManager.removeBlog(txn, feed.getBlog());
db.commitTransaction(txn);
} finally {
db.endTransaction(txn);