Package org.opencms.ade.upload
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
FieldsModifier and TypeFieldDescriptionprotected long
The content length of the request (larger than the sum of file sizes).protected RuntimeException
Stores the exception if one has been occurred.protected boolean
Signals that there occurred an exception before. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.getId()
Returns the listeners UUID.getInfo()
Returns the current progress info of the upload.int
getItem()
Returns the number of the field, which is currently being read.long
Returns the percent done of the current upload.boolean
Returnstrue
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.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.
-
Field Details
-
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
Signals that there occurred an exception before.
-
-
Constructor Details
-
CmsUploadListener
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
Returns the bytes transfered so far.- Returns:
- the bytes transfered so far
-
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
Returns the listeners UUID.- Returns:
- the listeners UUID
-
getInfo
Returns the current progress info of the upload.- Returns:
- the progress info
-
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
Returns the percent done of the current upload.- Returns:
- the percent done of the current upload
-
isCanceled
Returnstrue
if the process has been canceled due to an error or by the user.- Returns:
- boolean
true
if the process has been canceled due to an error or by the user
-
isFinished
Returns the finished.- Returns:
- the finished
-
setDelay
Sets the delay.- Parameters:
delay
- the delay to set
-
setFinished
Sets the finished.- Parameters:
finished
- the finished to set
-
toString
-
update
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 interfaceorg.apache.commons.fileupload.ProgressListener
- See Also:
-
ProgressListener.update(long, long, int)
-