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 java.util.concurrent.locks.ReadWriteLock;
24  
25  import org.apache.directory.api.ldap.model.entry.Entry;
26  import org.apache.directory.api.ldap.model.exception.LdapException;
27  import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
28  import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
29  import org.apache.directory.server.core.api.interceptor.context.BindOperationContext;
30  import org.apache.directory.server.core.api.interceptor.context.CompareOperationContext;
31  import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
32  import org.apache.directory.server.core.api.interceptor.context.GetRootDseOperationContext;
33  import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext;
34  import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext;
35  import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext;
36  import org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext;
37  import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext;
38  import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
39  import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
40  import org.apache.directory.server.core.api.interceptor.context.UnbindOperationContext;
41  
42  
43  /**
44   * An interface used by the DirectoryService to isolate operations that can be
45   * performed on it.
46   *
47   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
48   */
49  public interface OperationManager
50  {
51      /**
52       * Add an entry into the backend, going through the interceptor chain
53       * 
54       * @param addContext The context containing the information to process the addition
55       * @throws LdapException If the addition can't be processed successfully
56       */
57      void add( AddOperationContext addContext ) throws LdapException;
58  
59  
60      /**
61       * Get the RooDse entry.
62       * 
63       * @param getRootDseContext The getRootDse() context
64       * @return The rootDse if found
65       * @throws LdapException If we can't get back the rootDse entry
66       */
67      Entry getRootDse( GetRootDseOperationContext getRootDseContext ) throws LdapException;
68  
69  
70      /**
71       * TODO document after determining if this method should be here.
72       * 
73       * @param compareContext The Compare operation context
74       * @return <tt>true</tt> if the comparison is successful
75       * @throws LdapException If the compare failed
76       */
77      boolean compare( CompareOperationContext compareContext ) throws LdapException;
78  
79  
80      /**
81       * TODO document after determining if this method should be here.
82       * 
83       * @param deleteContext The Delete operation context
84       * @throws LdapException If the delete failed
85       */
86      void delete( DeleteOperationContext deleteContext ) throws LdapException;
87  
88  
89      /**
90       * TODO document after determining if this method should be here.
91       * 
92       * @param modifyContext The Modify operation context
93       * @throws LdapException If the modify failed
94       */
95      void modify( ModifyOperationContext modifyContext ) throws LdapException;
96  
97  
98      /**
99       * TODO document after determining if this method should be here.
100      * 
101      * @param searchContext The Search operation context
102      * @return The cursor on the found entries
103      * @throws LdapException If the search failed
104      */
105     EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException;
106 
107 
108     /**
109      * TODO document after determining if this method should be here.
110      * 
111      * @param lookupContext The Lookup operation context
112      * @return The found entry
113      * @throws LdapException If the lookup failed
114      */
115     Entry lookup( LookupOperationContext lookupContext ) throws LdapException;
116 
117 
118     /**
119      * TODO document after determining if this method should be here.
120      * 
121      * @param hasEntryContext The HasEntry operation context
122      * @return <tt>true</tt> if the entry exists
123      * @throws LdapException If the hasEntry failed
124      */
125     boolean hasEntry( HasEntryOperationContext hasEntryContext ) throws LdapException;
126 
127 
128     /**
129      * TODO document after determining if this method should be here.
130      * 
131      * @param renameContext The Rename operation context
132      * @throws LdapException If the rename failed
133      */
134     void rename( RenameOperationContext renameContext ) throws LdapException;
135 
136 
137     /**
138      * TODO document after determining if this method should be here.
139      * 
140      * @param moveContext The Move operation context
141      * @throws LdapException If the move failed
142      */
143     void move( MoveOperationContext moveContext ) throws LdapException;
144 
145 
146     /**
147      * TODO document after determining if this method should be here.
148      * 
149      * @param moveAndRenameContext The MoveAndRename operation context
150      * @throws LdapException If the moveAndRename failed
151      */
152     void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException;
153 
154 
155     /**
156      * TODO document after determining if this method should be here.
157      * 
158      * @param bindContext The Bind operation context
159      * @throws LdapException If the bind failed
160      */
161     void bind( BindOperationContext bindContext ) throws LdapException;
162 
163 
164     /**
165      * TODO document after determining if this method should be here.
166      * 
167      * @param unbindContext The Unbind operation context
168      * @throws LdapException If the unbind failed
169      */
170     void unbind( UnbindOperationContext unbindContext ) throws LdapException;
171 
172 
173     /**
174      * Acquires a WriteLock
175      */
176     void lockWrite();
177 
178 
179     /**
180      * Releases a WriteLock
181      */
182     void unlockWrite();
183 
184 
185     /**
186      * Acquires a ReadLock
187      */
188     void lockRead();
189 
190 
191     /**
192      * Releases a ReadLock
193      */
194     void unlockRead();
195 
196 
197     /**
198      * @return the OperationManager R/W lock
199      */
200     ReadWriteLock getRWLock();
201 }