Package org.ametys.plugins.core.upload
Class UploadAction
-
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,ThreadSafe
,Action
- Direct Known Subclasses:
CropImageAction
,UploadAction
public class UploadAction extends AbstractCurrentUserProviderServiceableAction
Action
for uploading a file and store it using theUploadManager
.
-
-
Field Summary
Fields Modifier and Type Field Description protected UploadManager
_uploadManager
The Upload Manager-
Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
-
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
-
Constructor Summary
Constructors Constructor Description UploadAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_doUpload(Request request, Parameters parameters, Map<String,Object> result)
Do upload the file and fill the result map.protected void
_fillSuccess(Upload upload, Map<String,Object> result)
Fill the result map.protected Part
_getPart(Request request)
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
_lookupComponents()
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.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 Detail
-
_uploadManager
protected UploadManager _uploadManager
The Upload Manager
-
-
Constructor Detail
-
UploadAction
public UploadAction()
-
-
Method Detail
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception
- Throws:
Exception
-
_lookupComponents
protected void _lookupComponents() throws ServiceException
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 Exception
Do 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
protected Part _getPart(Request request) throws Exception
Gets thePart
object which is trying to be uploaded
-
_storeUpload
protected void _storeUpload(InputStream is, String filename, Map<String,Object> result) throws IOException
Stores 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
protected void _fillSuccess(Upload upload, Map<String,Object> result)
Fill the result map.- Parameters:
upload
- The uploadresult
- The result map to fill
-
_handleStoreUploadException
protected 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.- Parameters:
e
- The exceptionobj
- The object representing the upload data (for logging purpose)result
- The result map to fill
-
_getUrlForView
protected String _getUrlForView(Upload upload)
Get the url for view the uploaded file- Parameters:
upload
- The file uploaded- Returns:
- The url for view
-
_getUrlForDownload
protected String _getUrlForDownload(Upload upload)
Get the url for download the uploaded file- Parameters:
upload
- The file uploaded- Returns:
- The url for view
-
-