Class ServerConstraintHandler

java.lang.Object
org.forgerock.opendj.config.server.ServerConstraintHandler

public abstract class ServerConstraintHandler extends Object
An interface for performing server-side constraint validation.

Constraints are evaluated immediately before and after write operations are performed. Server-side constraints are evaluated in two phases: the first phase determines if the proposed add, delete, or modification is acceptable according to the constraint. If one or more constraints fails, the write write operation is refused, and the client will receive an OperationRejectedException exception. The second phase is invoked once the add, delete, or modification request has been allowed and any changes applied. The second phase gives the constraint handler a chance to register listener call-backs if required.

A server constraint handler must override at least one of the provided methods.

See Also:
  • Constructor Details

    • ServerConstraintHandler

      protected ServerConstraintHandler()
      Creates a new server constraint handler.
  • Method Details

    • isDeleteAllowed

      public boolean isDeleteAllowed(ServerManagedObject<?> managedObject, Collection<LocalizableMessage> unacceptableReasons) throws ConfigException
      Determines whether the existing managed object can be deleted from the server's configuration. For example, an implementation might enforce referential integrity by preventing referenced managed objects from being deleted.

      If the constraint is not satisfied, the implementation must return false and add a message describing why the managed object cannot be deleted.

      The default implementation is to return true.

      Parameters:
      managedObject - The managed object which is about to be deleted.
      unacceptableReasons - A list of messages to which error messages should be added.
      Returns:
      Returns true if this constraint is satisfied, or false if it is not and the managed object cannot be deleted.
      Throws:
      ConfigException - If an configuration exception prevented this constraint from being evaluated.
    • isUsable

      public boolean isUsable(ServerManagedObject<?> managedObject, Collection<LocalizableMessage> unacceptableReasons) throws ConfigException
      Determines whether the provided managed object can be used by the server. This method is invoked each time a managed object is decoded by the administration framework: when an attempt is made to add a new configuration, modify an existing configuration, or during server initialization. If the constraint is not satisfied the managed object will be rejected.

      If the constraint is not satisfied, the implementation must return false and add a message describing why the managed object is not usable.

      The default implementation is to return true.

      Parameters:
      managedObject - The new managed object.
      unacceptableReasons - A list of messages to which error messages should be added.
      Returns:
      Returns true if this constraint is satisfied, or false if it is not and the managed object cannot be used.
      Throws:
      ConfigException - If an configuration exception prevented this constraint from being evaluated.
    • performPostAdd

      public void performPostAdd(ServerManagedObject<?> managedObject) throws ConfigException
      Performs any post-add processing required by this constraint. This method is invoked after a new managed object has been accepted for use by the administration framework. This might occur during initialization or when a managed object is added at run-time.

      The default implementation is to do nothing.

      Parameters:
      managedObject - The managed object which has just been added to the server's configuration.
      Throws:
      ConfigException - If the post-add processing fails due to a configuration exception.
    • performPostDelete

      public void performPostDelete(ServerManagedObject<?> managedObject) throws ConfigException
      Performs any post-delete processing required by this constraint. This method is invoked after a managed object has been accepted for deletion from the server's configuration.

      The default implementation is to do nothing.

      Parameters:
      managedObject - The managed object which was deleted.
      Throws:
      ConfigException - If the post-delete processing fails due to a configuration exception.
    • performPostModify

      public void performPostModify(ServerManagedObject<?> managedObject) throws ConfigException
      Performs any post-modify processing required by this constraint. This method is invoked after changes to an existing managed object have been accepted.

      The default implementation is to do nothing.

      Parameters:
      managedObject - The managed object which was modified.
      Throws:
      ConfigException - If the post-modify processing fails due to a configuration exception.