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


Java NonSuccessfulResponseCodeException类代码示例

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


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

示例1: retrievePart

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
private void retrievePart(MasterSecret masterSecret, PduPart part, long messageId, long partId)
    throws IOException
{
  PartDatabase database       = DatabaseFactory.getPartDatabase(context);
  File         attachmentFile = null;

  try {
    attachmentFile = createTempFile();

    TextSecureAttachmentPointer pointer    = createAttachmentPointer(masterSecret, part);
    InputStream                 attachment = messageReceiver.retrieveAttachment(pointer, attachmentFile);

    database.updateDownloadedPart(masterSecret, messageId, partId, part, attachment);
  } catch (InvalidPartException | NonSuccessfulResponseCodeException | InvalidMessageException | MmsException e) {
    Log.w(TAG, e);
    markFailed(messageId, part, partId);
  } finally {
    if (attachmentFile != null)
      attachmentFile.delete();
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:22,代码来源:AttachmentDownloadJob.java

示例2: retrievePart

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
private void retrievePart(MasterSecret masterSecret, PduPart part, long messageId)
    throws IOException
{
  PartDatabase        database       = DatabaseFactory.getPartDatabase(context);
  File                attachmentFile = null;
  PartDatabase.PartId partId         = part.getPartId();

  try {
    attachmentFile = createTempFile();

    TextSecureAttachmentPointer pointer    = createAttachmentPointer(masterSecret, part);
    InputStream                 attachment = messageReceiver.retrieveAttachment(pointer, attachmentFile);

    database.updateDownloadedPart(masterSecret, messageId, partId, part, attachment);
  } catch (InvalidPartException | NonSuccessfulResponseCodeException | InvalidMessageException | MmsException e) {
    Log.w(TAG, e);
    markFailed(messageId, part, partId);
  } finally {
    if (attachmentFile != null)
      attachmentFile.delete();
  }
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:23,代码来源:AttachmentDownloadJob.java

示例3: retrievePart

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
private void retrievePart(MasterSecret masterSecret, PduPart part, long messageId, long partId)
    throws IOException
{
  EncryptingPartDatabase    database       = DatabaseFactory.getEncryptingPartDatabase(context, masterSecret);
  File                      attachmentFile = null;

  try {
    attachmentFile = createTempFile();

    TextSecureAttachmentPointer pointer    = createAttachmentPointer(masterSecret, part);
    InputStream                 attachment = messageReceiver.retrieveAttachment(pointer, attachmentFile);

    database.updateDownloadedPart(messageId, partId, part, attachment);
  } catch (InvalidPartException | NonSuccessfulResponseCodeException | InvalidMessageException | MmsException e) {
    Log.w(TAG, e);
    markFailed(messageId, part, partId);
  } finally {
    if (attachmentFile != null)
      attachmentFile.delete();
  }
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:22,代码来源:AttachmentDownloadJob.java

示例4: onShouldRetry

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
@Override
public boolean onShouldRetry(Exception exception) {
  Log.w(TAG, exception);
  if (exception instanceof NonSuccessfulResponseCodeException) return false;
  if (exception instanceof PushNetworkException)               return true;

  return false;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:9,代码来源:DeliveryReceiptJob.java

示例5: onShouldRetryThrowable

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
@Override
public boolean onShouldRetryThrowable(Exception exception) {
  if (exception instanceof NonSuccessfulResponseCodeException) return false;
  if (exception instanceof PushNetworkException)               return true;

  return false;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:8,代码来源:RefreshPreKeysJob.java

示例6: retrieveDirectory

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
public List<ContactTokenDetails> retrieveDirectory(Set<String> contactTokens)
    throws NonSuccessfulResponseCodeException, PushNetworkException
{
  ContactTokenList        contactTokenList = new ContactTokenList(new LinkedList<>(contactTokens));
  String                  response         = makeRequest(DIRECTORY_TOKENS_PATH, "PUT", new Gson().toJson(contactTokenList));
  ContactTokenDetailsList activeTokens     = new Gson().fromJson(response, ContactTokenDetailsList.class);

  return activeTokens.getContacts();
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:10,代码来源:PushServiceSocket.java

示例7: downloadExternalFile

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
private void downloadExternalFile(String url, File localDestination)
    throws IOException
{
  URL               downloadUrl = new URL(url);
  HttpURLConnection connection  = (HttpURLConnection) downloadUrl.openConnection();
  connection.setRequestProperty("Content-Type", "application/octet-stream");
  connection.setRequestMethod("GET");
  connection.setDoInput(true);

  try {
    if (connection.getResponseCode() != 200) {
      throw new NonSuccessfulResponseCodeException("Bad response: " + connection.getResponseCode());
    }

    OutputStream output = new FileOutputStream(localDestination);
    InputStream input   = connection.getInputStream();
    byte[] buffer       = new byte[4096];
    int read;

    while ((read = input.read(buffer)) != -1) {
      output.write(buffer, 0, read);
    }

    output.close();
    Log.w("PushServiceSocket", "Downloaded: " + url + " to: " + localDestination.getAbsolutePath());
  } catch (IOException ioe) {
    throw new PushNetworkException(ioe);
  } finally {
    connection.disconnect();
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:32,代码来源:PushServiceSocket.java

示例8: makeRequest

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
private String makeRequest(String urlFragment, String method, String body)
    throws NonSuccessfulResponseCodeException, PushNetworkException
{
  HttpURLConnection connection = makeBaseRequest(urlFragment, method, body);

  try {
    String response = Util.readFully(connection.getInputStream());
    connection.disconnect();

    return response;
  } catch (IOException ioe) {
    throw new PushNetworkException(ioe);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:15,代码来源:PushServiceSocket.java

示例9: onRun

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws IOException {
  GroupDatabase             database   = DatabaseFactory.getGroupDatabase(context);
  GroupDatabase.GroupRecord record     = database.getGroup(groupId);
  File                      attachment = null;

  try {
    if (record != null) {
      long   avatarId = record.getAvatarId();
      byte[] key      = record.getAvatarKey();
      String relay    = record.getRelay();

      if (avatarId == -1 || key == null) {
        return;
      }

      attachment = downloadAttachment(relay, avatarId);

      InputStream scaleInputStream   = new AttachmentCipherInputStream(attachment, key);
      InputStream measureInputStream = new AttachmentCipherInputStream(attachment, key);
      Bitmap      avatar             = BitmapUtil.createScaledBitmap(measureInputStream, scaleInputStream, 500, 500);

      database.updateAvatar(groupId, avatar);
    }
  } catch (InvalidMessageException | BitmapDecodingException | NonSuccessfulResponseCodeException e) {
    Log.w(TAG, e);
  } finally {
    if (attachment != null)
      attachment.delete();
  }
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:32,代码来源:AvatarDownloadJob.java

示例10: downloadExternalFile

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
private void downloadExternalFile(String url, File localDestination)
        throws IOException
{
    URL               downloadUrl = new URL(url);
    HttpURLConnection connection  = (HttpURLConnection) downloadUrl.openConnection();
    connection.setRequestProperty("Content-Type", "application/octet-stream");
    connection.setRequestMethod("GET");
    connection.setDoInput(true);

    try {
        if (connection.getResponseCode() != 200) {
            throw new NonSuccessfulResponseCodeException("Bad response: " + connection.getResponseCode());
        }

        OutputStream output = new FileOutputStream(localDestination);
        InputStream input   = connection.getInputStream();
        byte[] buffer       = new byte[4096];
        int read;

        while ((read = input.read(buffer)) != -1) {
            output.write(buffer, 0, read);
        }

        output.close();
        Log.w("PushServiceSocket", "Downloaded: " + url + " to: " + localDestination.getAbsolutePath());
    } finally {
        connection.disconnect();
    }
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:30,代码来源:PushServiceSocket.java

示例11: makeRequest

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
private String makeRequest(String urlFragment, String method, String body)
        throws NonSuccessfulResponseCodeException, PushNetworkException
{
    HttpURLConnection connection = makeBaseRequest(urlFragment, method, body);

    try {
        String response = Util.readFully(connection.getInputStream());
        connection.disconnect();

        return response;
    } catch (IOException ioe) {
        throw new PushNetworkException(ioe);
    }
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:15,代码来源:PushServiceSocket.java

示例12: onShouldRetryThrowable

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
@Override
public boolean onShouldRetryThrowable(Exception throwable) {
  if (throwable instanceof NonSuccessfulResponseCodeException) return false;
  if (throwable instanceof PushNetworkException)               return true;
  return false;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:7,代码来源:CleanPreKeysJob.java

示例13: onShouldRetry

import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException; //导入依赖的package包/类
@Override
public boolean onShouldRetry(Exception throwable) {
  if (throwable instanceof NonSuccessfulResponseCodeException) return false;
  return true;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:6,代码来源:GcmRefreshJob.java


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