com.anwrt.anycontent.plugins.core.group
Class DefaultGroupManager

java.lang.Object
  extended bycom.anwrt.anycontent.plugins.core.group.AbstractGroupManager
      extended bycom.anwrt.anycontent.plugins.core.group.DefaultGroupManager
All Implemented Interfaces:
GroupManager, ModifiableGroupManager, UserListener

public class DefaultGroupManager
extends AbstractGroupManager
implements ModifiableGroupManager, UserListener

Standard implementation of the group manager from the core database.


Field Summary
protected static java.lang.String __GROUP_TABLE
          Name of the table group.
protected static java.lang.String __ID_GROUP_COL
          Name of the column for group id in the table group.
protected static java.lang.String __ID_USER_GROUP_COL
          Name of the column for group id in the table group/user.
protected static java.lang.String __LABEL_COL
          Name of the column for group label.
protected static java.lang.String __LOGIN_COL
          Name of the column for user's login.
protected static java.lang.String __USER_GROUP_TABLE
          Name of the table group/user.
protected  java.util.List _listeners
          Group listeners
protected  Logger _logger
          Logger for traces.
 
Fields inherited from class com.anwrt.anycontent.plugins.core.group.AbstractGroupManager
__GROUP_ID_ATTR, __GROUP_LABEL_TAG, __GROUP_TAG, __ROOT_TAG, __USER_TAG, __USERS_TAG
 
Constructor Summary
DefaultGroupManager()
           
 
Method Summary
protected  void _cleanup(java.sql.Connection con, java.sql.Statement stmt, java.sql.ResultSet rs)
          Clean a connection to the database by closing all resources.
protected  void _fillGroup(UserGroup group, java.sql.Connection connection)
          Fill users set in a group.
protected  java.sql.Connection _getConnection()
          Get the connection pool.
 UserGroup add(java.lang.String name)
          Add a new group of users.
 void configure(Configuration configuration)
          Configure an extension with its parameters.
 UserGroup getGroup(java.lang.String groupID)
          Returns a particular group.
 java.util.Set getGroups()
          Returns all groups.
 java.util.List getListeners()
          Get the list of user listeners
 java.util.Set getUserGroups(java.lang.String login)
          Get all groups a particular is in.
 void initialize()
          Initialize the plugin with deploy parameters.
 void onAddUser(java.lang.String login)
          When an user is added
 void onModifyUser(java.lang.String login)
          When an user is modify
 void onRemoveUser(java.lang.String login)
          When an user is deleted
 void registerListener(GroupListener listener)
          Registers an user listener
 void remove(java.lang.String groupID)
          Remove a group of users.
 void removeListener(GroupListener listener)
          Removes an user listener
 void removeUserGroups(java.lang.String login)
          Removes all groups associated with a user
 void update(UserGroup userGroup)
          Modify an existing group of users.
 
Methods inherited from class com.anwrt.anycontent.plugins.core.group.AbstractGroupManager
toSAX
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.anwrt.anycontent.extensions.group.GroupManager
toSAX
 

Field Detail

__GROUP_TABLE

protected static final java.lang.String __GROUP_TABLE
Name of the table group.

See Also:
Constant Field Values

__USER_GROUP_TABLE

protected static final java.lang.String __USER_GROUP_TABLE
Name of the table group/user.

See Also:
Constant Field Values

__ID_GROUP_COL

protected static final java.lang.String __ID_GROUP_COL
Name of the column for group id in the table group.

See Also:
Constant Field Values

__LABEL_COL

protected static final java.lang.String __LABEL_COL
Name of the column for group label.

See Also:
Constant Field Values

__ID_USER_GROUP_COL

protected static final java.lang.String __ID_USER_GROUP_COL
Name of the column for group id in the table group/user.

See Also:
Constant Field Values

__LOGIN_COL

protected static final java.lang.String __LOGIN_COL
Name of the column for user's login.

See Also:
Constant Field Values

_logger

protected Logger _logger
Logger for traces.


_listeners

protected java.util.List _listeners
Group listeners

Constructor Detail

DefaultGroupManager

public DefaultGroupManager()
Method Detail

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Description copied from interface: GroupManager
Configure an extension with its parameters.
Call once before initialization.
Deploy parameters are not yet available.

