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.util.Iterator;
024
025import org.apache.directory.api.ldap.model.exception.LdapException;
026import org.apache.directory.api.ldap.model.schema.DitStructureRule;
027
028
029/**
030 * An DitStructureRule registry service interface.
031 *
032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033 */
034public interface DitStructureRuleRegistry extends SchemaObjectRegistry<DitStructureRule>,
035    Iterable<DitStructureRule>
036{
037    /**
038     * Checks to see if an DitStructureRule exists in the registry, by its
039     * ruleId. 
040     * 
041     * @param ruleId the rule identifier of the DitStructureRule
042     * @return true if a DitStructureRule definition exists for the ruleId, false
043     * otherwise
044     */
045    boolean contains( int ruleId );
046
047
048    /**
049     * Gets an iterator over the registered descriptions in the registry.
050     *
051     * @return an Iterator of descriptions
052     */
053    @Override
054    Iterator<DitStructureRule> iterator();
055
056
057    /**
058     * Gets an iterator over the registered ruleId in the registry.
059     *
060     * @return an Iterator of ruleId
061     */
062    Iterator<Integer> ruleIdIterator();
063
064
065    /**
066     * Gets the name of the schema this schema object is associated with.
067     *
068     * @param ruleId the object identifier
069     * @return the schema name
070     * @throws LdapException if the schema object does not exist
071     */
072    String getSchemaName( int ruleId ) throws LdapException;
073
074
075    /**
076     * Registers a new DitStructureRule with this registry.
077     *
078     * @param ditStructureRule the DitStructureRule to register
079     * @throws LdapException if the DitStructureRule is already registered or
080     * the registration operation is not supported
081     */
082    @Override
083    void register( DitStructureRule ditStructureRule ) throws LdapException;
084
085
086    /**
087     * Looks up an dITStructureRule by its unique Object IDentifier or by its
088     * name.
089     * 
090     * @param ruleId the rule identifier for the DitStructureRule
091     * @return the DitStructureRule instance for rule identifier
092     * @throws LdapException if the DitStructureRule does not exist
093     */
094    DitStructureRule lookup( int ruleId ) throws LdapException;
095
096
097    /**
098     * Unregisters a DitStructureRule using it's rule identifier. 
099     * 
100     * @param ruleId the rule identifier for the DitStructureRule to unregister
101     * @throws LdapException if no such DitStructureRule exists
102     */
103    void unregister( int ruleId ) throws LdapException;
104
105
106    /**
107     * Unregisters all DITStructureRules defined for a specific schema from
108     * this registry.
109     * 
110     * @param schemaName the name of the schema whose syntaxCheckers will be removed from
111     * @throws LdapException if no such SchemaElement exists
112     */
113    @Override
114    void unregisterSchemaElements( String schemaName ) throws LdapException;
115
116
117    /**
118     * Modify all the DitStructureRule using a schemaName when this name changes.
119     *
120     * @param originalSchemaName The original Schema name
121     * @param newSchemaName The new Schema name
122     * @throws org.apache.directory.api.ldap.model.exception.LdapException if the schema can't be renamed
123     */
124    @Override
125    void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException;
126
127
128    /**
129     * Copy the DitStructureRuleRegistry
130     */
131    @Override
132    DitStructureRuleRegistry copy();
133}