Class CmsUploadListener

java.lang.Object
org.opencms.ade.upload.CmsUploadListener
All Implemented Interfaces:
Serializable, org.apache.commons.fileupload.ProgressListener

public class CmsUploadListener extends Object implements org.apache.commons.fileupload.ProgressListener, Serializable
Provides the upload listener for the upload widget.

Since:
8.0.0
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
    The content length of the request (larger than the sum of file sizes).
    Stores the exception if one has been occurred.
    protected boolean
    Signals that there occurred an exception before.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CmsUploadListener(int requestSize)
    The public constructor for the listener.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Sets the exception that should cancel the upload on the next update.
    long
    Returns the bytes transfered so far.
    long
    Returns the content length of the request (larger than the sum of file sizes).
    Returns the exception.
    Returns the listeners UUID.
    Returns the current progress info of the upload.
    int
    Returns the number of the field, which is currently being read.
    long
    Returns the percent done of the current upload.
    boolean
    Returns true if the process has been canceled due to an error or by the user.
    boolean
    Returns the finished.
    void
    setDelay(int delay)
    Sets the delay.
    void
    setFinished(boolean finished)
    Sets the finished.
     
    void
    update(long done, long total, int item)
    Updates the listeners status information and does the following steps: returns if there was already thrown an exception before sets the local variables to the current upload state throws an RuntimeException if it was set in the meanwhile (by another request e.g.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • m_contentLength

      protected long m_contentLength
      The content length of the request (larger than the sum of file sizes).
    • m_exception

      Stores the exception if one has been occurred.
    • m_exceptionTrhown

      protected boolean m_exceptionTrhown
      Signals that there occurred an exception before.
  • Constructor Details

    • CmsUploadListener

      public CmsUploadListener(int requestSize)
      The public constructor for the listener.

      Parameters:
      requestSize - content length of the request (larger than the sum of file sizes)
  • Method Details

    • cancelUpload

      Sets the exception that should cancel the upload on the next update.

      Parameters:
      e - the exception
    • getBytesRead

      public long getBytesRead()
      Returns the bytes transfered so far.

      Returns:
      the bytes transfered so far
    • getContentLength

      public long getContentLength()
      Returns the content length of the request (larger than the sum of file sizes).

      Returns:
      the content length of the request (larger than the sum of file sizes)
    • getException

      Returns the exception.

      Returns:
      the exception
    • getId

      public CmsUUID getId()
      Returns the listeners UUID.

      Returns:
      the listeners UUID
    • getInfo

      Returns the current progress info of the upload.

      Returns:
      the progress info
    • getItem

      public int getItem()
      Returns the number of the field, which is currently being read.

      • 0 = no item so far
      • 1 = first item is being read, ...
      Returns:
      the number of the field, which is currently being read.
    • getPercent

      public long getPercent()
      Returns the percent done of the current upload.

      Returns:
      the percent done of the current upload
    • isCanceled

      public boolean isCanceled()
      Returns true if the process has been canceled due to an error or by the user.

      Returns:
      booleantrue if the process has been canceled due to an error or by the user
    • isFinished

      public boolean isFinished()
      Returns the finished.

      Returns:
      the finished
    • setDelay

      public void setDelay(int delay)
      Sets the delay.

      Parameters:
      delay - the delay to set
    • setFinished

      public void setFinished(boolean finished)
      Sets the finished.

      Parameters:
      finished - the finished to set
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • update

      public void update(long done, long total, int item)
      Updates the listeners status information and does the following steps:
      • returns if there was already thrown an exception before
      • sets the local variables to the current upload state
      • throws an RuntimeException if it was set in the meanwhile (by another request e.g. user has canceled)
      • slows down the upload process if it's configured
      • stops the watcher if the upload has reached more than 100 percent
      Specified by:
      update in interface org.apache.commons.fileupload.ProgressListener
      See Also:
      • ProgressListener.update(long, long, int)