Use new UUID field instead of REMOTE_ID in a few more places

pull/14/head
Sam Bosley 12 years ago
parent 48d9c46d72
commit c771987cdc

@ -137,12 +137,14 @@ public class Astrid44SyncMigrator {
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
instance.readPropertiesFromCursor(cursor);
if (!instance.containsNonNullValue(RemoteModel.REMOTE_ID_PROPERTY)) {
Pair<Long, String> uuidPair = UUIDHelper.newUUID();
instance.setValue(RemoteModel.REMOTE_ID_PROPERTY, uuidPair.getLeft());
// No remote id exists, just create a UUID
Pair<BigInteger, String> uuidPair = UUIDHelper.newUUID();
instance.setValue(RemoteModel.UUID_PROPERTY, uuidPair.getLeft());
instance.setValue(RemoteModel.PROOF_TEXT_PROPERTY, uuidPair.getRight());
} else {
// Migrate remote id to uuid field
instance.setValue(RemoteModel.UUID_PROPERTY, BigInteger.valueOf(instance.getValue(RemoteModel.REMOTE_ID_PROPERTY)));
}
// Migrate remote id to uuid field
instance.setValue(RemoteModel.UUID_PROPERTY, BigInteger.valueOf(instance.getValue(RemoteModel.REMOTE_ID_PROPERTY)));
dao.saveExisting(instance);
}
} finally {

@ -1,5 +1,7 @@
package com.todoroo.astrid.dao;
import java.math.BigInteger;
import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.andlib.utility.Pair;
import com.todoroo.astrid.data.RemoteModel;
@ -22,9 +24,9 @@ public class RemoteModelDao<RTYPE extends RemoteModel> extends DatabaseDao<RTYPE
@Override
public boolean createNew(RTYPE item) {
if (!item.containsValue(RemoteModel.REMOTE_ID_PROPERTY)) {
Pair<Long, String> uuidPair = UUIDHelper.newUUID();
item.setValue(RemoteModel.REMOTE_ID_PROPERTY, uuidPair.getLeft());
if (!item.containsValue(RemoteModel.UUID_PROPERTY)) {
Pair<BigInteger, String> uuidPair = UUIDHelper.newUUID();
item.setValue(RemoteModel.UUID_PROPERTY, uuidPair.getLeft());
item.setValue(RemoteModel.PROOF_TEXT_PROPERTY, uuidPair.getRight());
}
return super.createNew(item);

@ -30,7 +30,7 @@ public class TagDataDao extends RemoteModelDao<TagData> {
private static final String[] IGNORE_OUTSTANDING_COLUMNS = new String[] {
TagData.MODIFICATION_DATE.name,
TagData.REMOTE_ID.name,
TagData.UUID.name,
};
@Override

@ -320,7 +320,7 @@ public class TaskDao extends RemoteModelDao<Task> {
Task.DETAILS.name,
Task.DETAILS_DATE.name,
Task.CALENDAR_URI.name,
Task.REMOTE_ID.name,
Task.UUID.name,
Task.PUSHED_AT.name,
Task.LAST_SYNC.name,
Task.ESTIMATED_SECONDS.name,

@ -1,5 +1,6 @@
package com.todoroo.astrid.helper;
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.UUID;
@ -39,7 +40,7 @@ public class UUIDHelper {
* @return a pair consisting of the newly
* generated uuid and the corresponding proof text
*/
public static Pair<Long, String> newUUID() {
public static Pair<BigInteger, String> newUUID() {
long uuid = 0;
String proofText = ""; //$NON-NLS-1$
do {
@ -54,7 +55,7 @@ public class UUIDHelper {
proofText = d + "," + s; //$NON-NLS-1$
uuid = bcryptToLong(proofText);
} while (uuid < MIN_UUID);
return Pair.create(uuid, proofText);
return Pair.create(BigInteger.valueOf(uuid), proofText);
}
private static final String SALT = "$2a$10$2RHhxhKaPb4VXlQUJyBU/O"; //$NON-NLS-1$

Loading…
Cancel
Save