Class FileAccessServiceImpl

  • All Implemented Interfaces:
    FileAccessService

    public class FileAccessServiceImpl
    extends Object
    implements FileAccessService
    Default FileAccessService implementation.
    Author:
    Alexander Pelov, Lyubomir Marinov
    • Constructor Detail

      • FileAccessServiceImpl

        public FileAccessServiceImpl()
    • Method Detail

      • getTemporaryFile

        public File getTemporaryFile()
                              throws IOException
        This method returns a created temporary file. After you close this file it is not guaranteed that you will be able to open it again nor that it will contain any information. Note: DO NOT store unencrypted sensitive information in this file
        Specified by:
        getTemporaryFile in interface FileAccessService
        Returns:
        The created temporary file
        Throws:
        IOException - If the file cannot be created
      • getPrivatePersistentFile

        public File getPrivatePersistentFile​(String fileName,
                                             FileCategory category)
                                      throws Exception
        This method returns a file specific to the current user. It may not exist, but it is guaranteed that you will have the sufficient rights to create it. This file should not be considered secure because the implementor may return a file accessible to everyone. Generally it will reside in current user's homedir, but it may as well reside in a shared directory. Note: DO NOT store unencrypted sensitive information in this file
        Specified by:
        getPrivatePersistentFile in interface FileAccessService
        Parameters:
        fileName - The name of the private file you wish to access
        category - The classification of the file.
        Returns:
        The file
        Throws:
        Exception - if we faile to create the file.
      • getPrivatePersistentDirectory

        public File getPrivatePersistentDirectory​(String dirName,
                                                  FileCategory category)
                                           throws Exception
        This method creates a directory specific to the current user. This directory should not be considered secure because the implementor may return a directory accessible to everyone. Generally it will reside in current user's homedir, but it may as well reside in a shared directory. It is guaranteed that you will be able to create files in it. Note: DO NOT store unencrypted sensitive information in this file
        Specified by:
        getPrivatePersistentDirectory in interface FileAccessService
        Parameters:
        dirName - The name of the private directory you wish to access.
        category - The classification of the directory.
        Returns:
        The created directory.
        Throws:
        Exception - Thrown if there is no suitable location for the persistent directory.
      • createFailSafeTransaction

        public FailSafeTransaction createFailSafeTransaction​(File file)
        Creates a failsafe transaction which can be used to safely store informations into a file.
        Specified by:
        createFailSafeTransaction in interface FileAccessService
        Parameters:
        file - The file concerned by the transaction, null if file is null.
        Returns:
        A new failsafe transaction related to the given file.