org.opends.server.core
Class GroupManager

java.lang.Object
  extended by org.opends.server.core.GroupManager
All Implemented Interfaces:
ConfigurationAddListener<GroupImplementationCfg>, ConfigurationChangeListener<GroupImplementationCfg>, ConfigurationDeleteListener<GroupImplementationCfg>, BackendInitializationListener, ChangeNotificationListener

public class GroupManager
extends java.lang.Object
implements ConfigurationChangeListener<GroupImplementationCfg>, ConfigurationAddListener<GroupImplementationCfg>, ConfigurationDeleteListener<GroupImplementationCfg>, BackendInitializationListener, ChangeNotificationListener

This class provides a mechanism for interacting with all groups defined in the Directory Server. It will handle all necessary processing at server startup to identify and load all group implementations, as well as to find all group instances within the server.

FIXME: At the present time, it assumes that all of the necessary information about all of the groups defined in the server can be held in memory. If it is determined that this approach is not workable in all cases, then we will need an alternate strategy.


Constructor Summary
GroupManager()
          Creates a new instance of this group manager.
 
Method Summary
 ConfigChangeResult applyConfigurationAdd(GroupImplementationCfg configuration)
          Adds a new configuration to this add listener.
 ConfigChangeResult applyConfigurationChange(GroupImplementationCfg configuration)
          Applies the configuration changes to this change listener.
 ConfigChangeResult applyConfigurationDelete(GroupImplementationCfg configuration)
          Deletes an existing configuration from this delete listener.
 void finalizeGroupManager()
          Performs any cleanup work that may be needed when the server is shutting down.
 java.lang.Iterable<Group> getGroupImplementations()
          Retrieves an Iterable object that may be used to cursor across the group implementations defined in the server.
 Group getGroupInstance(DN entryDN)
          Retrieves the group instance defined in the entry with the specified DN.
 java.lang.Iterable<Group> getGroupInstances()
          Retrieves an Iterable object that may be used to cursor across the group instances defined in the server.
 void handleAddOperation(PostResponseAddOperation addOperation, Entry entry)
          Performs any processing that may be required after an add operation.
 void handleDeleteOperation(PostResponseDeleteOperation deleteOperation, Entry entry)
          Performs any processing that may be required after a delete operation.
 void handleModifyDNOperation(PostResponseModifyDNOperation modifyDNOperation, Entry oldEntry, Entry newEntry)
          Performs any processing that may be required after a modify DN operation.
 void handleModifyOperation(PostResponseModifyOperation modifyOperation, Entry oldEntry, Entry newEntry)
          Performs any processing that may be required after a modify operation.
 boolean hasInstancesChanged(long token)
          Compare the specified token against the current group manager token value.
 void initializeGroupImplementations()
          Initializes all group implementations currently defined in the Directory Server configuration.
 boolean isConfigurationAddAcceptable(GroupImplementationCfg configuration, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed addition of a new configuration is acceptable to this add listener.
 boolean isConfigurationChangeAcceptable(GroupImplementationCfg configuration, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed change to the configuration is acceptable to this change listener.
 boolean isConfigurationDeleteAcceptable(GroupImplementationCfg configuration, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed deletion of an existing configuration is acceptable to this delete listener.
 void performBackendFinalizationProcessing(Backend backend)
          Performs any processing that may be required whenever a backend is finalized.
 void performBackendInitializationProcessing(Backend backend)
          Performs any processing that may be required whenever a backend is initialized for use in the Directory Server.
 long refreshToken()
          Return the current refresh token value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupManager

public GroupManager()
Creates a new instance of this group manager.

Method Detail

initializeGroupImplementations

public void initializeGroupImplementations()
                                    throws ConfigException,
                                           InitializationException
Initializes all group implementations currently defined in the Directory Server configuration. This should only be called at Directory Server startup.

Throws:
ConfigException - If a configuration problem causes the group implementation initialization process to fail.
InitializationException - If a problem occurs while initializing the group implementations that is not related to the server configuration.

isConfigurationAddAcceptable

public boolean isConfigurationAddAcceptable(GroupImplementationCfg configuration,
                                            java.util.List<Message> unacceptableReasons)
Indicates whether the proposed addition of a new configuration is acceptable to this add listener.

Specified by:
isConfigurationAddAcceptable in interface ConfigurationAddListener<GroupImplementationCfg>
Parameters:
configuration - The configuration that will be added.
unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
Returns:
Returns true if the proposed addition is acceptable, or false if it is not.

applyConfigurationAdd

public ConfigChangeResult applyConfigurationAdd(GroupImplementationCfg configuration)
Adds a new configuration to this add listener.

Specified by:
applyConfigurationAdd in interface ConfigurationAddListener<GroupImplementationCfg>
Parameters:
configuration - The configuration that will be added.
Returns:
Returns information about the result of adding the configuration.

isConfigurationDeleteAcceptable

public boolean isConfigurationDeleteAcceptable(GroupImplementationCfg configuration,
                                               java.util.List<Message> unacceptableReasons)
Indicates whether the proposed deletion of an existing configuration is acceptable to this delete listener.

Specified by:
isConfigurationDeleteAcceptable in interface ConfigurationDeleteListener<GroupImplementationCfg>
Parameters:
configuration - The configuration that will be deleted.
unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
Returns:
Returns true if the proposed deletion is acceptable, or false if it is not.

applyConfigurationDelete

public ConfigChangeResult applyConfigurationDelete(GroupImplementationCfg configuration)
Deletes an existing configuration from this delete listener.

Specified by:
applyConfigurationDelete in interface ConfigurationDeleteListener<GroupImplementationCfg>
Parameters:
configuration - The existing configuration that will be deleted.
Returns:
Returns information about the result of deleting the configuration.

isConfigurationChangeAcceptable

public boolean isConfigurationChangeAcceptable(GroupImplementationCfg configuration,
                                               java.util.List<Message> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.

Specified by:
isConfigurationChangeAcceptable in interface ConfigurationChangeListener<GroupImplementationCfg>
Parameters:
configuration - The new configuration containing the changes.
unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
Returns:
Returns true if the proposed change is acceptable, or false if it is not.

applyConfigurationChange

public ConfigChangeResult applyConfigurationChange(GroupImplementationCfg configuration)
Applies the configuration changes to this change listener.

Specified by:
applyConfigurationChange in interface ConfigurationChangeListener<GroupImplementationCfg>
Parameters:
configuration - The new configuration containing the changes.
Returns:
Returns information about the result of changing the configuration.

finalizeGroupManager

public void finalizeGroupManager()
Performs any cleanup work that may be needed when the server is shutting down.


getGroupImplementations

public java.lang.Iterable<Group> getGroupImplementations()
Retrieves an Iterable object that may be used to cursor across the group implementations defined in the server.

Returns:
An Iterable object that may be used to cursor across the group implementations defined in the server.

getGroupInstances

public java.lang.Iterable<Group> getGroupInstances()
Retrieves an Iterable object that may be used to cursor across the group instances defined in the server.

Returns:
An Iterable object that may be used to cursor across the group instances defined in the server.

getGroupInstance

public Group getGroupInstance(DN entryDN)
Retrieves the group instance defined in the entry with the specified DN.

Parameters:
entryDN - The DN of the entry containing the definition of the group instance to retrieve.
Returns:
The group instance defined in the entry with the specified DN, or null if no such group is currently defined.

performBackendInitializationProcessing

public void performBackendInitializationProcessing(Backend backend)
Performs any processing that may be required whenever a backend is initialized for use in the Directory Server. This method will be invoked after the backend has been initialized but before it has been put into service. In this case, the server will search the backend to find all group instances that it may contain and register them with this group manager.

Specified by:
performBackendInitializationProcessing in interface BackendInitializationListener
Parameters:
backend - The backend that has been initialized and is about to be put into service.

performBackendFinalizationProcessing

public void performBackendFinalizationProcessing(Backend backend)
Performs any processing that may be required whenever a backend is finalized. This method will be invoked after the backend has been taken out of service but before it has been finalized. In this case, the server will de-register all group instances associated with entries in the provided backend.

Specified by:
performBackendFinalizationProcessing in interface BackendInitializationListener
Parameters:
backend - The backend that has been taken out of service and is about to be finalized.

handleAddOperation

public void handleAddOperation(PostResponseAddOperation addOperation,
                               Entry entry)
Performs any processing that may be required after an add operation. In this case, each entry is checked to see if it contains a group definition, and if so it will be instantiated and registered with this group manager.

Specified by:
handleAddOperation in interface ChangeNotificationListener
Parameters:
addOperation - The add operation that was performed in the server.
entry - The entry that was added to the server.

handleDeleteOperation

public void handleDeleteOperation(PostResponseDeleteOperation deleteOperation,
                                  Entry entry)
Performs any processing that may be required after a delete operation. In this case, if the entry is associated with a registered group instance, then that group instance will be deregistered.

Specified by:
handleDeleteOperation in interface ChangeNotificationListener
Parameters:
deleteOperation - The delete operation that was performed in the server.
entry - The entry that was removed from the server.

handleModifyOperation

public void handleModifyOperation(PostResponseModifyOperation modifyOperation,
                                  Entry oldEntry,
                                  Entry newEntry)
Performs any processing that may be required after a modify operation. In this case, if the entry is associated with a registered group instance, then that instance will be recreated from the contents of the provided entry and re-registered with the group manager.

Specified by:
handleModifyOperation in interface ChangeNotificationListener
Parameters:
modifyOperation - The modify operation that was performed in the server.
oldEntry - The entry before it was updated.
newEntry - The entry after it was updated.

handleModifyDNOperation

public void handleModifyDNOperation(PostResponseModifyDNOperation modifyDNOperation,
                                    Entry oldEntry,
                                    Entry newEntry)
Performs any processing that may be required after a modify DN operation. In this case, if the entry is associated with a registered group instance, then that instance will be recreated from the contents of the provided entry and re-registered with the group manager under the new DN, and the old instance will be deregistered.

Specified by:
handleModifyDNOperation in interface ChangeNotificationListener
Parameters:
modifyDNOperation - The modify DN operation that was performed in the server.
oldEntry - The entry before it was updated.
newEntry - The entry after it was updated.

hasInstancesChanged

public boolean hasInstancesChanged(long token)
Compare the specified token against the current group manager token value. Can be used to reload cached group instances if there has been a group instance change.

Parameters:
token - The current token that the group class holds.
Returns:
true if the group class should reload its nested groups, or false if it shouldn't.

refreshToken

public long refreshToken()
Return the current refresh token value. Can be used to reload cached group instances if there has been a group instance change.

Returns:
The current token value.