/** * Marks the input stream as EOF since no further reads should be done. * * @param e Exception thrown by delegate stream. * @return Noting, just for return signature. * @throws IOException or {@link RuntimeException} */ private int onException(Exception e) throws IOException { eofReached = true; if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { // Impossible since InputStream throws no other checked exceptions. throw Throwables.failure(e); } }
/** * {@inheritDoc} */ @Override public T unmarshall(final Class<T> clazz, final String obj) { try { return Enum.valueOf(clazz, obj); } catch (final RuntimeException e) { throw failure(e, "Unable to unmarshall the string " + obj + " into " + clazz); } }
@Override public String marshall(T obj) { try { return writer.writeValueAsString(obj); } catch (JsonProcessingException e) { throw failure(e, "Unable to marshall the instance of " + obj.getClass() + "into a string"); } }
/** * {@inheritDoc} */ @Override public String marshall(final T obj) { try { return obj.name(); } catch (final RuntimeException e) { throw failure(e, "Unable to marshall the instance of " + obj.getClass() + " into a string"); } }
/** * Parses instruction data retrieved from S3 and returns a JSON string * representing the instruction. Made for testing purposes. */ static String parseInstructionFile(S3Object instructionFile) { try { return convertStreamToString(instructionFile.getObjectContent()); } catch (Exception e) { throw failure(e, "Error parsing JSON instruction file"); } }
@Override public T unmarshall(Class<T> clazz, String json) { try { return mapper.readValue(json, (getValueType() == null ? clazz : getValueType())); } catch (Exception e) { throw failure(e, "Unable to unmarshall the string " + json + "into " + clazz); } } }
JceEncryptionConstants.SYMMETRIC_KEY_ALGORITHM); } catch (Exception e) { throw failure(e, "Unable to decrypt symmetric key from object metadata");
appendToFile(output, input); } catch (NoSuchAlgorithmException e) { throw failure(e, "Unable to compute hash for data integrity"); } finally { closeQuietly(input, log);
} catch (Throwable t) { publishProgress(progressListener, ProgressEventType.TRANSFER_FAILED_EVENT); throw failure(t);
return new SecuredCEK(cipher.doFinal(toBeEncryptedBytes), null, matdesc); } catch (Exception e) { throw failure(e, "Unable to encrypt symmetric key");
} catch (Throwable t) { publishProgress(progressListener, ProgressEventType.TRANSFER_FAILED_EVENT); throw failure(t); publishProgress(progressListener, ProgressEventType.TRANSFER_FAILED_EVENT); glacier.abortMultipartUpload(new AbortMultipartUploadRequest(accountId, vaultName, uploadId)); throw failure(t, "Unable to finish the upload");
} catch (Exception e) { cleanupDataSource(req, fileOrig, isOrig, isCurr, log); throw failure(e,"Unable to create cipher input stream");
throw failure(e, "Unable to create cipher input stream");
private UploadResult uploadInSinglePart(final String accountId, final String vaultName, final String archiveDescription, final File file, ProgressListener progressListener) { String checksum = TreeHashGenerator.calculateTreeHash(file); ResettableInputStream is = newResettableInputStream(file); try { publishProgress(progressListener, ProgressEventType.TRANSFER_STARTED_EVENT); final UploadArchiveRequest req = new UploadArchiveRequest() .withAccountId(accountId) .withArchiveDescription(archiveDescription) .withVaultName(vaultName) .withChecksum(checksum) .withBody(is) .withContentLength(file.length()) // capture the bytes transferred .withGeneralProgressListener(progressListener) ; UploadArchiveResult uploadArchiveResult = glacier.uploadArchive(req); String artifactId = uploadArchiveResult.getArchiveId(); publishProgress(progressListener, ProgressEventType.TRANSFER_COMPLETED_EVENT); return new UploadResult(artifactId); } catch (Throwable t) { publishProgress(progressListener, ProgressEventType.TRANSFER_FAILED_EVENT); throw failure(t); } finally { is.release(); } } }
throw failure(t);
} catch (Throwable t) { publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT); throw failure(t);
throw failure(t); } finally { if (jobStatusMonitor != null) {
/** * {@inheritDoc} */ @Override public T unmarshall(final Class<T> clazz, final String obj) { try { return Enum.valueOf(clazz, obj); } catch (final RuntimeException e) { throw failure(e, "Unable to unmarshall the string " + obj + " into " + clazz); } }
@Override public String marshall(T obj) { try { return writer.writeValueAsString(obj); } catch (JsonProcessingException e) { throw failure(e, "Unable to marshall the instance of " + obj.getClass() + "into a string"); } }
@Override public T unmarshall(Class<T> clazz, String json) { try { return mapper.readValue(json, (getValueType() == null ? clazz : getValueType())); } catch (Exception e) { throw failure(e, "Unable to unmarshall the string " + json + "into " + clazz); } } }