Package io.guise.framework.platform
Class PlatformFileUploadTask
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- io.guise.framework.event.GuiseBoundPropertyObject
-
- io.guise.framework.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
-
-
Constructor Summary
Constructors Constructor Description PlatformFileUploadTask(java.lang.Iterable<PlatformFile> platformFiles, java.net.URI destinationBaseURI, Bookmark destinationBookmark)
Platform files, destination URI, and destination bookmark constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 io.guise.framework.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
-
-
-
-
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, ornull
if there is no bookmark specified.- Throws:
java.lang.NullPointerException
- if the given list of platform files and/or destination URI isnull
.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 interfacecom.globalmentor.model.Task
-
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, ornull
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 tofireProgressed(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.
-
-