Search in sources :

Example 1 with Notebook

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);
}
Also used : LinkedNotebook(com.evernote.edam.type.LinkedNotebook) Notebook(com.evernote.edam.type.Notebook) SharedNotebook(com.evernote.edam.type.SharedNotebook) LinkedNotebook(com.evernote.edam.type.LinkedNotebook) SharedNotebook(com.evernote.edam.type.SharedNotebook)

Example 2 with Notebook

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);
}
Also used : LinkedNotebook(com.evernote.edam.type.LinkedNotebook) Notebook(com.evernote.edam.type.Notebook) SharedNotebook(com.evernote.edam.type.SharedNotebook) LinkedNotebook(com.evernote.edam.type.LinkedNotebook) SharedNotebook(com.evernote.edam.type.SharedNotebook)

Example 3 with Notebook

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);
}
Also used : NoteFilter(com.evernote.edam.notestore.NoteFilter) Notebook(com.evernote.edam.type.Notebook) LinkedNotebook(com.evernote.edam.type.LinkedNotebook)

Example 4 with Notebook

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("");
}
Also used : Notebook(com.evernote.edam.type.Notebook)

Example 5 with Notebook

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;
    }
}
Also used : Notebook(com.evernote.edam.type.Notebook) ArrayList(java.util.ArrayList) NotesMetadataList(com.evernote.edam.notestore.NotesMetadataList) List(java.util.List) EDAMUserException(com.evernote.edam.error.EDAMUserException)

Aggregations

Notebook (com.evernote.edam.type.Notebook)9 LinkedNotebook (com.evernote.edam.type.LinkedNotebook)4 EDAMNotFoundException (com.evernote.edam.error.EDAMNotFoundException)3 EDAMUserException (com.evernote.edam.error.EDAMUserException)3 EvernoteNoteStoreClient (com.evernote.client.android.asyncclient.EvernoteNoteStoreClient)2 FileData (com.evernote.client.conn.mobile.FileData)2 EDAMSystemException (com.evernote.edam.error.EDAMSystemException)2 NoteFilter (com.evernote.edam.notestore.NoteFilter)2 Note (com.evernote.edam.type.Note)2 Resource (com.evernote.edam.type.Resource)2 ResourceAttributes (com.evernote.edam.type.ResourceAttributes)2 SharedNotebook (com.evernote.edam.type.SharedNotebook)2 TException (com.evernote.thrift.TException)2 BufferedInputStream (java.io.BufferedInputStream)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 List (java.util.List)2 Activity (android.app.Activity)1