Class JdbcGroupDirectory
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.core.impl.group.directory.jdbc.JdbcGroupDirectory
-
- All Implemented Interfaces:
GroupDirectory
,ModifiableGroupDirectory
,Cacheable
,LogEnabled
,Disposable
,Serviceable
public class JdbcGroupDirectory extends AbstractLogEnabled implements ModifiableGroupDirectory, Serviceable, Cacheable, Disposable
Standard implementation ofGroupDirectory
from the core database.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.core.util.Cacheable
Cacheable.SingleCacheConfiguration
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractCacheManager
_cacheManager
The cache managerprotected CurrentUserProvider
_currentUserProvider
The current user providerprotected String
_dataSourceId
The identifier of data sourceprotected String
_groupsCompositionTableName
The name of the SQL table storing the composition (i.e.protected String
_groupsListTableName
The name of the SQL table storing the groupsprotected String
_id
The idprotected I18nizableText
_label
The labelprotected ServiceManager
_manager
Avalon managerprotected ObservationManager
_observationManager
The observation managerprotected SourceResolver
_sourceResolver
The cocoon source resolver
-
Constructor Summary
Constructors Constructor Description JdbcGroupDirectory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
_createGetGroupsClause(String dbType)
Get the sql clause that gets all groupsprotected void
_fillGroup(org.ametys.plugins.core.impl.group.directory.jdbc.JdbcGroupDirectory.JdbcGroup group, Connection connection)
Fill users set in a group.ModifiableGroup
add(String name)
Add a new group of users.void
dispose()
AbstractCacheManager
getCacheManager()
Returns the instance of the implementation ofAbstractCacheManager
to use.ModifiableGroup
getGroup(String groupID)
Returns a particular group.String
getGroupDirectoryModelId()
Get the id of theGroupDirectoryModel
extension pointSet<Group>
getGroups()
Returns all groups.List<Group>
getGroups(int count, int offset, Map parameters)
Get groupsString
getId()
Get the id of the group directory.I18nizableText
getLabel()
Get the label of the group directory.Collection<Cacheable.SingleCacheConfiguration>
getManagedCaches()
Gets the managed caches.Map<String,Object>
getParameterValues()
Get the values of parameters (from group directory model)protected Connection
getSQLConnection()
Get the connection to the databaseSet<String>
getUserGroups(UserIdentity userIdentity)
Get all groups a particular user is in.void
init(String groupDirectoryModelId, Map<String,Object> paramValues)
Initialize the group directory with given parameter values.void
remove(String groupID)
Remove a group of users.void
service(ServiceManager manager)
void
setId(String id)
Set the id of the group directory.void
setLabel(I18nizableText label)
Set the label of the group directory.void
update(ModifiableGroup userGroup)
Modify an existing group of users.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.core.util.Cacheable
createCaches, getCache, hasComputableSize, isCachingEnabled, removeCaches
-
-
-
-
Field Detail
-
_observationManager
protected ObservationManager _observationManager
The observation manager
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_sourceResolver
protected SourceResolver _sourceResolver
The cocoon source resolver
-
_cacheManager
protected AbstractCacheManager _cacheManager
The cache manager
-
_dataSourceId
protected String _dataSourceId
The identifier of data source
-
_groupsListTableName
protected String _groupsListTableName
The name of the SQL table storing the groups
-
_groupsCompositionTableName
protected String _groupsCompositionTableName
The name of the SQL table storing the composition (i.e. users) of the groups
-
_manager
protected ServiceManager _manager
Avalon manager
-
_label
protected I18nizableText _label
The label
-
-
Constructor Detail
-
JdbcGroupDirectory
public JdbcGroupDirectory()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getId
public String getId()
Description copied from interface:GroupDirectory
Get the id of the group directory.- Specified by:
getId
in interfaceGroupDirectory
- Returns:
- The id of the group directory
-
getLabel
public I18nizableText getLabel()
Description copied from interface:GroupDirectory
Get the label of the group directory.- Specified by:
getLabel
in interfaceGroupDirectory
- Returns:
- The label of the group directory
-
setId
public void setId(String id)
Description copied from interface:GroupDirectory
Set the id of the group directory.- Specified by:
setId
in interfaceGroupDirectory
- Parameters:
id
- The id
-
setLabel
public void setLabel(I18nizableText label)
Description copied from interface:GroupDirectory
Set the label of the group directory.- Specified by:
setLabel
in interfaceGroupDirectory
- Parameters:
label
- The label
-
getGroupDirectoryModelId
public String getGroupDirectoryModelId()
Description copied from interface:GroupDirectory
Get the id of theGroupDirectoryModel
extension point- Specified by:
getGroupDirectoryModelId
in interfaceGroupDirectory
- Returns:
- the id of extension point
-
getParameterValues
public Map<String,Object> getParameterValues()
Description copied from interface:GroupDirectory
Get the values of parameters (from group directory model)- Specified by:
getParameterValues
in interfaceGroupDirectory
- Returns:
- the parameters' values
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceDisposable
-
getManagedCaches
public Collection<Cacheable.SingleCacheConfiguration> getManagedCaches()
Description copied from interface:Cacheable
Gets the managed caches.
This is meant to be implemented in order to describe the managed caches and automatically create and remove the corresponding caches inCacheable.createCaches()
andCacheable.removeCaches()
default methods.
This is not meant to be called manually.- Specified by:
getManagedCaches
in interfaceCacheable
- Returns:
- A collection of
Cacheable.SingleCacheConfiguration
s to manage
-
getCacheManager
public AbstractCacheManager getCacheManager()
Description copied from interface:Cacheable
Returns the instance of the implementation ofAbstractCacheManager
to use.
This is not meant to be called manually.- Specified by:
getCacheManager
in interfaceCacheable
- Returns:
- The
AbstractCacheManager
to bind
-
init
public void init(String groupDirectoryModelId, Map<String,Object> paramValues)
Description copied from interface:GroupDirectory
Initialize the group directory with given parameter values.- Specified by:
init
in interfaceGroupDirectory
- Parameters:
groupDirectoryModelId
- The id of group directory extension pointparamValues
- The parameters' values
-
getSQLConnection
protected Connection getSQLConnection()
Get the connection to the database- Returns:
- the SQL connection
-
getGroup
public ModifiableGroup getGroup(String groupID)
Description copied from interface:GroupDirectory
Returns a particular group.- Specified by:
getGroup
in interfaceGroupDirectory
- Specified by:
getGroup
in interfaceModifiableGroupDirectory
- Parameters:
groupID
- The id of the group.- Returns:
- The group or null if the group does not exist.
-
getGroups
public Set<Group> getGroups()
Description copied from interface:GroupDirectory
Returns all groups.- Specified by:
getGroups
in interfaceGroupDirectory
- Returns:
- The groups as a Set of UserGroup, empty if an error occurs.
-
_createGetGroupsClause
protected String _createGetGroupsClause(String dbType)
Get the sql clause that gets all groups- Parameters:
dbType
- The connection type- Returns:
- A non null sql clause (e.g. "select ... from ... where ...")
-
_fillGroup
protected void _fillGroup(org.ametys.plugins.core.impl.group.directory.jdbc.JdbcGroupDirectory.JdbcGroup group, Connection connection) throws SQLException
Fill users set in a group.- Parameters:
group
- The group to fill.connection
- The SQL connection.- Throws:
SQLException
- If a problem occurs.
-
getUserGroups
public Set<String> getUserGroups(UserIdentity userIdentity)
Description copied from interface:GroupDirectory
Get all groups a particular user is in.- Specified by:
getUserGroups
in interfaceGroupDirectory
- Parameters:
userIdentity
- The identity of the user- Returns:
- The groups as a Set of String (group ID), empty if the login does not match.
-
getGroups
public List<Group> getGroups(int count, int offset, Map parameters)
Description copied from interface:GroupDirectory
Get groups- Specified by:
getGroups
in interfaceGroupDirectory
- Parameters:
count
- The maximum number of groups to sax. (-1 to sax all)offset
- The offset to start with, first is 0.parameters
- Parameters for saxing user list differently, see implementation.- Returns:
- The matching groups
-
add
public ModifiableGroup add(String name) throws InvalidModificationException
Description copied from interface:ModifiableGroupDirectory
Add a new group of users.- Specified by:
add
in interfaceModifiableGroupDirectory
- Parameters:
name
- The name of the user group to create. Cannot be null;- Returns:
- The user group created
- Throws:
InvalidModificationException
- if the group id exists yet or if at least one of the parameter is invalid.
-
update
public void update(ModifiableGroup userGroup) throws InvalidModificationException
Description copied from interface:ModifiableGroupDirectory
Modify an existing group of users.- Specified by:
update
in interfaceModifiableGroupDirectory
- Parameters:
userGroup
- Informations about the new group. Cannot be null:- Throws:
InvalidModificationException
- if the group id does not exist yet
-
remove
public void remove(String groupID) throws InvalidModificationException
Description copied from interface:ModifiableGroupDirectory
Remove a group of users.- Specified by:
remove
in interfaceModifiableGroupDirectory
- Parameters:
groupID
- The id of the group. Cannot be null;- Throws:
InvalidModificationException
- if the group id does not exist.
-
-