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 */
020package org.apache.directory.api.ldap.model.schema.registries;
021
022
023import java.io.IOException;
024import java.util.Collection;
025import java.util.List;
026
027import org.apache.directory.api.ldap.model.entry.Entry;
028import org.apache.directory.api.ldap.model.exception.LdapException;
029
030
031/**
032 * Loads schemas into registries.
033 *
034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
035 */
036public interface SchemaLoader
037{
038    /**
039     * Gets a schema object based on it's name.
040     * 
041     * @param schemaName the name of the schema to load
042     * @return the Schema object associated with the name
043     */
044    Schema getSchema( String schemaName );
045
046
047    /**
048     * Build a list of AttributeTypes read from the underlying storage for
049     * a list of specified schema
050     *
051     * @param schemas the schemas from which AttributeTypes are loaded
052     * @return The list of loaded AttributeTypes
053     * @throws LdapException if there are failures accessing AttributeType information
054     * @throws IOException If we can't read the schemaObject
055     */
056    List<Entry> loadAttributeTypes( Schema... schemas ) throws LdapException, IOException;
057
058
059    /**
060     * Build a list of AttributeTypes read from the underlying storage for
061     * a list of specific schema, using their name
062     *
063     * @param schemaNames the schema names from which AttributeTypes are loaded
064     * @return The list of loaded AttributeTypes
065     * @throws LdapException if there are failures accessing AttributeType information
066     * @throws IOException If we can't read the schemaObject
067     */
068    List<Entry> loadAttributeTypes( String... schemaNames ) throws LdapException, IOException;
069
070
071    /**
072     * Build a list of Comparators read from the underlying storage for
073     * a list of specific schema.
074     *
075     * @param schemas the schemas from which Comparators are loaded
076     * @return The list of loaded Comparators
077     * @throws LdapException if there are failures accessing Comparator information
078     * @throws IOException If we can't read the schemaObject
079     */
080    List<Entry> loadComparators( Schema... schemas ) throws LdapException, IOException;
081
082
083    /**
084     * Build a list of Comparators read from the underlying storage for
085     * a list of specific schema, using their name
086     *
087     * @param schemaNames the schema names from which Comparators are loaded
088     * @return The list of loaded Comparators
089     * @throws LdapException if there are failures accessing Comparator information
090     * @throws IOException If we can't read the schemaObject
091     */
092    List<Entry> loadComparators( String... schemaNames ) throws LdapException, IOException;
093
094
095    /**
096     * Build a list of DitContentRules read from the underlying storage for
097     * a list of specific schema.
098     *
099     * @param schemas the schemas from which DitContentRules are loaded
100     * @return The list of loaded DitContentRules
101     * @throws LdapException if there are failures accessing DitContentRule information
102     * @throws IOException If we can't read the schemaObject
103     */
104    List<Entry> loadDitContentRules( Schema... schemas ) throws LdapException, IOException;
105
106
107    /**
108     * Build a list of DitContentRules read from the underlying storage for
109     * a list of specified schema names
110     *
111     * @param schemaNames the schema names from which DitContentRules are loaded
112     * @return The list of loaded DitContentRules
113     * @throws LdapException if there are failures accessing DitContentRule information
114     * @throws IOException If we can't read the schemaObject
115     */
116    List<Entry> loadDitContentRules( String... schemaNames ) throws LdapException, IOException;
117
118
119    /**
120     * Build a list of DitStructureRules read from the underlying storage for
121     * a list of specific schema.
122     *
123     * @param schemas the schemas from which DitStructureRules are loaded
124     * @return The list of loaded DitStructureRules
125     * @throws LdapException if there are failures accessing DitStructureRule information
126     * @throws IOException If we can't read the schemaObject
127     */
128    List<Entry> loadDitStructureRules( Schema... schemas ) throws LdapException, IOException;
129
130
131    /**
132     * Build a list of DitStructureRules read from the underlying storage for
133     * a list of specified schema names
134     *
135     * @param schemaNames the schema names from which DitStructureRules are loaded
136     * @return The list of loaded DitStructureRules
137     * @throws LdapException if there are failures accessing DitStructureRule information
138     * @throws IOException If we can't read the schemaObject
139     */
140    List<Entry> loadDitStructureRules( String... schemaNames ) throws LdapException, IOException;
141
142
143    /**
144     * Build a list of MatchingRules read from the underlying storage for
145     * a list of specific schema
146     *
147     * @param schemas the schemas from which MatchingRules are loaded
148     * @return The list of loaded MatchingRules
149     * @throws LdapException if there are failures accessing MatchingRule information
150     * @throws IOException If we can't read the schemaObject
151     */
152    List<Entry> loadMatchingRules( Schema... schemas ) throws LdapException, IOException;
153
154
155    /**
156     * Build a list of MatchingRules read from the underlying storage for
157     * a list of specific schema, using their name
158     *
159     * @param schemaNames the schema names from which MatchingRules are loaded
160     * @return The list of loaded MatchingRules
161     * @throws LdapException if there are failures accessing MatchingRule information
162     * @throws IOException If we can't read the schemaObject
163     */
164    List<Entry> loadMatchingRules( String... schemaNames ) throws LdapException, IOException;
165
166
167    /**
168     * Build a list of MatchingRuleUses read from the underlying storage for
169     * a list of specific schema.
170     *
171     * @param schemas the schemas from which MatchingRuleUses are loaded
172     * @return The list of loaded MatchingRuleUses
173     * @throws LdapException if there are failures accessing MatchingRuleUse information
174     * @throws IOException If we can't read the schemaObject
175     */
176    List<Entry> loadMatchingRuleUses( Schema... schemas ) throws LdapException, IOException;
177
178
179    /**
180     * Build a list of MatchingRuleUses read from the underlying storage for
181     * a list of specified schema names
182     *
183     * @param schemaNames the schema names from which MatchingRuleUses are loaded
184     * @return The list of loaded MatchingRuleUses
185     * @throws LdapException if there are failures accessing MatchingRuleUses information
186     * @throws IOException If we can't read the schemaObject
187     */
188    List<Entry> loadMatchingRuleUses( String... schemaNames ) throws LdapException, IOException;
189
190
191    /**
192     * Build a list of NameForms read from the underlying storage for
193     * a list of specific schema.
194     *
195     * @param schemas the schemas from which NameForms are loaded
196     * @return The list of loaded NameForms
197     * @throws LdapException if there are failures accessing NameForm information
198     * @throws IOException If we can't read the schemaObject
199     */
200    List<Entry> loadNameForms( Schema... schemas ) throws LdapException, IOException;
201
202
203    /**
204     * Build a list of NameForms read from the underlying storage for
205     * a list of specified schema names
206     *
207     * @param schemaNames the schema names from which NameForms are loaded
208     * @return The list of loaded NameForms
209     * @throws LdapException if there are failures accessing NameForms information
210     * @throws IOException If we can't read the schemaObject
211     */
212    List<Entry> loadNameForms( String... schemaNames ) throws LdapException, IOException;
213
214
215    /**
216     * Build a list of Normalizers read from the underlying storage for
217     * a list of specified schema
218     *
219     * @param schemas the schemas from which Normalizers are loaded
220     * @return The list of loaded Normalizers
221     * @throws LdapException if there are failures accessing Normalizer information
222     * @throws IOException If we can't read the schemaObject
223     */
224    List<Entry> loadNormalizers( Schema... schemas ) throws LdapException, IOException;
225
226
227    /**
228     * Build a list of Normalizers read from the underlying storage for
229     * a list of specified schema names
230     *
231     * @param schemaNames the schema names from which Normalizers are loaded
232     * @return The list of loaded Normalizers
233     * @throws LdapException if there are failures accessing Normalizer information
234     * @throws IOException If we can't read the schemaObject
235     */
236    List<Entry> loadNormalizers( String... schemaNames ) throws LdapException, IOException;
237
238
239    /**
240     * Build a list of ObjectClasses read from the underlying storage for
241     * a list of specific schema.
242     *
243     * @param schemas the schemas from which ObjectClasses are loaded
244     * @return The list of loaded ObjectClasses
245     * @throws LdapException if there are failures accessing ObjectClass information
246     * @throws IOException If we can't read the schemaObject
247     */
248    List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException, IOException;
249
250
251    /**
252     * Build a list of ObjectClasses read from the underlying storage for
253     * a list of specified schema names
254     *
255     * @param schemaNames the schema names from which ObjectClasses are loaded
256     * @return The list of loaded ObjectClasses
257     * @throws LdapException if there are failures accessing ObjectClasses information
258     * @throws IOException If we can't read the schemaObject
259     */
260    List<Entry> loadObjectClasses( String... schemaNames ) throws LdapException, IOException;
261
262
263    /**
264     * Build a list of Syntaxes read from the underlying storage for
265     * a list of specified schema
266     *
267     * @param schemas the schemas from which Syntaxes are loaded
268     * @return The list of loaded Syntaxes
269     * @throws LdapException if there are failures accessing Syntax information
270     * @throws IOException If we can't read the schemaObject
271     */
272    List<Entry> loadSyntaxes( Schema... schemas ) throws LdapException, IOException;
273
274
275    /**
276     * Build a list of Syntaxes read from the underlying storage for
277     * a list of specified schema names
278     *
279     * @param schemaNames the schema names from which Syntaxes are loaded
280     * @return The list of loaded Syntaxes
281     * @throws LdapException if there are failures accessing Syntax information
282     * @throws IOException If we can't read the schemaObject
283     */
284    List<Entry> loadSyntaxes( String... schemaNames ) throws LdapException, IOException;
285
286
287    /**
288     * Build a list of SyntaxCheckers read from the underlying storage for
289     * a list of specified schema
290     *
291     * @param schemas the schemas from which SyntaxCheckers are loaded
292     * @return The list of loaded SyntaxeCheckers
293     * @throws LdapException if there are failures accessing SyntaxChecker information
294     * @throws IOException If we can't read the schemaObject
295     */
296    List<Entry> loadSyntaxCheckers( Schema... schemas ) throws LdapException, IOException;
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     * @return A list of loaded SyntaxCheckers
305     * @throws LdapException if there are failures accessing SyntaxChecker information
306     * @throws IOException If we had some issues loading the schemas
307     * @throws IOException If we can't read the schemaObject
308     */
309    List<Entry> loadSyntaxCheckers( String... schemaNames ) throws LdapException, IOException;
310
311
312    /**
313     * @return the list of enabled schemas
314     */
315    Collection<Schema> getAllEnabled();
316
317
318    /**
319     * @return the list of all schemas
320     */
321    Collection<Schema> getAllSchemas();
322
323
324    /**
325     * Add a new schema to the schema's list
326     * 
327     * @param schema The schema to add
328     */
329    void addSchema( Schema schema );
330
331
332    /**
333     * Remove a schema from the schema's list
334     * 
335     * @param schema The schema to remove
336     */
337    void removeSchema( Schema schema );
338    
339    
340    /**
341     * @return Tells if the SchemaLoader is in RELAXED mode
342     */
343    boolean isRelaxed();
344    
345    
346    /**
347     * @return Tells if the SchemaLoader is in STRICT mode
348     */
349    boolean isStrict();
350    
351    
352    /**
353     * Set the SchemzLoader in STRICT or RELAXED mode.
354     * 
355     * @param relaxed if <code>true</code>, the SchemaLoader will be in relaxed mode, otherwise
356     * it will be in strict mode (the default)
357     */
358    void setRelaxed( boolean relaxed );
359}