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
  • 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

    Constructors
    Constructor
    Description
    PlatformFileUploadTask(Iterable<PlatformFile> platformFiles, URI destinationBaseURI, Bookmark destinationBookmark)
    Platform files, destination URI, and destination bookmark constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a progress listener.
    void
    Cancels the task.
    protected void
    Fires a progress event to all registered progress listeners with the current .
    protected void
    Fires a given progress event to all registered progress listeners.
    final long
     
     
     
    protected com.globalmentor.event.EventListenerManager
     
    protected PlatformFile
     
     
    long
     
    com.globalmentor.model.TaskState
     
    protected void
    Initializes and begins an upload for the current platform file.
    void
    Removes an progress listener.
    protected void
    setState(com.globalmentor.model.TaskState newState)
    Updates the state of the task.
    void
    Starts the task.
    protected void
    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

    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 Details

    • PlatformFileUploadTask

      public PlatformFileUploadTask(Iterable<PlatformFile> platformFiles, 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:
      NullPointerException - if the given list of platform files and/or destination URI is null.
      IllegalArgumentException - if the provided URI is not a collection URI.
      IllegalArgumentException - if the provided URI specifies a query and/or fragment.
  • Method Details

    • getEventListenerManager

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

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

      public 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
    • 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<Long> progressListener)
      Adds a progress listener.
      Parameters:
      progressListener - The progress listener to add.
    • removeProgressListener

      public void removeProgressListener(ProgressListener<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 fireProgressed(ProgressEvent).
      See Also:
    • fireProgressed

      protected void fireProgressed(ProgressEvent<Long> progressEvent)
      Fires a given progress event to all registered progress listeners.
      Parameters:
      progressEvent - The progress event to fire.