fr.paris.lutece.plugins.directory.service.upload
Class DirectoryAsynchronousUploadHandler

java.lang.Object
  extended by fr.paris.lutece.plugins.directory.service.upload.DirectoryAsynchronousUploadHandler
All Implemented Interfaces:
fr.paris.lutece.portal.web.upload.IAsynchronousUploadHandler

public class DirectoryAsynchronousUploadHandler
extends java.lang.Object
implements fr.paris.lutece.portal.web.upload.IAsynchronousUploadHandler

Handler for asynchronous uploads. Files are stored using SubForm#addFileItem(String, String, FileItem). The jessionid parameter should be the REAL session id, not the flash player one. The uploaded files are deleted by SubForm when filling fields.


Field Summary
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<org.apache.commons.fileupload.FileItem>>> _mapAsynchronousUpload
          >
 
Method Summary
 void addFileItemToUploadedFile(org.apache.commons.fileupload.FileItem fileItem, java.lang.String strIdEntry, javax.servlet.http.HttpSession session)
          Add file item to the list of uploaded files
 java.lang.String buildFieldName(java.lang.String strIdEntry)
          Build the field name from a given id entry i.e. : directory_1
 org.apache.commons.fileupload.FileItem doDownloadFile(java.lang.String strUrl)
          Do download the file
 void doDownloadFile(java.lang.String strUrl, java.lang.String strFilePath)
          Do download the file
 void doRemoveFile(RecordField recordField, IEntry entry, java.lang.String strWSRestUrl)
          Do remove a file from a given record field
 void doRemoveFile(Record record, IEntry entry, java.lang.String strWSRestUrl)
          Do remove a file from a given record and entry
 void doUploadAction(javax.servlet.http.HttpServletRequest request, java.lang.String strUploadAction, java.util.Map<java.lang.String,java.util.List<RecordField>> map, Record record, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Performs an upload action.
 java.lang.String doUploadFile(java.lang.String strBaseUrl, org.apache.commons.fileupload.FileItem fileItem, java.lang.String strBlobStore)
          Do upload a file in the blobstore webapp
 java.util.List<org.apache.commons.fileupload.FileItem> getFileItems(java.lang.String strIdEntry, java.lang.String strSessionId)
          Gets the fileItem for the entry and the given session.
 java.lang.String getFileName(java.lang.String strUrl)
          Get the file name from a given url
 java.lang.String getFileUrl(java.lang.String strBaseUrl, java.lang.String strBlobKey, java.lang.String strBlobStore)
          Get the file url
static DirectoryAsynchronousUploadHandler getHandler()
          Get the handler
 java.lang.String getUploadAction(javax.servlet.http.HttpServletRequest request)
          Checks the request parameters to see if an upload submit has been called.
 boolean isBlobStoreClientServiceAvailable()
          Check if the service is available
 boolean isInvoked(javax.servlet.http.HttpServletRequest request)
          
 void process(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, net.sf.json.JSONObject mainObject, java.util.List<org.apache.commons.fileupload.FileItem> listFileItemsToUpload)
          
 void reinitMap(javax.servlet.http.HttpServletRequest request, java.util.Map<java.lang.String,java.util.List<RecordField>> map, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Reinit the map with the default files stored in database and blobstore
 void removeFileItem(java.lang.String strIdEntry, java.lang.String strSessionId, int nIndex)
          Removes the file from the list.
 void removeSessionFiles(java.lang.String strSessionId)
          Removes all files associated to the session
 void setBlobStoreClientService(fr.paris.lutece.portal.service.blobstore.IBlobStoreClientService blobStoreClientService)
          Set the blobstore client service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_mapAsynchronousUpload

public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<org.apache.commons.fileupload.FileItem>>> _mapAsynchronousUpload
>

Method Detail

getHandler

public static DirectoryAsynchronousUploadHandler getHandler()
Get the handler

Returns:
the handler

setBlobStoreClientService

public void setBlobStoreClientService(fr.paris.lutece.portal.service.blobstore.IBlobStoreClientService blobStoreClientService)
Set the blobstore client service

Parameters:
blobStoreClientService - the blob store client service

isInvoked

public boolean isInvoked(javax.servlet.http.HttpServletRequest request)

Specified by:
isInvoked in interface fr.paris.lutece.portal.web.upload.IAsynchronousUploadHandler

isBlobStoreClientServiceAvailable

public boolean isBlobStoreClientServiceAvailable()
Check if the service is available

Returns:
true if the service is available, false otherwise

process

public void process(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response,
                    net.sf.json.JSONObject mainObject,
                    java.util.List<org.apache.commons.fileupload.FileItem> listFileItemsToUpload)

Specified by:
process in interface fr.paris.lutece.portal.web.upload.IAsynchronousUploadHandler

doUploadFile

public java.lang.String doUploadFile(java.lang.String strBaseUrl,
                                     org.apache.commons.fileupload.FileItem fileItem,
                                     java.lang.String strBlobStore)
                              throws fr.paris.lutece.portal.service.blobstore.BlobStoreClientException
Do upload a file in the blobstore webapp

Parameters:
strBaseUrl - the base url
fileItem - the file
strBlobStore - the blobstore service name
Returns:
the blob key of the uploaded file
Throws:
fr.paris.lutece.portal.service.blobstore.BlobStoreClientException - Exception if there is an issue

doRemoveFile

public void doRemoveFile(Record record,
                         IEntry entry,
                         java.lang.String strWSRestUrl)
                  throws fr.paris.lutece.portal.service.blobstore.BlobStoreClientException
Do remove a file from a given record and entry

Parameters:
record - the record
entry - the entry
strWSRestUrl - the url of the WS rest
Throws:
fr.paris.lutece.portal.service.blobstore.BlobStoreClientException - Exception if there is an issue

doRemoveFile

public void doRemoveFile(RecordField recordField,
                         IEntry entry,
                         java.lang.String strWSRestUrl)
                  throws fr.paris.lutece.portal.service.blobstore.BlobStoreClientException
Do remove a file from a given record field

Parameters:
recordField - the record field
entry - the entry
strWSRestUrl - the url of the WS rest
Throws:
fr.paris.lutece.portal.service.blobstore.BlobStoreClientException - Exception if there is an issue

getFileUrl

public java.lang.String getFileUrl(java.lang.String strBaseUrl,
                                   java.lang.String strBlobKey,
                                   java.lang.String strBlobStore)
                            throws fr.paris.lutece.portal.service.blobstore.BlobStoreClientException
Get the file url

Parameters:
strBaseUrl - the base url
strBlobKey - the blob key
strBlobStore - the blobstore service name
Returns:
the file url
Throws:
fr.paris.lutece.portal.service.blobstore.BlobStoreClientException - Exception if there is an issue

getFileName

public java.lang.String getFileName(java.lang.String strUrl)
                             throws fr.paris.lutece.portal.service.blobstore.BlobStoreClientException
Get the file name from a given url

Parameters:
strUrl - the url
Returns:
the file name
Throws:
fr.paris.lutece.portal.service.blobstore.BlobStoreClientException - Exception if there is an issue

doDownloadFile

public void doDownloadFile(java.lang.String strUrl,
                           java.lang.String strFilePath)
                    throws fr.paris.lutece.portal.service.blobstore.BlobStoreClientException
Do download the file

Parameters:
strUrl - the file of the file to download
strFilePath - the file path to download
Throws:
fr.paris.lutece.portal.service.blobstore.BlobStoreClientException - exception if there is an error

doDownloadFile

public org.apache.commons.fileupload.FileItem doDownloadFile(java.lang.String strUrl)
                                                      throws fr.paris.lutece.portal.service.blobstore.BlobStoreClientException
Do download the file

Parameters:
strUrl - the file of the file to download
Returns:
a FileItem
Throws:
fr.paris.lutece.portal.service.blobstore.BlobStoreClientException - exception if there is an error

getFileItems

public java.util.List<org.apache.commons.fileupload.FileItem> getFileItems(java.lang.String strIdEntry,
                                                                           java.lang.String strSessionId)
Gets the fileItem for the entry and the given session.

Parameters:
strIdEntry - the entry
strSessionId - the session id
Returns:
the fileItem found, null otherwise.

removeFileItem

public void removeFileItem(java.lang.String strIdEntry,
                           java.lang.String strSessionId,
                           int nIndex)
Removes the file from the list.

Parameters:
strIdEntry - the entry id
strSessionId - the session id

removeSessionFiles

public void removeSessionFiles(java.lang.String strSessionId)
Removes all files associated to the session

Parameters:
strSessionId - the session id

addFileItemToUploadedFile

public void addFileItemToUploadedFile(org.apache.commons.fileupload.FileItem fileItem,
                                      java.lang.String strIdEntry,
                                      javax.servlet.http.HttpSession session)
Add file item to the list of uploaded files

Parameters:
fileItem - the file item
strIdEntry - the id entry
session - the session

buildFieldName

public java.lang.String buildFieldName(java.lang.String strIdEntry)
Build the field name from a given id entry i.e. : directory_1

Parameters:
strIdEntry - the id entry
Returns:
the field name

getUploadAction

public java.lang.String getUploadAction(javax.servlet.http.HttpServletRequest request)
Checks the request parameters to see if an upload submit has been called.

Parameters:
request - the HTTP request
Returns:
the name of the upload action, if any. Null otherwise.

doUploadAction

public void doUploadAction(javax.servlet.http.HttpServletRequest request,
                           java.lang.String strUploadAction,
                           java.util.Map<java.lang.String,java.util.List<RecordField>> map,
                           Record record,
                           fr.paris.lutece.portal.service.plugin.Plugin plugin)
                    throws DirectoryErrorException
Performs an upload action.

Parameters:
request - the HTTP request
strUploadAction - the name of the upload action
map - the map of
plugin - the plugin
Throws:
DirectoryErrorException - exception if there is an error

reinitMap

public void reinitMap(javax.servlet.http.HttpServletRequest request,
                      java.util.Map<java.lang.String,java.util.List<RecordField>> map,
                      fr.paris.lutece.portal.service.plugin.Plugin plugin)
Reinit the map with the default files stored in database and blobstore

Parameters:
request - the HTTP request
map - the map
plugin - the plugin


Copyright © 2012 Mairie de Paris. All Rights Reserved.