View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   *
19   */
20  package org.apache.directory.server.core.api;
21  
22  
23  import org.apache.directory.api.ldap.model.entry.Entry;
24  import org.apache.directory.api.ldap.model.exception.LdapException;
25  import org.apache.directory.api.ldap.model.name.Dn;
26  
27  
28  /**
29   * An interface for managing referrals in the server
30   *
31   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32   */
33  public interface ReferralManager
34  {
35      /**
36       * Get a read-lock on the referralManager.
37       * No read operation can be done on the referralManager if this
38       * method is not called before.
39       */
40      void lockRead();
41  
42  
43      /**
44       * Get a write-lock on the referralManager.
45       * No write operation can be done on the referralManager if this
46       * method is not called before.
47       */
48      void lockWrite();
49  
50  
51      /**
52       * Release the read-write lock on the referralManager.
53       * This method must be called after having read or modified the
54       * ReferralManager
55       */
56      void unlock();
57  
58  
59      /**
60       * Tells if a Dn is a referral (its associated entry contains the Referral ObjectClass).
61       *
62       * It does not check that the associated entry inherits from a referral.
63       *
64       * @param dn The entry's Dn we want to check
65       * @return <code>true</code> if the Dn is associated with a referral
66       */
67      boolean isReferral( Dn dn );
68  
69  
70      /**
71       * Tells if this Dn has a parent which is a referral.
72       * <br>
73       * For instance, if cn=example, dc=acme, dc=org is the Dn to check,
74       * and if dc=acme, dc=org is a referral, this this method will return true.
75       *
76       * @param dn The Dn we want to check for a referral in its partents
77       * @return <code>true</code> if there is a parent referral
78       */
79      boolean hasParentReferral( Dn dn );
80  
81  
82      /**
83       * Get the Dn of the parent referral for a specific Dn
84       *
85       * @param dn The Dn from which we want to get the parent referral
86       * @return The parent referral of null if none is found
87       */
88      Entry getParentReferral( Dn dn );
89  
90  
91      /**
92       * Add a referral to the manager.
93       *
94       * @param entry The referral to add
95       */
96      void addReferral( Entry entry );
97  
98  
99      /**
100      * Remove a referral from the manager.
101      *
102      * @param entry The referral to remove
103      * @throws LdapException If the referal can't be removed
104      */
105     void removeReferral( Entry entry ) throws LdapException;
106 
107 
108     /**
109      * Initialize the manager, reading all the referrals from the base.
110      * The manager will search for every entries having a Referral ObjectClass.
111      *
112      * @param directoryService The associated LDAP service
113      * @param suffixes The partition list
114      * @exception Exception If the initialization failed
115      */
116     void init( DirectoryService directoryService, String... suffixes ) throws Exception;
117 
118 
119     /**
120      * Remove a partition from the manager, reading all the referrals from the base.
121      * The manager will search for every entries having a Referral ObjectClass, and
122      * will remove them from the referrals table.
123      *
124      * @param directoryService The associated LDAP service
125      * @param suffixes The partition Dn to remove
126      * @exception Exception If the removal failed
127      */
128     void remove( DirectoryService directoryService, Dn suffixes ) throws Exception;
129 }