mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 07:09:56 +01:00
s/transport details/transport properties/g
This commit is contained in:
@@ -55,8 +55,8 @@ public interface DatabaseComponent {
|
|||||||
void removeListener(DatabaseListener d);
|
void removeListener(DatabaseListener d);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new contact to the database with the given transport details and
|
* Adds a new contact to the database with the given transport properties
|
||||||
* returns an ID for the contact.
|
* and returns an ID for the contact.
|
||||||
*/
|
*/
|
||||||
ContactId addContact(Map<String, String> transports) throws DbException;
|
ContactId addContact(Map<String, String> transports) throws DbException;
|
||||||
|
|
||||||
@@ -110,10 +110,10 @@ public interface DatabaseComponent {
|
|||||||
/** Returns the set of groups to which the user subscribes. */
|
/** Returns the set of groups to which the user subscribes. */
|
||||||
Collection<Group> getSubscriptions() throws DbException;
|
Collection<Group> getSubscriptions() throws DbException;
|
||||||
|
|
||||||
/** Returns the local transport details. */
|
/** Returns the local transport properties. */
|
||||||
Map<String, String> getTransports() throws DbException;
|
Map<String, String> getTransports() throws DbException;
|
||||||
|
|
||||||
/** Returns the transport details for the given contact. */
|
/** Returns the transport properties for the given contact. */
|
||||||
Map<String, String> getTransports(ContactId c) throws DbException;
|
Map<String, String> getTransports(ContactId c) throws DbException;
|
||||||
|
|
||||||
/** Returns the contacts to which the given group is visible. */
|
/** Returns the contacts to which the given group is visible. */
|
||||||
@@ -151,7 +151,9 @@ public interface DatabaseComponent {
|
|||||||
/** Records the user's rating for the given author. */
|
/** Records the user's rating for the given author. */
|
||||||
void setRating(AuthorId a, Rating r) throws DbException;
|
void setRating(AuthorId a, Rating r) throws DbException;
|
||||||
|
|
||||||
/** Sets the local transport details, replacing any existing details. */
|
/**
|
||||||
|
* Sets the local transport properties, replacing any existing properties.
|
||||||
|
*/
|
||||||
void setTransports(Map<String, String> transports) throws DbException;
|
void setTransports(Map<String, String> transports) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ interface Database<T> {
|
|||||||
void addBatchToAck(T txn, ContactId c, BatchId b) throws DbException;
|
void addBatchToAck(T txn, ContactId c, BatchId b) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new contact to the database with the given transport details and
|
* Adds a new contact to the database with the given transport properties
|
||||||
* returns an ID for the contact.
|
* and returns an ID for the contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contacts write, transports write.
|
* Locking: contacts write, transports write.
|
||||||
*/
|
*/
|
||||||
@@ -268,14 +268,14 @@ interface Database<T> {
|
|||||||
Collection<Group> getSubscriptions(T txn, ContactId c) throws DbException;
|
Collection<Group> getSubscriptions(T txn, ContactId c) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the local transport details.
|
* Returns the local transport properties.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transports read.
|
* Locking: transports read.
|
||||||
*/
|
*/
|
||||||
Map<String, String> getTransports(T txn) throws DbException;
|
Map<String, String> getTransports(T txn) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the transport details for the given contact.
|
* Returns the transport properties for the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contacts read, transports read.
|
* Locking: contacts read, transports read.
|
||||||
*/
|
*/
|
||||||
@@ -397,8 +397,7 @@ interface Database<T> {
|
|||||||
long timestamp) throws DbException;
|
long timestamp) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the local transport details, replacing any existing transport
|
* Sets the local transport properties, replacing any existing properties.
|
||||||
* details.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transports write.
|
* Locking: transports write.
|
||||||
*/
|
*/
|
||||||
@@ -406,8 +405,9 @@ interface Database<T> {
|
|||||||
throws DbException;
|
throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the transport details for the given contact, replacing any existing
|
* Sets the transport properties for the given contact, replacing any
|
||||||
* transport details unless the existing details have a newer timestamp.
|
* existing properties unless the existing properties have a newer
|
||||||
|
* timestamp.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contacts write, transports write.
|
* Locking: contacts write, transports write.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
int rowsAffected = ps.executeUpdate();
|
int rowsAffected = ps.executeUpdate();
|
||||||
assert rowsAffected == 1;
|
assert rowsAffected == 1;
|
||||||
ps.close();
|
ps.close();
|
||||||
// Store the contact's transport details
|
// Store the contact's transport properties
|
||||||
if(transports != null) {
|
if(transports != null) {
|
||||||
sql = "INSERT INTO contactTransports (contactId, key, value)"
|
sql = "INSERT INTO contactTransports (contactId, key, value)"
|
||||||
+ " VALUES (?, ?, ?)";
|
+ " VALUES (?, ?, ?)";
|
||||||
|
|||||||
@@ -818,7 +818,7 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
|||||||
|
|
||||||
public void receiveTransports(ContactId c, Transports t)
|
public void receiveTransports(ContactId c, Transports t)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
// Update the contact's transport details
|
// Update the contact's transport properties
|
||||||
contactLock.writeLock().lock();
|
contactLock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
if(!containsContact(c)) throw new NoSuchContactException();
|
if(!containsContact(c)) throw new NoSuchContactException();
|
||||||
|
|||||||
@@ -608,7 +608,7 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
|||||||
|
|
||||||
public void receiveTransports(ContactId c, Transports t)
|
public void receiveTransports(ContactId c, Transports t)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
// Update the contact's transport details
|
// Update the contact's transport properties
|
||||||
synchronized(contactLock) {
|
synchronized(contactLock) {
|
||||||
if(!containsContact(c)) throw new NoSuchContactException();
|
if(!containsContact(c)) throw new NoSuchContactException();
|
||||||
synchronized(transportLock) {
|
synchronized(transportLock) {
|
||||||
|
|||||||
@@ -744,10 +744,10 @@ public abstract class DatabaseComponentTest extends TestCase {
|
|||||||
allowing(database).commitTransaction(txn);
|
allowing(database).commitTransaction(txn);
|
||||||
allowing(database).containsContact(txn, contactId);
|
allowing(database).containsContact(txn, contactId);
|
||||||
will(returnValue(true));
|
will(returnValue(true));
|
||||||
// Get the local transport details
|
// Get the local transport properties
|
||||||
oneOf(database).getTransports(txn);
|
oneOf(database).getTransports(txn);
|
||||||
will(returnValue(transports));
|
will(returnValue(transports));
|
||||||
// Add the transports to the writer
|
// Add the properties to the writer
|
||||||
oneOf(transportWriter).writeTransports(transports);
|
oneOf(transportWriter).writeTransports(transports);
|
||||||
}});
|
}});
|
||||||
DatabaseComponent db = createDatabaseComponent(database, cleaner);
|
DatabaseComponent db = createDatabaseComponent(database, cleaner);
|
||||||
|
|||||||
@@ -783,24 +783,24 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
Database<Connection> db = open(false);
|
Database<Connection> db = open(false);
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
|
|
||||||
// Add a contact with some transport details
|
// Add a contact with some transport properties
|
||||||
Map<String, String> transports = Collections.singletonMap("foo", "bar");
|
Map<String, String> transports = Collections.singletonMap("foo", "bar");
|
||||||
assertEquals(contactId, db.addContact(txn, transports));
|
assertEquals(contactId, db.addContact(txn, transports));
|
||||||
assertEquals(transports, db.getTransports(txn, contactId));
|
assertEquals(transports, db.getTransports(txn, contactId));
|
||||||
// Replace the transport details
|
// Replace the transport properties
|
||||||
transports = new TreeMap<String, String>();
|
transports = new TreeMap<String, String>();
|
||||||
transports.put("foo", "bar baz");
|
transports.put("foo", "bar baz");
|
||||||
transports.put("bar", "baz quux");
|
transports.put("bar", "baz quux");
|
||||||
db.setTransports(txn, contactId, transports, 1);
|
db.setTransports(txn, contactId, transports, 1);
|
||||||
assertEquals(transports, db.getTransports(txn, contactId));
|
assertEquals(transports, db.getTransports(txn, contactId));
|
||||||
// Remove the transport details
|
// Remove the transport properties
|
||||||
db.setTransports(txn, contactId,
|
db.setTransports(txn, contactId,
|
||||||
Collections.<String, String>emptyMap(), 2);
|
Collections.<String, String>emptyMap(), 2);
|
||||||
assertEquals(Collections.emptyMap(), db.getTransports(txn, contactId));
|
assertEquals(Collections.emptyMap(), db.getTransports(txn, contactId));
|
||||||
// Set the local transport details
|
// Set the local transport properties
|
||||||
db.setTransports(txn, transports);
|
db.setTransports(txn, transports);
|
||||||
assertEquals(transports, db.getTransports(txn));
|
assertEquals(transports, db.getTransports(txn));
|
||||||
// Remove the local transport details
|
// Remove the local transport properties
|
||||||
db.setTransports(txn, Collections.<String, String>emptyMap());
|
db.setTransports(txn, Collections.<String, String>emptyMap());
|
||||||
assertEquals(Collections.emptyMap(), db.getTransports(txn));
|
assertEquals(Collections.emptyMap(), db.getTransports(txn));
|
||||||
|
|
||||||
@@ -813,22 +813,22 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
Database<Connection> db = open(false);
|
Database<Connection> db = open(false);
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
|
|
||||||
// Add a contact with some transport details
|
// Add a contact with some transport properties
|
||||||
Map<String, String> transports = Collections.singletonMap("foo", "bar");
|
Map<String, String> transports = Collections.singletonMap("foo", "bar");
|
||||||
assertEquals(contactId, db.addContact(txn, transports));
|
assertEquals(contactId, db.addContact(txn, transports));
|
||||||
assertEquals(transports, db.getTransports(txn, contactId));
|
assertEquals(transports, db.getTransports(txn, contactId));
|
||||||
// Replace the transport details using a timestamp of 2
|
// Replace the transport properties using a timestamp of 2
|
||||||
Map<String, String> transports1 = new TreeMap<String, String>();
|
Map<String, String> transports1 = new TreeMap<String, String>();
|
||||||
transports1.put("foo", "bar baz");
|
transports1.put("foo", "bar baz");
|
||||||
transports1.put("bar", "baz quux");
|
transports1.put("bar", "baz quux");
|
||||||
db.setTransports(txn, contactId, transports1, 2);
|
db.setTransports(txn, contactId, transports1, 2);
|
||||||
assertEquals(transports1, db.getTransports(txn, contactId));
|
assertEquals(transports1, db.getTransports(txn, contactId));
|
||||||
// Try to replace the transport details using a timestamp of 1
|
// Try to replace the transport properties using a timestamp of 1
|
||||||
Map<String, String> transports2 = new TreeMap<String, String>();
|
Map<String, String> transports2 = new TreeMap<String, String>();
|
||||||
transports2.put("bar", "baz");
|
transports2.put("bar", "baz");
|
||||||
transports2.put("quux", "fnord");
|
transports2.put("quux", "fnord");
|
||||||
db.setTransports(txn, contactId, transports2, 1);
|
db.setTransports(txn, contactId, transports2, 1);
|
||||||
// The old transports should still be there
|
// The old properties should still be there
|
||||||
assertEquals(transports1, db.getTransports(txn, contactId));
|
assertEquals(transports1, db.getTransports(txn, contactId));
|
||||||
|
|
||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|||||||
Reference in New Issue
Block a user