Package org.ametys.plugins.core.upload
Class UploadAction
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,ThreadSafe
,Action
- Direct Known Subclasses:
CropImageAction
,UploadAction
Action
for uploading a file and store it using the UploadManager
.-
Field Summary
Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Do upload the file and fill the result map.protected void
_fillSuccess
(Upload upload, Map<String, Object> result) Fill the result map.protected Part
Gets thePart
object which is trying to be uploadedprotected String
_getUrlForDownload
(Upload upload) Get the url for download the uploaded fileprotected String
_getUrlForView
(Upload upload) Get the url for view the uploaded fileprotected void
_handleStoreUploadException
(IOException e, Object obj, Map<String, Object> result) Handles a store upload exception by filling the result map with information about the exception.protected void
Lookup components (lazy initialize)protected void
_storeUpload
(InputStream is, String filename, Map<String, Object> result) Stores the given upload data (as anInputStream
) into theUploadManager
system and fill the result map.act
(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) Methods inherited from class org.ametys.core.util.cocoon.AbstractCurrentUserProviderServiceableAction
_getCurrentUser
Methods inherited from class org.apache.cocoon.acting.ServiceableAction
service
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_uploadManager
The Upload Manager
-
-
Constructor Details
-
UploadAction
public UploadAction()
-
-
Method Details
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception - Throws:
Exception
-
_lookupComponents
Lookup components (lazy initialize)- Throws:
ServiceException
- If some components cannot be looked up
-
_doUpload
protected void _doUpload(Request request, Parameters parameters, Map<String, Object> result) throws ExceptionDo upload the file and fill the result map.- Parameters:
request
- The requestparameters
- The parametersresult
- The result map to fill- Throws:
Exception
- if an error occurs.
-
_getPart
Gets thePart
object which is trying to be uploaded -
_storeUpload
protected void _storeUpload(InputStream is, String filename, Map<String, Object> result) throws IOExceptionStores the given upload data (as anInputStream
) into theUploadManager
system and fill the result map.- Parameters:
is
- The upload datafilename
- The file nameresult
- The result map to fill- Throws:
IOException
- if an I/O error occurs
-
_fillSuccess
Fill the result map.- Parameters:
upload
- The uploadresult
- The result map to fill
-
_handleStoreUploadException
Handles a store upload exception by filling the result map with information about the exception.- Parameters:
e
- The exceptionobj
- The object representing the upload data (for logging purpose)result
- The result map to fill
-
_getUrlForView
Get the url for view the uploaded file- Parameters:
upload
- The file uploaded- Returns:
- The url for view
-
_getUrlForDownload
Get the url for download the uploaded file- Parameters:
upload
- The file uploaded- Returns:
- The url for view
-