本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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;
}
示例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;
}