mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 22:29:53 +01:00
Add transactional getSharedWith() method to SharingManager.
This commit is contained in:
@@ -3,6 +3,7 @@ package org.briarproject.briar.api.sharing;
|
|||||||
import org.briarproject.bramble.api.contact.Contact;
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
|
import org.briarproject.bramble.api.db.Transaction;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.briar.api.client.SessionId;
|
import org.briarproject.briar.api.client.SessionId;
|
||||||
@@ -45,6 +46,12 @@ public interface SharingManager<S extends Shareable>
|
|||||||
*/
|
*/
|
||||||
Collection<Contact> getSharedWith(GroupId g) throws DbException;
|
Collection<Contact> getSharedWith(GroupId g) throws DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all contacts with whom the given group is shared.
|
||||||
|
*/
|
||||||
|
Collection<Contact> getSharedWith(Transaction txn, GroupId g)
|
||||||
|
throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the group not already shared and no invitation is open
|
* Returns true if the group not already shared and no invitation is open
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -426,17 +426,17 @@ abstract class SharingManagerImpl<S extends Shareable>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Contact> getSharedWith(GroupId g) throws DbException {
|
public Collection<Contact> getSharedWith(GroupId g) throws DbException {
|
||||||
|
return db.transactionWithResult(true, txn -> getSharedWith(txn, g));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Contact> getSharedWith(Transaction txn, GroupId g)
|
||||||
|
throws DbException {
|
||||||
// TODO report also pending invitations
|
// TODO report also pending invitations
|
||||||
Collection<Contact> contacts = new ArrayList<>();
|
Collection<Contact> contacts = new ArrayList<>();
|
||||||
Transaction txn = db.startTransaction(true);
|
for (Contact c : db.getContacts(txn)) {
|
||||||
try {
|
if (db.getGroupVisibility(txn, c.getId(), g) == SHARED)
|
||||||
for (Contact c : db.getContacts(txn)) {
|
contacts.add(c);
|
||||||
if (db.getGroupVisibility(txn, c.getId(), g) == SHARED)
|
|
||||||
contacts.add(c);
|
|
||||||
}
|
|
||||||
db.commitTransaction(txn);
|
|
||||||
} finally {
|
|
||||||
db.endTransaction(txn);
|
|
||||||
}
|
}
|
||||||
return contacts;
|
return contacts;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user