Class AssociatedFilesManager

java.lang.Object
com.jalios.jcms.AssociatedFilesManager

public class AssociatedFilesManager extends Object
Manager class to deal with associated files
  • Constructor Details

    • AssociatedFilesManager

      public AssociatedFilesManager()
  • Method Details

    • getInstance

      public static AssociatedFilesManager getInstance()
      returns the singleton instance
      Returns:
      the singleton instance
    • getFiles

      public Set<File> getFiles(File file)
      Retrieve all associated files of the File
      Parameters:
      file - the File. It must not be a directory
      Returns:
      All associated files of the File
    • addFile

      public File addFile(File file, File associatedFile, boolean replace) throws IOException
      Add a associated File to a File. If the provided File is not in the correct directory, the file is moved into correct directory and rename if replace is false.
      Parameters:
      file - the File. It must not be a directory
      associatedFile - the File
      replace - true if a associated file with the same name should be overwrite or not
      Returns:
      the moved and/or renamed File
      Throws:
      IOException - Exception if any problem on file
    • addFile

      public File addFile(File file, File associatedFile) throws IOException
      Add a associated File to a File. If the provided File is not in the correct directory, the file is moved into correct directory and rename if needed.
      Parameters:
      file - the File. It must not be a directory
      associatedFile - the File
      Returns:
      the moved and/or renamed File
      Throws:
      IOException - Exception if any problem on file
    • addFile

      public File addFile(File file, String associatedFilename) throws IOException
      Add a associated File to a File. If the File already exists in associated directory, it will be overwrite.
      Parameters:
      file - the File. It must not be a directory
      associatedFilename - the file name
      Returns:
      the associated File
      Throws:
      IOException - Exception if any problem on file
    • addFile

      public File addFile(File file, String associatedFilename, boolean replace) throws IOException
      Add a associated File to a File.
      Parameters:
      file - the File. It must not be a directory
      associatedFilename - the file name
      replace - true if a associated file with the same name should be overwrite or not
      Returns:
      the associated File
      Throws:
      IOException - Exception if any problem on file
    • removeFile

      public void removeFile(File file, String filename)
      Remove File associated to a File
      Parameters:
      file - the File. It must not be a directory
      filename - the name of the associated file
    • removeFile

      public void removeFile(File file, File associatedFile)
      Remove File associated to a File
      Parameters:
      file - the File. It must not be a directory
      associatedFile - the associated File
    • getAssociatedFile

      public File getAssociatedFile(File file, String filename)
      Returns the File associated with a File with provided name
      Parameters:
      file - the File
      filename - the name of the associated associatedFile
      Returns:
      the File associated with a File with provided name
    • getAssociatedDirectory

      public File getAssociatedDirectory(FileDocument fileDoc)
      Returns the File which is the directory in which associated files are stored
      Parameters:
      fileDoc - the FileDocument
      Returns:
      the File which is the directory in which associated files are stored
    • getAssociatedDirectory

      public File getAssociatedDirectory(File file)
      Returns the File which is the directory in which associated files are stored
      Parameters:
      file - the File
      Returns:
      the File which is the directory in which associated files are stored
    • getAssociatedDirectory

      public File getAssociatedDirectory(File file, boolean createMissingDir)
      Returns the File which is the directory in which associated files are stored
      Parameters:
      file - the File
      createMissingDir - true if the directory should be created
      Returns:
      the File which is the directory in which associated files are stored
    • fireAddEvent

      public void fireAddEvent(File file, File associatedFile)
    • fireDeleteEvent

      public void fireDeleteEvent(File file, File associatedFile)
    • fireUpdateEvent

      public void fireUpdateEvent(File file, File associatedFile)
    • addAssociatedFilesEventListener

      public void addAssociatedFilesEventListener(AssociatedFilesEventListener listener)
    • removeAssociatedFilesEventListener

      public void removeAssociatedFilesEventListener(AssociatedFilesEventListener listener)
    • getAssociatedFilesEventListener

      public List<AssociatedFilesEventListener> getAssociatedFilesEventListener()
    • removeAllAssociatedFilesEventListener

      public void removeAllAssociatedFilesEventListener()
    • deleteAllAssociatedFile

      public void deleteAllAssociatedFile(File fileDocument) throws IOException
      Throws:
      IOException
    • getFile

      public File getFile(File file, String filename)
    • getOriginatedFile

      public File getOriginatedFile(File file)