THttpClient linkedNoteStoreTrans = new THttpClient(linkedNoteStoreUrl);\r
TBinaryProtocol linkedNoteStoreProt = new TBinaryProtocol(linkedNoteStoreTrans);\r
Client linkedNoteStore = new NoteStore.Client(linkedNoteStoreProt, linkedNoteStoreProt); \r
- \r
- linkedAuthResult = linkedNoteStore.authenticateToSharedNotebook(books.get(i).getShareKey(), authToken);\r
+\r
+ linkedAuthResult = null;\r
+ if (books.get(i).getShareKey() != null)\r
+ linkedAuthResult = linkedNoteStore.authenticateToSharedNotebook(books.get(i).getShareKey(), authToken);\r
+ else {\r
+ linkedAuthResult = new AuthenticationResult();\r
+ linkedAuthResult.setAuthenticationToken("");\r
+ }\r
SyncState linkedSyncState = \r
linkedNoteStore.getLinkedNotebookSyncState(linkedAuthResult.getAuthenticationToken(), books.get(i));\r
if (linkedSyncState.getUpdateCount() > lastSequenceNumber) {\r
if (lastSyncDate < linkedSyncState.getFullSyncBefore()) {\r
lastSequenceNumber = 0;\r
} \r
- syncLinkedNotebook(linkedNoteStore, books.get(i), lastSequenceNumber, linkedSyncState.getUpdateCount());\r
+ syncLinkedNotebook(linkedNoteStore, books.get(i), \r
+ lastSequenceNumber, linkedSyncState.getUpdateCount(), linkedAuthResult.getAuthenticationToken());\r
}\r
\r
// Synchronize local changes\r
//**************************************************************\r
//* Linked notebook contents (from someone else's account)\r
//*************************************************************\r
- private void syncLinkedNotebook(Client linkedNoteStore, LinkedNotebook book, int usn, int highSequence) {\r
+ private void syncLinkedNotebook(Client linkedNoteStore, LinkedNotebook book, int usn, int highSequence, String token) {\r
if (ignoreLinkedNotebooks.contains(book.getGuid()))\r
return;\r
List<Note> dirtyNotes = conn.getNoteTable().getDirtyLinkedNotes();\r
boolean fullSync = false;\r
if (usn == 0)\r
fullSync = true;\r
- while (usn < highSequence) {\r
+ boolean syncError = false;\r
+ while (usn < highSequence && !syncError) {\r
refreshNeeded = true;\r
try {\r
SyncChunk chunk = \r
- linkedNoteStore.getLinkedNotebookSyncChunk(authToken, book, usn, 10, fullSync);\r
+ linkedNoteStore.getLinkedNotebookSyncChunk(token, book, usn, 10, fullSync);\r
\r
// Expunge notes\r
syncExpungedNotes(chunk);\r
syncRemoteResource(linkedNoteStore, chunk.getResources().get(i), linkedAuthResult.getAuthenticationToken());\r
}\r
syncRemoteLinkedNotebooks(linkedNoteStore, chunk.getNotebooks(), false, book);\r
- SharedNotebook s = linkedNoteStore.getSharedNotebookByAuth(linkedAuthResult.getAuthenticationToken());\r
- syncLinkedTags(chunk.getTags(), s.getNotebookGuid());\r
+// SharedNotebook s = linkedNoteStore.getSharedNotebookByAuth(linkedAuthResult.getAuthenticationToken());\r
+// syncLinkedTags(chunk.getTags(), s.getNotebookGuid());\r
+ syncLinkedTags(chunk.getTags(), book.getGuid());\r
\r
// Go through & signal any notes that have changed so we can refresh the user's view\r
for (int i=0; i<chunk.getNotesSize(); i++) \r
conn.getLinkedNotebookTable().setLastSequenceDate(book.getGuid(),chunk.getCurrentTime());\r
conn.getLinkedNotebookTable().setLastSequenceNumber(book.getGuid(),chunk.getChunkHighUSN());\r
} catch (EDAMUserException e) {\r
+ syncError = true;\r
+ status.message.emit(tr("EDAM UserException synchronizing linked notbook. See the log for datails."));\r
e.printStackTrace();\r
+ logger.log(logger.LOW, e.getMessage());\r
} catch (EDAMSystemException e) {\r
+ syncError = true;\r
+ status.message.emit(tr("EDAM SystemException synchronizing linked notbook. See the log for datails."));\r
e.printStackTrace();\r
+ logger.log(logger.LOW, e.getMessage());\r
} catch (EDAMNotFoundException e) {\r
- e.printStackTrace();\r
+ syncError = true;\r
+ status.message.emit(tr("EDAM NotFoundException synchronizing linked notbook. See the log for datails."));\r
+ e.printStackTrace(); /// DELETE OLD NOTEBOOKS HERE\r
+ logger.log(logger.LOW, e.getMessage());\r
} catch (TException e) {\r
+ syncError = true;\r
+ status.message.emit(tr("EDAM TException synchronizing linked notbook. See the log for datails."));\r
e.printStackTrace();\r
+ logger.log(logger.LOW, e.getMessage());\r
}\r
}\r
}\r
if (notebooks != null) {\r
for (int i=0; i<notebooks.size() && keepRunning; i++) {\r
try {\r
- SharedNotebook s = noteStore.getSharedNotebookByAuth(linkedAuthResult.getAuthenticationToken());\r
- conn.getLinkedNotebookTable().setNotebookGuid(s.getShareKey(), s.getNotebookGuid());\r
- readOnly = !s.isNotebookModifiable();\r
+ if (!linkedAuthResult.getAuthenticationToken().equals("")) {\r
+ SharedNotebook s = noteStore.getSharedNotebookByAuth(linkedAuthResult.getAuthenticationToken());\r
+ conn.getLinkedNotebookTable().setNotebookGuid(s.getShareKey(), s.getNotebookGuid());\r
+ readOnly = !s.isNotebookModifiable();\r
+ } else {\r
+ readOnly = true;\r
+ }\r
notebooks.get(i).setName(linked.getShareName());\r
notebooks.get(i).setDefaultNotebook(false);\r
conn.getNotebookTable().syncLinkedNotebook(notebooks.get(i), false, readOnly); \r