Class CmsUploadListener

  • All Implemented Interfaces:
    java.io.Serializable, org.apache.commons.fileupload.ProgressListener

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

    Since:
    8.0.0
    See Also:
    Serialized Form
    • Field Summary

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

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancelUpload​(CmsUploadException e)
      Sets the exception that should cancel the upload on the next update.
      long getBytesRead()
      Returns the bytes transfered so far.
      long getContentLength()
      Returns the content length of the request (larger than the sum of file sizes).
      java.lang.RuntimeException getException()
      Returns the exception.
      CmsUUID getId()
      Returns the listeners UUID.
      CmsUploadProgessInfo getInfo()
      Returns the current progress info of the upload.
      int getItem()
      Returns the number of the field, which is currently being read.
      long getPercent()
      Returns the percent done of the current upload.
      boolean isCanceled()
      Returns true if the process has been canceled due to an error or by the user.
      boolean isFinished()
      Returns the finished.
      void setDelay​(int delay)
      Sets the delay.
      void setFinished​(boolean finished)
      Sets the finished.
      java.lang.String toString()  
      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 Detail

      • m_contentLength

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

        protected java.lang.RuntimeException m_exception
        Stores the exception if one has been occurred.
      • m_exceptionTrhown

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

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

      • cancelUpload

        public void cancelUpload​(CmsUploadException e)
        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

        public java.lang.RuntimeException getException()
        Returns the exception.

        Returns:
        the exception
      • getId

        public CmsUUID getId()
        Returns the listeners UUID.

        Returns:
        the listeners UUID
      • 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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • 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)