public static CopyObjectsEvent newInProgressEvent(ThreadWatcher threadWatcher, Map[] completedResults, Object uniqueOperationId) { CopyObjectsEvent event = new CopyObjectsEvent(EVENT_IN_PROGRESS, uniqueOperationId); event.setThreadWatcher(threadWatcher); event.setResults(completedResults); return event; }
/** * @return * the Map results for the objects that have been copied since the last progress event was fired. * @throws IllegalStateException * results are only available from EVENT_IN_PROGRESS events. */ public Map[] getCopyResults() throws IllegalStateException { if (getEventCode() != EVENT_IN_PROGRESS) { throw new IllegalStateException("Copy results are only available from EVENT_IN_PROGRESS events"); } return results; }
public static CopyObjectsEvent newErrorEvent(Throwable t, Object uniqueOperationId) { CopyObjectsEvent event = new CopyObjectsEvent(EVENT_ERROR, uniqueOperationId); event.setErrorCause(t); return event; }
public static CopyObjectsEvent newCancelledEvent(S3Object[] incompletedObjects, Object uniqueOperationId) { CopyObjectsEvent event = new CopyObjectsEvent(EVENT_CANCELLED, uniqueOperationId); event.setCopyCancelledObjects(incompletedObjects); return event; }
public static CopyObjectsEvent newCompletedEvent(Object uniqueOperationId, String[] sourceObjectKeys, S3Object[] destinationObjects) { CopyObjectsEvent event = new CopyObjectsEvent(EVENT_COMPLETED, uniqueOperationId); event.setDestinationObjects(destinationObjects); event.setSourceObjectKeys(sourceObjectKeys); return event; }
if (ServiceEvent.EVENT_STARTED == event.getEventCode()) { ThreadWatcher watcher = event.getThreadWatcher(); startProgressDialog("Copied 0 of " + watcher.getThreadCount() + " objects", "", 0, (int) watcher.getThreadCount(), "Cancel Copy", event.getThreadWatcher().getCancelEventListener()); else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) { ThreadWatcher watcher = event.getThreadWatcher(); String statusText = "Copied " + watcher.getCompletedThreads() + " of " + watcher.getThreadCount() + " objects"; updateProgressDialog(statusText, "", (int) watcher.getCompletedThreads()); else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode() || ServiceEvent.EVENT_CANCELLED == event.getEventCode()) else if (ServiceEvent.EVENT_ERROR == event.getEventCode()) { stopProgressDialog(); log.error(message, event.getErrorCause()); ErrorDialog.showDialog(ownerFrame, this, message, event.getErrorCause());
@Override public void s3ServiceEventPerformed(CopyObjectsEvent event) { super.s3ServiceEventPerformed(event); if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) { resultsList.addAll(Arrays.asList(event.getCopyResults())); } }; };
public static CopyObjectsEvent newIgnoredErrorsEvent(ThreadWatcher threadWatcher, Throwable[] ignoredErrors, Object uniqueOperationId) { CopyObjectsEvent event = new CopyObjectsEvent(EVENT_IGNORED_ERRORS, uniqueOperationId); event.setIgnoredErrors(ignoredErrors); return event; }
public static CopyObjectsEvent newStartedEvent(ThreadWatcher threadWatcher, Object uniqueOperationId) { CopyObjectsEvent event = new CopyObjectsEvent(EVENT_STARTED, uniqueOperationId); event.setThreadWatcher(threadWatcher); return event; }
@Override public void fireProgressEvent(ThreadWatcher threadWatcher, List completedResults) { incompletedObjectsList.removeAll(completedResults); Map[] copyResults = (Map[]) completedResults .toArray(new Map[completedResults.size()]); fireServiceEvent(CopyObjectsEvent.newInProgressEvent(threadWatcher, copyResults, uniqueOperationId)); } @Override
@Override public void fireCancelEvent() { S3Object[] incompletedObjects = (S3Object[]) incompletedObjectsList .toArray(new S3Object[incompletedObjectsList.size()]); success[0] = false; fireServiceEvent(CopyObjectsEvent.newCancelledEvent(incompletedObjects, uniqueOperationId)); } @Override
@Override public void fireIgnoredErrorsEvent(ThreadWatcher threadWatcher, Throwable[] ignoredErrors) { success[0] = false; fireServiceEvent(CopyObjectsEvent.newIgnoredErrorsEvent(threadWatcher, ignoredErrors, uniqueOperationId)); } }).run();
@Override public void fireErrorEvent(Throwable throwable) { success[0] = false; fireServiceEvent(CopyObjectsEvent.newErrorEvent(throwable, uniqueOperationId)); } @Override
@Override public void fireCompletedEvent() { fireServiceEvent(CopyObjectsEvent.newCompletedEvent(uniqueOperationId, sourceObjectKeys, destinationObjects)); } @Override
public static CopyObjectsEvent newCompletedEvent(Object uniqueOperationId, String[] sourceObjectKeys, S3Object[] destinationObjects) { CopyObjectsEvent event = new CopyObjectsEvent(EVENT_COMPLETED, uniqueOperationId); event.setDestinationObjects(destinationObjects); event.setSourceObjectKeys(sourceObjectKeys); return event; }
if (ServiceEvent.EVENT_STARTED == event.getEventCode()) { ThreadWatcher watcher = event.getThreadWatcher(); startProgressDialog("Copied 0 of " + watcher.getThreadCount() + " objects", "", 0, (int) watcher.getThreadCount(), "Cancel Copy", event.getThreadWatcher().getCancelEventListener()); else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) { ThreadWatcher watcher = event.getThreadWatcher(); String statusText = "Copied " + watcher.getCompletedThreads() + " of " + watcher.getThreadCount() + " objects"; updateProgressDialog(statusText, "", (int) watcher.getCompletedThreads()); else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode() || ServiceEvent.EVENT_CANCELLED == event.getEventCode()) else if (ServiceEvent.EVENT_ERROR == event.getEventCode()) { stopProgressDialog(); log.error(message, event.getErrorCause()); ErrorDialog.showDialog(ownerFrame, this, message, event.getErrorCause());
@Override public void s3ServiceEventPerformed(CopyObjectsEvent event) { super.s3ServiceEventPerformed(event); if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) { resultsList.addAll(Arrays.asList(event.getCopyResults())); } }; };
public static CopyObjectsEvent newErrorEvent(Throwable t, Object uniqueOperationId) { CopyObjectsEvent event = new CopyObjectsEvent(EVENT_ERROR, uniqueOperationId); event.setErrorCause(t); return event; }
public static CopyObjectsEvent newCancelledEvent(S3Object[] incompletedObjects, Object uniqueOperationId) { CopyObjectsEvent event = new CopyObjectsEvent(EVENT_CANCELLED, uniqueOperationId); event.setCopyCancelledObjects(incompletedObjects); return event; }
public static CopyObjectsEvent newIgnoredErrorsEvent(ThreadWatcher threadWatcher, Throwable[] ignoredErrors, Object uniqueOperationId) { CopyObjectsEvent event = new CopyObjectsEvent(EVENT_IGNORED_ERRORS, uniqueOperationId); event.setIgnoredErrors(ignoredErrors); return event; }