diff --git a/briar-core/src/net/sf/briar/db/Database.java b/briar-core/src/net/sf/briar/db/Database.java index 0eca48b0832d3162ccf112789ad99c0d314a35e7..9df90f43f4f1be46e4531267e80cce5b0a482292 100644 --- a/briar-core/src/net/sf/briar/db/Database.java +++ b/briar-core/src/net/sf/briar/db/Database.java @@ -282,14 +282,6 @@ interface Database<T> { */ MessageId getGroupMessageParent(T txn, MessageId m) throws DbException; - /** - * Returns the IDs of all group messages posted by the given author. - * <p> - * Locking: message read. - */ - Collection<MessageId> getGroupMessages(T txn, AuthorId a) - throws DbException; - /** * Returns the time at which a connection to each contact was last opened * or closed. diff --git a/briar-core/src/net/sf/briar/db/JdbcDatabase.java b/briar-core/src/net/sf/briar/db/JdbcDatabase.java index 2192b23d8024655821d3f4e4fb1f360154842800..f7de855305340c6a4102332c7f27f3100c86d669 100644 --- a/briar-core/src/net/sf/briar/db/JdbcDatabase.java +++ b/briar-core/src/net/sf/briar/db/JdbcDatabase.java @@ -161,9 +161,6 @@ abstract class JdbcDatabase implements Database<Connection> { + " REFERENCES contacts (contactId)" + " ON DELETE CASCADE)"; - private static final String INDEX_MESSAGES_BY_AUTHOR = - "CREATE INDEX messagesByAuthor ON messages (authorId)"; - private static final String INDEX_MESSAGES_BY_TIMESTAMP = "CREATE INDEX messagesByTimestamp ON messages (timestamp)"; @@ -385,7 +382,6 @@ abstract class JdbcDatabase implements Database<Connection> { s.executeUpdate(insertTypeNames(CREATE_CONTACT_GROUPS)); s.executeUpdate(insertTypeNames(CREATE_GROUP_VERSIONS)); s.executeUpdate(insertTypeNames(CREATE_MESSAGES)); - s.executeUpdate(INDEX_MESSAGES_BY_AUTHOR); s.executeUpdate(INDEX_MESSAGES_BY_TIMESTAMP); s.executeUpdate(insertTypeNames(CREATE_MESSAGES_TO_ACK)); s.executeUpdate(insertTypeNames(CREATE_STATUSES)); @@ -1351,31 +1347,6 @@ abstract class JdbcDatabase implements Database<Connection> { } } - public Collection<MessageId> getGroupMessages(Connection txn, - AuthorId a) throws DbException { - PreparedStatement ps = null; - ResultSet rs = null; - try { - String sql = "SELECT messageId" - + " FROM messages AS m" - + " JOIN groups AS g" - + " ON m.groupId = g.groupId" - + " WHERE authorId = ?"; - ps = txn.prepareStatement(sql); - ps.setBytes(1, a.getBytes()); - rs = ps.executeQuery(); - List<MessageId> ids = new ArrayList<MessageId>(); - while(rs.next()) ids.add(new MessageId(rs.getBytes(1))); - rs.close(); - ps.close(); - return Collections.unmodifiableList(ids); - } catch(SQLException e) { - tryToClose(rs); - tryToClose(ps); - throw new DbException(e); - } - } - public Map<ContactId, Long> getLastConnected(Connection txn) throws DbException { PreparedStatement ps = null; diff --git a/briar-tests/src/net/sf/briar/db/H2DatabaseTest.java b/briar-tests/src/net/sf/briar/db/H2DatabaseTest.java index 3219dfd080a2968ca539a7f20c1ced213b11c74d..c6719eab2629ef1b640c64cc656f634fe491899e 100644 --- a/briar-tests/src/net/sf/briar/db/H2DatabaseTest.java +++ b/briar-tests/src/net/sf/briar/db/H2DatabaseTest.java @@ -473,38 +473,6 @@ public class H2DatabaseTest extends BriarTestCase { db.close(); } - @Test - public void testGetGroupMessages() throws Exception { - AuthorId authorId1 = new AuthorId(TestUtils.getRandomId()); - Author author1 = new Author(authorId1, "Bob", - new byte[MAX_PUBLIC_KEY_LENGTH]); - MessageId messageId1 = new MessageId(TestUtils.getRandomId()); - Message message1 = new TestMessage(messageId1, null, group, author1, - contentType, subject, timestamp, raw); - Database<Connection> db = open(false); - Connection txn = db.startTransaction(); - - // Subscribe to a group and store two messages - db.addSubscription(txn, group); - db.addGroupMessage(txn, message, false); - db.addGroupMessage(txn, message1, false); - - // Check that both messages are retrievable by their authors - Collection<MessageId> ids = db.getGroupMessages(txn, authorId); - Iterator<MessageId> it = ids.iterator(); - assertTrue(it.hasNext()); - assertEquals(messageId, it.next()); - assertFalse(it.hasNext()); - ids = db.getGroupMessages(txn, authorId1); - it = ids.iterator(); - assertTrue(it.hasNext()); - assertEquals(messageId1, it.next()); - assertFalse(it.hasNext()); - - db.commitTransaction(txn); - db.close(); - } - @Test public void testGetOldMessages() throws Exception { MessageId messageId1 = new MessageId(TestUtils.getRandomId());