org.apache.directory.server.ldap.handlers
Class ReferralAwareRequestHandler<T extends org.apache.directory.shared.ldap.message.internal.InternalResultResponseRequest>

java.lang.Object
  extended by org.apache.directory.server.ldap.handlers.LdapRequestHandler<T>
      extended by org.apache.directory.server.ldap.handlers.ReferralAwareRequestHandler<T>
All Implemented Interfaces:
org.apache.mina.handler.demux.MessageHandler<T>
Direct Known Subclasses:
SearchHandler

public abstract class ReferralAwareRequestHandler<T extends org.apache.directory.shared.ldap.message.internal.InternalResultResponseRequest>
extends LdapRequestHandler<T>

A based class for handlers which deal with SingleReplyRequests. This class provides various capabilities out of the box for these kinds of requests so common handling code is not duplicated. Namely, exception handling and referral handling code common to most SingleReplyRequests (minus ExtendedRequests) are handled thanks to this class.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.server.ldap.handlers.LdapRequestHandler
ldapServer
 
Fields inherited from interface org.apache.mina.handler.demux.MessageHandler
NOOP
 
Constructor Summary
ReferralAwareRequestHandler()
           
 
Method Summary
static ClonedServerEntry getFarthestReferralAncestor(LdapSession session, org.apache.directory.shared.ldap.name.DN target)
          Searches up the ancestry of a DN searching for the farthest referral ancestor.
 org.apache.directory.shared.ldap.message.internal.InternalReferral getReferralOnAncestor(LdapSession session, org.apache.directory.shared.ldap.name.DN reqTargetDn, T req, ClonedServerEntry referralAncestor)
          Handles processing with referrals without ManageDsaIT control and with an ancestor that is a referral.
 org.apache.directory.shared.ldap.message.internal.InternalReferral getReferralOnAncestorForSearch(LdapSession session, org.apache.directory.shared.ldap.message.internal.InternalSearchRequest req, ClonedServerEntry referralAncestor)
          Handles processing with referrals without ManageDsaIT control and with an ancestor that is a referral.
 void handle(LdapSession session, T req)
          Handle a Ldap message associated with a session
 void handleException(LdapSession session, org.apache.directory.shared.ldap.message.internal.InternalResultResponseRequest req, java.lang.Exception e)
          Handles processing with referrals without ManageDsaIT control.
abstract  void handleIgnoringReferrals(LdapSession session, T req)
          Handles processing without referral handling in effect: either with the ManageDsaIT control or when the entry or all of it's ancestors are non- referral entries.
abstract  void handleWithReferrals(LdapSession session, org.apache.directory.shared.ldap.name.DN reqTargetDn, T req)
          Handles processing with referrals without ManageDsaIT control.
static boolean isEntryReferral(ClonedServerEntry entry)
           
 
Methods inherited from class org.apache.directory.server.ldap.handlers.LdapRequestHandler
getLdapServer, handleMessage, isConfidentialityRequirementSatisfied, rejectWithoutConfidentiality, setLdapServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReferralAwareRequestHandler

public ReferralAwareRequestHandler()
Method Detail

handle

public final void handle(LdapSession session,
                         T req)
                  throws java.lang.Exception
Description copied from class: LdapRequestHandler
Handle a Ldap message associated with a session

Specified by:
handle in class LdapRequestHandler<T extends org.apache.directory.shared.ldap.message.internal.InternalResultResponseRequest>
Parameters:
session - The associated session
req - The message we have to handle
Throws:
java.lang.Exception - If there is an error during the processing of this message

isEntryReferral

public static final boolean isEntryReferral(ClonedServerEntry entry)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

getFarthestReferralAncestor

public static final ClonedServerEntry getFarthestReferralAncestor(LdapSession session,
                                                                  org.apache.directory.shared.ldap.name.DN target)
                                                           throws java.lang.Exception
Searches up the ancestry of a DN searching for the farthest referral ancestor. This is required to properly handle referrals. Note that this function is quite costly since it attempts to lookup all the ancestors up the hierarchy just to see if they represent referrals. Techniques can be employed later to improve this performance hit by having an intelligent referral cache.

Returns:
the farthest referral ancestor or null
Throws:
java.lang.Exception - if there are problems during this search

getReferralOnAncestor

public org.apache.directory.shared.ldap.message.internal.InternalReferral getReferralOnAncestor(LdapSession session,
                                                                                                org.apache.directory.shared.ldap.name.DN reqTargetDn,
                                                                                                T req,
                                                                                                ClonedServerEntry referralAncestor)
                                                                                         throws java.lang.Exception
Handles processing with referrals without ManageDsaIT control and with an ancestor that is a referral. The original entry was not found and the walk of the ancestry returned a referral.

Parameters:
referralAncestor - the farthest referral ancestor of the missing entry
Throws:
java.lang.Exception

getReferralOnAncestorForSearch

public org.apache.directory.shared.ldap.message.internal.InternalReferral getReferralOnAncestorForSearch(LdapSession session,
                                                                                                         org.apache.directory.shared.ldap.message.internal.InternalSearchRequest req,
                                                                                                         ClonedServerEntry referralAncestor)
                                                                                                  throws java.lang.Exception
Handles processing with referrals without ManageDsaIT control and with an ancestor that is a referral. The original entry was not found and the walk of the ancestry returned a referral.

Parameters:
referralAncestor - the farthest referral ancestor of the missing entry
Throws:
java.lang.Exception

handleException

public void handleException(LdapSession session,
                            org.apache.directory.shared.ldap.message.internal.InternalResultResponseRequest req,
                            java.lang.Exception e)
Handles processing with referrals without ManageDsaIT control.

Overrides:
handleException in class LdapRequestHandler<T extends org.apache.directory.shared.ldap.message.internal.InternalResultResponseRequest>

handleIgnoringReferrals

public abstract void handleIgnoringReferrals(LdapSession session,
                                             T req)
Handles processing without referral handling in effect: either with the ManageDsaIT control or when the entry or all of it's ancestors are non- referral entries. Implementors

Parameters:
session - the LDAP session under which processing occurs
reqTargetDn - the target entry DN associated with the request
entry - the target entry if it exists and has been looked up, may be null even if the entry exists, offered in case the entry is looked up to avoid repeat lookups. Implementations should check if the entry is null and attempt a lookup instead of presuming the entry does not exist.
req - the request to be handled

handleWithReferrals

public abstract void handleWithReferrals(LdapSession session,
                                         org.apache.directory.shared.ldap.name.DN reqTargetDn,
                                         T req)
                                  throws org.apache.directory.shared.ldap.exception.LdapException
Handles processing with referrals without ManageDsaIT control.

Throws:
org.apache.directory.shared.ldap.exception.LdapException


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.