mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Use numeric IDs rather than names to identify transports.
This commit is contained in:
@@ -83,7 +83,7 @@ interface Database<T> {
|
||||
* <p>
|
||||
* Locking: contacts write, transports write.
|
||||
*/
|
||||
ContactId addContact(T txn, Map<String, Map<String, String>> transports,
|
||||
ContactId addContact(T txn, Map<Integer, Map<String, String>> transports,
|
||||
byte[] secret) throws DbException;
|
||||
|
||||
/**
|
||||
@@ -315,11 +315,11 @@ interface Database<T> {
|
||||
Collection<Group> getSubscriptions(T txn, ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the configuration for the transport with the given name.
|
||||
* Returns the configuration for the given transport.
|
||||
* <p>
|
||||
* Locking: transports read.
|
||||
*/
|
||||
Map<String, String> getTransportConfig(T txn, String name)
|
||||
Map<String, String> getTransportConfig(T txn, int transportId)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
@@ -327,14 +327,14 @@ interface Database<T> {
|
||||
* <p>
|
||||
* Locking: transports read.
|
||||
*/
|
||||
Map<String, Map<String, String>> getTransports(T txn) throws DbException;
|
||||
Map<Integer, Map<String, String>> getTransports(T txn) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all transport properties for the given contact.
|
||||
* <p>
|
||||
* Locking: contacts read, transports read.
|
||||
*/
|
||||
Map<String, Map<String, String>> getTransports(T txn, ContactId c)
|
||||
Map<Integer, Map<String, String>> getTransports(T txn, ContactId c)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
@@ -471,21 +471,21 @@ interface Database<T> {
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the configuration for the transport with the given name, replacing
|
||||
* any existing configuration for that transport.
|
||||
* Sets the configuration for the given transport, replacing any existing
|
||||
* configuration for that transport.
|
||||
* <p>
|
||||
* Locking: transports write.
|
||||
*/
|
||||
void setTransportConfig(T txn, String name, Map<String, String> config)
|
||||
void setTransportConfig(T txn, int transportId, Map<String, String> config)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the transport properties for the transport with the given name,
|
||||
* replacing any existing properties for that transport.
|
||||
* Sets the transport properties for the given transport, replacing any
|
||||
* existing properties for that transport.
|
||||
* <p>
|
||||
* Locking: transports write.
|
||||
*/
|
||||
void setTransportProperties(T txn, String name,
|
||||
void setTransportProperties(T txn, int transportId,
|
||||
Map<String, String> properties) throws DbException;
|
||||
|
||||
/**
|
||||
@@ -496,7 +496,7 @@ interface Database<T> {
|
||||
* Locking: contacts read, transports write.
|
||||
*/
|
||||
void setTransports(T txn, ContactId c,
|
||||
Map<String, Map<String, String>> transports, long timestamp)
|
||||
Map<Integer, Map<String, String>> transports, long timestamp)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -117,7 +117,7 @@ DatabaseCleaner.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
public ContactId addContact(Map<String, Map<String, String>> transports,
|
||||
public ContactId addContact(Map<Integer, Map<String, String>> transports,
|
||||
byte[] secret) throws DbException {
|
||||
if(LOG.isLoggable(Level.FINE)) LOG.fine("Adding contact");
|
||||
ContactId c;
|
||||
@@ -604,7 +604,7 @@ DatabaseCleaner.Callback {
|
||||
|
||||
public void generateTransportUpdate(ContactId c, TransportWriter t)
|
||||
throws DbException, IOException {
|
||||
Map<String, Map<String, String>> transports;
|
||||
Map<Integer, Map<String, String>> transports;
|
||||
long timestamp;
|
||||
contactLock.readLock().lock();
|
||||
try {
|
||||
@@ -750,13 +750,14 @@ DatabaseCleaner.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getTransportConfig(String name)
|
||||
public Map<String, String> getTransportConfig(int transportId)
|
||||
throws DbException {
|
||||
transportLock.readLock().lock();
|
||||
try {
|
||||
T txn = db.startTransaction();
|
||||
try {
|
||||
Map<String, String> config = db.getTransportConfig(txn, name);
|
||||
Map<String, String> config =
|
||||
db.getTransportConfig(txn, transportId);
|
||||
db.commitTransaction(txn);
|
||||
return config;
|
||||
} catch(DbException e) {
|
||||
@@ -768,12 +769,13 @@ DatabaseCleaner.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> getTransports() throws DbException {
|
||||
public Map<Integer, Map<String, String>> getTransports()
|
||||
throws DbException {
|
||||
transportLock.readLock().lock();
|
||||
try {
|
||||
T txn = db.startTransaction();
|
||||
try {
|
||||
Map<String, Map<String, String>> transports =
|
||||
Map<Integer, Map<String, String>> transports =
|
||||
db.getTransports(txn);
|
||||
db.commitTransaction(txn);
|
||||
return transports;
|
||||
@@ -786,7 +788,7 @@ DatabaseCleaner.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> getTransports(ContactId c)
|
||||
public Map<Integer, Map<String, String>> getTransports(ContactId c)
|
||||
throws DbException {
|
||||
contactLock.readLock().lock();
|
||||
try {
|
||||
@@ -795,7 +797,7 @@ DatabaseCleaner.Callback {
|
||||
try {
|
||||
T txn = db.startTransaction();
|
||||
try {
|
||||
Map<String, Map<String, String>> transports =
|
||||
Map<Integer, Map<String, String>> transports =
|
||||
db.getTransports(txn, c);
|
||||
db.commitTransaction(txn);
|
||||
return transports;
|
||||
@@ -1044,7 +1046,7 @@ DatabaseCleaner.Callback {
|
||||
try {
|
||||
T txn = db.startTransaction();
|
||||
try {
|
||||
Map<String, Map<String, String>> transports =
|
||||
Map<Integer, Map<String, String>> transports =
|
||||
t.getTransports();
|
||||
db.setTransports(txn, c, transports, t.getTimestamp());
|
||||
if(LOG.isLoggable(Level.FINE))
|
||||
@@ -1218,16 +1220,17 @@ DatabaseCleaner.Callback {
|
||||
+ indirect + " indirectly");
|
||||
}
|
||||
|
||||
public void setTransportConfig(String name,
|
||||
public void setTransportConfig(int transportId,
|
||||
Map<String, String> config) throws DbException {
|
||||
boolean changed = false;
|
||||
transportLock.writeLock().lock();
|
||||
try {
|
||||
T txn = db.startTransaction();
|
||||
try {
|
||||
Map<String, String> old = db.getTransportConfig(txn, name);
|
||||
Map<String, String> old =
|
||||
db.getTransportConfig(txn, transportId);
|
||||
if(!config.equals(old)) {
|
||||
db.setTransportConfig(txn, name, config);
|
||||
db.setTransportConfig(txn, transportId, config);
|
||||
changed = true;
|
||||
}
|
||||
db.commitTransaction(txn);
|
||||
@@ -1242,16 +1245,18 @@ DatabaseCleaner.Callback {
|
||||
if(changed) callListeners(Event.TRANSPORTS_UPDATED);
|
||||
}
|
||||
|
||||
public void setTransportProperties(String name,
|
||||
public void setTransportProperties(int transportId,
|
||||
Map<String, String> properties) throws DbException {
|
||||
boolean changed = false;
|
||||
transportLock.writeLock().lock();
|
||||
try {
|
||||
T txn = db.startTransaction();
|
||||
try {
|
||||
Map<String, String> old = db.getTransports(txn).get(name);
|
||||
Map<Integer, Map<String, String>> transports =
|
||||
db.getTransports(txn);
|
||||
Map<String, String> old = transports.get(transportId);
|
||||
if(!properties.equals(old)) {
|
||||
db.setTransportProperties(txn, name, properties);
|
||||
db.setTransportProperties(txn, transportId, properties);
|
||||
changed = true;
|
||||
}
|
||||
db.commitTransaction(txn);
|
||||
|
||||
@@ -167,26 +167,26 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
private static final String CREATE_CONTACT_TRANSPORTS =
|
||||
"CREATE TABLE contactTransports"
|
||||
+ " (contactId INT NOT NULL,"
|
||||
+ " name VARCHAR NOT NULL,"
|
||||
+ " transportId INT NOT NULL,"
|
||||
+ " key VARCHAR NOT NULL,"
|
||||
+ " value VARCHAR NOT NULL,"
|
||||
+ " PRIMARY KEY (contactId, name, key),"
|
||||
+ " PRIMARY KEY (contactId, transportId, key),"
|
||||
+ " FOREIGN KEY (contactId) REFERENCES contacts (contactId)"
|
||||
+ " ON DELETE CASCADE)";
|
||||
|
||||
private static final String CREATE_TRANSPORTS =
|
||||
"CREATE TABLE transports"
|
||||
+ " (name VARCHAR NOT NULL,"
|
||||
+ " (transportId INT NOT NULL,"
|
||||
+ " key VARCHAR NOT NULL,"
|
||||
+ " value VARCHAR NOT NULL,"
|
||||
+ " PRIMARY KEY (name, key))";
|
||||
+ " PRIMARY KEY (transportId, key))";
|
||||
|
||||
private static final String CREATE_TRANSPORT_CONFIG =
|
||||
"CREATE TABLE transportConfig"
|
||||
+ " (name VARCHAR NOT NULL,"
|
||||
+ " (transportId INT NOT NULL,"
|
||||
+ " key VARCHAR NOT NULL,"
|
||||
+ " value VARCHAR NOT NULL,"
|
||||
+ " PRIMARY KEY (name, key))";
|
||||
+ " PRIMARY KEY (transportId, key))";
|
||||
|
||||
private static final String CREATE_CONNECTION_WINDOWS =
|
||||
"CREATE TABLE connectionWindows"
|
||||
@@ -455,7 +455,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
|
||||
public ContactId addContact(Connection txn,
|
||||
Map<String, Map<String, String>> transports, byte[] secret)
|
||||
Map<Integer, Map<String, String>> transports, byte[] secret)
|
||||
throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
@@ -481,13 +481,13 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
ps.close();
|
||||
// Store the contact's transport properties
|
||||
sql = "INSERT INTO contactTransports"
|
||||
+ " (contactId, name, key, value)"
|
||||
+ " (contactId, transportId, key, value)"
|
||||
+ " VALUES (?, ?, ?, ?)";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setInt(1, c.getInt());
|
||||
int batchSize = 0;
|
||||
for(Entry<String, Map<String, String>> e : transports.entrySet()) {
|
||||
ps.setString(2, e.getKey());
|
||||
for(Entry<Integer, Map<String, String>> e : transports.entrySet()) {
|
||||
ps.setInt(2, e.getKey());
|
||||
for(Entry<String, String> e1 : e.getValue().entrySet()) {
|
||||
ps.setString(3, e1.getKey());
|
||||
ps.setString(4, e1.getValue());
|
||||
@@ -1394,14 +1394,14 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
|
||||
public Map<String, String> getTransportConfig(Connection txn,
|
||||
String name) throws DbException {
|
||||
int transportId) throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = "SELECT key, value FROM transportConfig"
|
||||
+ " WHERE name = ?";
|
||||
+ " WHERE transportId = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setString(1, name);
|
||||
ps.setInt(1, transportId);
|
||||
rs = ps.executeQuery();
|
||||
Map<String, String> config = new TreeMap<String, String>();
|
||||
while(rs.next()) config.put(rs.getString(1), rs.getString(2));
|
||||
@@ -1415,24 +1415,24 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> getTransports(Connection txn)
|
||||
public Map<Integer, Map<String, String>> getTransports(Connection txn)
|
||||
throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = "SELECT name, key, value FROM transports"
|
||||
+ " ORDER BY name";
|
||||
String sql = "SELECT transportId, key, value FROM transports"
|
||||
+ " ORDER BY transportId";
|
||||
ps = txn.prepareStatement(sql);
|
||||
rs = ps.executeQuery();
|
||||
Map<String, Map<String, String>> transports =
|
||||
new TreeMap<String, Map<String, String>>();
|
||||
Map<Integer, Map<String, String>> transports =
|
||||
new TreeMap<Integer, Map<String, String>>();
|
||||
Map<String, String> properties = null;
|
||||
String lastName = null;
|
||||
Integer lastId = null;
|
||||
while(rs.next()) {
|
||||
String name = rs.getString(1);
|
||||
if(!name.equals(lastName)) {
|
||||
Integer transportId = rs.getInt(1);
|
||||
if(!transportId.equals(lastId)) {
|
||||
properties = new TreeMap<String, String>();
|
||||
transports.put(name, properties);
|
||||
transports.put(transportId, properties);
|
||||
}
|
||||
properties.put(rs.getString(2), rs.getString(3));
|
||||
}
|
||||
@@ -1446,26 +1446,26 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> getTransports(Connection txn,
|
||||
public Map<Integer, Map<String, String>> getTransports(Connection txn,
|
||||
ContactId c) throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = "SELECT name, key, value FROM contactTransports"
|
||||
String sql = "SELECT transportId, key, value FROM contactTransports"
|
||||
+ " WHERE contactId = ?"
|
||||
+ " ORDER BY name";
|
||||
+ " ORDER BY transportId";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setInt(1, c.getInt());
|
||||
rs = ps.executeQuery();
|
||||
Map<String, Map<String, String>> transports =
|
||||
new TreeMap<String, Map<String, String>>();
|
||||
Map<Integer, Map<String, String>> transports =
|
||||
new TreeMap<Integer, Map<String, String>>();
|
||||
Map<String, String> properties = null;
|
||||
String lastName = null;
|
||||
Integer lastId = null;
|
||||
while(rs.next()) {
|
||||
String name = rs.getString(1);
|
||||
if(!name.equals(lastName)) {
|
||||
Integer transportId = rs.getInt(1);
|
||||
if(!transportId.equals(lastId)) {
|
||||
properties = new TreeMap<String, String>();
|
||||
transports.put(name, properties);
|
||||
transports.put(transportId, properties);
|
||||
}
|
||||
properties.put(rs.getString(2), rs.getString(3));
|
||||
}
|
||||
@@ -2039,26 +2039,26 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
}
|
||||
|
||||
public void setTransportConfig(Connection txn, String name,
|
||||
public void setTransportConfig(Connection txn, int transportId,
|
||||
Map<String, String> config) throws DbException {
|
||||
setTransportDetails(txn, name, config, "transportConfig");
|
||||
setTransportDetails(txn, transportId, config, "transportConfig");
|
||||
}
|
||||
|
||||
private void setTransportDetails(Connection txn, String name,
|
||||
private void setTransportDetails(Connection txn, int transportId,
|
||||
Map<String, String> details, String table) throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
// Delete any existing details for the named transport
|
||||
String sql = "DELETE FROM " + table + " WHERE name = ?";
|
||||
// Delete any existing details for the given transport
|
||||
String sql = "DELETE FROM " + table + " WHERE transportId = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setString(1, name);
|
||||
ps.setInt(1, transportId);
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
// Store the new details
|
||||
sql = "INSERT INTO " + table + " (name, key, value)"
|
||||
sql = "INSERT INTO " + table + " (transportId, key, value)"
|
||||
+ " VALUES (?, ?, ?)";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setString(1, name);
|
||||
ps.setInt(1, transportId);
|
||||
for(Entry<String, String> e : details.entrySet()) {
|
||||
ps.setString(2, e.getKey());
|
||||
ps.setString(3, e.getValue());
|
||||
@@ -2077,13 +2077,13 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
}
|
||||
|
||||
public void setTransportProperties(Connection txn, String name,
|
||||
public void setTransportProperties(Connection txn, int transportId,
|
||||
Map<String, String> properties) throws DbException {
|
||||
setTransportDetails(txn, name, properties, "transports");
|
||||
setTransportDetails(txn, transportId, properties, "transports");
|
||||
}
|
||||
|
||||
public void setTransports(Connection txn, ContactId c,
|
||||
Map<String, Map<String, String>> transports, long timestamp)
|
||||
Map<Integer, Map<String, String>> transports, long timestamp)
|
||||
throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
@@ -2107,13 +2107,14 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
// Store the new transports
|
||||
sql = "INSERT INTO contactTransports (contactId, name, key, value)"
|
||||
sql = "INSERT INTO contactTransports"
|
||||
+ " (contactId, transportId, key, value)"
|
||||
+ " VALUES (?, ?, ?, ?)";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setInt(1, c.getInt());
|
||||
int batchSize = 0;
|
||||
for(Entry<String, Map<String, String>> e : transports.entrySet()) {
|
||||
ps.setString(2, e.getKey());
|
||||
for(Entry<Integer, Map<String, String>> e : transports.entrySet()) {
|
||||
ps.setInt(2, e.getKey());
|
||||
for(Entry<String, String> e1 : e.getValue().entrySet()) {
|
||||
ps.setString(3, e1.getKey());
|
||||
ps.setString(4, e1.getValue());
|
||||
|
||||
@@ -70,7 +70,7 @@ class InvitationWorker implements Runnable {
|
||||
File invitationDat = new File(dir, "invitation.dat");
|
||||
callback.encryptingFile(invitationDat);
|
||||
// FIXME: Create a real invitation
|
||||
Map<String, Map<String, String>> transports;
|
||||
Map<Integer, Map<String, String>> transports;
|
||||
try {
|
||||
transports = db.getTransports();
|
||||
} catch(DbException e) {
|
||||
|
||||
@@ -6,6 +6,6 @@ import net.sf.briar.api.protocol.TransportUpdate;
|
||||
|
||||
interface TransportFactory {
|
||||
|
||||
TransportUpdate createTransports(Map<String, Map<String, String>> transports,
|
||||
long timestamp);
|
||||
TransportUpdate createTransportUpdate(
|
||||
Map<Integer, Map<String, String>> transports, long timestamp);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import net.sf.briar.api.protocol.TransportUpdate;
|
||||
|
||||
class TransportFactoryImpl implements TransportFactory {
|
||||
|
||||
public TransportUpdate createTransports(Map<String, Map<String, String>> transports,
|
||||
long timestamp) {
|
||||
public TransportUpdate createTransportUpdate(
|
||||
Map<Integer, Map<String, String>> transports, long timestamp) {
|
||||
return new TransportUpdateImpl(transports, timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,25 +37,25 @@ class TransportReader implements ObjectReader<TransportUpdate> {
|
||||
r.removeObjectReader(Types.TRANSPORT_PROPERTIES);
|
||||
if(l.size() > TransportUpdate.MAX_PLUGINS_PER_UPDATE)
|
||||
throw new FormatException();
|
||||
Map<String, Map<String, String>> transports =
|
||||
new TreeMap<String, Map<String, String>>();
|
||||
Map<Integer, Map<String, String>> transports =
|
||||
new TreeMap<Integer, Map<String, String>>();
|
||||
for(TransportProperties t : l) {
|
||||
if(transports.put(t.name, t.properties) != null)
|
||||
if(transports.put(t.transportId, t.properties) != null)
|
||||
throw new FormatException(); // Duplicate plugin name
|
||||
}
|
||||
long timestamp = r.readInt64();
|
||||
r.removeConsumer(counting);
|
||||
// Build and return the transport update
|
||||
return transportFactory.createTransports(transports, timestamp);
|
||||
return transportFactory.createTransportUpdate(transports, timestamp);
|
||||
}
|
||||
|
||||
private static class TransportProperties {
|
||||
|
||||
private final String name;
|
||||
private final int transportId;
|
||||
private final Map<String, String> properties;
|
||||
|
||||
TransportProperties(String name, Map<String, String> properties) {
|
||||
this.name = name;
|
||||
TransportProperties(int transportId, Map<String, String> properties) {
|
||||
this.transportId = transportId;
|
||||
this.properties = properties;
|
||||
}
|
||||
}
|
||||
@@ -65,14 +65,14 @@ class TransportReader implements ObjectReader<TransportUpdate> {
|
||||
|
||||
public TransportProperties readObject(Reader r) throws IOException {
|
||||
r.readUserDefinedId(Types.TRANSPORT_PROPERTIES);
|
||||
String name = r.readString(TransportUpdate.MAX_NAME_LENGTH);
|
||||
int transportId = r.readInt32();
|
||||
r.setMaxStringLength(TransportUpdate.MAX_KEY_OR_VALUE_LENGTH);
|
||||
Map<String, String> properties =
|
||||
r.readMap(String.class, String.class);
|
||||
r.resetMaxStringLength();
|
||||
if(properties.size() > TransportUpdate.MAX_PROPERTIES_PER_PLUGIN)
|
||||
throw new FormatException();
|
||||
return new TransportProperties(name, properties);
|
||||
return new TransportProperties(transportId, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ import net.sf.briar.api.protocol.TransportUpdate;
|
||||
|
||||
class TransportUpdateImpl implements TransportUpdate {
|
||||
|
||||
private final Map<String, Map<String, String>> transports;
|
||||
private final Map<Integer, Map<String, String>> transports;
|
||||
private final long timestamp;
|
||||
|
||||
TransportUpdateImpl(Map<String, Map<String, String>> transports,
|
||||
TransportUpdateImpl(Map<Integer, Map<String, String>> transports,
|
||||
long timestamp) {
|
||||
this.transports = transports;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> getTransports() {
|
||||
public Map<Integer, Map<String, String>> getTransports() {
|
||||
return transports;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ class TransportWriterImpl implements TransportWriter {
|
||||
w = writerFactory.createWriter(out);
|
||||
}
|
||||
|
||||
public void writeTransports(Map<String, Map<String, String>> transports,
|
||||
public void writeTransports(Map<Integer, Map<String, String>> transports,
|
||||
long timestamp) throws IOException {
|
||||
w.writeUserDefinedId(Types.TRANSPORT_UPDATE);
|
||||
w.writeListStart();
|
||||
for(Entry<String, Map<String, String>> e : transports.entrySet()) {
|
||||
for(Entry<Integer, Map<String, String>> e : transports.entrySet()) {
|
||||
w.writeUserDefinedId(Types.TRANSPORT_PROPERTIES);
|
||||
w.writeString(e.getKey());
|
||||
w.writeInt32(e.getKey());
|
||||
w.writeMap(e.getValue());
|
||||
}
|
||||
w.writeListEnd();
|
||||
|
||||
Reference in New Issue
Block a user