mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
StorageStatus is no longer needed.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.api.contact;
|
||||
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
|
||||
@@ -9,14 +8,11 @@ public class Contact {
|
||||
private final ContactId id;
|
||||
private final Author author;
|
||||
private final AuthorId localAuthorId;
|
||||
private final StorageStatus status;
|
||||
|
||||
public Contact(ContactId id, Author author, AuthorId localAuthorId,
|
||||
StorageStatus status) {
|
||||
public Contact(ContactId id, Author author, AuthorId localAuthorId) {
|
||||
this.id = id;
|
||||
this.author = author;
|
||||
this.localAuthorId = localAuthorId;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public ContactId getId() {
|
||||
@@ -31,10 +27,6 @@ public class Contact {
|
||||
return localAuthorId;
|
||||
}
|
||||
|
||||
public StorageStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
|
||||
@@ -317,18 +317,6 @@ public interface DatabaseComponent {
|
||||
*/
|
||||
void removeTransport(Transaction txn, TransportId t) throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the status of the given contact.
|
||||
*/
|
||||
void setContactStatus(Transaction txn, ContactId c, StorageStatus s)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the status of the given local pseudonym.
|
||||
*/
|
||||
void setLocalAuthorStatus(Transaction txn, AuthorId a, StorageStatus s)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Marks the given message as shared or unshared.
|
||||
*/
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.briarproject.api.db;
|
||||
|
||||
public enum StorageStatus {
|
||||
|
||||
ADDING(0), ACTIVE(1), REMOVING(2);
|
||||
|
||||
private final int value;
|
||||
|
||||
StorageStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static StorageStatus fromValue(int value) {
|
||||
for (StorageStatus s : values()) if (s.value == value) return s;
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,16 @@
|
||||
package org.briarproject.api.identity;
|
||||
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
|
||||
/** A pseudonym for the local user. */
|
||||
public class LocalAuthor extends Author {
|
||||
|
||||
private final byte[] privateKey;
|
||||
private final long created;
|
||||
private final StorageStatus status;
|
||||
|
||||
public LocalAuthor(AuthorId id, String name, byte[] publicKey,
|
||||
byte[] privateKey, long created, StorageStatus status) {
|
||||
byte[] privateKey, long created) {
|
||||
super(id, name, publicKey);
|
||||
this.privateKey = privateKey;
|
||||
this.created = created;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/** Returns the private key used to generate the pseudonym's signatures. */
|
||||
@@ -29,9 +25,4 @@ public class LocalAuthor extends Author {
|
||||
public long getTimeCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/** Returns the status of the pseudonym. */
|
||||
public StorageStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.Metadata;
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
@@ -441,18 +440,6 @@ interface Database<T> {
|
||||
*/
|
||||
void resetExpiryTime(T txn, ContactId c, MessageId m) throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the status of the given contact.
|
||||
*/
|
||||
void setContactStatus(T txn, ContactId c, StorageStatus s)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the status of the given local pseudonym.
|
||||
*/
|
||||
void setLocalAuthorStatus(T txn, AuthorId a, StorageStatus s)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Marks the given message as shared or unshared.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.briarproject.api.db.NoSuchGroupException;
|
||||
import org.briarproject.api.db.NoSuchLocalAuthorException;
|
||||
import org.briarproject.api.db.NoSuchMessageException;
|
||||
import org.briarproject.api.db.NoSuchTransportException;
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.event.ContactAddedEvent;
|
||||
import org.briarproject.api.event.ContactRemovedEvent;
|
||||
@@ -608,22 +607,6 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
||||
transaction.attach(new TransportRemovedEvent(t));
|
||||
}
|
||||
|
||||
public void setContactStatus(Transaction transaction, ContactId c,
|
||||
StorageStatus s) throws DbException {
|
||||
T txn = unbox(transaction);
|
||||
if (!db.containsContact(txn, c))
|
||||
throw new NoSuchContactException();
|
||||
db.setContactStatus(txn, c, s);
|
||||
}
|
||||
|
||||
public void setLocalAuthorStatus(Transaction transaction, AuthorId a,
|
||||
StorageStatus s) throws DbException {
|
||||
T txn = unbox(transaction);
|
||||
if (!db.containsLocalAuthor(txn, a))
|
||||
throw new NoSuchLocalAuthorException();
|
||||
db.setLocalAuthorStatus(txn, a, s);
|
||||
}
|
||||
|
||||
public void setMessageShared(Transaction transaction, Message m,
|
||||
boolean shared) throws DbException {
|
||||
T txn = unbox(transaction);
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.briarproject.api.crypto.SecretKey;
|
||||
import org.briarproject.api.db.DbClosedException;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.Metadata;
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
@@ -48,7 +47,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.api.db.Metadata.REMOVE;
|
||||
import static org.briarproject.api.db.StorageStatus.ADDING;
|
||||
import static org.briarproject.api.sync.ValidationManager.Validity.INVALID;
|
||||
import static org.briarproject.api.sync.ValidationManager.Validity.UNKNOWN;
|
||||
import static org.briarproject.api.sync.ValidationManager.Validity.VALID;
|
||||
@@ -65,8 +63,8 @@ import static org.briarproject.db.ExponentialBackoff.calculateExpiry;
|
||||
*/
|
||||
abstract class JdbcDatabase implements Database<Connection> {
|
||||
|
||||
private static final int SCHEMA_VERSION = 20;
|
||||
private static final int MIN_SCHEMA_VERSION = 20;
|
||||
private static final int SCHEMA_VERSION = 21;
|
||||
private static final int MIN_SCHEMA_VERSION = 21;
|
||||
|
||||
private static final String CREATE_SETTINGS =
|
||||
"CREATE TABLE settings"
|
||||
@@ -82,7 +80,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
+ " publicKey BINARY NOT NULL,"
|
||||
+ " privateKey BINARY NOT NULL,"
|
||||
+ " created BIGINT NOT NULL,"
|
||||
+ " status INT NOT NULL,"
|
||||
+ " PRIMARY KEY (authorId))";
|
||||
|
||||
private static final String CREATE_CONTACTS =
|
||||
@@ -92,7 +89,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
+ " name VARCHAR NOT NULL,"
|
||||
+ " publicKey BINARY NOT NULL,"
|
||||
+ " localAuthorId HASH NOT NULL,"
|
||||
+ " status INT NOT NULL,"
|
||||
+ " PRIMARY KEY (contactId),"
|
||||
+ " FOREIGN KEY (localAuthorId)"
|
||||
+ " REFERENCES localAuthors (authorId)"
|
||||
@@ -452,14 +448,13 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
try {
|
||||
// Create a contact row
|
||||
String sql = "INSERT INTO contacts"
|
||||
+ " (authorId, name, publicKey, localAuthorId, status)"
|
||||
+ " VALUES (?, ?, ?, ?, ?)";
|
||||
+ " (authorId, name, publicKey, localAuthorId)"
|
||||
+ " VALUES (?, ?, ?, ?)";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setBytes(1, remote.getId().getBytes());
|
||||
ps.setString(2, remote.getName());
|
||||
ps.setBytes(3, remote.getPublicKey());
|
||||
ps.setBytes(4, local.getBytes());
|
||||
ps.setInt(5, ADDING.getValue());
|
||||
int affected = ps.executeUpdate();
|
||||
if (affected != 1) throw new DbStateException();
|
||||
ps.close();
|
||||
@@ -528,16 +523,15 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "INSERT INTO localAuthors (authorId, name, publicKey,"
|
||||
+ " privateKey, created, status)"
|
||||
+ " VALUES (?, ?, ?, ?, ?, ?)";
|
||||
String sql = "INSERT INTO localAuthors"
|
||||
+ " (authorId, name, publicKey, privateKey, created)"
|
||||
+ " VALUES (?, ?, ?, ?, ?)";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setBytes(1, a.getId().getBytes());
|
||||
ps.setString(2, a.getName());
|
||||
ps.setBytes(3, a.getPublicKey());
|
||||
ps.setBytes(4, a.getPrivateKey());
|
||||
ps.setLong(5, a.getTimeCreated());
|
||||
ps.setInt(6, a.getStatus().getValue());
|
||||
int affected = ps.executeUpdate();
|
||||
if (affected != 1) throw new DbStateException();
|
||||
ps.close();
|
||||
@@ -957,8 +951,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = "SELECT authorId, name, publicKey, localAuthorId,"
|
||||
+ " status"
|
||||
String sql = "SELECT authorId, name, publicKey, localAuthorId"
|
||||
+ " FROM contacts"
|
||||
+ " WHERE contactId = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
@@ -969,11 +962,10 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
String name = rs.getString(2);
|
||||
byte[] publicKey = rs.getBytes(3);
|
||||
AuthorId localAuthorId = new AuthorId(rs.getBytes(4));
|
||||
StorageStatus status = StorageStatus.fromValue(rs.getInt(5));
|
||||
rs.close();
|
||||
ps.close();
|
||||
Author author = new Author(authorId, name, publicKey);
|
||||
return new Contact(c, author, localAuthorId, status);
|
||||
return new Contact(c, author, localAuthorId);
|
||||
} catch (SQLException e) {
|
||||
tryToClose(rs);
|
||||
tryToClose(ps);
|
||||
@@ -1007,7 +999,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = "SELECT contactId, authorId, name, publicKey,"
|
||||
+ " localAuthorId, status"
|
||||
+ " localAuthorId"
|
||||
+ " FROM contacts";
|
||||
ps = txn.prepareStatement(sql);
|
||||
rs = ps.executeQuery();
|
||||
@@ -1019,9 +1011,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
byte[] publicKey = rs.getBytes(4);
|
||||
Author author = new Author(authorId, name, publicKey);
|
||||
AuthorId localAuthorId = new AuthorId(rs.getBytes(5));
|
||||
StorageStatus status = StorageStatus.fromValue(rs.getInt(6));
|
||||
contacts.add(new Contact(contactId, author, localAuthorId,
|
||||
status));
|
||||
contacts.add(new Contact(contactId, author, localAuthorId));
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
@@ -1108,7 +1098,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = "SELECT name, publicKey, privateKey, created, status"
|
||||
String sql = "SELECT name, publicKey, privateKey, created"
|
||||
+ " FROM localAuthors"
|
||||
+ " WHERE authorId = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
@@ -1119,9 +1109,8 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
byte[] publicKey = rs.getBytes(2);
|
||||
byte[] privateKey = rs.getBytes(3);
|
||||
long created = rs.getLong(4);
|
||||
StorageStatus status = StorageStatus.fromValue(rs.getInt(5));
|
||||
LocalAuthor localAuthor = new LocalAuthor(a, name, publicKey,
|
||||
privateKey, created, status);
|
||||
privateKey, created);
|
||||
if (rs.next()) throw new DbStateException();
|
||||
rs.close();
|
||||
ps.close();
|
||||
@@ -1138,8 +1127,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = "SELECT authorId, name, publicKey, privateKey,"
|
||||
+ " created, status"
|
||||
String sql = "SELECT authorId, name, publicKey, privateKey, created"
|
||||
+ " FROM localAuthors";
|
||||
ps = txn.prepareStatement(sql);
|
||||
rs = ps.executeQuery();
|
||||
@@ -1150,9 +1138,8 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
byte[] publicKey = rs.getBytes(3);
|
||||
byte[] privateKey = rs.getBytes(4);
|
||||
long created = rs.getLong(5);
|
||||
StorageStatus status = StorageStatus.fromValue(rs.getInt(6));
|
||||
authors.add(new LocalAuthor(authorId, name, publicKey,
|
||||
privateKey, created, status));
|
||||
privateKey, created));
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
@@ -2041,41 +2028,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
}
|
||||
|
||||
public void setContactStatus(Connection txn, ContactId c, StorageStatus s)
|
||||
throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "UPDATE contacts SET status = ? WHERE contactId = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setInt(1, s.getValue());
|
||||
ps.setInt(2, c.getInt());
|
||||
int affected = ps.executeUpdate();
|
||||
if (affected < 0 || affected > 1) throw new DbStateException();
|
||||
ps.close();
|
||||
} catch (SQLException e) {
|
||||
tryToClose(ps);
|
||||
throw new DbException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLocalAuthorStatus(Connection txn, AuthorId a,
|
||||
StorageStatus s) throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "UPDATE localAuthors SET status = ?"
|
||||
+ " WHERE authorId = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setInt(1, s.getValue());
|
||||
ps.setBytes(2, a.getBytes());
|
||||
int affected = ps.executeUpdate();
|
||||
if (affected < 0 || affected > 1) throw new DbStateException();
|
||||
ps.close();
|
||||
} catch (SQLException e) {
|
||||
tryToClose(ps);
|
||||
throw new DbException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessageShared(Connection txn, MessageId m, boolean shared)
|
||||
throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
|
||||
@@ -14,8 +14,6 @@ import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.db.StorageStatus.ADDING;
|
||||
|
||||
class AuthorFactoryImpl implements AuthorFactory {
|
||||
|
||||
private final CryptoComponent crypto;
|
||||
@@ -37,7 +35,7 @@ class AuthorFactoryImpl implements AuthorFactory {
|
||||
public LocalAuthor createLocalAuthor(String name, byte[] publicKey,
|
||||
byte[] privateKey) {
|
||||
return new LocalAuthor(getId(name, publicKey), name, publicKey,
|
||||
privateKey, clock.currentTimeMillis(), ADDING);
|
||||
privateKey, clock.currentTimeMillis());
|
||||
}
|
||||
|
||||
private AuthorId getId(String name, byte[] publicKey) {
|
||||
|
||||
@@ -4,21 +4,15 @@ import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchLocalAuthorException;
|
||||
import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.identity.IdentityManager;
|
||||
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 IdentityManagerImpl implements IdentityManager {
|
||||
|
||||
private final DatabaseComponent db;
|
||||
@@ -49,7 +43,6 @@ class IdentityManagerImpl implements IdentityManager {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
for (AddIdentityHook hook : addHooks)
|
||||
hook.addingIdentity(txn, localAuthor);
|
||||
db.setLocalAuthorStatus(txn, localAuthor.getId(), ACTIVE);
|
||||
txn.setComplete();
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
@@ -66,8 +59,7 @@ class IdentityManagerImpl implements IdentityManager {
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
if (author.getStatus().equals(ACTIVE)) return author;
|
||||
throw new NoSuchLocalAuthorException();
|
||||
return author;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,11 +72,7 @@ class IdentityManagerImpl implements IdentityManager {
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
// Filter out any pseudonyms that are being added or removed
|
||||
List<LocalAuthor> active = new ArrayList<LocalAuthor>(authors.size());
|
||||
for (LocalAuthor a : authors)
|
||||
if (a.getStatus().equals(ACTIVE)) active.add(a);
|
||||
return Collections.unmodifiableList(active);
|
||||
return authors;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,7 +80,6 @@ class IdentityManagerImpl implements IdentityManager {
|
||||
Transaction txn = db.startTransaction();
|
||||
try {
|
||||
LocalAuthor localAuthor = db.getLocalAuthor(txn, a);
|
||||
db.setLocalAuthorStatus(txn, a, REMOVING);
|
||||
for (RemoveIdentityHook hook : removeHooks)
|
||||
hook.removingIdentity(txn, localAuthor);
|
||||
db.removeLocalAuthor(txn, a);
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.briarproject.api.db.NoSuchGroupException;
|
||||
import org.briarproject.api.db.NoSuchLocalAuthorException;
|
||||
import org.briarproject.api.db.NoSuchMessageException;
|
||||
import org.briarproject.api.db.NoSuchTransportException;
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.event.ContactAddedEvent;
|
||||
import org.briarproject.api.event.ContactRemovedEvent;
|
||||
@@ -97,8 +96,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
||||
localAuthorId = new AuthorId(TestUtils.getRandomId());
|
||||
long timestamp = System.currentTimeMillis();
|
||||
localAuthor = new LocalAuthor(localAuthorId, "Bob",
|
||||
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp,
|
||||
StorageStatus.ACTIVE);
|
||||
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp);
|
||||
messageId = new MessageId(TestUtils.getRandomId());
|
||||
messageId1 = new MessageId(TestUtils.getRandomId());
|
||||
size = 1234;
|
||||
@@ -109,8 +107,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
||||
transportId = new TransportId("id");
|
||||
maxLatency = Integer.MAX_VALUE;
|
||||
contactId = new ContactId(234);
|
||||
contact = new Contact(contactId, author, localAuthorId,
|
||||
StorageStatus.ACTIVE);
|
||||
contact = new Contact(contactId, author, localAuthorId);
|
||||
}
|
||||
|
||||
private DatabaseComponent createDatabaseComponent(Database<Object> database,
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.crypto.SecretKey;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.Metadata;
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
@@ -87,8 +86,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
localAuthorId = new AuthorId(TestUtils.getRandomId());
|
||||
timestamp = System.currentTimeMillis();
|
||||
localAuthor = new LocalAuthor(localAuthorId, "Bob",
|
||||
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp,
|
||||
StorageStatus.ACTIVE);
|
||||
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp);
|
||||
messageId = new MessageId(TestUtils.getRandomId());
|
||||
size = 1234;
|
||||
raw = new byte[size];
|
||||
@@ -1060,8 +1058,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
throws Exception {
|
||||
AuthorId localAuthorId1 = new AuthorId(TestUtils.getRandomId());
|
||||
LocalAuthor localAuthor1 = new LocalAuthor(localAuthorId1, "Carol",
|
||||
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp,
|
||||
StorageStatus.ACTIVE);
|
||||
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp);
|
||||
|
||||
Database<Connection> db = open(false);
|
||||
Connection txn = db.startTransaction();
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.crypto.SecretKey;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
@@ -130,8 +129,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
}
|
||||
// Add an identity for Alice
|
||||
LocalAuthor aliceAuthor = new LocalAuthor(aliceId, "Alice",
|
||||
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp,
|
||||
StorageStatus.ADDING);
|
||||
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp);
|
||||
identityManager.addLocalAuthor(aliceAuthor);
|
||||
// Add Bob as a contact
|
||||
Author bobAuthor = new Author(bobId, "Bob",
|
||||
@@ -201,8 +199,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
}
|
||||
// Add an identity for Bob
|
||||
LocalAuthor bobAuthor = new LocalAuthor(bobId, "Bob",
|
||||
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp,
|
||||
StorageStatus.ADDING);
|
||||
new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp);
|
||||
identityManager.addLocalAuthor(bobAuthor);
|
||||
// Add Alice as a contact
|
||||
Author aliceAuthor = new Author(aliceId, "Alice",
|
||||
|
||||
Reference in New Issue
Block a user