Package org.ametys.core.group
Class GroupDirectoryDAO
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.group.GroupDirectoryDAO
-
- All Implemented Interfaces:
LogEnabled
,Disposable
,Initializable
,Component
,Serviceable
public class GroupDirectoryDAO extends AbstractLogEnabled implements Component, Initializable, Serviceable, Disposable
DAO for accessingGroupDirectory
-
-
Field Summary
Fields Modifier and Type Field Description private static File
__GROUP_DIRECTORIES_FILE
The path of the XML file containing the group directoriesprivate static String
__ID_REGEX
The regular expression for an id of a group directoryprivate Map<String,GroupDirectory>
_groupDirectories
The whole group directories of the applicationprivate GroupDirectoryFactory
_groupDirectoryFactory
The factory for group directoriesprivate long
_lastFileReading
The date (as a long) of the last time theGroupDirectories file
was read (last update)static String
ROLE
Avalon Role
-
Constructor Summary
Constructors Constructor Description GroupDirectoryDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private GroupDirectory
_configureGroupDirectory(Configuration configuration)
private void
_createDirectoriesFile(File file)
private GroupDirectory
_createGroupDirectory(String id, String label, String modelId, Map<String,String> params)
private Map<String,Object>
_getParametersFromConfiguration(Configuration conf, String modelId)
private Map<String,Object>
_getTypedParams(Map<String,String> params, String modelId)
private boolean
_isCorrectId(String id)
private void
_read(boolean forceRead)
If needed, reads the config file representing the group directories and then reinitializes and updates the internal representation of the group directories.private void
_saxGroupDirectory(GroupDirectory groupDirectory, TransformerHandler handler)
private void
_toSAX(TransformerHandler handler)
private boolean
_write()
Erases the config file representing the group directories and rebuild it from the internal representation of the group directories.Map<String,Object>
add(String id, String label, String modelId, Map<String,String> params)
Adds a new group directoryvoid
dispose()
Map<String,Object>
edit(String id, String label, String modelId, Map<String,String> params)
Edits the given group directoryMap<String,Object>
getEditionConfiguration()
Gets the configuration for creating/editing a group directory.List<GroupDirectory>
getGroupDirectories()
Gets all the group directories of this applicationList<Object>
getGroupDirectories2Json()
Gets all the group directories to JSON formatSet<String>
getGroupDirectoriesIds()
Gets the list of the ids of all the group directories of the applicationGroupDirectory
getGroupDirectory(String id)
Gets a group directory by its id.Map<String,Object>
getGroupDirectory2Json(GroupDirectory groupDirectory)
gets a group directory to JSON formatMap<String,Object>
getGroupDirectoryParameterValues(String id)
Gets the values of the parameters of the given group directoryvoid
initialize()
Map<String,Object>
remove(String id)
Removes the given group directoryvoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__GROUP_DIRECTORIES_FILE
private static File __GROUP_DIRECTORIES_FILE
The path of the XML file containing the group directories
-
__ID_REGEX
private static final String __ID_REGEX
The regular expression for an id of a group directory- See Also:
- Constant Field Values
-
_lastFileReading
private long _lastFileReading
The date (as a long) of the last time theGroupDirectories file
was read (last update)
-
_groupDirectories
private Map<String,GroupDirectory> _groupDirectories
The whole group directories of the application
-
_groupDirectoryFactory
private GroupDirectoryFactory _groupDirectoryFactory
The factory for group directories
-
-
Constructor Detail
-
GroupDirectoryDAO
public GroupDirectoryDAO()
-
-
Method Detail
-
initialize
public void initialize()
- Specified by:
initialize
in interfaceInitializable
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getGroupDirectories2Json
public List<Object> getGroupDirectories2Json()
Gets all the group directories to JSON format- Returns:
- A list of object representing the
GroupDirectories
-
getGroupDirectory2Json
public Map<String,Object> getGroupDirectory2Json(GroupDirectory groupDirectory)
gets a group directory to JSON format- Parameters:
groupDirectory
- The group directory to get- Returns:
- An object representing a
GroupDirectory
-
getGroupDirectories
public List<GroupDirectory> getGroupDirectories()
Gets all the group directories of this application- Returns:
- A list of
GroupDirectories
-
getGroupDirectory
public GroupDirectory getGroupDirectory(String id)
Gets a group directory by its id.- Parameters:
id
- The id of the group directory- Returns:
- The
GroupDirectory
, or null if not found
-
getGroupDirectoriesIds
public Set<String> getGroupDirectoriesIds()
Gets the list of the ids of all the group directories of the application- Returns:
- The list of the ids of all the group directories
-
getEditionConfiguration
public Map<String,Object> getEditionConfiguration() throws Exception
Gets the configuration for creating/editing a group directory.- Returns:
- A map containing information about what is needed to create/edit a group directory
- Throws:
Exception
- If an error occurs.
-
getGroupDirectoryParameterValues
public Map<String,Object> getGroupDirectoryParameterValues(String id)
Gets the values of the parameters of the given group directory- Parameters:
id
- The id of the group directory- Returns:
- The values of the parameters
-
add
public Map<String,Object> add(String id, String label, String modelId, Map<String,String> params)
Adds a new group directory- Parameters:
id
- The unique id of the group directorylabel
- The label of the group directorymodelId
- The id of the group directory modelparams
- The parameters of the group directory- Returns:
- A map containing the id of the created group directory, or the kind of error that occured
-
_isCorrectId
private boolean _isCorrectId(String id)
-
edit
public Map<String,Object> edit(String id, String label, String modelId, Map<String,String> params)
Edits the given group directory- Parameters:
id
- The id of the group directory to editlabel
- The label of the group directorymodelId
- The id of the group directory modelparams
- The parameters of the group directory- Returns:
- A map containing the id of the edited group directory, or the kind of error that occured
-
_createGroupDirectory
private GroupDirectory _createGroupDirectory(String id, String label, String modelId, Map<String,String> params)
-
_getTypedParams
private Map<String,Object> _getTypedParams(Map<String,String> params, String modelId)
-
remove
public Map<String,Object> remove(String id)
Removes the given group directory- Parameters:
id
- The id of the group directory to remove- Returns:
- A map containing the id of the removed group directory
-
_read
private void _read(boolean forceRead)
If needed, reads the config file representing the group directories and then reinitializes and updates the internal representation of the group directories.- Parameters:
forceRead
- True to avoid the use of the cache and force the reading of the file
-
_createDirectoriesFile
private void _createDirectoriesFile(File file) throws IOException, TransformerConfigurationException, SAXException
-
_configureGroupDirectory
private GroupDirectory _configureGroupDirectory(Configuration configuration) throws ConfigurationException
- Throws:
ConfigurationException
-
_getParametersFromConfiguration
private Map<String,Object> _getParametersFromConfiguration(Configuration conf, String modelId)
-
_write
private boolean _write()
Erases the config file representing the group directories and rebuild it from the internal representation of the group directories.- Returns:
- True if an error occured
-
_toSAX
private void _toSAX(TransformerHandler handler) throws SAXException, IOException
- Throws:
SAXException
IOException
-
_saxGroupDirectory
private void _saxGroupDirectory(GroupDirectory groupDirectory, TransformerHandler handler) throws SAXException, IOException
- Throws:
SAXException
IOException
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceDisposable
-
-