当前位置: 首页>>代码示例>>Java>>正文


Java TEvernoteHttpClient类代码示例

本文整理汇总了Java中com.evernote.client.conn.mobile.TEvernoteHttpClient的典型用法代码示例。如果您正苦于以下问题:Java TEvernoteHttpClient类的具体用法?Java TEvernoteHttpClient怎么用?Java TEvernoteHttpClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TEvernoteHttpClient类属于com.evernote.client.conn.mobile包,在下文中一共展示了TEvernoteHttpClient类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBusinessNoteStoreClient

import com.evernote.client.conn.mobile.TEvernoteHttpClient; //导入依赖的package包/类
/**
 *
 * Create a new Business NoteStore client. Each call to this method will return
 * a new NoteStore.Client instance. The returned client can be used for any
 * number of API calls, but is NOT thread safe.
 *
 * This method will check expiration time for the business authorization token, this is a network request
 *
 * This method is synchronous
 *
 * @throws TException
 * @throws EDAMUserException
 * @throws EDAMSystemException User is not part of a business
 */
public AsyncBusinessNoteStoreClient createBusinessNoteStoreClient() throws TException, EDAMUserException, EDAMSystemException {
  com.evernote.client.android.AuthenticationResult authResult =
      EvernoteSession.getOpenSession().getAuthenticationResult();

  if(authResult.getBusinessAuthToken() == null ||
      authResult.getBusinessAuthTokenExpiration() < System.currentTimeMillis()) {

    AuthenticationResult businessAuthResult = createUserStoreClient().getClient().authenticateToBusiness(authResult.getAuthToken());

    authResult.setBusinessAuthToken(businessAuthResult.getAuthenticationToken());
    authResult.setBusinessAuthTokenExpiration(businessAuthResult.getExpiration());
    authResult.setBusinessNoteStoreUrl(businessAuthResult.getNoteStoreUrl());
    authResult.setBusinessUser(businessAuthResult.getUser());
  }

  TEvernoteHttpClient transport =
      new TEvernoteHttpClient(authResult.getBusinessNoteStoreUrl(), mUserAgent, mTempDir);
  TBinaryProtocol protocol = new TBinaryProtocol(transport);
  return new AsyncBusinessNoteStoreClient(protocol, protocol, authResult.getBusinessAuthToken(), this);
}
 
开发者ID:duanze,项目名称:PureNote,代码行数:35,代码来源:ClientFactory.java

示例2: createUserStoreClient

import com.evernote.client.conn.mobile.TEvernoteHttpClient; //导入依赖的package包/类
/**
 * Create a new UserStore client. Each call to this method will return
 * a new UserStore.Client instance. The returned client can be used for any
 * number of API calls, but is NOT thread safe.
 *
 * @param url to connect to
 * @param port to connect on
 *
 * @throws IllegalStateException if @link #isLoggedIn() is false.
 * @throws TTransportException if an error occurs setting up the
 * connection to the Evernote service.
 *
 */
AsyncUserStoreClient createUserStoreClient(String url, int port) throws TTransportException {
  String serviceUrl = getFullUrl(url, port);

  TEvernoteHttpClient transport =
      new TEvernoteHttpClient(serviceUrl, mUserAgent, mTempDir);

  if (mCustomHeaders != null) {
    for (Map.Entry<String, String> header : mCustomHeaders.entrySet()) {
      transport.setCustomHeader(header.getKey(), header.getValue());
    }
  }
  if (mUserAgent != null) {
    transport.setCustomHeader(USER_AGENT_KEY, mUserAgent);
  }
  TBinaryProtocol protocol = new TBinaryProtocol(transport);
  String authToken = null;
  if(EvernoteSession.getOpenSession().isLoggedIn()) {
    authToken = EvernoteSession.getOpenSession().getAuthenticationResult().getAuthToken();
  }

  return new AsyncUserStoreClient(protocol, protocol, authToken);
}
 
开发者ID:duanze,项目名称:PureNote,代码行数:36,代码来源:ClientFactory.java

示例3: createNoteStoreClient

import com.evernote.client.conn.mobile.TEvernoteHttpClient; //导入依赖的package包/类
/**
 * Create a new NoteStore client. Each call to this method will return
 * a new NoteStore.Client instance. The returned client can be used for any
 * number of API calls, but is NOT thread safe.
 *
 * @throws IllegalStateException if @link #isLoggedIn() is false.
 * @throws TTransportException if an error occurs setting up the
 * connection to the Evernote service.
 */
public AsyncNoteStoreClient createNoteStoreClient() throws TTransportException {
  if(EvernoteSession.getOpenSession() == null || EvernoteSession.getOpenSession().getAuthenticationResult() == null) {
    throw new IllegalStateException();
  }

  TEvernoteHttpClient transport =
      new TEvernoteHttpClient(EvernoteSession.getOpenSession().getAuthenticationResult().getNoteStoreUrl(), mUserAgent, mTempDir);
  TBinaryProtocol protocol = new TBinaryProtocol(transport);
  return new AsyncNoteStoreClient(protocol, protocol, EvernoteSession.getOpenSession().getAuthenticationResult().getAuthToken());
}
 
开发者ID:duanze,项目名称:PureNote,代码行数:20,代码来源:ClientFactory.java

示例4: createNoteStore

import com.evernote.client.conn.mobile.TEvernoteHttpClient; //导入依赖的package包/类
public NoteStore.Client createNoteStore() throws TTransportException{
 if(EvernoteSession.getOpenSession() == null || EvernoteSession.getOpenSession().getAuthenticationResult() == null){
  throw new IllegalStateException();
 }
 TEvernoteHttpClient transport =
        new TEvernoteHttpClient(EvernoteSession.getOpenSession().getAuthenticationResult().getNoteStoreUrl(), mUserAgent, mTempDir);
 TBinaryProtocol protocol = new TBinaryProtocol(transport);
 return new NoteStore.Client(protocol, protocol);
}
 
开发者ID:duanze,项目名称:PureNote,代码行数:10,代码来源:ClientFactory.java

示例5: createLinkedNoteStoreClient

import com.evernote.client.conn.mobile.TEvernoteHttpClient; //导入依赖的package包/类
/**
 * Creates a LinkedNoteStoreClient from a {@link LinkedNotebook} synchronously
 *
 * @param linkedNotebook
 */
public AsyncLinkedNoteStoreClient createLinkedNoteStoreClient(LinkedNotebook linkedNotebook) throws EDAMUserException, EDAMSystemException, TException, EDAMNotFoundException {
  com.evernote.client.android.AuthenticationResult authResult =
      EvernoteSession.getOpenSession().getAuthenticationResult();

  TEvernoteHttpClient transport =
      new TEvernoteHttpClient(linkedNotebook.getNoteStoreUrl(), mUserAgent, mTempDir);
  TBinaryProtocol protocol = new TBinaryProtocol(transport);

  AsyncLinkedNoteStoreClient sharedNoteStore = new AsyncLinkedNoteStoreClient(protocol, protocol, authResult.getAuthToken(), this);
  AuthenticationResult sharedAuthKey = sharedNoteStore.getAsyncClient().getClient().authenticateToSharedNotebook(linkedNotebook.getShareKey(), authResult.getAuthToken());
  sharedNoteStore.setAuthToken(sharedAuthKey.getAuthenticationToken());
  return sharedNoteStore;
}
 
开发者ID:duanze,项目名称:PureNote,代码行数:19,代码来源:ClientFactory.java


注:本文中的com.evernote.client.conn.mobile.TEvernoteHttpClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。