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.schema.registries;
021
022
023 import java.util.Iterator;
024 import java.util.List;
025 import java.util.Map;
026
027 import javax.naming.NamingException;
028
029
030 /**
031 * Object identifier registry.
032 *
033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
034 * @version $Rev: 777078 $
035 */
036 public interface OidRegistry
037 {
038 /**
039 * Gets the object identifier for a common name or returns the argument
040 * as-is if it is an object identifier.
041 *
042 * @param name the name to lookup an OID for
043 * @return the OID string associated with a name
044 * @throws NamingException if name does not map to an OID
045 */
046 String getOid( String name ) throws NamingException;
047
048
049 /**
050 * Checks to see if an identifier, oid or name exists within this registry.
051 *
052 * @param id the oid or name to look for
053 * @return true if the id exists false otherwise
054 */
055 boolean hasOid( String id );
056
057
058 /**
059 * Gets the primary name associated with an OID. The primary name is the
060 * first name specified for the OID.
061 *
062 * @param oid the object identifier
063 * @return the primary name
064 * @throws NamingException if oid does not exist
065 */
066 String getPrimaryName( String oid ) throws NamingException;
067
068
069 /**
070 * Gets the names associated with an OID. An OID is unique however it may
071 * have many names used to refer to it. A good example is the cn and
072 * commonName attribute names for OID 2.5.4.3. Within a server one name
073 * within the set must be chosen as the primary name. This is used to
074 * name certain things within the server internally. If there is more than
075 * one name then the first name is taken to be the primary.
076 *
077 * @param oid the OID for which we return the set of common names
078 * @return a sorted set of names
079 * @throws NamingException if oid does not exist
080 */
081 List<String> getNameSet( String oid ) throws NamingException;
082
083
084 /**
085 * Lists all the OIDs within the registry. This may be a really big list.
086 *
087 * @return all the OIDs registered
088 */
089 Iterator<String> list();
090
091
092 /**
093 * Adds an OID name pair to the registry.
094 *
095 * @param name the name to associate with the OID
096 * @param oid the OID to add or associate a new name with
097 */
098 void register( String name, String oid ) throws NamingException;
099
100
101 /**
102 * Get the map of all the oids by their name
103 * @return The Map that contains all the oids
104 */
105 public Map<String,String> getOidByName();
106
107
108 /**
109 * Get the map of all the oids by their name
110 * @return The Map that contains all the oids
111 */
112 public Map<String,List<String>> getNameByOid();
113
114
115 /**
116 * Removes an oid from this registry.
117 *
118 * @param numericOid the numeric identifier for the object
119 * @throws NamingException if the identifier is not numeric
120 */
121 void unregister( String numericOid ) throws NamingException;
122 }