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 of
GroupDirectory
from the core database.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ametys.core.util.Cacheable
Cacheable.SingleCacheConfiguration
-
Field Summary
Modifier and TypeFieldDescriptionprotected AbstractCacheManager
The cache managerprotected CurrentUserProvider
The current user providerprotected String
The identifier of data sourceprotected String
The name of the SQL table storing the composition (i.e.protected String
The name of the SQL table storing the groupsprotected String
The idprotected I18nizableText
The labelprotected ServiceManager
Avalon managerprotected ObservationManager
The observation managerprotected SourceResolver
The cocoon source resolver -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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.Add a new group of users.void
dispose()
Returns the instance of the implementation ofAbstractCacheManager
to use.Returns a particular group.Get the id of theGroupDirectoryModel
extension pointReturns all groups.Get groupsgetId()
Get the id of the group directory.getLabel()
Get the label of the group directory.Gets the managed caches.Get the values of parameters (from group directory model)protected Connection
Get the connection to the databasegetUserGroups
(UserIdentity userIdentity) Get all groups a particular user is in.void
Initialize the group directory with given parameter values.void
Remove a group of users.void
service
(ServiceManager manager) void
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 Details
-
_observationManager
The observation manager -
_currentUserProvider
The current user provider -
_sourceResolver
The cocoon source resolver -
_cacheManager
The cache manager -
_dataSourceId
The identifier of data source -
_groupsListTableName
The name of the SQL table storing the groups -
_groupsCompositionTableName
The name of the SQL table storing the composition (i.e. users) of the groups -
_manager
Avalon manager -
_id
The id -
_label
The label
-
-
Constructor Details
-
JdbcGroupDirectory
public JdbcGroupDirectory()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
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
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
Description copied from interface:GroupDirectory
Set the id of the group directory.- Specified by:
setId
in interfaceGroupDirectory
- Parameters:
id
- The id
-
setLabel
Description copied from interface:GroupDirectory
Set the label of the group directory.- Specified by:
setLabel
in interfaceGroupDirectory
- Parameters:
label
- The label
-
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
Description copied from interface:GroupDirectory
Get the values of parameters (from group directory model)- Specified by:
getParameterValues
in interfaceGroupDirectory
- Returns:
- the parameters' values
-
dispose
- Specified by:
dispose
in interfaceDisposable
-
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
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
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
Get the connection to the database- Returns:
- the SQL connection
-
getGroup
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
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
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
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
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
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
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
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.
-