org.olat.core.commons.modules.bc
Class FileUploadController

java.lang.Object
  extended by org.olat.core.gui.control.DefaultController
      extended by org.olat.core.gui.control.controller.BasicController
          extended by org.olat.core.gui.components.form.flexible.impl.FormBasicController
              extended by org.olat.core.commons.modules.bc.FileUploadController
All Implemented Interfaces:
Controller, ControllerEventListener, Disposable

public class FileUploadController
extends FormBasicController

Description

This controller offers a file upload in a dedicated form. It can be configured with an upload limit, a limitation to mime types as allowed upload types and if the path to the target directory should be displayed in the form.

Events fired by this controller

Initial Date: August 15, 2005

Author:
Alexander Schneider, Florian Gnägi

Field Summary
 
Fields inherited from class org.olat.core.gui.components.form.flexible.impl.FormBasicController
LAYOUT_CUSTOM, LAYOUT_DEFAULT, LAYOUT_HORIZONTAL, LAYOUT_VERTICAL
 
Constructor Summary
FileUploadController(WindowControl wControl, VFSContainer curContainer, UserRequest ureq, int upLimitKB, int remainingQuotKB, java.util.Set<java.lang.String> mimeTypesRestriction, boolean showTargetPath)
           
FileUploadController(WindowControl wControl, VFSContainer curContainer, UserRequest ureq, int upLimitKB, int remainingQuotKB, java.util.Set<java.lang.String> mimeTypesRestriction, boolean showTargetPath, boolean showMetadata)
           
 
Method Summary
 void event(UserRequest ureq, Controller source, Event event)
          the only method of the interface controllereventlistener.
 java.lang.String getNewFileName()
           
 int getStatus()
           
 void hideTitleAndFieldset()
          Call this to remove the fieldset and title from the form rendering.
 boolean isExistingFileOverwritten()
           
 void reset()
          Reset the upload controller
 void setMaxUploadSizeKB(int uploadLimitKB)
          Set the max upload limit.
 void setUploadRelPath(java.lang.String uploadRelPath)
          Set the relative path within the rootDir where uploaded files should be put into.
 
Methods inherited from class org.olat.core.gui.components.form.flexible.impl.FormBasicController
dispose, event
 
Methods inherited from class org.olat.core.gui.control.DefaultController
addControllerListener, addLoggingResourceable, dispatchEvent, dispatchEvent, getControllerCount, getInitialComponent, getUserActivityLogger, getWindowControlForDebug, isDisposed, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileUploadController

public FileUploadController(WindowControl wControl,
                            VFSContainer curContainer,
                            UserRequest ureq,
                            int upLimitKB,
                            int remainingQuotKB,
                            java.util.Set<java.lang.String> mimeTypesRestriction,
                            boolean showTargetPath)
Parameters:
wControl -
curContainer - Path to the upload directory. Used to check for existing files with same name and for displaying the optional targetPath
ureq -
upLimitKB - the max upload file size in kBytes (e.g. 10*1024*1024 for 10MB)
remainingQuotKB - the available space left for file upload kBytes (e.g. 10*1024*1024 for 10MB). Quota.UNLIMITED for no limitation, 0 for no more space left
mimeTypes - Set of supported mime types (image/*, image/jpg) or NULL if no restriction should be applied.
showTargetPath - true: show the relative path where the file will be uploaded to; false: show no path

FileUploadController

public FileUploadController(WindowControl wControl,
                            VFSContainer curContainer,
                            UserRequest ureq,
                            int upLimitKB,
                            int remainingQuotKB,
                            java.util.Set<java.lang.String> mimeTypesRestriction,
                            boolean showTargetPath,
                            boolean showMetadata)
Parameters:
wControl -
curContainer -
ureq -
upLimitKB -
remainingQuotKB -
mimeTypesRestriction -
showTargetPath -
showMetadata - Display the meta data sub form
Method Detail

event

public void event(UserRequest ureq,
                  Controller source,
                  Event event)
Description copied from class: DefaultController
the only method of the interface controllereventlistener. always gets called when a controller we 'subscribed' to fires an event. we provide a default implementation here since there are many controllers which are standalone and need no subcontrollers

See Also:
DefaultController.event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)

getStatus

public int getStatus()
Returns:
The upload status

isExistingFileOverwritten

public boolean isExistingFileOverwritten()
Returns:
true: an existing file has benn overwritten; false: no file with same name existed or new file has been renamed

setMaxUploadSizeKB

public void setMaxUploadSizeKB(int uploadLimitKB)
Set the max upload limit.

Parameters:
uploadLimitKB -

reset

public void reset()
Reset the upload controller


hideTitleAndFieldset

public void hideTitleAndFieldset()
Call this to remove the fieldset and title from the form rendering. This can not be reverted. Default is to show the upload title and fieldset, after calling this function no more title will be shown.


setUploadRelPath

public void setUploadRelPath(java.lang.String uploadRelPath)
Set the relative path within the rootDir where uploaded files should be put into. If NULL, the root Dir is used

Parameters:
uploadRelPath -

getNewFileName

public java.lang.String getNewFileName()