//*****************************************
//* Sync linked/shared notebooks
//*****************************************
- //syncLinkedNotebooks();
+ syncLinkedNotebooks();
//conn.getNoteTable().getDirty();
//disableUploads = true; /// DELETE THIS LINE!!!!
if (!disableUploads) {
try {
if (expunged.get(i).type.equalsIgnoreCase("TAG")) {
logger.log(logger.EXTREME, "Tag expunged");
- conn.getDeletedTable().expungeDeletedItem(expunged.get(i).guid, "TAG"); \r
+ conn.getDeletedTable().expungeDeletedItem(expunged.get(i).guid, "TAG");
updateSequenceNumber = noteStore.expungeTag(authToken, expunged.get(i).guid);
conn.getSyncTable().setUpdateSequenceNumber(updateSequenceNumber);
conn.getSyncTable().setLastSequenceDate(sequenceDate);
- conn.getSyncTable().setUpdateSequenceNumber(updateSequenceNumber); \r
+ conn.getSyncTable().setUpdateSequenceNumber(updateSequenceNumber);
}
if (expunged.get(i).type.equalsIgnoreCase("NOTEBOOK")) {
logger.log(logger.EXTREME, "Notebook expunged");
- conn.getDeletedTable().expungeDeletedItem(expunged.get(i).guid, "NOTEBOOK");\r
+ conn.getDeletedTable().expungeDeletedItem(expunged.get(i).guid, "NOTEBOOK");
updateSequenceNumber = noteStore.expungeNotebook(authToken, expunged.get(i).guid);
conn.getSyncTable().setLastSequenceDate(sequenceDate);
conn.getSyncTable().setUpdateSequenceNumber(updateSequenceNumber);
}
if (expunged.get(i).type.equalsIgnoreCase("NOTE")) {
logger.log(logger.EXTREME, "Note expunged");
- conn.getDeletedTable().expungeDeletedItem(expunged.get(i).guid, "NOTE");\r
+ conn.getDeletedTable().expungeDeletedItem(expunged.get(i).guid, "NOTE");
updateSequenceNumber = noteStore.deleteNote(authToken, expunged.get(i).guid);
refreshNeeded = true;
conn.getSyncTable().setLastSequenceDate(sequenceDate);
}
if (expunged.get(i).type.equalsIgnoreCase("SAVEDSEARCH")) {
logger.log(logger.EXTREME, "saved search expunged");
- conn.getDeletedTable().expungeDeletedItem(expunged.get(i).guid, "SAVEDSEARCH");\r
+ conn.getDeletedTable().expungeDeletedItem(expunged.get(i).guid, "SAVEDSEARCH");
updateSequenceNumber = noteStore.expungeSearch(authToken, expunged.get(i).guid);
conn.getSyncTable().setLastSequenceDate(sequenceDate);
conn.getSyncTable().setUpdateSequenceNumber(updateSequenceNumber);
Note enNote = notes.get(i);
try {
if (enNote.getUpdateSequenceNum() > 0 && (enNote.isActive() == false || enNote.getDeleted() > 0)) {
- // Check that the note is valid. \r
- if (enNote.isActive() == true || enNote.getDeleted() == 0) {\r
- conn.getNoteTable().deleteNote(enNote.getGuid());\r
- enNote = conn.getNoteTable().getNote(enNote.getGuid(), false, false, false, false, false);\r
- }\r
+ // Check that the note is valid.
+ if (enNote.isActive() == true || enNote.getDeleted() == 0) {
+ conn.getNoteTable().deleteNote(enNote.getGuid());
+ enNote = conn.getNoteTable().getNote(enNote.getGuid(), false, false, false, false, false);
+ }
if (syncDeletedContent) {
logger.log(logger.EXTREME, "Deleted note found & synch content selected");
Note delNote = conn.getNoteTable().getNote(enNote.getGuid(), true, true, true, true, true);
conn.getSyncTable().setUpdateSequenceNumber(updateSequenceNumber);
}
} catch (EDAMUserException e) {
- logger.log(logger.LOW, "*** EDAM User Excepton syncLocalNotes "+e);\r
+ logger.log(logger.LOW, "*** EDAM User Excepton syncLocalNotes "+e);
//status.message.emit("Error sending local note: " +e.getParameter());
//logger.log(logger.LOW, e.toString());
//error = true;
logger.log(logger.LOW, e.toString());
error = true;
} catch (EDAMNotFoundException e) {
- logger.log(logger.LOW, "*** EDAM Not Found Excepton syncLocalNotes " +e);\r
+ logger.log(logger.LOW, "*** EDAM Not Found Excepton syncLocalNotes " +e);
//status.message.emit("Error deleting local note: " +e +" - Continuing");
//logger.log(logger.LOW, e.toString());
//error = true;
logger.log(logger.HIGH, "Entering SyncRunner.syncRemoteToLocal");
List<Note> dirtyNotes = conn.getNoteTable().getDirty();
- dirtyNoteGuids = new ArrayList<String>();\r
+ dirtyNoteGuids = new ArrayList<String>();
for (int i=0; i<dirtyNotes.size() && keepRunning; i++) {
dirtyNoteGuids.add(dirtyNotes.get(i).getGuid());
}
conn.getNoteTable().updateNoteSequence(guid.get(i), 0);
notebookGuid = localNote.getNotebookGuid();
}
- // If the note is in a local notebook (which means we moved it) or if the \r
- // note returned is null (which means it is already deleted or flagged expunged) \r
- // we delete it.\r
- if (!conn.getNotebookTable().isNotebookLocal(notebookGuid) || localNote == null) {\r
+ // If the note is in a local notebook (which means we moved it) or if the
+ // note returned is null (which means it is already deleted or flagged expunged)
+ // we delete it.
+ if (!conn.getNotebookTable().isNotebookLocal(notebookGuid) || localNote == null) {
logger.log(logger.EXTREME, "Expunging local note from database");
conn.getNoteTable().expungeNote(guid.get(i), true, false);
}
}
// Sync remote notes
private void syncRemoteNotes(Client noteStore, List<Note> note, boolean fullSync, String token) {
-\r
+
if (note != null) {
- \r
- logger.log(logger.EXTREME, "Entering SyncRunner.syncRemoteNotes");\r
- logger.log(logger.LOW, "Local Dirty Notes: ");\r
- logger.log(logger.LOW, "Remote Dirty Notes:");\r
- for (int i=0; i<note.size();i++) {\r
- logger.log(logger.LOW, i +" : " +note.get(i).getGuid() + " : " +note.get(i).getTitle() );\r
- }\r
- logger.log(logger.LOW, "---");\r
- \r
+
+ logger.log(logger.EXTREME, "Entering SyncRunner.syncRemoteNotes");
+ logger.log(logger.LOW, "Local Dirty Notes: ");
+ logger.log(logger.LOW, "Remote Dirty Notes:");
+ for (int i=0; i<note.size();i++) {
+ logger.log(logger.LOW, i +" : " +note.get(i).getGuid() + " : " +note.get(i).getTitle() );
+ }
+ logger.log(logger.LOW, "---");
+
for (int i=0; i<note.size() && keepRunning; i++) {
Note n = getEvernoteNote(noteStore, note.get(i).getGuid(), true, fullSync, true,true, token);
syncRemoteNote(n, fullSync, token);
// are different we move the local copy to a local notebook (making sure
// to copy all resources) and we accept the new one.
boolean conflictingNote = true;
- logger.log(logger.EXTREME, "Checking for duplicate note " +n.getGuid() +" : " +n.getTitle());\r
+ logger.log(logger.EXTREME, "Checking for duplicate note " +n.getGuid() +" : " +n.getTitle());
if (dirtyNoteGuids != null && dirtyNoteGuids.contains(n.getGuid())) {
logger.log(logger.EXTREME, "Conflict check beginning");
conflictingNote = checkForConflict(n);
logger.log(logger.EXTREME, "Checking note sequence number " +n.getGuid());
Note oldNote = conn.getNoteTable().getNote(n.getGuid(), false, false, false, false, false);
logger.log(logger.EXTREME, "Local/Remote sequence numbers: " +oldNote.getUpdateSequenceNum()+"/"+n.getUpdateSequenceNum());
- logger.log(logger.LOW, "Remote Note Title:" +n.getTitle());\r
- logger.log(logger.LOW, "Local Note Title:" +oldNote.getTitle());\r
- if (oldNote.getUpdateSequenceNum() == n.getUpdateSequenceNum()) {\r
- return false;\r
- } \r
- boolean oldIsDirty = conn.getNoteTable().isNoteDirty(n.getGuid());\r
- if (!oldIsDirty) \r
+ logger.log(logger.LOW, "Remote Note Title:" +n.getTitle());
+ logger.log(logger.LOW, "Local Note Title:" +oldNote.getTitle());
+ if (oldNote.getUpdateSequenceNum() == n.getUpdateSequenceNum()) {
+ return false;
+ }
+ boolean oldIsDirty = conn.getNoteTable().isNoteDirty(n.getGuid());
+ if (!oldIsDirty)
return false;
return true;
}
//if (authResult != null) {
//user = authResult.getUser();
//authToken = authResult.getAuthenticationToken();
- if (user == null || noteStoreUrlBase == null) {\r
- logger.log(logger.LOW, "Error retrieving user information. Aborting.");\r
- System.err.println("Error retrieving user information.");\r
- isConnected = false; \r
- QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, tr("Connection Error"), tr("Error retrieving user information. Synchronization not complete"));\r
- mb.exec();\r
- return false;\r
- \r
- }\r
+ if (user == null || noteStoreUrlBase == null) {
+ logger.log(logger.LOW, "Error retrieving user information. Aborting.");
+ System.err.println("Error retrieving user information.");
+ isConnected = false;
+ QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, tr("Connection Error"), tr("Error retrieving user information. Synchronization not complete"));
+ mb.exec();
+ return false;
+
+ }
noteStoreUrl = noteStoreUrlBase + user.getShardId();
syncSignal.saveAuthToken.emit(authToken);
syncSignal.saveNoteStore.emit(localNoteStore);
return;
List<Note> dirtyNotes = conn.getNoteTable().getDirtyLinkedNotes();
if (dirtyNoteGuids == null)
- dirtyNoteGuids = new ArrayList<String>();\r
+ dirtyNoteGuids = new ArrayList<String>();
for (int i=0; i<dirtyNotes.size() && keepRunning; i++) {
dirtyNoteGuids.add(dirtyNotes.get(i).getGuid());