Class FSUploadManager
- java.lang.Object
-
- java.util.TimerTask
-
- org.ametys.plugins.core.impl.upload.FSUploadManager
-
- All Implemented Interfaces:
Runnable
,UploadManager
,Disposable
,Initializable
,Contextualizable
,LogEnabled
,ThreadSafe
public class FSUploadManager extends TimerTask implements UploadManager, ThreadSafe, Initializable, Contextualizable, LogEnabled, Disposable
UploadManager
which stores uploaded files into theuploads-user
directory located in Ametys homeNote that this implementation is not cluster safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
FSUploadManager.FSUpload
Upload
implementation on file system.
-
Field Summary
Fields Modifier and Type Field Description protected Context
_context
Context.protected File
_globalUploadsDir
Global uploads directory.private Logger
_logger
Logger available to subclasses.protected Timer
_timer
Timer.static String
UPLOADS_DIRECTORY
The path to the global uploads directory relative to ametys home-
Fields inherited from interface org.ametys.core.upload.UploadManager
ROLE
-
-
Constructor Summary
Constructors Constructor Description FSUploadManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected File
_getUploadDir(String login, String id)
Retrieves the upload directory for a login and an upload id.void
contextualize(Context context)
void
dispose()
void
enableLogging(Logger logger)
Upload
getUpload(UserIdentity user, String id)
Retrieves a previous file uploaded by an user.void
initialize()
void
run()
Upload
storeUpload(UserIdentity user, String filename, InputStream is)
Stores a file uploaded by an user.-
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
-
-
-
Field Detail
-
UPLOADS_DIRECTORY
public static final String UPLOADS_DIRECTORY
The path to the global uploads directory relative to ametys home- See Also:
- Constant Field Values
-
_globalUploadsDir
protected File _globalUploadsDir
Global uploads directory.
-
-
Constructor Detail
-
FSUploadManager
public FSUploadManager()
-
-
Method Detail
-
enableLogging
public void enableLogging(Logger logger)
- Specified by:
enableLogging
in interfaceLogEnabled
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
storeUpload
public Upload storeUpload(UserIdentity user, String filename, InputStream is) throws IOException
Description copied from interface:UploadManager
Stores a file uploaded by an user.- Specified by:
storeUpload
in interfaceUploadManager
- Parameters:
user
- the user.filename
- the upload filename.is
- the upload data.- Returns:
- the upload.
- Throws:
IOException
- if an error occurs.
-
getUpload
public Upload getUpload(UserIdentity user, String id) throws NoSuchElementException
Description copied from interface:UploadManager
Retrieves a previous file uploaded by an user.- Specified by:
getUpload
in interfaceUploadManager
- Parameters:
user
- the user.id
- the upload id.- Returns:
- the upload.
- Throws:
NoSuchElementException
- if there is no upload for this parameters.
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceDisposable
-
_getUploadDir
protected File _getUploadDir(String login, String id)
Retrieves the upload directory for a login and an upload id.- Parameters:
login
- the login.id
- the upload id.- Returns:
- the upload directory.
-
-