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.shared.ldap.schema.registries;
021    
022    
023    import java.util.Collection;
024    import java.util.List;
025    
026    import org.apache.directory.shared.ldap.entry.Entry;
027    
028    
029    /**
030     * Loads schemas into registres.
031     *
032     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033     * @version $Rev$
034     */
035    public interface SchemaLoader
036    {
037        /**
038         * Sets listener used to notify of newly loaded schemas.
039         * 
040         * @param listener the listener to notify (only one is enough for us)
041         */
042        void setListener( SchemaLoaderListener listener );
043    
044    
045        /**
046         * Gets a schema object based on it's name.
047         * 
048         * @param schemaName the name of the schema to load
049         * @return the Schema object associated with the name
050         */
051        Schema getSchema( String schemaName );
052    
053    
054        /**
055         * Loads a set of schemas.  A best effort should be made to load the dependended 
056         * schemas that these schemas may rely on even if they are not included in the collection.
057         * 
058         * @param registries the registries to populate with these schemas
059         * @param check tells if the Registries must be checked after having been loaded
060         * @param schemas the set of schemas to load
061         * @return the list of erros we met during the loading of schemas
062         * @throws Exception if any kind of problems are encountered during the load
063         *
064        List<Throwable> loadWithDependencies( Registries registries, boolean check, Schema... schemas ) throws Exception;
065        
066        
067        /**
068         * Loads all available enabled schemas.
069         *
070         * @param registries the registry to load all enabled schemas into
071         * @param check tells if the Registries must be checked after having been loaded
072         * @return the list of erros we met during the loading of schemas
073         * @throws Exception if there are any failures
074         *
075        List<Throwable> loadAllEnabled( Registries registries, boolean check ) throws Exception;
076        
077        
078        /**
079         * Loads a single schema.  Do not try to resolve dependencies while implementing this method.
080         * 
081         * @param schema the schema to load
082         * @param registries the registries to populate with these schemas
083         * @param isDepLoad tells the loader if this load request is to satisfy a dependency
084         * @throws Exception if any kind of problems are encountered during the load
085         *
086        void load( Schema schema, Registries registries, boolean isDepLoad ) throws Exception;
087        
088        
089        /**
090         * Build a list of AttributeTypes read from the underlying storage for
091         * a list of specified schema
092         *
093         * @param schemas the schemas from which AttributeTypes are loaded
094         * @throws Exception if there are failures accessing AttributeType information
095         */
096        List<Entry> loadAttributeTypes( Schema... schemas ) throws Exception;
097    
098    
099        /**
100         * Build a list of AttributeTypes read from the underlying storage for
101         * a list of specific schema, using their name
102         *
103         * @param schemaNames the schema names from which AttributeTypes are loaded
104         * @throws Exception if there are failures accessing AttributeType information
105         */
106        List<Entry> loadAttributeTypes( String... schemaNames ) throws Exception;
107    
108    
109        /**
110         * Build a list of Comparators read from the underlying storage for
111         * a list of specific schema.
112         *
113         * @param schemas the schemas from which Comparators are loaded
114         * @throws Exception if there are failures accessing Comparator information
115         */
116        List<Entry> loadComparators( Schema... schemas ) throws Exception;
117    
118    
119        /**
120         * Build a list of Comparators read from the underlying storage for
121         * a list of specific schema, using their name
122         *
123         * @param schemaNames the schema names from which Comparators are loaded
124         * @throws Exception if there are failures accessing Comparator information
125         */
126        List<Entry> loadComparators( String... schemaNames ) throws Exception;
127    
128    
129        /**
130         * Build a list of DitContentRules read from the underlying storage for
131         * a list of specific schema.
132         *
133         * @param schemas the schemas from which DitContentRules are loaded
134         * @throws Exception if there are failures accessing DitContentRule information
135         */
136        List<Entry> loadDitContentRules( Schema... schemas ) throws Exception;
137    
138    
139        /**
140         * Build a list of DitContentRules read from the underlying storage for
141         * a list of specified schema names
142         *
143         * @param schemaNames the schema names from which DitContentRules are loaded
144         * @throws Exception if there are failures accessing DitContentRule information
145         */
146        List<Entry> loadDitContentRules( String... schemanames ) throws Exception;
147    
148    
149        /**
150         * Build a list of DitStructureRules read from the underlying storage for
151         * a list of specific schema.
152         *
153         * @param schemas the schemas from which DitStructureRules are loaded
154         * @throws Exception if there are failures accessing DitStructureRule information
155         */
156        List<Entry> loadDitStructureRules( Schema... schemas ) throws Exception;
157    
158    
159        /**
160         * Build a list of DitStructureRules read from the underlying storage for
161         * a list of specified schema names
162         *
163         * @param schemaNames the schema names from which DitStructureRules are loaded
164         * @throws Exception if there are failures accessing DitStructureRule information
165         */
166        List<Entry> loadDitStructureRules( String... schemanames ) throws Exception;
167    
168    
169        /**
170         * Build a list of MatchingRules read from the underlying storage for
171         * a list of specific schema
172         *
173         * @param schemas the schemas from which MatchingRules are loaded
174         * @throws Exception if there are failures accessing MatchingRule information
175         */
176        List<Entry> loadMatchingRules( Schema... schemas ) throws Exception;
177    
178    
179        /**
180         * Build a list of MatchingRules read from the underlying storage for
181         * a list of specific schema, using their name
182         *
183         * @param schemaNames the schema names from which MatchingRules are loaded
184         * @throws Exception if there are failures accessing MatchingRule information
185         */
186        List<Entry> loadMatchingRules( String... schemaNames ) throws Exception;
187    
188    
189        /**
190         * Build a list of MatchingRuleUses read from the underlying storage for
191         * a list of specific schema.
192         *
193         * @param schemas the schemas from which MatchingRuleUses are loaded
194         * @throws Exception if there are failures accessing MatchingRuleUse information
195         */
196        List<Entry> loadMatchingRuleUses( Schema... schemas ) throws Exception;
197    
198    
199        /**
200         * Build a list of MatchingRuleUses read from the underlying storage for
201         * a list of specified schema names
202         *
203         * @param schemaNames the schema names from which MatchingRuleUses are loaded
204         * @throws Exception if there are failures accessing MatchingRuleUses information
205         */
206        List<Entry> loadMatchingRuleUses( String... schemanames ) throws Exception;
207    
208    
209        /**
210         * Build a list of NameForms read from the underlying storage for
211         * a list of specific schema.
212         *
213         * @param schemas the schemas from which NameForms are loaded
214         * @throws Exception if there are failures accessing NameForm information
215         */
216        List<Entry> loadNameForms( Schema... schemas ) throws Exception;
217    
218    
219        /**
220         * Build a list of NameForms read from the underlying storage for
221         * a list of specified schema names
222         *
223         * @param schemaNames the schema names from which NameForms are loaded
224         * @throws Exception if there are failures accessing NameForms information
225         */
226        List<Entry> loadNameForms( String... schemanames ) throws Exception;
227    
228    
229        /**
230         * Build a list of Normalizers read from the underlying storage for
231         * a list of specified schema
232         *
233         * @param schemas the schemas from which Normalizers are loaded
234         * @throws Exception if there are failures accessing Normalizer information
235         */
236        List<Entry> loadNormalizers( Schema... schemas ) throws Exception;
237    
238    
239        /**
240         * Build a list of Normalizers read from the underlying storage for
241         * a list of specified schema names
242         *
243         * @param schemaNames the schema names from which Normalizers are loaded
244         * @throws Exception if there are failures accessing Normalizer information
245         */
246        List<Entry> loadNormalizers( String... schemaNames ) throws Exception;
247    
248    
249        /**
250         * Build a list of ObjectClasses read from the underlying storage for
251         * a list of specific schema.
252         *
253         * @param schemas the schemas from which ObjectClasses are loaded
254         * @throws Exception if there are failures accessing ObjectClass information
255         */
256        List<Entry> loadObjectClasses( Schema... schemas ) throws Exception;
257    
258    
259        /**
260         * Build a list of ObjectClasses read from the underlying storage for
261         * a list of specified schema names
262         *
263         * @param schemaNames the schema names from which ObjectClasses are loaded
264         * @throws Exception if there are failures accessing ObjectClasses information
265         */
266        List<Entry> loadObjectClasses( String... schemaNames ) throws Exception;
267    
268    
269        /**
270         * Build a list of Syntaxes read from the underlying storage for
271         * a list of specified schema
272         *
273         * @param schemas the schemas from which Syntaxes are loaded
274         * @throws Exception if there are failures accessing Syntax information
275         */
276        List<Entry> loadSyntaxes( Schema... schemas ) throws Exception;
277    
278    
279        /**
280         * Build a list of Syntaxes read from the underlying storage for
281         * a list of specified schema names
282         *
283         * @param schemaNames the schema names from which Syntaxes are loaded
284         * @throws Exception if there are failures accessing Syntax information
285         */
286        List<Entry> loadSyntaxes( String... schemaNames ) throws Exception;
287    
288    
289        /**
290         * Build a list of SyntaxCheckers read from the underlying storage for
291         * a list of specified schema
292         *
293         * @param schemas the schemas from which SyntaxCheckers are loaded
294         * @throws Exception if there are failures accessing SyntaxChecker information
295         */
296        List<Entry> loadSyntaxCheckers( Schema... schemas ) throws Exception;
297    
298    
299        /**
300         * Build a list of SyntaxCheckers read from the underlying storage for
301         * a list of specified schema names
302         *
303         * @param schemaNames the schema names from which SyntaxCheckers are loaded
304         * @throws Exception if there are failures accessing SyntaxChecker information
305         */
306        List<Entry> loadSyntaxCheckers( String... schemanames ) throws Exception;
307    
308    
309        /**
310         * @return the list of enabled schemas
311         * @throws Exception TODO
312         */
313        Collection<Schema> getAllEnabled() throws Exception;
314    
315        
316        /**
317         * @return the list of all schemas
318         * @throws Exception TODO
319         */
320        Collection<Schema> getAllSchemas() throws Exception;
321    
322        
323        /**
324         * Add a new schema to the schema's list
325         */
326        void addSchema( Schema schema );
327    
328        
329        /**
330         * Remove a schema from the schema's list
331         */
332        void removeSchema( Schema schema );
333    }