use of com.evernote.edam.type.Notebook in project Notes by lguipeng.
the class EvernoteBusinessNotebookHelper method createBusinessNotebook.
/**
* @param notebook The new business notebook.
* @param defaultClient The note store client, which references the user's note store.
* @return The new created {@link LinkedNotebook}, which has an business ID.
*/
public LinkedNotebook createBusinessNotebook(@NonNull Notebook notebook, @NonNull EvernoteNoteStoreClient defaultClient) throws TException, EDAMUserException, EDAMSystemException, EDAMNotFoundException {
Notebook originalNotebook = mClient.createNotebook(notebook);
List<SharedNotebook> sharedNotebooks = originalNotebook.getSharedNotebooks();
SharedNotebook sharedNotebook = sharedNotebooks.get(0);
LinkedNotebook linkedNotebook = new LinkedNotebook();
linkedNotebook.setShareKey(sharedNotebook.getShareKey());
linkedNotebook.setShareName(originalNotebook.getName());
linkedNotebook.setUsername(mBusinessUserName);
linkedNotebook.setShardId(mBusinessUserShardId);
return defaultClient.createLinkedNotebook(linkedNotebook);
}
use of com.evernote.edam.type.Notebook in project Notes by lguipeng.
the class AsyncLinkedNoteStoreClient method createNotebook.
/**
* Create Linked Notebook from a Notebook.
*
* Synchronous call
*
* @return {@link LinkedNotebook} with guid from server
*/
@Deprecated
public LinkedNotebook createNotebook(Notebook notebook) throws TException, EDAMUserException, EDAMSystemException, EDAMNotFoundException {
Notebook originalNotebook = getAsyncClient().getClient().createNotebook(getAuthenticationToken(), notebook);
SharedNotebook sharedNotebook = originalNotebook.getSharedNotebooks().get(0);
LinkedNotebook linkedNotebook = new LinkedNotebook();
linkedNotebook.setShareKey(sharedNotebook.getShareKey());
linkedNotebook.setShareName(originalNotebook.getName());
linkedNotebook.setUsername(mClientFactory.getBusinessAuthResult().getUser().getUsername());
linkedNotebook.setShardId(mClientFactory.getBusinessAuthResult().getUser().getShardId());
return getAsyncPersonalClient().getClient().createLinkedNotebook(getAsyncPersonalClient().getAuthenticationToken(), linkedNotebook);
}
use of com.evernote.edam.type.Notebook in project Notes by lguipeng.
the class EvernoteSearchHelper method findNotesInBusinessNotebook.
protected List<NotesMetadataList> findNotesInBusinessNotebook(Search search, LinkedNotebook linkedNotebook) throws Exception {
EvernoteBusinessNotebookHelper businessNotebookHelper = mClientFactory.getBusinessNotebookHelper();
EvernoteLinkedNotebookHelper linkedNotebookHelper = mClientFactory.getLinkedNotebookHelper(linkedNotebook);
Notebook correspondingNotebook = linkedNotebookHelper.getCorrespondingNotebook();
// create a deep copy so that we don't touch the initial search request values
NoteFilter noteFilter = new NoteFilter(search.getNoteFilter());
noteFilter.setNotebookGuid(correspondingNotebook.getGuid());
return findAllNotes(search, businessNotebookHelper.getClient(), noteFilter);
}
use of com.evernote.edam.type.Notebook in project Notes by lguipeng.
the class EverNoteUtils method makeSureNoteBookExist.
private void makeSureNoteBookExist(String notebookName) throws Exception {
NotesLog.d("");
String guid = mPreferenceUtils.getStringParam(PreferenceUtils.EVERNOTE_NOTEBOOK_GUID_KEY);
if (!TextUtils.isEmpty(guid)) {
Notebook notebook = findNotebook(guid);
if (notebook != null && TextUtils.equals(notebook.getName(), notebookName)) {
mPreferenceUtils.saveParam(PreferenceUtils.EVERNOTE_NOTEBOOK_GUID_KEY, notebook.getGuid());
} else {
tryCreateNoteBook(notebookName);
}
} else {
tryCreateNoteBook(notebookName);
}
NotesLog.d("");
}
use of com.evernote.edam.type.Notebook in project Notes by lguipeng.
the class EverNoteUtils method tryCreateNoteBook.
private Notebook tryCreateNoteBook(String bookName) throws Exception {
Notebook notebook = new Notebook();
notebook.setName(bookName);
try {
Notebook result = mEvernoteSession.getEvernoteClientFactory().getNoteStoreClient().createNotebook(notebook);
mPreferenceUtils.saveParam(PreferenceUtils.EVERNOTE_NOTEBOOK_GUID_KEY, result.getGuid());
return result;
} catch (EDAMUserException e) {
if (e.getErrorCode() == EDAMErrorCode.DATA_CONFLICT) {
List<Notebook> books = listNotebooks();
for (Notebook book : books) {
if (TextUtils.equals(book.getName(), bookName)) {
mPreferenceUtils.saveParam(PreferenceUtils.EVERNOTE_NOTEBOOK_GUID_KEY, book.getGuid());
return book;
}
}
}
handleException(e);
return null;
}
}
Aggregations