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.api.ldap.model.schema.registries; 21 22 23 import java.util.Iterator; 24 25 import org.apache.directory.api.ldap.model.exception.LdapException; 26 import org.apache.directory.api.ldap.model.schema.SchemaObject; 27 import org.apache.directory.api.ldap.model.schema.SchemaObjectType; 28 29 30 /** 31 * Common schema object registry interface. 32 * 33 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 34 */ 35 public interface SchemaObjectRegistry<T extends SchemaObject> 36 { 37 /** 38 * Checks to see if an SchemaObject exists in the registry, by its 39 * OID or name. 40 * 41 * @param oid the object identifier or name of the SchemaObject 42 * @return true if a SchemaObject definition exists for the oid, false 43 * otherwise 44 */ 45 boolean contains( String oid ); 46 47 48 /** 49 * Gets the name of the schema this schema object is associated with. 50 * 51 * @param oid the object identifier or the name 52 * @return the schema name 53 * @throws LdapException if the schema object does not exist 54 */ 55 String getSchemaName( String oid ) throws LdapException; 56 57 58 /** 59 * Gets the SchemaObject associated with a given OID. 60 * 61 * @param oid The SchemaObject's OID we are looking for 62 * @return The SchemaObject, if any. Null otherwise 63 */ 64 T get( String oid ); 65 66 67 /** 68 * Modify all the SchemaObject using a schemaName when this name changes. 69 * 70 * @param originalSchemaName The original Schema name 71 * @param newSchemaName The new Schema name 72 * @throws LdapException if the schema object does not exist 73 */ 74 void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException; 75 76 77 /** 78 * Gets an iterator over the registered schema objects in the registry. 79 * 80 * @return an Iterator of homogeneous schema objects 81 */ 82 Iterator<T> iterator(); 83 84 85 /** 86 * Gets an iterator over the registered schema objects'OID in the registry. 87 * 88 * @return an Iterator of OIDs 89 */ 90 Iterator<String> oidsIterator(); 91 92 93 /** 94 * Looks up a SchemaObject by its unique Object Identifier or by name. 95 * 96 * @param oid the object identifier or name 97 * @return the SchemaObject instance for the id 98 * @throws LdapException if the SchemaObject does not exist 99 */ 100 T lookup( String oid ) throws LdapException; 101 102 103 /** 104 * Registers a new SchemaObject with this registry. 105 * 106 * @param schemaObject the SchemaObject to register 107 * @throws LdapException if the SchemaObject is already registered or 108 * the registration operation is not supported 109 */ 110 void register( T schemaObject ) throws LdapException; 111 112 113 /** 114 * Removes the SchemaObject registered with this registry, using its 115 * numeric OID. 116 * 117 * @param numericOid the numeric identifier 118 * @throws LdapException if the numeric identifier is invalid 119 */ 120 T unregister( String numericOid ) throws LdapException; 121 122 123 /** 124 * Removes the SchemaObject registered with this registry. 125 * 126 * @param schemaObject the schemaObject to unregister 127 * @throws LdapException if the schemaObject can't be unregistered is invalid 128 */ 129 T unregister( T schemaObject ) throws LdapException; 130 131 132 /** 133 * Unregisters all SchemaObjects defined for a specific schema from 134 * this registry. 135 * 136 * @param schemaName the name of the schema whose SchemaObjects will be removed from 137 */ 138 void unregisterSchemaElements( String schemaName ) throws LdapException; 139 140 141 /** 142 * Gets the numericOid for a name/alias if one is associated. To prevent 143 * lookup failures due to case variance in the name, a failure to lookup the 144 * OID, will trigger a lookup using a lower cased version of the name and 145 * the name that failed to match will automatically be associated with the 146 * OID. 147 * 148 * @param name The name we are looking the oid for 149 * @return The numericOID associated with this name 150 * @throws LdapException If the OID can't be found 151 */ 152 String getOidByName( String name ) throws LdapException; 153 154 155 /** 156 * Copy a DefaultSchemaObjectRegistry. All the stored SchemaObject will also 157 * be copied, by the cross references will be lost. 158 * 159 * @return SchemaObjectRegistry<T> The copied registry 160 */ 161 SchemaObjectRegistry<T> copy(); 162 163 164 /** 165 * @return the type 166 */ 167 SchemaObjectType getType(); 168 169 170 /** 171 * @return The number of AttributeType stored 172 */ 173 int size(); 174 175 176 /** 177 * Clear the registry from all its content 178 */ 179 void clear() throws LdapException; 180 }