001    /*
002     *   Licensed to the Apache Software Foundation (ASF) under one
003     *   or more contributor license agreements.  See the NOTICE file
004     *   distributed with this work for additional information
005     *   regarding copyright ownership.  The ASF licenses this file
006     *   to you under the Apache License, Version 2.0 (the
007     *   "License"); you may not use this file except in compliance
008     *   with the License.  You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     *   Unless required by applicable law or agreed to in writing,
013     *   software distributed under the License is distributed on an
014     *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *   KIND, either express or implied.  See the License for the
016     *   specific language governing permissions and limitations
017     *   under the License.
018     *
019     */
020    package org.apache.directory.server.core.partition;
021    
022    
023    import java.util.Collections;
024    import java.util.Iterator;
025    import java.util.List;
026    
027    import javax.naming.InvalidNameException;
028    
029    import org.apache.commons.collections.iterators.EmptyIterator;
030    import org.apache.directory.server.core.entry.ClonedServerEntry;
031    import org.apache.directory.server.core.filtering.EntryFilter;
032    import org.apache.directory.server.core.filtering.EntryFilteringCursor;
033    import org.apache.directory.server.core.interceptor.context.AddOperationContext;
034    import org.apache.directory.server.core.interceptor.context.BindOperationContext;
035    import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
036    import org.apache.directory.server.core.interceptor.context.ListOperationContext;
037    import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
038    import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
039    import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
040    import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
041    import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
042    import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
043    import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
044    import org.apache.directory.server.core.interceptor.context.UnbindOperationContext;
045    import org.apache.directory.shared.ldap.cursor.ClosureMonitor;
046    import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
047    import org.apache.directory.shared.ldap.name.DN;
048    import org.apache.directory.shared.ldap.schema.SchemaManager;
049    
050    
051    /**
052     * A dummy do nothing partition that is useful for testing NullPartition.
053     *
054     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
055     * @version $Rev$, $Date$
056     */
057    public class NullPartition extends AbstractPartition
058    {
059        private String id;
060        private DN suffix;
061        
062    
063        /**
064         * Creates a new instance of NullPartition.
065         *
066         */
067        public NullPartition()
068        {
069        }
070    
071    
072        /* (non-Javadoc)
073         * @see org.apache.directory.server.core.partition.Partition#add(org.apache.directory.server.core.interceptor.context.AddOperationContext)
074         */
075        public void add( AddOperationContext opContext ) throws Exception
076        {
077        }
078    
079    
080        /* (non-Javadoc)
081         * @see org.apache.directory.server.core.partition.Partition#bind(org.apache.directory.server.core.interceptor.context.BindOperationContext)
082         */
083        public void bind( BindOperationContext opContext ) throws Exception
084        {
085        }
086    
087    
088        /* (non-Javadoc)
089         * @see org.apache.directory.server.core.partition.Partition#delete(org.apache.directory.server.core.interceptor.context.DeleteOperationContext)
090         */
091        public void delete( DeleteOperationContext opContext ) throws Exception
092        {
093        }
094    
095    
096        /* (non-Javadoc)
097         * @see org.apache.directory.server.core.partition.Partition#getId()
098         */
099        public String getId()
100        {
101            return id;
102        }
103    
104    
105        /* (non-Javadoc)
106         * @see org.apache.directory.server.core.partition.Partition#getSuffix()
107         */
108        public DN getSuffixDn()
109        {
110            return suffix;
111        }
112    
113    
114        /* (non-Javadoc)
115         * @see org.apache.directory.server.core.partition.Partition#list(org.apache.directory.server.core.interceptor.context.ListOperationContext)
116         */
117        public EntryFilteringCursor list( ListOperationContext opContext ) throws Exception
118        {
119            return new EntryFilteringCursor()
120            {
121                
122                public Iterator<ClonedServerEntry> iterator()
123                {
124                    return EmptyIterator.INSTANCE;
125                }
126                
127            
128                public void setClosureMonitor( ClosureMonitor monitor )
129                {
130                }
131                
132            
133                public boolean previous() throws Exception
134                {
135                    return false;
136                }
137                
138            
139                public boolean next() throws Exception
140                {
141                    return false;
142                }
143                
144            
145                public boolean last() throws Exception
146                {
147                    return false;
148                }
149                
150            
151                public boolean isElementReused()
152                {
153                    return false;
154                }
155                
156            
157                public boolean isClosed() throws Exception
158                {
159                    return true;
160                }
161                
162            
163                public ClonedServerEntry get() throws Exception
164                {
165                    return null;
166                }
167                
168            
169                public boolean first() throws Exception
170                {
171                    return false;
172                }
173                
174            
175                public void close( Exception reason ) throws Exception
176                {
177                }
178                
179            
180                public void close() throws Exception
181                {
182                }
183                
184            
185                public void beforeFirst() throws Exception
186                {
187                }
188                
189            
190                public void before( ClonedServerEntry element ) throws Exception
191                {
192                }
193                
194            
195                public boolean available()
196                {
197                    return false;
198                }
199                
200            
201                public void afterLast() throws Exception
202                {
203                }
204                
205            
206                public void after( ClonedServerEntry element ) throws Exception
207                {
208                }
209                
210            
211                public void setAbandoned( boolean abandoned )
212                {
213                }
214                
215            
216                public boolean removeEntryFilter( EntryFilter filter )
217                {
218                    return false;
219                }
220                
221            
222                public boolean isAbandoned()
223                {
224                    return true;
225                }
226                
227            
228                public SearchingOperationContext getOperationContext()
229                {
230                    return null;
231                }
232                
233            
234                public List<EntryFilter> getEntryFilters()
235                {
236                    return Collections.emptyList();
237                }
238                
239            
240                public boolean addEntryFilter( EntryFilter filter )
241                {
242                    return false;
243                }
244            };
245        }
246    
247    
248        /* (non-Javadoc)
249         * @see org.apache.directory.server.core.partition.Partition#lookup(java.lang.Long)
250         */
251        public ClonedServerEntry lookup( Long id ) throws Exception
252        {
253            return null;
254        }
255    
256    
257        /* (non-Javadoc)
258         * @see org.apache.directory.server.core.partition.Partition#modify(org.apache.directory.server.core.interceptor.context.ModifyOperationContext)
259         */
260        public void modify( ModifyOperationContext opContext ) throws Exception
261        {
262        }
263    
264    
265        /* (non-Javadoc)
266         * @see org.apache.directory.server.core.partition.Partition#move(org.apache.directory.server.core.interceptor.context.MoveOperationContext)
267         */
268        public void move( MoveOperationContext opContext ) throws Exception
269        {
270        }
271    
272    
273        /* (non-Javadoc)
274         * @see org.apache.directory.server.core.partition.Partition#moveAndRename(org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext)
275         */
276        public void moveAndRename( MoveAndRenameOperationContext opContext ) throws Exception
277        {
278        }
279    
280    
281        /* (non-Javadoc)
282         * @see org.apache.directory.server.core.partition.Partition#rename(org.apache.directory.server.core.interceptor.context.RenameOperationContext)
283         */
284        public void rename( RenameOperationContext opContext ) throws Exception
285        {
286        }
287    
288    
289        /* (non-Javadoc)
290         * @see org.apache.directory.server.core.partition.Partition#search(org.apache.directory.server.core.interceptor.context.SearchOperationContext)
291         */
292        public EntryFilteringCursor search( SearchOperationContext opContext ) throws Exception
293        {
294            return null;
295        }
296    
297    
298        /* (non-Javadoc)
299         * @see org.apache.directory.server.core.partition.Partition#setId(java.lang.String)
300         */
301        public void setId( String id )
302        {
303            this.id = id;
304        }
305    
306    
307        /**
308         * {@inheritDoc}
309         */
310        public void setSuffix( String suffix ) throws LdapInvalidDnException
311        {
312            this.suffix = new DN( suffix );
313        }
314    
315    
316        /* (non-Javadoc)
317         * @see org.apache.directory.server.core.partition.Partition#unbind(org.apache.directory.server.core.interceptor.context.UnbindOperationContext)
318         */
319        public void unbind( UnbindOperationContext opContext ) throws Exception
320        {
321        }
322    
323    
324        public String getSuffix()
325        {
326            return suffix.getName();
327        }
328    
329    
330        public SchemaManager getSchemaManager()
331        {
332            return null;
333        }
334    
335    
336        public void setSchemaManager( SchemaManager schemaManager )
337        {
338        }
339    
340    
341        @Override
342        protected void doDestroy() throws Exception
343        {
344        }
345    
346    
347        @Override
348        protected void doInit() throws InvalidNameException, Exception
349        {
350        }
351    
352    
353        @Override
354        public ClonedServerEntry lookup( LookupOperationContext lookupContext ) throws Exception
355        {
356            return null;
357        }
358    
359    
360        @Override
361        public void sync() throws Exception
362        {
363        }
364    }