本文整理汇总了Java中com.evernote.thrift.transport.TTransportException类的典型用法代码示例。如果您正苦于以下问题:Java TTransportException类的具体用法?Java TTransportException怎么用?Java TTransportException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TTransportException类属于com.evernote.thrift.transport包,在下文中一共展示了TTransportException类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: read
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
@Override
public int read(byte[] buf, int off, int len) throws TTransportException {
if (mResponseBody == null) {
throw new TTransportException("Response buffer is empty, no request.");
}
try {
int ret = mResponseBody.read(buf, off, len);
if (ret == -1) {
throw new TTransportException("No more data available.");
}
return ret;
} catch (IOException e) {
throw new TTransportException(e);
}
}
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:18,代码来源:TAndroidTransport.java
示例2: createUserStoreClient
import com.evernote.thrift.transport.TTransportException; //导入依赖的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: handleDesignTimeErr
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
public static boolean handleDesignTimeErr(final Shell shell, final Throwable e, final EeClipper clipper) {
if (e instanceof EDAMUserException) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
result = new EDAMUserExceptionHandler().handleDesingTime(shell, (EDAMUserException) e, clipper);
}
});
return result;
} else if (e instanceof OutOfDateException) {
openError(shell, Messages.bind(Messages.Plugin_OutOfDate, EemoryPlugin.getVersion()));
} else if (e instanceof TTransportException) {
if (clipper != null) {
clipper.setInvalid();
}
openError(shell, ExceptionUtils.getRootCauseMessage(e));
} else {
openError(shell, ExceptionUtils.getRootCauseMessage(e));
}
return false;
}
开发者ID:LTTPP,项目名称:Eemory,代码行数:22,代码来源:ThrowableHandler.java
示例4: handleJobErr
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
public static IStatus handleJobErr(final Throwable e, final EeClipper clipper, final ENNote args, final Shell shell) {
if (e instanceof EDAMNotFoundException) {
if (args != null) {
return new EDAMNotFoundHandler(EncryptionUtil.decrypt(IDialogSettingsUtil.get(Constants.PLUGIN_SETTINGS_KEY_TOKEN))).fixNotFoundException((EDAMNotFoundException) e, args);
}
} else if (e instanceof EDAMUserException) {
return new EDAMUserExceptionHandler().handleRuntime(shell, (EDAMUserException) e, clipper);
} else if (e instanceof OutOfDateException) {
return LogUtil.error(Messages.bind(Messages.Plugin_OutOfDate, EemoryPlugin.getVersion()));
} else if (e instanceof TTransportException) {
if (clipper != null) {
clipper.setInvalid();
}
} else if (e instanceof NoDataFoundException) {
return LogUtil.warning(ExceptionUtils.getRootCauseMessage(e));
}
return LogUtil.error(e);
}
开发者ID:LTTPP,项目名称:Eemory,代码行数:19,代码来源:ThrowableHandler.java
示例5: isValid
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
@Override
public boolean isValid() {
if (!super.isValid()) {
return false;
}
if (factory == null) {
return false;
}
try {
factory.getNoteStoreClient().getDefaultNotebook();
} catch (Throwable e) {
if (e instanceof TTransportException) {
return false;
}
/*
* // As new StoreClientFactory(token); will not identify
* auth-expired exception, so the following code is not needed. if
* (e instanceof EDAMUserException) { if (((EDAMUserException)
* e).getErrorCode() == EDAMErrorCode.AUTH_EXPIRED) { return false;
* } }
*/
}
return true;
}
开发者ID:LTTPP,项目名称:Eemory,代码行数:25,代码来源:EeClipperImpl.java
示例6: testUserStoreClientWithException
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
@Test
public void testUserStoreClientWithException() throws Exception {
TTransportException exception = new TTransportException();
ClientFactory clientFactory = mock(ClientFactory.class);
when(clientFactory.createUserStoreClient()).thenThrow(exception);
EvernoteTemplate template = new EvernoteTemplate(EvernoteService.SANDBOX, "token");
replaceClientFactory(template, clientFactory);
try {
template.userStoreClient();
fail("didn't thrown exception");
} catch (EvernoteException e) {
Throwable cause = e.getCause();
assertThat(cause, is(instanceOf(TTransportException.class)));
assertThat((TTransportException) cause, is(sameInstance(exception)));
}
}
开发者ID:ttddyy,项目名称:spring-social-evernote,代码行数:19,代码来源:EvernoteTemplateStoreClientTest.java
示例7: write
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
@Override
public void write(byte[] buf, int off, int len) throws TTransportException {
try {
mByteStore.write(buf, off, len);
} catch (IOException e) {
throw new TTransportException(e);
}
}
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:9,代码来源:TAndroidTransport.java
示例8: createNoteStoreClient
import com.evernote.thrift.transport.TTransportException; //导入依赖的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
示例9: createNoteStore
import com.evernote.thrift.transport.TTransportException; //导入依赖的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
示例10: TEvernoteHttpClient
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
/**
* Create a new TAndroidHttpClient.
*
* @param url The Thrift server URL, for example, https://www.evernote.com/edam/user.
* @param userAgent The User-Agent string to send, which should identify the
* client application.
* @param tempPath A temp directory where Thrift messages should be cached
* before they're sent.
* @throws TTransportException If an error occurs creating the temporary
* file that will be used to cache Thrift messages to disk before sending.
*/
public TEvernoteHttpClient(String url, String userAgent, File tempDir)
throws TTransportException {
getHTTPClient();
this.userAgent = userAgent;
try {
url_ = new URL(url);
requestBuffer_ =
new DiskBackedByteStore(tempDir, "http", MEMORY_BUFFER_SIZE);
} catch (IOException iox) {
throw new TTransportException(iox);
}
}
开发者ID:duanze,项目名称:PureNote,代码行数:26,代码来源:TEvernoteHttpClient.java
示例11: read
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
public int read(byte[] buf, int off, int len) throws TTransportException {
if (inputStream_ == null) {
throw new TTransportException("Response buffer is empty, no request.");
}
try {
int ret = inputStream_.read(buf, off, len);
if (ret == -1) {
throw new TTransportException("No more data available.");
}
return ret;
} catch (IOException iox) {
throw new TTransportException(iox);
}
}
开发者ID:duanze,项目名称:PureNote,代码行数:16,代码来源:TEvernoteHttpClient.java
示例12: handleExecErr
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
public static ExecutionException handleExecErr(final Throwable e, final EeClipper clipper) {
if (e instanceof OutOfDateException) {
return new ExecutionException(Messages.bind(Messages.Plugin_OutOfDate, EemoryPlugin.getVersion()));
} else if (e instanceof TTransportException) {
if (clipper != null) {
clipper.setInvalid();
}
}
return new ExecutionException(ExceptionUtils.getRootCauseMessage(e), e);
}
开发者ID:LTTPP,项目名称:Eemory,代码行数:11,代码来源:ThrowableHandler.java
示例13: getUserStoreClient
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
public UserStoreClient getUserStoreClient() throws TTransportException {
if (userStoreClient == null) {
synchronized (StoreClientFactory.class) {
if (userStoreClient == null) {
userStoreClient = factory.createUserStoreClient();
}
}
}
return userStoreClient;
}
开发者ID:LTTPP,项目名称:Eemory,代码行数:11,代码来源:StoreClientFactory.java
示例14: open
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
@Override
public void open() throws TTransportException {
// do nothing
}
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:5,代码来源:TAndroidTransport.java
示例15: flush
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
@Override
public void flush() throws TTransportException {
Util.closeQuietly(mResponseBody);
mResponseBody = null;
RequestBody requestBody = new RequestBody() {
@Override
public MediaType contentType() {
if (mHeaders != null && mHeaders.containsKey("Content-Type")) {
return MediaType.parse(mHeaders.get("Content-Type"));
} else {
return MEDIA_TYPE_THRIFT;
}
}
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(mByteStore.getData(), 0, mByteStore.getBytesWritten());
}
};
try {
Request.Builder builder = new Request.Builder()
.url(mUrl)
.post(requestBody);
if (mHeaders != null) {
for (String name : mHeaders.keySet()) {
builder.header(name, mHeaders.get(name));
}
}
Response response = mHttpClient.newCall(builder.build()).execute();
if (response.code() != 200) {
throw new TTransportException("HTTP Response code: " + response.code() + ", message " + response.message());
}
mResponseBody = response.body().byteStream();
} catch (Exception e) {
throw new TTransportException(e);
} finally {
try {
mByteStore.reset();
} catch (IOException ignored) {
}
}
}
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:51,代码来源:TAndroidTransport.java
示例16: AsyncBusinessNoteStoreClient
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
/**
* Reference to your personal note store
*/
AsyncBusinessNoteStoreClient(TProtocol iprot, TProtocol oprot, String authenticationToken, ClientFactory clientFactory) throws TTransportException {
super(iprot, oprot, authenticationToken, clientFactory);
}
开发者ID:duanze,项目名称:PureNote,代码行数:8,代码来源:AsyncBusinessNoteStoreClient.java
示例17: AsyncLinkedNoteStoreClient
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
AsyncLinkedNoteStoreClient(TProtocol iprot, TProtocol oprot, String authenticationToken, ClientFactory clientFactory) throws TTransportException {
mLinkedStoreClient = new AsyncNoteStoreClient(iprot, oprot, authenticationToken);
mMainNoteStoreClient = EvernoteSession.getOpenSession().getClientFactory().createNoteStoreClient();
mAuthToken = authenticationToken;
mClientFactory = clientFactory;
}
开发者ID:duanze,项目名称:PureNote,代码行数:7,代码来源:AsyncLinkedNoteStoreClient.java
示例18: flush
import com.evernote.thrift.transport.TTransportException; //导入依赖的package包/类
public void flush() throws TTransportException {
long timer = System.currentTimeMillis();
HttpEntity httpEntity = null;
// Extract request and reset buffer
try {
// Prepare http post request
HttpPost request = new HttpPost(url_.toExternalForm());
this.request = request;
request.addHeader("Content-Type", "application/x-thrift");
request.addHeader("Cache-Control", "no-transform");
if (customHeaders_ != null) {
for (Map.Entry<String, String> header : customHeaders_.entrySet()) {
request.addHeader(header.getKey(), header.getValue());
}
}
InputStreamEntity entity =
new InputStreamEntity(requestBuffer_.getInputStream(), requestBuffer_
.getSize());
request.setEntity(entity);
request.addHeader("Accept", "application/x-thrift");
request.addHeader("User-Agent", userAgent == null ? "Java/THttpClient"
: userAgent);
request.getParams().setBooleanParameter(
CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
DefaultHttpClient dHTTP = getHTTPClient();
HttpResponse response = dHTTP.execute(request);
httpEntity = response.getEntity();
int responseCode = response.getStatusLine().getStatusCode();
if (responseCode != 200) {
if (httpEntity != null) {
httpEntity.consumeContent();
}
throw new TTransportException("HTTP Response code: " + responseCode);
}
// Read the responses
requestBuffer_.reset();
inputStream_ = response.getEntity().getContent();
} catch (IOException iox) {
throw new TTransportException(iox);
} catch (Exception ex) {
throw new TTransportException(ex);
} finally {
try {
requestBuffer_.reset();
} catch (IOException e) {
}
this.request = null;
}
}
开发者ID:duanze,项目名称:PureNote,代码行数:54,代码来源:TEvernoteHttpClient.java
注:本文中的com.evernote.thrift.transport.TTransportException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论