mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
StorageStatus is no longer needed.
This commit is contained in:
@@ -7,22 +7,16 @@ import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchContactException;
|
||||
import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.identity.IdentityManager.RemoveIdentityHook;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import static org.briarproject.api.db.StorageStatus.ACTIVE;
|
||||
import static org.briarproject.api.db.StorageStatus.REMOVING;
|
||||
|
||||
class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
||||
|
||||
private final DatabaseComponent db;
|
||||
@@ -56,7 +50,6 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
||||
Contact contact = db.getContact(txn, c);
|
||||
for (AddContactHook hook : addHooks)
|
||||
hook.addingContact(txn, contact);
|
||||
db.setContactStatus(txn, c, ACTIVE);
|
||||
txn.setComplete();
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
@@ -74,8 +67,7 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
if (contact.getStatus().equals(ACTIVE)) return contact;
|
||||
throw new NoSuchContactException();
|
||||
return contact;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,11 +80,7 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
// Filter out any contacts that are being added or removed
|
||||
List<Contact> active = new ArrayList<Contact>(contacts.size());
|
||||
for (Contact c : contacts)
|
||||
if (c.getStatus().equals(ACTIVE)) active.add(c);
|
||||
return Collections.unmodifiableList(active);
|
||||
return contacts;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,7 +97,6 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
||||
private void removeContact(Transaction txn, ContactId c)
|
||||
throws DbException {
|
||||
Contact contact = db.getContact(txn, c);
|
||||
db.setContactStatus(txn, c, REMOVING);
|
||||
for (RemoveContactHook hook : removeHooks)
|
||||
hook.removingContact(txn, contact);
|
||||
db.removeContact(txn, c);
|
||||
|
||||
Reference in New Issue
Block a user