Skip to content
Snippets Groups Projects
Verified Commit d42b49af authored by Torsten Grote's avatar Torsten Grote
Browse files

Allow to get a forum from the ForumManager within a transaction

parent 5a84e0fe
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,9 @@ public interface ForumManager {
/** Returns the forum with the given ID. */
Forum getForum(GroupId g) throws DbException;
/** Returns the forum with the given ID. */
Forum getForum(Transaction txn, GroupId g) throws DbException;
/** Returns all forums to which the user subscribes. */
Collection<Forum> getForums() throws DbException;
......
......@@ -141,15 +141,21 @@ class ForumManagerImpl implements ForumManager {
@Override
public Forum getForum(GroupId g) throws DbException {
Forum forum;
Transaction txn = db.startTransaction(true);
try {
Group group;
Transaction txn = db.startTransaction(true);
try {
group = db.getGroup(txn, g);
txn.setComplete();
} finally {
db.endTransaction(txn);
}
forum = getForum(txn, g);
txn.setComplete();
} finally {
db.endTransaction(txn);
}
return forum;
}
@Override
public Forum getForum(Transaction txn, GroupId g) throws DbException {
try {
Group group = db.getGroup(txn, g);
return parseForum(group);
} catch (FormatException e) {
throw new DbException(e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment