Package com.jalios.jcms
Class AssociatedFilesManager
- java.lang.Object
-
- com.jalios.jcms.AssociatedFilesManager
-
public class AssociatedFilesManager extends java.lang.Object
Manager class to deal with associated files
-
-
Constructor Summary
Constructors Constructor Description AssociatedFilesManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAssociatedFilesEventListener(AssociatedFilesEventListener listener)
java.io.File
addFile(java.io.File file, java.io.File associatedFile)
Add a associatedFile
to aFile
.java.io.File
addFile(java.io.File file, java.io.File associatedFile, boolean replace)
Add a associatedFile
to aFile
.java.io.File
addFile(java.io.File file, java.lang.String associatedFilename)
Add a associatedFile
to aFile
.java.io.File
addFile(java.io.File file, java.lang.String associatedFilename, boolean replace)
Add a associatedFile
to aFile
.void
deleteAllAssociatedFile(java.io.File fileDocument)
void
fireAddEvent(java.io.File file, java.io.File associatedFile)
void
fireDeleteEvent(java.io.File file, java.io.File associatedFile)
void
fireUpdateEvent(java.io.File file, java.io.File associatedFile)
java.io.File
getAssociatedDirectory(FileDocument fileDoc)
Returns theFile
which is the directory in which associated files are storedjava.io.File
getAssociatedDirectory(java.io.File file)
Returns theFile
which is the directory in which associated files are storedjava.io.File
getAssociatedDirectory(java.io.File file, boolean createMissingDir)
Returns theFile
which is the directory in which associated files are storedjava.io.File
getAssociatedFile(java.io.File file, java.lang.String filename)
Returns theFile
associated with aFile
with provided namejava.util.List<AssociatedFilesEventListener>
getAssociatedFilesEventListener()
java.io.File
getFile(java.io.File file, java.lang.String filename)
java.util.Set<java.io.File>
getFiles(java.io.File file)
Retrieve all associated files of theFile
static AssociatedFilesManager
getInstance()
returns the singleton instancejava.io.File
getOriginatedFile(java.io.File file)
void
removeAllAssociatedFilesEventListener()
void
removeAssociatedFilesEventListener(AssociatedFilesEventListener listener)
void
removeFile(java.io.File file, java.io.File associatedFile)
RemoveFile
associated to aFile
void
removeFile(java.io.File file, java.lang.String filename)
RemoveFile
associated to aFile
-
-
-
Method Detail
-
getInstance
public static AssociatedFilesManager getInstance()
returns the singleton instance- Returns:
- the singleton instance
-
getFiles
public java.util.Set<java.io.File> getFiles(java.io.File file)
Retrieve all associated files of theFile
- Parameters:
file
- theFile
. It must not be a directory- Returns:
- All associated files of the
File
-
addFile
public java.io.File addFile(java.io.File file, java.io.File associatedFile, boolean replace) throws java.io.IOException
Add a associatedFile
to aFile
. If the providedFile
is not in the correct directory, the file is moved into correct directory and rename if replace is false.- Parameters:
file
- theFile
. It must not be a directoryassociatedFile
- theFile
replace
- true if a associated file with the same name should be overwrite or not- Returns:
- the moved and/or renamed
File
- Throws:
java.io.IOException
- Exception if any problem on file
-
addFile
public java.io.File addFile(java.io.File file, java.io.File associatedFile) throws java.io.IOException
Add a associatedFile
to aFile
. If the providedFile
is not in the correct directory, the file is moved into correct directory and rename if needed.- Parameters:
file
- theFile
. It must not be a directoryassociatedFile
- theFile
- Returns:
- the moved and/or renamed
File
- Throws:
java.io.IOException
- Exception if any problem on file
-
addFile
public java.io.File addFile(java.io.File file, java.lang.String associatedFilename) throws java.io.IOException
Add a associatedFile
to aFile
. If theFile
already exists in associated directory, it will be overwrite.- Parameters:
file
- theFile
. It must not be a directoryassociatedFilename
- the file name- Returns:
- the associated
File
- Throws:
java.io.IOException
- Exception if any problem on file
-
addFile
public java.io.File addFile(java.io.File file, java.lang.String associatedFilename, boolean replace) throws java.io.IOException
Add a associatedFile
to aFile
.- Parameters:
file
- theFile
. It must not be a directoryassociatedFilename
- the file namereplace
- true if a associated file with the same name should be overwrite or not- Returns:
- the associated
File
- Throws:
java.io.IOException
- Exception if any problem on file
-
removeFile
public void removeFile(java.io.File file, java.lang.String filename)
RemoveFile
associated to aFile
- Parameters:
file
- theFile
. It must not be a directoryfilename
- the name of the associated file
-
removeFile
public void removeFile(java.io.File file, java.io.File associatedFile)
RemoveFile
associated to aFile
- Parameters:
file
- theFile
. It must not be a directoryassociatedFile
- the associatedFile
-
getAssociatedFile
public java.io.File getAssociatedFile(java.io.File file, java.lang.String filename)
Returns theFile
associated with aFile
with provided name- Parameters:
file
- theFile
filename
- the name of the associated associatedFile- Returns:
- the
File
associated with aFile
with provided name
-
getAssociatedDirectory
public java.io.File getAssociatedDirectory(FileDocument fileDoc)
Returns theFile
which is the directory in which associated files are stored- Parameters:
fileDoc
- theFileDocument
- Returns:
- the
File
which is the directory in which associated files are stored
-
getAssociatedDirectory
public java.io.File getAssociatedDirectory(java.io.File file)
Returns theFile
which is the directory in which associated files are stored- Parameters:
file
- theFile
- Returns:
- the
File
which is the directory in which associated files are stored
-
getAssociatedDirectory
public java.io.File getAssociatedDirectory(java.io.File file, boolean createMissingDir)
Returns theFile
which is the directory in which associated files are stored- Parameters:
file
- theFile
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(java.io.File file, java.io.File associatedFile)
-
fireDeleteEvent
public void fireDeleteEvent(java.io.File file, java.io.File associatedFile)
-
fireUpdateEvent
public void fireUpdateEvent(java.io.File file, java.io.File associatedFile)
-
addAssociatedFilesEventListener
public void addAssociatedFilesEventListener(AssociatedFilesEventListener listener)
-
removeAssociatedFilesEventListener
public void removeAssociatedFilesEventListener(AssociatedFilesEventListener listener)
-
getAssociatedFilesEventListener
public java.util.List<AssociatedFilesEventListener> getAssociatedFilesEventListener()
-
removeAllAssociatedFilesEventListener
public void removeAllAssociatedFilesEventListener()
-
deleteAllAssociatedFile
public void deleteAllAssociatedFile(java.io.File fileDocument) throws java.io.IOException
- Throws:
java.io.IOException
-
getFile
public java.io.File getFile(java.io.File file, java.lang.String filename)
-
getOriginatedFile
public java.io.File getOriginatedFile(java.io.File file)
-
-