com.guiseframework.platform
Class PlatformFileUploadTask

java.lang.Object
  extended by com.globalmentor.beans.BoundPropertyObject
      extended by com.guiseframework.event.GuiseBoundPropertyObject
          extended by com.guiseframework.platform.PlatformFileUploadTask
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, com.globalmentor.model.Task

public class PlatformFileUploadTask
extends GuiseBoundPropertyObject
implements com.globalmentor.model.Task

A task to upload a series of files from the platform. The files are uploaded sequentially. This task fires progress events indicating the overall bytes transferred out of the total bytes to transfer. The task state indicates the state of the overall transfer, not each individual transfer.

Author:
Garret Wilson

Field Summary
 
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
 
Fields inherited from interface com.globalmentor.model.Task
STATE_PROPERTY
 
Constructor Summary
PlatformFileUploadTask(java.lang.Iterable<PlatformFile> platformFiles, java.net.URI destinationBaseURI, Bookmark destinationBookmark)
          Platform files, destination URI, and destination bookmark constructor.
 
Method Summary
 void addProgressListener(ProgressListener<java.lang.Long> progressListener)
          Adds a progress listener.
 void cancel()
          Cancels the task.
protected  void fireProgressed()
          Fires a progress event to all registered progress listeners with the current .
protected  void fireProgressed(ProgressEvent<java.lang.Long> progressEvent)
          Fires a given progress event to all registered progress listeners.
 long getCompletion()
           
 java.net.URI getDestinationBaseURI()
           
 Bookmark getDestinationBookmark()
           
protected  com.globalmentor.event.EventListenerManager getEventListenerManager()
           
protected  PlatformFile getPlatformFile()
           
 java.util.List<PlatformFile> getPlatformFiles()
           
 long getProgress()
           
 com.globalmentor.model.TaskState getState()
           
protected  void initializeUpload()
          Initializes and begins an upload for the current platform file.
 void removeProgressListener(ProgressListener<java.lang.Long> progressListener)
          Removes an progress listener.
protected  void setState(com.globalmentor.model.TaskState newState)
          Updates the state of the task.
 void start()
          Starts the task.
protected  void uninitializeUpload()
          Cleans up after an upload for the current platform file.
 
Methods inherited from class com.guiseframework.event.GuiseBoundPropertyObject
getSession
 
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface com.globalmentor.beans.PropertyConstrainable
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, hasVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
 

Constructor Detail

PlatformFileUploadTask

public PlatformFileUploadTask(java.lang.Iterable<PlatformFile> platformFiles,
                              java.net.URI destinationBaseURI,
                              Bookmark destinationBookmark)
Platform files, destination URI, and destination bookmark constructor.

Parameters:
platformFiles - The platform files to upload.
destinationBaseURI - The collection URI representing the base destination of the platform files, either absolute or relative to the application.
destinationBookmark - The bookmark to be used in sending resources to the destination URI, or null if there is no bookmark specified.
Throws:
java.lang.NullPointerException - if the given list of platform files and/or destination URI is null.
java.lang.IllegalArgumentException - if the provided URI is not a collection URI.
java.lang.IllegalArgumentException - if the provided URI specifies a query and/or fragment.
Method Detail

getEventListenerManager

protected com.globalmentor.event.EventListenerManager getEventListenerManager()
Returns:
The object managing event listeners.

getPlatformFiles

public java.util.List<PlatformFile> getPlatformFiles()
Returns:
The platform files to upload.

getDestinationBaseURI

public java.net.URI getDestinationBaseURI()
Returns:
The collection URI representing the base destination of the platform files, either absolute or relative to the application, or null if the destination URI has not yet been set.

getDestinationBookmark

public Bookmark getDestinationBookmark()
Returns:
The bookmark to be used in sending resources to the destination URI, or null if there is no bookmark specified.

getState

public com.globalmentor.model.TaskState getState()
Specified by:
getState in interface com.globalmentor.model.Task
Returns:
The state of the task, or null if the task has not been started.

setState

protected void setState(com.globalmentor.model.TaskState newState)
Updates the state of the task. This is a bound property.

Parameters:
newState - The new state of the task, or null if the task has not been started.
See Also:
Task.STATE_PROPERTY

getProgress

public long getProgress()
Returns:
The total progress.

getCompletion

public final long getCompletion()
Returns:
The total number of bytes to transfer.

getPlatformFile

protected PlatformFile getPlatformFile()
Returns:
The platform file currently being uploaded, or null if no platform file is currently being uploaded.

start

public void start()
Starts the task. If the task has already been started no action occurs.


cancel

public void cancel()
Cancels the task. If the task is not progressing, no action occurs.


initializeUpload

protected void initializeUpload()
Initializes and begins an upload for the current platform file. The current progress and completion are set to zero, a listener is installed for the given platform file, and the upload is initiated.


uninitializeUpload

protected void uninitializeUpload()
Cleans up after an upload for the current platform file. The last progress is updated with the current completion amount for the current file.


addProgressListener

public void addProgressListener(ProgressListener<java.lang.Long> progressListener)
Adds a progress listener.

Parameters:
progressListener - The progress listener to add.

removeProgressListener

public void removeProgressListener(ProgressListener<java.lang.Long> progressListener)
Removes an progress listener.

Parameters:
progressListener - The progress listener to remove.

fireProgressed

protected void fireProgressed()
Fires a progress event to all registered progress listeners with the current . This method delegates to #fireProgessed(ProgressEvent).

See Also:
ProgressListener, ProgressEvent

fireProgressed

protected void fireProgressed(ProgressEvent<java.lang.Long> progressEvent)
Fires a given progress event to all registered progress listeners.

Parameters:
progressEvent - The progress event to fire.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.