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;
021
022
023 import java.io.Serializable;
024 import java.util.List;
025 import java.util.Map;
026
027 import javax.naming.NamingException;
028
029 import org.apache.directory.shared.ldap.schema.registries.Registries;
030
031
032 /**
033 * Most schema objects have some common attributes. This class
034 * contains the minimum set of properties exposed by a SchemaObject.<br>
035 * We have 11 types of SchemaObjects :
036 * <li> AttributeType
037 * <li> DitCOntentRule
038 * <li> DitStructureRule
039 * <li> LdapComparator (specific to ADS)
040 * <li> LdapSyntaxe
041 * <li> MatchingRule
042 * <li> MatchingRuleUse
043 * <li> NameForm
044 * <li> Normalizer (specific to ADS)
045 * <li> ObjectClass
046 * <li> SyntaxChecker (specific to ADS)
047 * <br>
048 * <br>
049 * This class provides accessors and setters for the following attributes,
050 * which are common to all those SchemaObjects :
051 * <li>oid : The numeric OID
052 * <li>description : The SchemaObject description
053 * <li>obsolete : Tells if the schema object is obsolete
054 * <li>extensions : The extensions, a key/Values map
055 * <li>schemaObjectType : The SchemaObject type (see upper)
056 * <li>schema : The schema the SchemaObject is associated with (it's an extension).
057 * Can be null
058 * <li>isEnabled : The SchemaObject status (it's related to the schema status)
059 * <li>isReadOnly : Tells if the SchemaObject can be modified or not
060 * <br><br>
061 * Some of those attributes are not used by some Schema elements, even if they should
062 * have been used. Here is the list :
063 * <b>name</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker
064 * <b>numericOid</b> : DitStructureRule,
065 * <b>obsolete</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker
066 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
067 * @version $Rev: 896579 $
068 */
069 public interface SchemaObject extends Serializable
070 {
071 /**
072 * Gets usually what is the numeric object identifier assigned to this
073 * SchemaObject. All schema objects except for MatchingRuleUses have an OID
074 * assigned specifically to then. A MatchingRuleUse's OID really is the OID
075 * of it's MatchingRule and not specific to the MatchingRuleUse. This
076 * effects how MatchingRuleUse objects are maintained by the system.
077 *
078 * @return an OID for this SchemaObject or its MatchingRule if this
079 * SchemaObject is a MatchingRuleUse object
080 */
081 String getOid();
082
083
084 /**
085 * A special method used when renaming an SchemaObject: we may have to
086 * change it's OID
087 * @param oid The new OID
088 */
089 void setOid( String oid );
090
091
092 /**
093 * Gets short names for this SchemaObject if any exists for it, otherwise,
094 * returns an empty list.
095 *
096 * @return the names for this SchemaObject
097 */
098 List<String> getNames();
099
100
101 /**
102 * Gets the first name in the set of short names for this SchemaObject if
103 * any exists for it.
104 *
105 * @return the first of the names for this SchemaObject or the oid
106 * if one does not exist
107 */
108 String getName();
109
110
111 /**
112 * Inject this SchemaObject into the given registries, updating the references to
113 * other SchemaObject
114 *
115 * @param errors The errors we got
116 * @param registries The Registries
117 */
118 void addToRegistries( List<Throwable> errors, Registries registries ) throws NamingException;
119
120
121 /**
122 * Remove this SchemaObject from the given registries, updating the references to
123 * other SchemaObject
124 *
125 * @param errors The errors we got
126 * @param registries The Registries
127 */
128 void removeFromRegistries( List<Throwable> errors, Registries registries ) throws NamingException;
129
130
131 /**
132 * Add a new name to the list of names for this SchemaObject. The name
133 * is lowercased and trimmed.
134 *
135 * @param names The names to add
136 */
137 void addName( String... names );
138
139
140 /**
141 * Sets the list of names for this SchemaObject. The names are
142 * lowercased and trimmed.
143 *
144 * @param names The list of names. Can be empty
145 */
146 void setNames( List<String> names );
147
148
149 /**
150 * Gets a short description about this SchemaObject.
151 *
152 * @return a short description about this SchemaObject
153 */
154 public String getDescription();
155
156
157 /**
158 * Sets the SchemaObject's description
159 *
160 * @param description The SchemaObject's description
161 */
162 public void setDescription( String description );
163
164
165 /**
166 * Gets the SchemaObject specification.
167 *
168 * @return the SchemaObject specification
169 */
170 public String getSpecification();
171
172
173 /**
174 * Sets the SchemaObject's specification
175 *
176 * @param specification The SchemaObject's specification
177 */
178 void setSpecification( String specification );
179
180
181 /**
182 * Tells if this SchemaObject is enabled.
183 *
184 * @param schemaEnabled the associated schema status
185 * @return true if the SchemaObject is enabled, or if it depends on
186 * an enabled schema
187 */
188 boolean isEnabled();
189
190
191 /**
192 * Tells if this SchemaObject is disabled.
193 *
194 * @return true if the SchemaObject is disabled
195 */
196 boolean isDisabled();
197
198
199 /**
200 * Sets the SchemaObject state, either enabled or disabled.
201 *
202 * @param enabled The current SchemaObject state
203 */
204 void setEnabled( boolean enabled );
205
206
207 /**
208 * Tells if this SchemaObject is ReadOnly.
209 *
210 * @return true if the SchemaObject is not modifiable
211 */
212 boolean isReadOnly();
213
214
215 /**
216 * Sets the SchemaObject readOnly flag
217 *
218 * @param enabled The current SchemaObject ReadOnly status
219 */
220 void setReadOnly( boolean isReadOnly );
221
222
223 /**
224 * Gets whether or not this SchemaObject has been inactivated. All
225 * SchemaObjects except Syntaxes allow for this parameter within their
226 * definition. For Syntaxes this property should always return false in
227 * which case it is never included in the description.
228 *
229 * @return true if inactive, false if active
230 */
231 boolean isObsolete();
232
233
234 /**
235 * Sets the Obsolete flag.
236 *
237 * @param obsolete The Obsolete flag state
238 */
239 void setObsolete( boolean obsolete );
240
241
242 /**
243 * @return The SchemaObject extensions, as a Map of [extension, values]
244 */
245 Map<String, List<String>> getExtensions();
246
247
248 /**
249 * Add an extension with its values
250 * @param key The extension key
251 * @param values The associated values
252 */
253 void addExtension( String key, List<String> values );
254
255
256 /**
257 * Add an extensions with their values. (Actually do a copy)
258 *
259 * @param key The extension key
260 * @param values The associated values
261 */
262 void setExtensions( Map<String, List<String>> extensions );
263
264
265 /**
266 * The SchemaObject type :
267 * <li> AttributeType
268 * <li> DitCOntentRule
269 * <li> DitStructureRule
270 * <li> LdapComparator (specific to ADS)
271 * <li> LdapSyntaxe
272 * <li> MatchingRule
273 * <li> MatchingRuleUse
274 * <li> NameForm
275 * <li> Normalizer (specific to ADS)
276 * <li> ObjectClass
277 * <li> SyntaxChecker (specific to ADS)
278 *
279 * @return the SchemaObject type
280 */
281 SchemaObjectType getObjectType();
282
283
284 /**
285 * Gets the name of the schema this SchemaObject is associated with.
286 *
287 * @return the name of the schema associated with this schemaObject
288 */
289 String getSchemaName();
290
291
292 /**
293 * Sets the name of the schema this SchemaObject is associated with.
294 *
295 * @param schemaName the new schema name
296 */
297 void setSchemaName( String schemaName );
298
299
300 /**
301 * @see Object#hashCode()
302 */
303 int hashCode();
304
305
306 /**
307 * @see Object#equals(Object)
308 */
309 boolean equals( Object o1 );
310
311
312 /**
313 * Register the given SchemaObject into the given registries' globalOidRegistry
314 *
315 * @param schemaObject the SchemaObject we want to register
316 * @param registries The registries in which we want it to be stored
317 * @throws NamingException If the OID is invalid
318 */
319 void registerOid( SchemaObject schemaObject, Registries registries ) throws NamingException;
320
321
322 /**
323 * Copy the current SchemaObject on place
324 *
325 * @return The copied SchemaObject
326 */
327 SchemaObject copy();
328
329
330 /**
331 * Copy a SchemaObject.
332 *
333 * @return A copy of the current SchemaObject
334 */
335 SchemaObject copy( SchemaObject original );
336
337
338 /**
339 * Clear the current SchemaObject : remove all the references to other objects,
340 * and all the Maps.
341 */
342 void clear();
343
344
345 /**
346 * Inject the Registries into the SchemaObject
347 *
348 * @param registries The Registries
349 */
350 void setRegistries( Registries registries );
351 }