diff --git a/briar-api/src/org/briarproject/api/db/DatabaseComponent.java b/briar-api/src/org/briarproject/api/db/DatabaseComponent.java index 1b8a900f6..2292bc0ba 100644 --- a/briar-api/src/org/briarproject/api/db/DatabaseComponent.java +++ b/briar-api/src/org/briarproject/api/db/DatabaseComponent.java @@ -142,70 +142,97 @@ public interface DatabaseComponent { /** * Returns the contact with the given ID. + *

+ * Read-only. */ Contact getContact(Transaction txn, ContactId c) throws DbException; /** * Returns all contacts. + *

+ * Read-only. */ Collection getContacts(Transaction txn) throws DbException; /** * Returns all contacts associated with the given local pseudonym. + *

+ * Read-only. */ Collection getContacts(Transaction txn, AuthorId a) throws DbException; /** * Returns the unique ID for this device. + *

+ * Read-only. */ DeviceId getDeviceId(Transaction txn) throws DbException; /** * Returns the group with the given ID. + *

+ * Read-only. */ Group getGroup(Transaction txn, GroupId g) throws DbException; /** * Returns the metadata for the given group. + *

+ * Read-only. */ Metadata getGroupMetadata(Transaction txn, GroupId g) throws DbException; /** * Returns all groups belonging to the given client. + *

+ * Read-only. */ Collection getGroups(Transaction txn, ClientId c) throws DbException; /** * Returns the local pseudonym with the given ID. + *

+ * Read-only. */ LocalAuthor getLocalAuthor(Transaction txn, AuthorId a) throws DbException; /** * Returns all local pseudonyms. + *

+ * Read-only. */ Collection getLocalAuthors(Transaction txn) throws DbException; /** * Returns the IDs of any messages that need to be validated by the given * client. + *

+ * Read-only. */ Collection getMessagesToValidate(Transaction txn, ClientId c) throws DbException; /** - * Returns the message with the given ID, in serialised form. + * Returns the message with the given ID, in serialised form, or null if + * the message has been deleted. + *

+ * Read-only. */ byte[] getRawMessage(Transaction txn, MessageId m) throws DbException; /** * Returns the metadata for all messages in the given group. + *

+ * Read-only. */ Map getMessageMetadata(Transaction txn, GroupId g) throws DbException; /** * Returns the metadata for the given message. + *

+ * Read-only. */ Metadata getMessageMetadata(Transaction txn, MessageId m) throws DbException; @@ -213,6 +240,8 @@ public interface DatabaseComponent { /** * Returns the status of all messages in the given group with respect to * the given contact. + *

+ * Read-only. */ Collection getMessageStatus(Transaction txn, ContactId c, GroupId g) throws DbException; @@ -220,17 +249,23 @@ public interface DatabaseComponent { /** * Returns the status of the given message with respect to the given * contact. + *

+ * Read-only. */ MessageStatus getMessageStatus(Transaction txn, ContactId c, MessageId m) throws DbException; /** * Returns all settings in the given namespace. + *

+ * Read-only. */ Settings getSettings(Transaction txn, String namespace) throws DbException; /** * Returns all transport keys for the given transport. + *

+ * Read-only. */ Map getTransportKeys(Transaction txn, TransportId t) throws DbException; @@ -244,6 +279,8 @@ public interface DatabaseComponent { /** * Returns true if the given group is visible to the given contact. + *

+ * Read-only. */ boolean isVisibleToContact(Transaction txn, ContactId c, GroupId g) throws DbException; diff --git a/briar-core/src/org/briarproject/db/Database.java b/briar-core/src/org/briarproject/db/Database.java index 6a642d74e..bcd1b7f44 100644 --- a/briar-core/src/org/briarproject/db/Database.java +++ b/briar-core/src/org/briarproject/db/Database.java @@ -118,38 +118,52 @@ interface Database { /** * Returns true if the database contains the given contact for the given * local pseudonym. + *

+ * Read-only. */ boolean containsContact(T txn, AuthorId remote, AuthorId local) throws DbException; /** * Returns true if the database contains the given contact. + *

+ * Read-only. */ boolean containsContact(T txn, ContactId c) throws DbException; /** * Returns true if the database contains the given group. + *

+ * Read-only. */ boolean containsGroup(T txn, GroupId g) throws DbException; /** * Returns true if the database contains the given local pseudonym. + *

+ * Read-only. */ boolean containsLocalAuthor(T txn, AuthorId a) throws DbException; /** * Returns true if the database contains the given message. + *

+ * Read-only. */ boolean containsMessage(T txn, MessageId m) throws DbException; /** * Returns true if the database contains the given transport. + *

+ * Read-only. */ boolean containsTransport(T txn, TransportId t) throws DbException; /** * Returns true if the database contains the given group and the group is * visible to the given contact. + *

+ * Read-only. */ boolean containsVisibleGroup(T txn, ContactId c, GroupId g) throws DbException; @@ -157,12 +171,16 @@ interface Database { /** * Returns true if the database contains the given message and the message * is visible to the given contact. + *

+ * Read-only. */ boolean containsVisibleMessage(T txn, ContactId c, MessageId m) throws DbException; /** * Returns the number of messages offered by the given contact. + *

+ * Read-only. */ int countOfferedMessages(T txn, ContactId c) throws DbException; @@ -171,35 +189,39 @@ interface Database { * {@link #removeMessage(Object, MessageId)}, the message ID and any other * associated data are not deleted, and * {@link #containsMessage(Object, MessageId)} will continue to return true. - *

- * Locking: write. */ void deleteMessage(T txn, MessageId m) throws DbException; /** * Deletes any metadata associated with the given message. - *

- * Locking: write. */ void deleteMessageMetadata(T txn, MessageId m) throws DbException; /** * Returns the contact with the given ID. + *

+ * Read-only. */ Contact getContact(T txn, ContactId c) throws DbException; /** * Returns all contacts. + *

+ * Read-only. */ Collection getContacts(T txn) throws DbException; /** * Returns all contacts associated with the given local pseudonym. + *

+ * Read-only. */ Collection getContacts(T txn, AuthorId a) throws DbException; /** * Returns the unique ID for this device. + *

+ * Read-only. */ DeviceId getDeviceId(T txn) throws DbException; @@ -212,48 +234,66 @@ interface Database { /** * Returns the group with the given ID. + *

+ * Read-only. */ Group getGroup(T txn, GroupId g) throws DbException; /** * Returns the metadata for the given group. + *

+ * Read-only. */ Metadata getGroupMetadata(T txn, GroupId g) throws DbException; /** * Returns all groups belonging to the given client. + *

+ * Read-only. */ Collection getGroups(T txn, ClientId c) throws DbException; /** * Returns the local pseudonym with the given ID. + *

+ * Read-only. */ LocalAuthor getLocalAuthor(T txn, AuthorId a) throws DbException; /** * Returns all local pseudonyms. + *

+ * Read-only. */ Collection getLocalAuthors(T txn) throws DbException; /** * Returns the IDs of all messages in the given group. + *

+ * Read-only. */ Collection getMessageIds(T txn, GroupId g) throws DbException; /** * Returns the metadata for all messages in the given group. + *

+ * Read-only. */ Map getMessageMetadata(T txn, GroupId g) throws DbException; /** * Returns the metadata for the given message. + *

+ * Read-only. */ Metadata getMessageMetadata(T txn, MessageId m) throws DbException; /** * Returns the status of all messages in the given group with respect * to the given contact. + *

+ * Read-only. */ Collection getMessageStatus(T txn, ContactId c, GroupId g) throws DbException; @@ -261,6 +301,8 @@ interface Database { /** * Returns the status of the given message with respect to the given * contact. + *

+ * Read-only. */ MessageStatus getMessageStatus(T txn, ContactId c, MessageId m) throws DbException; @@ -268,6 +310,8 @@ interface Database { /** * Returns the IDs of some messages received from the given contact that * need to be acknowledged, up to the given number of messages. + *

+ * Read-only. */ Collection getMessagesToAck(T txn, ContactId c, int maxMessages) throws DbException; @@ -275,6 +319,8 @@ interface Database { /** * Returns the IDs of some messages that are eligible to be offered to the * given contact, up to the given number of messages. + *

+ * Read-only. */ Collection getMessagesToOffer(T txn, ContactId c, int maxMessages) throws DbException; @@ -282,6 +328,8 @@ interface Database { /** * Returns the IDs of some messages that are eligible to be sent to the * given contact, up to the given total length. + *

+ * Read-only. */ Collection getMessagesToSend(T txn, ContactId c, int maxLength) throws DbException; @@ -289,6 +337,8 @@ interface Database { /** * Returns the IDs of some messages that are eligible to be requested from * the given contact, up to the given number of messages. + *

+ * Read-only. */ Collection getMessagesToRequest(T txn, ContactId c, int maxMessages) throws DbException; @@ -296,12 +346,17 @@ interface Database { /** * Returns the IDs of any messages that need to be validated by the given * client. + *

+ * Read-only. */ Collection getMessagesToValidate(T txn, ClientId c) throws DbException; /** - * Returns the message with the given ID, in serialised form. + * Returns the message with the given ID, in serialised form, or null if + * the message has been deleted. + *

+ * Read-only. */ byte[] getRawMessage(T txn, MessageId m) throws DbException; @@ -309,23 +364,31 @@ interface Database { * Returns the IDs of some messages that are eligible to be sent to the * given contact and have been requested by the contact, up to the given * total length. + *

+ * Read-only. */ Collection getRequestedMessagesToSend(T txn, ContactId c, int maxLength) throws DbException; /** * Returns all settings in the given namespace. + *

+ * Read-only. */ Settings getSettings(T txn, String namespace) throws DbException; /** * Returns all transport keys for the given transport. + *

+ * Read-only. */ Map getTransportKeys(T txn, TransportId t) throws DbException; /** * Returns the IDs of all contacts to which the given group is visible. + *

+ * Read-only. */ Collection getVisibility(T txn, GroupId g) throws DbException;