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.i18n.I18n;
026import org.apache.directory.api.ldap.model.exception.LdapException;
027import org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException;
028import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
029import org.apache.directory.api.ldap.model.schema.DitContentRule;
030import org.apache.directory.api.ldap.model.schema.SchemaObjectType;
031
032
033/**
034 * An immutable wrapper of the DitContentRule registry.
035 *
036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
037 */
038public class ImmutableDitContentRuleRegistry implements DitContentRuleRegistry
039{
040    /** The wrapped DitContentRule registry */
041    DitContentRuleRegistry immutableDITContentRuleRegistry;
042
043
044    /**
045     * Creates a new instance of ImmutableDitContentRuleRegistry.
046     *
047     * @param ditContentRuleRegistry The wrapped DitContentRule registry
048     */
049    public ImmutableDitContentRuleRegistry( DitContentRuleRegistry ditContentRuleRegistry )
050    {
051        immutableDITContentRuleRegistry = ditContentRuleRegistry;
052    }
053
054
055    /**
056     * {@inheritDoc}
057     */
058    public ImmutableDitContentRuleRegistry copy()
059    {
060        return ( ImmutableDitContentRuleRegistry ) immutableDITContentRuleRegistry.copy();
061    }
062
063
064    /**
065     * {@inheritDoc}
066     */
067    public int size()
068    {
069        return immutableDITContentRuleRegistry.size();
070    }
071
072
073    /**
074     * {@inheritDoc}
075     */
076    public boolean contains( String oid )
077    {
078        return immutableDITContentRuleRegistry.contains( oid );
079    }
080
081
082    /**
083     * {@inheritDoc}
084     */
085    public String getOidByName( String name ) throws LdapException
086    {
087        return immutableDITContentRuleRegistry.getOidByName( name );
088    }
089
090
091    /**
092     * {@inheritDoc}
093     */
094    public String getSchemaName( String oid ) throws LdapException
095    {
096        return immutableDITContentRuleRegistry.getSchemaName( oid );
097    }
098
099
100    /**
101     * {@inheritDoc}
102     */
103    public SchemaObjectType getType()
104    {
105        return immutableDITContentRuleRegistry.getType();
106    }
107
108
109    /**
110     * {@inheritDoc}
111     */
112    public Iterator<DitContentRule> iterator()
113    {
114        return immutableDITContentRuleRegistry.iterator();
115    }
116
117
118    /**
119     * {@inheritDoc}
120     */
121    public DitContentRule lookup( String oid ) throws LdapException
122    {
123        return immutableDITContentRuleRegistry.lookup( oid );
124    }
125
126
127    /**
128     * {@inheritDoc}
129     */
130    public Iterator<String> oidsIterator()
131    {
132        return immutableDITContentRuleRegistry.oidsIterator();
133    }
134
135
136    /**
137     * {@inheritDoc}
138     */
139    public void register( DitContentRule schemaObject ) throws LdapException
140    {
141        throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
142    }
143
144
145    /**
146     * {@inheritDoc}
147     */
148    public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
149    {
150        throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
151    }
152
153
154    /**
155     * {@inheritDoc}
156     */
157    public DitContentRule unregister( String numericOid ) throws LdapException
158    {
159        throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
160    }
161
162
163    /**
164     * {@inheritDoc}
165     */
166    public void unregisterSchemaElements( String schemaName ) throws LdapException
167    {
168        throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
169    }
170
171
172    /**
173     * {@inheritDoc}
174     */
175    public DitContentRule get( String oid )
176    {
177        return immutableDITContentRuleRegistry.get( oid );
178    }
179
180
181    /**
182     * {@inheritDoc}
183     */
184    public void clear() throws LdapException
185    {
186        throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
187    }
188
189
190    /**
191     * {@inheritDoc}
192     */
193    public DitContentRule unregister( DitContentRule schemaObject ) throws LdapException
194    {
195        throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04277 ) );
196    }
197}