Package lumis.portal.file
Class FileManager
- java.lang.Object
-
- lumis.portal.file.FileManager
-
- All Implemented Interfaces:
IFileManager
public class FileManager extends java.lang.Object implements IFileManager
Manager for file and files- Since:
- 4.0.0
- Version:
- $Revision: 24707 $ $Date: 2021-09-13 09:33:01 -0300 (Mon, 13 Sep 2021) $
-
-
Field Summary
-
Fields inherited from interface lumis.portal.file.IFileManager
CONTENT_TYPE_PROVIDER_PROPERTY_NAME
-
-
Constructor Summary
Constructors Constructor Description FileManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description FileConfig
add(SessionConfig sessionConfig, java.lang.String name, java.io.File file, java.lang.String contentType, java.lang.String serviceInstanceId, ITransaction transaction)
Persists a file.FileConfig
add(SessionConfig sessionConfig, java.lang.String fileId, java.lang.String fileRelativePath, java.lang.String name, java.io.File file, java.lang.String contentType, java.lang.String serviceInstanceId, ITransaction transaction)
Persists a file.FileConfig
add(SessionConfig sessionConfig, java.lang.String fileId, java.lang.String fileRelativePath, java.lang.String name, java.io.File file, java.lang.String serviceInstanceId, ITransaction transaction)
Persists a file.FileConfig
add(SessionConfig sessionConfig, FileConfig fileConfig, ITransaction transaction)
Deprecated.void
changeFilename(SessionConfig sessionConfig, java.lang.String fileId, java.lang.String newFilename, ITransaction transaction)
Changes the filename of a file.FileConfig
findByFullPath(SessionConfig sessionConfig, java.lang.String fullPath, ITransaction transaction)
Finds the FileConfig by the full path.FileConfig
get(SessionConfig sessionConfig, java.lang.String fileId, ITransaction transaction)
Returns the FileConfig for a file with the given fileId.java.io.File
getFile(SessionConfig sessionConfig, FileConfig fileConfig, ITransaction transaction)
Deprecated.java.util.Collection<FileConfig>
getFileConfigsByFilesId(SessionConfig sessionConfig, java.lang.String filesId, ITransaction transaction)
Returns a collection of FileConfig of file entries belonging to the files with the given id.java.util.Collection<FileConfig>
getFileConfigsByServiceInstanceId(java.lang.String serviceInstanceId, ITransaction transaction)
Returns all file configs by a given service instance id.IServiceInterfaceUrl
getFileHref(SessionConfig sessionConfig, java.lang.String fileId, ITransaction transaction)
Returns the href that is used to access the specified file.FilesConfig
getFilesConfig(SessionConfig sessionConfig, java.lang.String filesId, ITransaction transaction)
Returns the FilesConfig for a files with the given filesId.FileMimeTypeConfig
getMimeType(SessionConfig sessionConfig, java.lang.String fileMimeType, ITransaction transaction)
Returns a mime type information.int
getNumberOfServiceInstanceFiles(SessionConfig sessionConfig, java.lang.String serviceInstanceId, ITransaction transaction)
Returns the number of files for a service instance.IFile
getPortalFile(SessionConfig sessionConfig, FileConfig fileConfig, ITransaction transaction)
Returns the File object for accessing the corresponding file in the portal filesystem.void
moveFile(FileConfig file, IWebRootPortalBaseFolder oldWebRoot, IWebRootPortalBaseFolder newWebRoot)
Moves the givenfile
from one web root to another.void
publicServiceInstanceFiles(SessionConfig sessionConfig, java.lang.String serviceInstanceId, boolean filesArePublic, ITransaction transaction)
Creates or deletes the public copy of the files of a service instance.void
removeStoredFile(SessionConfig sessionConfig, java.lang.String fileId, ITransaction transaction)
Removes the specified file.void
removeStoredFiles(SessionConfig sessionConfig, java.lang.String filesId, ITransaction transaction)
Removes the files associated with the filesId given.void
setFileContentLocaleId(java.lang.String fileId, java.lang.String contentLocaleId)
Sets the given content locale identifier in the file with the given identifier.void
updateMetadata(java.lang.String fileId, ITransaction transaction)
Updates metadata information from a given file
-
-
-
Method Detail
-
get
public FileConfig get(SessionConfig sessionConfig, java.lang.String fileId, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Returns the FileConfig for a file with the given fileId.- Specified by:
get
in interfaceIFileManager
- Parameters:
sessionConfig
- identifier for the session.fileId
- the id of the file.transaction
- the transaction for persistence access.- Returns:
- the FileConfig for the file, or null if it is not found.
- Throws:
PortalException
-
findByFullPath
public FileConfig findByFullPath(SessionConfig sessionConfig, java.lang.String fullPath, ITransaction transaction) throws PortalException
Finds the FileConfig by the full path.- Parameters:
sessionConfig
- identifier for the session.fullPath
- the full path.transaction
- the transaction for persistence access.- Returns:
- the FileConfig for the file, or null if it is not found.
- Throws:
PortalException
- Since:
- 6.0.0
-
getFilesConfig
public FilesConfig getFilesConfig(SessionConfig sessionConfig, java.lang.String filesId, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Returns the FilesConfig for a files with the given filesId.- Specified by:
getFilesConfig
in interfaceIFileManager
- Parameters:
sessionConfig
- identifier for the session.filesId
- the id of the files.transaction
- the transaction for persistence access.- Returns:
- the FilesConfig for the files, or null if it is not found.
- Throws:
PortalException
-
getFileConfigsByFilesId
public java.util.Collection<FileConfig> getFileConfigsByFilesId(SessionConfig sessionConfig, java.lang.String filesId, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Returns a collection of FileConfig of file entries belonging to the files with the given id.- Specified by:
getFileConfigsByFilesId
in interfaceIFileManager
- Parameters:
sessionConfig
- identifier for the session.filesId
- id of the files entry.transaction
- the transaction for persistence access.- Returns:
- the collection contaning the FileConfig instances, or an empty collection if none is found.
- Throws:
PortalException
-
removeStoredFile
public void removeStoredFile(SessionConfig sessionConfig, java.lang.String fileId, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Removes the specified file. The file entry from database is removed and the corresponding file in the filesystem is deleted.- Specified by:
removeStoredFile
in interfaceIFileManager
- Parameters:
sessionConfig
- identifier for the session.fileId
- the file id.transaction
- the transaction for persistence access.- Throws:
PortalException
-
removeStoredFiles
public void removeStoredFiles(SessionConfig sessionConfig, java.lang.String filesId, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Removes the files associated with the filesId given.- Specified by:
removeStoredFiles
in interfaceIFileManager
- Parameters:
sessionConfig
- identifier for the session.filesId
- the filesId.transaction
- the transaction for persistence access.- Throws:
PortalException
-
add
public FileConfig add(SessionConfig sessionConfig, java.lang.String name, java.io.File file, java.lang.String contentType, java.lang.String serviceInstanceId, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Persists a file.- Specified by:
add
in interfaceIFileManager
- Parameters:
sessionConfig
- The session information.name
- The name of the file.file
- The file to be added.contentType
- The contentType of the file.serviceInstanceId
- The ID of the service instance used to add this file.transaction
- The transaction used for the persistence- Returns:
- an instance of FileConfig holding the information of the file.
- Throws:
PortalException
- If any error occursFileUploadDeniedException
- if the file was not added because it did not comply with portal file upload restrictions configuration.
-
add
public FileConfig add(SessionConfig sessionConfig, java.lang.String fileId, java.lang.String fileRelativePath, java.lang.String name, java.io.File file, java.lang.String serviceInstanceId, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Persists a file. Calculates the file's content type automatically.- Specified by:
add
in interfaceIFileManager
- Parameters:
sessionConfig
- The session information.fileId
- Identifier of the filefileRelativePath
- path of the file starting at the files directoryname
- The name of the file.file
- The file to be added.serviceInstanceId
- The ID of the service instance used to add this file.transaction
- The transaction used for the persistence- Returns:
- an instance of FileConfig holding the information of the file.
- Throws:
PortalException
- If any error occursFileUploadDeniedException
- if the file was not added because it did not comply with portal file upload restrictions configuration.
-
add
public FileConfig add(SessionConfig sessionConfig, java.lang.String fileId, java.lang.String fileRelativePath, java.lang.String name, java.io.File file, java.lang.String contentType, java.lang.String serviceInstanceId, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Persists a file.- Specified by:
add
in interfaceIFileManager
- Parameters:
sessionConfig
- The session information.fileId
- Identifier of the filefileRelativePath
- path of the file starting at the files directoryname
- The name of the file.file
- The file to be added.contentType
- The contentType of the file.serviceInstanceId
- The ID of the service instance used to add this file.transaction
- The transaction used for the persistence- Returns:
- an instance of FileConfig holding the information of the file.
- Throws:
PortalException
- If any error occursFileUploadDeniedException
- if the file was not added because it did not comply with portal file upload restrictions configuration.
-
add
@Deprecated public FileConfig add(SessionConfig sessionConfig, FileConfig fileConfig, ITransaction transaction) throws PortalException
Deprecated.Description copied from interface:IFileManager
Adds a file. The file must be available until the transaction is committed.- Specified by:
add
in interfaceIFileManager
- Parameters:
sessionConfig
- identifier for the session.fileConfig
- file config of the file to be added.transaction
- the transaction for persistence access.- Returns:
- the FileConfig for the file added.
- Throws:
FileUploadDeniedException
- if the file was not added because it did not comply with portal file upload restrictions configuration.PortalException
-
getFile
@Deprecated public java.io.File getFile(SessionConfig sessionConfig, FileConfig fileConfig, ITransaction transaction) throws PortalException
Deprecated.Description copied from interface:IFileManager
Returns the File object for accessing the corresponding file in the filesystem.- Specified by:
getFile
in interfaceIFileManager
- Parameters:
sessionConfig
- identifier for the session.fileConfig
- the fileConfig of the asked file.transaction
- the transaction for persistence access.- Returns:
- the File object for accessing the corresponding file in the filesystem.
- Throws:
PortalException
-
getPortalFile
public IFile getPortalFile(SessionConfig sessionConfig, FileConfig fileConfig, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Returns the File object for accessing the corresponding file in the portal filesystem.- Specified by:
getPortalFile
in interfaceIFileManager
- Parameters:
sessionConfig
- identifier for the session.fileConfig
- the fileConfig of the asked file.transaction
- the transaction for persistence access.- Returns:
- the File object for accessing the corresponding file in the portal filesystem.
- Throws:
PortalException
-
changeFilename
public void changeFilename(SessionConfig sessionConfig, java.lang.String fileId, java.lang.String newFilename, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Changes the filename of a file.- Specified by:
changeFilename
in interfaceIFileManager
- Parameters:
sessionConfig
- identifier for the session.fileId
- the file id.newFilename
- the new filename for the file.transaction
- the transaction for persistence access.- Throws:
PortalException
-
getFileHref
public IServiceInterfaceUrl getFileHref(SessionConfig sessionConfig, java.lang.String fileId, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Returns the href that is used to access the specified file.- Specified by:
getFileHref
in interfaceIFileManager
- Parameters:
sessionConfig
- identifier for the session.fileId
- the file id.transaction
- the transaction for persistence access.- Throws:
PortalException
-
publicServiceInstanceFiles
public void publicServiceInstanceFiles(SessionConfig sessionConfig, java.lang.String serviceInstanceId, boolean filesArePublic, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Creates or deletes the public copy of the files of a service instance.- Specified by:
publicServiceInstanceFiles
in interfaceIFileManager
- Parameters:
sessionConfig
- the user session information.serviceInstanceId
- the service instance id.filesArePublic
- if true the files are copied to the public area, if false the files are deleted from the public area.transaction
- the transaction for persistence access.- Throws:
PortalException
-
getMimeType
public FileMimeTypeConfig getMimeType(SessionConfig sessionConfig, java.lang.String fileMimeType, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Returns a mime type information.- Specified by:
getMimeType
in interfaceIFileManager
- Parameters:
sessionConfig
- the user session information.fileMimeType
- the mime type.transaction
- the transaction for persistence access.- Returns:
- the mime type information.
- Throws:
PortalException
-
updateMetadata
public void updateMetadata(java.lang.String fileId, ITransaction transaction) throws PortalException
Updates metadata information from a given file- Parameters:
fileId
- file that the metadata information will be updatedtransaction
- the transaction for persistence access.- Throws:
PortalException
- if any error updating occurs- Since:
- 6.0.0
-
getNumberOfServiceInstanceFiles
public int getNumberOfServiceInstanceFiles(SessionConfig sessionConfig, java.lang.String serviceInstanceId, ITransaction transaction) throws PortalException
Description copied from interface:IFileManager
Returns the number of files for a service instance.- Specified by:
getNumberOfServiceInstanceFiles
in interfaceIFileManager
- Parameters:
sessionConfig
- the user session information.serviceInstanceId
- the service instance identifier.transaction
- the transaction for persistence access.- Returns:
- the number of files for the specified service instance.
- Throws:
PortalException
-
getFileConfigsByServiceInstanceId
public java.util.Collection<FileConfig> getFileConfigsByServiceInstanceId(java.lang.String serviceInstanceId, ITransaction transaction) throws PortalException
Returns all file configs by a given service instance id.- Parameters:
serviceInstanceId
- the wished service instance idtransaction
- the current transaction- Returns:
- the file configs for the given service instance
- Throws:
PortalException
- Since:
- 6.1.0
-
moveFile
public void moveFile(FileConfig file, IWebRootPortalBaseFolder oldWebRoot, IWebRootPortalBaseFolder newWebRoot) throws PortalException
Moves the givenfile
from one web root to another. The actual move operation will occur after the current transaction commits.This method also moves all
transformed files
derived from the given file.Note: this method does not validates whether the file is public or if it should be in the specified web root. This method is just a low-level movement operation.
- Parameters:
file
- the file to be moved.oldWebRoot
- the web root base folder the file will be moved from. May benull
if the file is not in any web root.newWebRoot
- the web root base folder the file will be moved to. May benull
if the file will not be in any web root.- Throws:
PortalException
- Since:
- 6.2.0
-
setFileContentLocaleId
public void setFileContentLocaleId(java.lang.String fileId, java.lang.String contentLocaleId) throws PortalException
Description copied from interface:IFileManager
Sets the given content locale identifier in the file with the given identifier. If no file config is found with the given file identifier, nothing will be performed.- Specified by:
setFileContentLocaleId
in interfaceIFileManager
- Parameters:
fileId
- the file identifier.contentLocaleId
- the content locale identifier.- Throws:
PortalException
-
-