Class LocalDatabaseFileService
- java.lang.Object
-
- fr.paris.lutece.portal.service.file.implementation.LocalDatabaseFileService
-
- All Implemented Interfaces:
IFileStoreServiceProvider,Serializable
public class LocalDatabaseFileService extends Object implements IFileStoreServiceProvider
DatabaseBlobStoreService.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LocalDatabaseFileService(IFileDownloadUrlService _fileDownloadUrlService, IFileRBACService _fileRBACService)init
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckAccessRights(Map<String,String> fileData, fr.paris.lutece.api.user.User user)check if current user can access the filevoidcheckLinkValidity(Map<String,String> fileData)check if link is validvoiddelete(String strKey)Delete a blobIFileDownloadUrlServicegetDownloadUrlService()Get the downloadServiceFilegetFile(String strKey)Get a fileFilegetFile(String strKey, boolean withPhysicalFile)get file from databaseStringgetFileDownloadUrlBO(String strKey)Gets the file download url for Back Office admin Lutece usersStringgetFileDownloadUrlBO(String strKey, Map<String,String> additionnalData)Gets the file download url for Back Office admin Lutece usersStringgetFileDownloadUrlFO(String strKey)Gets the file download url for Front Office Lutece usersStringgetFileDownloadUrlFO(String strKey, Map<String,String> additionnalData)Gets the file download url for Front Office Lutece usersFilegetFileFromRequestBO(javax.servlet.http.HttpServletRequest request)get requested file from BOFilegetFileFromRequestFO(javax.servlet.http.HttpServletRequest request)get requested file from FOFilegetFileMetaData(String strKey)Get a file object only filled with the meta data (name, size ...) without the physical file contentIFileRBACServicegetFileRBACService()get the FileRBACServiceInputStreamgetInputStream(String strKey)Gets a blob asInputStreamStringgetName()get the service namebooleanisDefault()get the defaultvoidsetDefault(boolean bDefault)voidsetDownloadUrlService(IFileDownloadUrlService downloadUrlService)Sets the downloadServicevoidsetFileRBACService(IFileRBACService fileRBACService)set the FileRBACServicevoidsetName(String strName)StringstoreBytes(byte[] blob)Store a blob from a bytes arrayStringstoreFile(File file)Stores a file Lutece FileStringstoreFileItem(org.apache.commons.fileupload.FileItem fileItem)Stores a org.apache.commons.fileupload.FileItemStringstoreInputStream(InputStream inputStream)Stores an input stream
-
-
-
Constructor Detail
-
LocalDatabaseFileService
public LocalDatabaseFileService(IFileDownloadUrlService _fileDownloadUrlService, IFileRBACService _fileRBACService)
init- Parameters:
_fileDownloadUrlService-_fileRBACService-
-
-
Method Detail
-
getFileRBACService
public IFileRBACService getFileRBACService()
get the FileRBACService- Returns:
- the FileRBACService
-
setFileRBACService
public void setFileRBACService(IFileRBACService fileRBACService)
set the FileRBACService- Parameters:
fileRBACService-
-
getDownloadUrlService
public IFileDownloadUrlService getDownloadUrlService()
Get the downloadService- Returns:
- the downloadService
-
setDownloadUrlService
public void setDownloadUrlService(IFileDownloadUrlService downloadUrlService)
Sets the downloadService- Parameters:
downloadUrlService- downloadService
-
getName
public String getName()
get the service name- Specified by:
getNamein interfaceIFileStoreServiceProvider- Returns:
- the service name
-
delete
public void delete(String strKey)
Delete a blob- Specified by:
deletein interfaceIFileStoreServiceProvider- Parameters:
strKey- The key of the blob
-
getFile
public File getFile(String strKey)
Get a file- Specified by:
getFilein interfaceIFileStoreServiceProvider- Parameters:
strKey- The key of the file- Returns:
- The file
-
getFileMetaData
public File getFileMetaData(String strKey)
Get a file object only filled with the meta data (name, size ...) without the physical file content- Specified by:
getFileMetaDatain interfaceIFileStoreServiceProvider- Parameters:
strKey- The key of the file- Returns:
- The file
-
getFile
public File getFile(String strKey, boolean withPhysicalFile)
get file from database- Parameters:
strKey-withPhysicalFile-- Returns:
- the file with the physical file content if withPhysicalFile is true, null otherwise
-
storeBytes
public String storeBytes(byte[] blob)
Store a blob from a bytes array- Specified by:
storeBytesin interfaceIFileStoreServiceProvider- Parameters:
blob- The blob- Returns:
- The key of the blob
-
storeInputStream
public String storeInputStream(InputStream inputStream)
Stores an input stream- Specified by:
storeInputStreamin interfaceIFileStoreServiceProvider- Parameters:
inputStream- the input stream- Returns:
- The key of the blob
-
storeFileItem
public String storeFileItem(org.apache.commons.fileupload.FileItem fileItem)
Stores a org.apache.commons.fileupload.FileItem- Specified by:
storeFileItemin interfaceIFileStoreServiceProvider- Parameters:
fileItem- the fileItem- Returns:
- The key of the blob
-
storeFile
public String storeFile(File file)
Stores a file Lutece File- Specified by:
storeFilein interfaceIFileStoreServiceProvider- Parameters:
file- the file- Returns:
- The key of the stored file
-
setDefault
public void setDefault(boolean bDefault)
-
setName
public void setName(String strName)
-
isDefault
public boolean isDefault()
get the default- Specified by:
isDefaultin interfaceIFileStoreServiceProvider- Returns:
- true if default
-
getInputStream
public InputStream getInputStream(String strKey)
Gets a blob asInputStream- Specified by:
getInputStreamin interfaceIFileStoreServiceProvider- Parameters:
strKey- the key- Returns:
- the
InputStream
-
getFileDownloadUrlFO
public String getFileDownloadUrlFO(String strKey)
Gets the file download url for Front Office Lutece users- Specified by:
getFileDownloadUrlFOin interfaceIFileStoreServiceProvider- Parameters:
strKey- the- Returns:
- the download link
-
getFileDownloadUrlFO
public String getFileDownloadUrlFO(String strKey, Map<String,String> additionnalData)
Gets the file download url for Front Office Lutece users- Specified by:
getFileDownloadUrlFOin interfaceIFileStoreServiceProvider- Parameters:
strKey- the- Returns:
- the download link
-
getFileDownloadUrlBO
public String getFileDownloadUrlBO(String strKey)
Gets the file download url for Back Office admin Lutece users- Specified by:
getFileDownloadUrlBOin interfaceIFileStoreServiceProvider- Parameters:
strKey- the- Returns:
- the download link
-
getFileDownloadUrlBO
public String getFileDownloadUrlBO(String strKey, Map<String,String> additionnalData)
Gets the file download url for Back Office admin Lutece users- Specified by:
getFileDownloadUrlBOin interfaceIFileStoreServiceProvider- Parameters:
strKey- the- Returns:
- the download link
-
checkAccessRights
public void checkAccessRights(Map<String,String> fileData, fr.paris.lutece.api.user.User user) throws AccessDeniedException, UserNotSignedException
check if current user can access the file- Specified by:
checkAccessRightsin interfaceIFileStoreServiceProvideruser- the current user- Throws:
AccessDeniedExceptionUserNotSignedException
-
checkLinkValidity
public void checkLinkValidity(Map<String,String> fileData) throws ExpiredLinkException
check if link is valid- Specified by:
checkLinkValidityin interfaceIFileStoreServiceProvider- Throws:
ExpiredLinkException
-
getFileFromRequestBO
public File getFileFromRequestBO(javax.servlet.http.HttpServletRequest request) throws AccessDeniedException, ExpiredLinkException, UserNotSignedException
get requested file from BO- Specified by:
getFileFromRequestBOin interfaceIFileStoreServiceProvider- Returns:
- the file
- Throws:
AccessDeniedExceptionExpiredLinkExceptionUserNotSignedException
-
getFileFromRequestFO
public File getFileFromRequestFO(javax.servlet.http.HttpServletRequest request) throws AccessDeniedException, ExpiredLinkException, UserNotSignedException
get requested file from FO- Specified by:
getFileFromRequestFOin interfaceIFileStoreServiceProvider- Returns:
- the file
- Throws:
AccessDeniedExceptionExpiredLinkExceptionUserNotSignedException
-
-