Specified by:
configure in interface GroupManager
Parameters:
configuration - The configuration.
Throws:
ConfigurationException

getListeners

public java.util.List getListeners()
Description copied from interface: ModifiableGroupManager
Get the list of user listeners

Specified by:
getListeners in interface ModifiableGroupManager
Returns:
The user listeners as a list

registerListener

public void registerListener(GroupListener listener)
Description copied from interface: ModifiableGroupManager
Registers an user listener

Specified by:
registerListener in interface ModifiableGroupManager
Parameters:
listener - the user listener

removeListener

public void removeListener(GroupListener listener)
Description copied from interface: ModifiableGroupManager
Removes an user listener

Specified by:
removeListener in interface ModifiableGroupManager
Parameters:
listener - the user listener

initialize

public void initialize()
Description copied from interface: GroupManager
Initialize the plugin with deploy parameters.
Call once after configuration.

Specified by:
initialize in interface GroupManager

getGroup

public UserGroup getGroup(java.lang.String groupID)
Description copied from interface: GroupManager
Returns a particular group.

Specified by:
getGroup in interface GroupManager
Parameters:
groupID - The id of the group.
Returns:
The group or null if the group does not exists.

getGroups

public java.util.Set getGroups()
Description copied from interface: GroupManager
Returns all groups.

Specified by:
getGroups in interface GroupManager
Returns:
The groups as a Set of UserGroup, empty if an error occurs.

getUserGroups

public java.util.Set getUserGroups(java.lang.String login)
Description copied from interface: GroupManager
Get all groups a particular is in.

Specified by:
getUserGroups in interface GroupManager
Parameters:
login - The login of the user.
Returns:
The groups as a Set of String (group ID), empty if the login does not match.

removeUserGroups

public void removeUserGroups(java.lang.String login)
Removes all groups associated with a user

Parameters:
login - the login of the user

onAddUser

public void onAddUser(java.lang.String login)
Description copied from interface: UserListener
When an user is added

Specified by:
onAddUser in interface UserListener
Parameters:
login - the user's login

onModifyUser

public void onModifyUser(java.lang.String login)
Description copied from interface: UserListener
When an user is modify

Specified by:
onModifyUser in interface UserListener
Parameters:
login - the user's login

onRemoveUser

public void onRemoveUser(java.lang.String login)
Description copied from interface: UserListener
When an user is deleted

Specified by:
onRemoveUser in interface UserListener
Parameters:
login - the user's login

_fillGroup

protected void _fillGroup(UserGroup group,
                          java.sql.Connection connection)
                   throws java.sql.SQLException
Fill users set in a group.

Parameters:
group - The group to fill.
connection - The SQL connection.
Throws:
java.sql.SQLException - If a problem occurs.

_getConnection

protected java.sql.Connection _getConnection()
Get the connection pool.

Returns:
The connection pool.

_cleanup

protected void _cleanup(java.sql.Connection con,
                        java.sql.Statement stmt,
                        java.sql.ResultSet rs)
Clean a connection to the database by closing all resources.

Parameters:
con - The connection to the database to close.
stmt - The statement to close.
rs - The result set to close.

add

public UserGroup add(java.lang.String name)
              throws InvalidModificationException
Description copied from interface: ModifiableGroupManager
Add a new group of users.

Specified by:
add in interface ModifiableGroupManager
Parameters:
name - The name of the user group to create
Returns:
The user group created
Throws:
InvalidModificationException - if the group id exists yet or if at least one of the parameter is invalid.

remove

public void remove(java.lang.String groupID)
            throws InvalidModificationException
Description copied from interface: ModifiableGroupManager
Remove a group of users.

Specified by:
remove in interface ModifiableGroupManager
Parameters:
groupID - The id of the group.
Throws:
InvalidModificationException - if the group id does not exists.

update

public void update(UserGroup userGroup)
            throws InvalidModificationException
Description copied from interface: ModifiableGroupManager
Modify an existing group of users.

Specified by:
update in interface ModifiableGroupManager
Parameters:
userGroup - Informations about the new group.
Throws:
InvalidModificationException - if the group id does not exists yet


Copyright © 2006 Anyware Technologies. All Rights Reserved.