public static DownloadObjectsEvent newInProgressEvent(ThreadWatcher threadWatcher, StorageObject[] completedObjects, Object uniqueOperationId) { DownloadObjectsEvent event = new DownloadObjectsEvent(EVENT_IN_PROGRESS, uniqueOperationId); event.setThreadWatcher(threadWatcher); event.setObjects(completedObjects); return event; }
/** * @return * the {@link StorageObject}s that were not downloaded before the operation was cancelled. * @throws IllegalStateException * cancelled objects are only available from EVENT_CANCELLED events. */ public StorageObject[] getCancelledObjects() throws IllegalStateException { if (getEventCode() != EVENT_CANCELLED) { throw new IllegalStateException("Cancelled Objects are only available from EVENT_CANCELLED events"); } return objects; }
public static DownloadObjectsEvent newErrorEvent(Throwable t, Object uniqueOperationId) { DownloadObjectsEvent event = new DownloadObjectsEvent(EVENT_ERROR, uniqueOperationId); event.setErrorCause(t); return event; }
public static DownloadObjectsEvent newStartedEvent(ThreadWatcher threadWatcher, Object uniqueOperationId) { DownloadObjectsEvent event = new DownloadObjectsEvent(EVENT_STARTED, uniqueOperationId); event.setThreadWatcher(threadWatcher); return event; }
@Override public void event(DownloadObjectsEvent event) { super.event(event); displayIgnoredErrors(event); if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) { displayProgressStatus("Download: ", event.getThreadWatcher()); } }
@Override public void event(DownloadObjectsEvent event) { super.event(event); if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) { objectList.addAll(Arrays.asList(event.getDownloadedObjects())); } }; };
public static DownloadObjectsEvent newIgnoredErrorsEvent(ThreadWatcher threadWatcher, Throwable[] ignoredErrors, Object uniqueOperationId) { DownloadObjectsEvent event = new DownloadObjectsEvent(EVENT_IGNORED_ERRORS, uniqueOperationId); event.setIgnoredErrors(ignoredErrors); return event; }
public static DownloadObjectsEvent newCancelledEvent(StorageObject[] incompletedObjects, Object uniqueOperationId) { DownloadObjectsEvent event = new DownloadObjectsEvent(EVENT_CANCELLED, uniqueOperationId); event.setObjects(incompletedObjects); return event; }
@Override public void fireProgressEvent(ThreadWatcher threadWatcher, List completedResults) { incompleteObjectDownloadList.removeAll(completedResults); StorageObject[] completedObjects = (StorageObject[]) completedResults .toArray(new StorageObject[completedResults.size()]); fireServiceEvent(DownloadObjectsEvent.newInProgressEvent(threadWatcher, completedObjects, uniqueOperationId)); } @Override
@Override public void fireCancelEvent() { StorageObject[] incompleteObjects = (StorageObject[]) incompleteObjectDownloadList .toArray(new StorageObject[incompleteObjectDownloadList.size()]); success[0] = false; fireServiceEvent(DownloadObjectsEvent.newCancelledEvent(incompleteObjects, uniqueOperationId)); } @Override
@Override public void fireIgnoredErrorsEvent(ThreadWatcher threadWatcher, Throwable[] ignoredErrors) { success[0] = false; fireServiceEvent(DownloadObjectsEvent.newIgnoredErrorsEvent(threadWatcher, ignoredErrors, uniqueOperationId)); } }).run();
@Override public void fireErrorEvent(Throwable throwable) { success[0] = false; fireServiceEvent(DownloadObjectsEvent.newErrorEvent(throwable, uniqueOperationId)); } @Override
@Override public void fireStartEvent(ThreadWatcher threadWatcher) { fireServiceEvent(DownloadObjectsEvent.newStartedEvent(threadWatcher, uniqueOperationId)); } @Override
@Override public void fireCompletedEvent() { fireServiceEvent(DownloadObjectsEvent.newCompletedEvent(uniqueOperationId)); } @Override
public static DownloadObjectsEvent newCompletedEvent(Object uniqueOperationId) { DownloadObjectsEvent event = new DownloadObjectsEvent(EVENT_COMPLETED, uniqueOperationId); return event; }
@Override public void event(DownloadObjectsEvent event) { super.event(event); displayIgnoredErrors(event); if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) { displayProgressStatus("Download: ", event.getThreadWatcher()); } }
@Override public void event(DownloadObjectsEvent event) { super.event(event); if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) { objectList.addAll(Arrays.asList(event.getDownloadedObjects())); } }; };
public static DownloadObjectsEvent newErrorEvent(Throwable t, Object uniqueOperationId) { DownloadObjectsEvent event = new DownloadObjectsEvent(EVENT_ERROR, uniqueOperationId); event.setErrorCause(t); return event; }
public static DownloadObjectsEvent newStartedEvent(ThreadWatcher threadWatcher, Object uniqueOperationId) { DownloadObjectsEvent event = new DownloadObjectsEvent(EVENT_STARTED, uniqueOperationId); event.setThreadWatcher(threadWatcher); return event; }
public static DownloadObjectsEvent newIgnoredErrorsEvent(ThreadWatcher threadWatcher, Throwable[] ignoredErrors, Object uniqueOperationId) { DownloadObjectsEvent event = new DownloadObjectsEvent(EVENT_IGNORED_ERRORS, uniqueOperationId); event.setIgnoredErrors(ignoredErrors); return event; }