Updated group-related events and exceptions.

This commit is contained in:
akwizgran
2016-01-27 17:29:17 +00:00
parent 9d537dce00
commit 3837efca6b
23 changed files with 159 additions and 226 deletions

View File

@@ -45,11 +45,8 @@ public interface DatabaseComponent {
*/
ContactId addContact(Author remote, AuthorId local) throws DbException;
/**
* Subscribes to a group, or returns false if the user already has the
* maximum number of subscriptions.
*/
boolean addGroup(Group g) throws DbException;
/** Stores a group. */
void addGroup(Group g) throws DbException;
/** Stores a local pseudonym. */
void addLocalAuthor(LocalAuthor a) throws DbException;
@@ -120,16 +117,13 @@ public interface DatabaseComponent {
/** Returns the unique ID for this device. */
DeviceId getDeviceId() throws DbException;
/** Returns the group with the given ID, if the user subscribes to it. */
/** Returns the group with the given ID. */
Group getGroup(GroupId g) throws DbException;
/** Returns the metadata for the given group. */
Metadata getGroupMetadata(GroupId g) throws DbException;
/**
* Returns all groups belonging to the given client to which the user
* subscribes.
*/
/** Returns all groups belonging to the given client. */
Collection<Group> getGroups(ClientId c) throws DbException;
/** Returns the local pseudonym with the given ID. */
@@ -221,10 +215,7 @@ public interface DatabaseComponent {
/** Removes a contact (and all associated state) from the database. */
void removeContact(ContactId c) throws DbException;
/**
* Unsubscribes from a group. Any messages belonging to the group
* are deleted from the database.
*/
/** Removes a group (and all associated state) from the database. */
void removeGroup(Group g) throws DbException;
/**
@@ -232,10 +223,7 @@ public interface DatabaseComponent {
*/
void removeLocalAuthor(AuthorId a) throws DbException;
/**
* Removes a transport (and any associated configuration and local
* properties) from the database.
*/
/** Removes a transport (and all associated state) from the database. */
void removeTransport(TransportId t) throws DbException;
/** Sets the status of the given contact. */

View File

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

View File

@@ -1,12 +0,0 @@
package org.briarproject.api.db;
/**
* Thrown when a database operation is attempted for a group to which the user
* does not subscribe. This exception may occur due to concurrent updates and
* does not indicate a database error.
*/
public class NoSuchSubscriptionException extends DbException {
private static final long serialVersionUID = -5494178507342571697L;
}

View File

@@ -2,12 +2,12 @@ package org.briarproject.api.event;
import org.briarproject.api.sync.Group;
/** An event that is broadcast when the user subscribes to a group. */
public class SubscriptionAddedEvent extends Event {
/** An event that is broadcast when a group is added. */
public class GroupAddedEvent extends Event {
private final Group group;
public SubscriptionAddedEvent(Group group) {
public GroupAddedEvent(Group group) {
this.group = group;
}

View File

@@ -2,12 +2,12 @@ package org.briarproject.api.event;
import org.briarproject.api.sync.Group;
/** An event that is broadcast when the user unsubscribes from a group. */
public class SubscriptionRemovedEvent extends Event {
/** An event that is broadcast when a group is removed. */
public class GroupRemovedEvent extends Event {
private final Group group;
public SubscriptionRemovedEvent(Group group) {
public GroupRemovedEvent(Group group) {
this.group = group;
}

View File

@@ -4,15 +4,12 @@ import org.briarproject.api.contact.ContactId;
import java.util.Collection;
/**
* An event that is broadcast when the set of subscriptions visible to one or
* more contacts is updated.
*/
public class LocalSubscriptionsUpdatedEvent extends Event {
/** An event that is broadcast when the visibility of a group is updated. */
public class GroupVisibilityUpdatedEvent extends Event {
private final Collection<ContactId> affected;
public LocalSubscriptionsUpdatedEvent(Collection<ContactId> affected) {
public GroupVisibilityUpdatedEvent(Collection<ContactId> affected) {
this.affected = affected;
}

View File

@@ -1,17 +0,0 @@
package org.briarproject.api.event;
import org.briarproject.api.contact.ContactId;
/** An event that is broadcast when a contact's subscriptions are updated. */
public class RemoteSubscriptionsUpdatedEvent extends Event {
private final ContactId contactId;
public RemoteSubscriptionsUpdatedEvent(ContactId contactId) {
this.contactId = contactId;
}
public ContactId getContactId() {
return contactId;
}
}

View File

@@ -17,11 +17,8 @@ public interface ForumManager {
/** Creates a forum with the given name. */
Forum createForum(String name);
/**
* Subscribes to a forum, or returns false if the user already has the
* maximum number of forum subscriptions.
*/
boolean addForum(Forum f) throws DbException;
/** Subscribes to a forum. */
void addForum(Forum f) throws DbException;
/** Stores a local forum post. */
void addLocalPost(ForumPost p) throws DbException;
@@ -29,7 +26,7 @@ public interface ForumManager {
/** Returns all forums to which the user could subscribe. */
Collection<Forum> getAvailableForums() throws DbException;
/** Returns the forum with the given ID, if the user subscribes to it. */
/** Returns the forum with the given ID. */
Forum getForum(GroupId g) throws DbException;
/** Returns all forums to which the user subscribes. */
@@ -47,10 +44,7 @@ public interface ForumManager {
/** Returns the IDs of all contacts to which the given forum is visible. */
Collection<ContactId> getVisibility(GroupId g) throws DbException;
/**
* Unsubscribes from a forum. Any messages belonging to the forum are
* deleted.
*/
/** Unsubscribes from a forum. */
void removeForum(Forum f) throws DbException;
/** Marks a forum post as read or unread. */

View File

@@ -2,7 +2,6 @@ package org.briarproject.api.sync;
import static org.briarproject.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
/** A group to which users may subscribe. */
public class Group {
private final GroupId id;

View File

@@ -13,11 +13,8 @@ public interface SyncConstants {
/** The maximum length of the packet payload in bytes. */
int MAX_PACKET_PAYLOAD_LENGTH = 32 * 1024; // 32 KiB
/** The maximum number of groups a user may subscribe to. */
int MAX_SUBSCRIPTIONS = 200; // TODO: Remove
/** The maximum length of a group descriptor in bytes. */
int MAX_GROUP_DESCRIPTOR_LENGTH = 100; // TODO: Remove
int MAX_GROUP_DESCRIPTOR_LENGTH = 1000; // TODO: Remove
/** The maximum length of a message in bytes. */
int MAX_MESSAGE_LENGTH = MAX_PACKET_PAYLOAD_LENGTH - PACKET_HEADER_LENGTH;