private void write(final DataIdentifier identifier, final File file, final boolean async, final AsyncUploadCallback callback) throws DataStoreException { log("write " + identifier + " " + file.length()); byte[] buffer = new byte[(int) file.length()]; try { if (async && callback == null) { throw new IllegalArgumentException( "callback parameter cannot be null"); } DataInputStream din = new DataInputStream(new FileInputStream(file)); din.readFully(buffer); din.close(); data.put(identifier, buffer); timeMap.put(identifier, System.currentTimeMillis()); } catch (IOException e) { if (async) { callback.onAbort(new AsyncUploadResult(identifier, file)); } throw new DataStoreException(e); } if (async) { callback.onSuccess(new AsyncUploadResult(identifier, file)); } }
LOG.debug("lastModified of [{}] updated successfully.", identifier); if (callback != null) { callback.onSuccess(new AsyncUploadResult(identifier, file)); asyncUpRes.setException(e2); if (callback != null) { callback.onAbort(asyncUpRes); LOG.debug("synchronous upload to identifier [{}] completed.", identifier); if (callback != null) { callback.onSuccess(new AsyncUploadResult( identifier, file)); asyncUpRes.setException(e2); if (callback != null) { callback.onAbort(asyncUpRes);
LOG.debug("lastModified of [{}] updated successfully.", identifier); if (callback != null) { callback.onSuccess(new AsyncUploadResult(identifier, file)); asyncUpRes.setException(e2); if (callback != null) { callback.onAbort(asyncUpRes); LOG.debug("synchronous upload to identifier [{}] completed.", identifier); if (callback != null) { callback.onSuccess(new AsyncUploadResult( identifier, file)); asyncUpRes.setException(e2); if (callback != null) { callback.onAbort(asyncUpRes);
public void progressChanged(ProgressEvent progressEvent) { switch (progressEvent.getEventCode()) { case ProgressEvent.COMPLETED_EVENT_CODE: callback.onSuccess(new AsyncUploadResult(identifier, file)); break; case ProgressEvent.FAILED_EVENT_CODE: AsyncUploadResult result = new AsyncUploadResult( identifier, file); try { AmazonClientException e = upload.waitForException(); if (e != null) { result.setException(e); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } callback.onFailure(result); break; default: break; } } }
public void progressChanged(ProgressEvent progressEvent) { switch (progressEvent.getEventCode()) { case ProgressEvent.COMPLETED_EVENT_CODE: callback.onSuccess(new AsyncUploadResult(identifier, file)); break; case ProgressEvent.FAILED_EVENT_CODE: AsyncUploadResult result = new AsyncUploadResult( identifier, file); try { AmazonClientException e = upload.waitForException(); if (e != null) { result.setException(e); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } callback.onFailure(result); break; default: break; } } }