Class FileRepositoryManager


  • public class FileRepositoryManager
    extends Object
    Provides useful methods to handle files and directories in the Silverpeas specific filesystem.
    Author:
    Norbert CHAIX
    • 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 some Initialization services can use to persist their data required for their work.
        Returns:
        the path of the directory of initialization data.
      • getAbsolutePath

        public static String getAbsolutePath​(String sComponentId)
      • 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()
      • getDomainPropertiesPath

        public static String getDomainPropertiesPath​(String domainName)
      • getDomainAuthenticationPropertiesPath

        public static String getDomainAuthenticationPropertiesPath​(String domainName)
      • getComponentTemporaryPath

        public static String getComponentTemporaryPath​(String sComponentId)
      • createAbsolutePath

        public static void createAbsolutePath​(String componentId,
                                              String directoryName)
      • createGlobalTempPath

        public static void createGlobalTempPath​(String sDirectoryName)
      • deleteAbsolutePath

        public static void deleteAbsolutePath​(String sComponentId,
                                              String sDirectoryName)
      • getFileIcon

        public static String getFileIcon​(String extension)
      • getFileIcon

        public static String getFileIcon​(boolean small,
                                         String filename)
      • getFileExtension

        public static String getFileExtension​(String fileName)
      • 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.