Package org.silverpeas.core.util.file
Class FileRepositoryManager
- java.lang.Object
-
- org.silverpeas.core.util.file.FileRepositoryManager
-
public class FileRepositoryManager extends Object
Provides useful methods to handle files and directories in the Silverpeas specific filesystem.- Author:
- Norbert CHAIX
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
copyFile(String from, String to)
Copy a contents from a file to another onestatic void
createAbsolutePath(String componentId, String directoryName)
static void
createGlobalTempPath(String sDirectoryName)
static void
deleteAbsolutePath(String sComponentId, String sDirectoryName)
static String
formatFileSize(long lSize)
Get the file size with the suitable unitstatic String
formatFileUploadTime(long size)
static String
getAbsolutePath(String sComponentId)
static String
getAbsolutePath(String componentId, String[] directoryName)
static String[]
getAttachmentContext(String str)
to create the array of the string this array represents the repertories where the files must be stored.static String
getAvatarPath()
static String
getComponentTemporaryPath(String sComponentId)
static <T> long
getDirectorySize(Collection<T> directories)
Computes as fast as possible the size of a given directory list.static <T> long
getDirectorySize(T directory)
Computes as fast as possible the size of a given directory.static String
getDomainAuthenticationPropertiesPath(String domainName)
static String
getDomainPropertiesPath(String domainName)
static String
getExportTemplateRepository()
Gets the path of the repository that contains the templates to use in exports.static String
getFileDownloadTime(long size)
Get the estimated download timestatic String
getFileExtension(String fileName)
static String
getFileIcon(boolean small, String filename)
static String
getFileIcon(String extension)
static long
getFileSize(String sourceFile)
Get the size of a file (in bytes)static String
getInitDataDirPath()
Gets the path of the directory of initialization data with which someInitialization
services can use to persist their data required for their work.static String
getRelativePath(String... directories)
Construct an OS specific relative path.static String
getSecurityDirPath()
Gets the path of the directory in which all the resources related to the security in Silverpeas are stored.static String
getTemporaryPath()
static long
getUploadMaximumFileSize()
Gets the file size limit for an upload.static String
getUploadPath()
Gets the path of the repository into which attachments and other files are uploaded in Silverpeas.
-
-
-
Method Detail
-
getSecurityDirPath
public static String getSecurityDirPath()
Gets the path of the directory in which all the resources related to the security in Silverpeas are stored.- Returns:
- the path of the Silverpeas security directory.
-
getInitDataDirPath
public static String getInitDataDirPath()
Gets the path of the directory of initialization data with which someInitialization
services can use to persist their data required for their work.- Returns:
- the path of the directory of initialization data.
-
getAvatarPath
public static String getAvatarPath()
-
getUploadPath
public static String getUploadPath()
Gets the path of the repository into which attachments and other files are uploaded in Silverpeas.- Returns:
- the path of the root repository for uploads.
-
getAbsolutePath
public static String getAbsolutePath(String componentId, String[] directoryName)
- Parameters:
componentId
-directoryName
-- Returns:
- path
-
getRelativePath
public static String getRelativePath(String... directories)
Construct an OS specific relative path.- Parameters:
directories
- the names of sub directory. (path1, path2,...)- Returns:
- path1/path2/.../
-
getTemporaryPath
public static String getTemporaryPath()
-
getDomainAuthenticationPropertiesPath
public static String getDomainAuthenticationPropertiesPath(String domainName)
-
createGlobalTempPath
public static void createGlobalTempPath(String sDirectoryName)
-
deleteAbsolutePath
public static void deleteAbsolutePath(String sComponentId, String sDirectoryName)
-
formatFileSize
public static String formatFileSize(long lSize)
Get the file size with the suitable unit- Parameters:
lSize
- : size- Returns:
- String
-
getFileSize
public static long getFileSize(String sourceFile)
Get the size of a file (in bytes)- Parameters:
sourceFile
-- Returns:
- int
-
getDirectorySize
public static <T> long getDirectorySize(Collection<T> directories)
Computes as fast as possible the size of a given directory list.- Parameters:
directories
- a list of directory.- Returns:
- the size of given directory list as long.
-
getDirectorySize
public static <T> long getDirectorySize(T directory)
Computes as fast as possible the size of a given directory.- Parameters:
directory
- a directory.- Returns:
- the size of given directory as long.
-
getFileDownloadTime
public static String getFileDownloadTime(long size)
Get the estimated download time- Parameters:
size
- the file's size- Returns:
- String
-
getUploadMaximumFileSize
public static long getUploadMaximumFileSize()
Gets the file size limit for an upload.- Returns:
-
copyFile
public static void copyFile(String from, String to) throws IOException
Copy a contents from a file to another one- Parameters:
from
- The name of the source file, the one to copy.to
- The name of the destination file, where to paste data.- Throws:
IOException
-
formatFileUploadTime
public static String formatFileUploadTime(long size)
-
getAttachmentContext
public static String[] getAttachmentContext(String str)
to create the array of the string this array represents the repertories where the files must be stored.- Parameters:
str
- : type String: the string of repertories- Returns:
-
getExportTemplateRepository
public static String getExportTemplateRepository()
Gets the path of the repository that contains the templates to use in exports.- Returns:
- the path of the export template repository.
-
-