Class SkinResourceDAO
- java.lang.Object
-
- org.ametys.plugins.skineditor.resources.SkinResourceDAO
-
- All Implemented Interfaces:
Component
,Serviceable
public class SkinResourceDAO extends Object implements Serviceable, Component
DAO for files and folders inside a skin directory
-
-
Field Summary
Fields Modifier and Type Field Description protected FileHelper
_fileHelper
The file helperprotected SkinLockManager
_lockManager
The lock managerprotected SkinEditionHelper
_skinHelper
The skin edition helperprotected SourceResolver
_srcResolver
The source resolverstatic String
SKIN_EDITOR_TOOL_ID
Constant for skin editor tool id
-
Constructor Summary
Constructors Constructor Description SkinResourceDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map
addFolder(String skinName, String parentRelPath, String originalName, boolean renameIfExists)
Create a folderboolean
checkSourceExists(String skinName, String parentRelPath, String fileName)
checks if the resource already exists in the parentMap<String,Object>
copySource(String skinName, String srcPath, String parentTargetPath)
Copy a file or directoryMap
deleteFile(String skinName, String relPath)
Delete a file or a directoryMap<String,Object>
moveSource(String skinName, String srcPath, String targetPath)
Move a file or a directoryMap
renameSource(String skinName, String relPath, String name)
Rename a file or a directoryMap<String,Object>
save(String skinName, String relPath, String text)
Saves the text in filevoid
service(ServiceManager manager)
-
-
-
Field Detail
-
SKIN_EDITOR_TOOL_ID
public static final String SKIN_EDITOR_TOOL_ID
Constant for skin editor tool id- See Also:
- Constant Field Values
-
_lockManager
protected SkinLockManager _lockManager
The lock manager
-
_skinHelper
protected SkinEditionHelper _skinHelper
The skin edition helper
-
_fileHelper
protected FileHelper _fileHelper
The file helper
-
_srcResolver
protected SourceResolver _srcResolver
The source resolver
-
-
Constructor Detail
-
SkinResourceDAO
public SkinResourceDAO()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
save
public Map<String,Object> save(String skinName, String relPath, String text) throws IOException
Saves the text in file- Parameters:
skinName
- The name of the skin containing the resourcerelPath
- the relative path of file under the skin directorytext
- the file content to save- Returns:
- The result map
- Throws:
IOException
- If an error occurred while saving
-
checkSourceExists
public boolean checkSourceExists(String skinName, String parentRelPath, String fileName) throws IOException
checks if the resource already exists in the parent- Parameters:
skinName
- The name of the skin containing the resourceparentRelPath
- The parent pathfileName
- the file name to check- Returns:
- true if the file exists
- Throws:
IOException
- if something goes wrong while trying to retrieve a file
-
copySource
public Map<String,Object> copySource(String skinName, String srcPath, String parentTargetPath) throws IOException
Copy a file or directory- Parameters:
skinName
- the name of the current skinsrcPath
- the path of the source file or directoryparentTargetPath
- the new path for the source file or directory- Returns:
- a map of data
- Throws:
IOException
- if something went wrong during the source copy processing
-
addFolder
public Map addFolder(String skinName, String parentRelPath, String originalName, boolean renameIfExists) throws IOException
Create a folder- Parameters:
skinName
- the name of the current skinparentRelPath
- the path of the parent containing the folderoriginalName
- the name of the new folderrenameIfExists
- if true, will generate a valid name if "originalName" already exists.- Returns:
- a map of data
- Throws:
IOException
- if an error occurs while manipulating files
-
deleteFile
public Map deleteFile(String skinName, String relPath) throws IOException
Delete a file or a directory- Parameters:
skinName
- the name of the current skinrelPath
- the path of the file or directory- Returns:
- a map of data
- Throws:
IOException
- if an error occurs while manipulating files
-
moveSource
public Map<String,Object> moveSource(String skinName, String srcPath, String targetPath) throws IOException
Move a file or a directory- Parameters:
skinName
- the name of current skinsrcPath
- the path of the file or directorytargetPath
- the targeted path- Returns:
- a map of data
- Throws:
IOException
- if something goes wrong during the source moving process
-
renameSource
public Map renameSource(String skinName, String relPath, String name) throws IOException
Rename a file or a directory- Parameters:
skinName
- the current skin namerelPath
- the path of the filename
- the new name- Returns:
- a map of data
- Throws:
IOException
- if something goes wrong when renaming the source
-
-