Added the ability to remove pseudonyms from the database.

This commit is contained in:
akwizgran
2013-12-10 22:23:37 +00:00
parent 667dbfdd4a
commit 47708d489d
10 changed files with 368 additions and 41 deletions

View File

@@ -56,7 +56,7 @@ public interface DatabaseComponent {
/** Stores an endpoint. */
void addEndpoint(Endpoint ep) throws DbException;
/** Stores a pseudonym that the user can use to sign messages. */
/** Stores a local pseudonym. */
void addLocalAuthor(LocalAuthor a) throws DbException;
/** Stores a locally generated group message. */
@@ -179,10 +179,10 @@ public interface DatabaseComponent {
*/
Map<ContactId, Long> getLastConnected() throws DbException;
/** Returns the pseudonym with the given ID. */
/** Returns the local pseudonym with the given ID. */
LocalAuthor getLocalAuthor(AuthorId a) throws DbException;
/** Returns all pseudonyms that the user can use to sign messages. */
/** Returns all local pseudonyms. */
Collection<LocalAuthor> getLocalAuthors() throws DbException;
/** Returns the local transport properties for all transports. */
@@ -295,6 +295,11 @@ public interface DatabaseComponent {
/** Removes a contact (and all associated state) from the database. */
void removeContact(ContactId c) throws DbException;
/**
* Removes a local pseudonym (and all associated state) from the database.
*/
void removeLocalAuthor(AuthorId a) throws DbException;
/**
* Removes a transport (and any associated configuration and local
* properties) from the database.
@@ -302,8 +307,8 @@ public interface DatabaseComponent {
void removeTransport(TransportId t) throws DbException;
/**
* Sets the connection reordering window for the given endoint in the given
* rotation period.
* Sets the connection reordering window for the given endpoint in the
* given rotation period.
*/
void setConnectionWindow(ContactId c, TransportId t, long period,
long centre, byte[] bitmap) throws DbException;

View File

@@ -0,0 +1,10 @@
package net.sf.briar.api.db;
/**
* Thrown when a duplicate pseudonym is added to the database. This exception
* may occur due to concurrent updates and does not indicate a database error.
*/
public class LocalAuthorExistsException extends DbException {
private static final long serialVersionUID = -1483877298070151673L;
}

View File

@@ -0,0 +1,11 @@
package net.sf.briar.api.db;
/**
* Thrown when a database operation is attempted for a pseudonym that is not in
* the database. This exception may occur due to concurrent updates and does
* not indicate a database error.
*/
public class NoSuchLocalAuthorException extends DbException {
private static final long serialVersionUID = 494398665376703860L;
}

View File

@@ -0,0 +1,17 @@
package net.sf.briar.api.db.event;
import net.sf.briar.api.AuthorId;
/** An event that is broadcast when a pseudonym for the user is added. */
public class LocalAuthorAddedEvent extends DatabaseEvent {
private final AuthorId authorId;
public LocalAuthorAddedEvent(AuthorId authorId) {
this.authorId = authorId;
}
public AuthorId getAuthorId() {
return authorId;
}
}

View File

@@ -0,0 +1,17 @@
package net.sf.briar.api.db.event;
import net.sf.briar.api.AuthorId;
/** An event that is broadcast when a pseudonym for the user is removed. */
public class LocalAuthorRemovedEvent extends DatabaseEvent {
private final AuthorId authorId;
public LocalAuthorRemovedEvent(AuthorId authorId) {
this.authorId = authorId;
}
public AuthorId getAuthorId() {
return authorId;
}
}