Class ParametersClientSideElement
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.ui.StaticFileImportsClientSideElement
-
- org.ametys.core.ui.StaticClientSideElement
-
- org.ametys.plugins.core.ui.parameter.files.ParametersClientSideElement
-
- All Implemented Interfaces:
ClientSideElement
,LogEnabled
,PluginAware
,Configurable
,Serviceable
public class ParametersClientSideElement extends StaticClientSideElement
Component for operations on parameters files and folders
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.core.ui.ClientSideElement
ClientSideElement.Script, ClientSideElement.ScriptFile
-
-
Field Summary
Fields Modifier and Type Field Description private FileHelper
_fileHelper
private static String
_ROOT_PARAMETERS_DIRECTORY_URI
private SourceResolver
_srcResolver
-
Fields inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_currentUserProvider, _dependencies, _featureName, _id, _pluginName, _rightManager, _rights, _rightsMode, _script
-
-
Constructor Summary
Constructors Constructor Description ParametersClientSideElement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_checkNotSafeMode()
Check if application is in normal mode, otherwise throw an exception.protected void
_checkUserRight(String rightId, String context)
Check if the user right to access the featureMap<String,Object>
addFolder(String parentRelPath, String name)
Add a new folderMap<String,Object>
deleteFile(String relPath)
Remove a folder or a fileboolean
fileExists(String parentRelPath, String name)
Check if a file with same name already existMap<String,Object>
renameFile(String relPath, String name)
Rename a file or a folderMap<String,Object>
saveParameters(String relPath, String text)
Saves parameters file.void
service(ServiceManager serviceManager)
-
Methods inherited from class org.ametys.core.ui.StaticClientSideElement
_configureClass, _configureParameters, _configureScript, configureInitialParameters
-
Methods inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_configureDependencies, _configureImports, _configureRights, _configureRightsMode, configure, getDependencies, getId, getPluginName, getRights, getScripts, getScripts, hasRight, setPluginInfo, toString
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_ROOT_PARAMETERS_DIRECTORY_URI
private static final String _ROOT_PARAMETERS_DIRECTORY_URI
- See Also:
- Constant Field Values
-
_fileHelper
private FileHelper _fileHelper
-
_srcResolver
private SourceResolver _srcResolver
-
-
Constructor Detail
-
ParametersClientSideElement
public ParametersClientSideElement()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classStaticFileImportsClientSideElement
- Throws:
ServiceException
-
saveParameters
public Map<String,Object> saveParameters(String relPath, String text) throws IOException
Saves parameters file.- Parameters:
relPath
- the relative file's path from parameters files root directorytext
- the UTF-8 file content to save- Returns:
- The result map
- Throws:
IOException
- If an error occurred while saving
-
addFolder
public Map<String,Object> addFolder(String parentRelPath, String name) throws IOException
Add a new folder- Parameters:
parentRelPath
- the relative parent file's path from parameters files root directoryname
- The name of folder to create- Returns:
- a map containing the name of the created folder, its path and the path of its parent
- Throws:
IOException
- If an error occurred while creating folder
-
deleteFile
public Map<String,Object> deleteFile(String relPath) throws IOException
Remove a folder or a file- Parameters:
relPath
- the relative file's path from parameters files root directory- Returns:
- the result map
- Throws:
IOException
- If an error occurs while removing the folder
-
renameFile
public Map<String,Object> renameFile(String relPath, String name) throws IOException
Rename a file or a folder- Parameters:
relPath
- the relative file's path from parameters files root directoryname
- the new name of the file/folder- Returns:
- the result map
- Throws:
IOException
- if an error occurs while renaming the file/folder
-
fileExists
public boolean fileExists(String parentRelPath, String name) throws Exception
Check if a file with same name already exist- Parameters:
parentRelPath
- the path where the file will be addedname
- the name of the file- Returns:
- result the server's response in JSON
- Throws:
Exception
- if an error occurred
-
_checkUserRight
protected void _checkUserRight(String rightId, String context) throws IllegalStateException
Check if the user right to access the feature- Parameters:
rightId
- The right idcontext
- The right context- Throws:
IllegalStateException
- if the user has no right
-
_checkNotSafeMode
protected void _checkNotSafeMode()
Check if application is in normal mode, otherwise throw an exception.
-
-