Class SkinResourceDAO
java.lang.Object
org.ametys.plugins.skineditor.resources.SkinResourceDAO
- All Implemented Interfaces:
Component
,Serviceable
DAO for files and folders inside a skin directory
-
Field Summary
Modifier and TypeFieldDescriptionprotected CurrentUserProvider
The current user providerprotected FileHelper
The file helperprotected SkinLockManager
The lock managerprotected RightManager
The rights managerprotected SkinEditionHelper
The skin edition helperprotected SkinsManager
The skins managerprotected SourceResolver
The source resolverstatic final String
Constant for skin editor tool idstatic final String
Constant for skin editor tool id -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreate a folderaddOrUpdateFile
(String skinName, Part part, String toPath, String mode, boolean unzip) Add or update a file into a skinboolean
checkSourceExists
(String skinName, String parentRelPath, String fileName) checks if the resource already exists in the parentcopySource
(String skinName, String srcPath, String parentTargetPath) Copy a file or directorydeleteFile
(String skinName, String relPath) Delete a file or a directorymoveSource
(String skinName, String srcPath, String targetPath) Move a file or a directoryrenameSource
(String skinName, String relPath, String name) Rename a file or a directorySaves the text in filevoid
service
(ServiceManager manager)
-
Field Details
-
ROLE
Constant for skin editor tool id -
SKIN_EDITOR_TOOL_ID
Constant for skin editor tool id- See Also:
-
_lockManager
The lock manager -
_skinHelper
The skin edition helper -
_fileHelper
The file helper -
_srcResolver
The source resolver -
_currentUserProvider
The current user provider -
_rightManager
The rights manager -
_skinManager
The skins manager
-
-
Constructor Details
-
SkinResourceDAO
public SkinResourceDAO()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
save
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
-
addOrUpdateFile
public Map addOrUpdateFile(String skinName, Part part, String toPath, String mode, boolean unzip) throws IOException Add or update a file into a skin- Parameters:
skinName
- the name of the skinpart
- The file multipart to uploadtoPath
- The path of parent directorymode
- The insertion mode: 'add-rename' or 'update' or null.unzip
- true to unzip .zip file- Returns:
- the result map
- Throws:
IOException
- If an error occurred manipulating the file
-
deleteFile
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
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
-