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.registries;
021    
022    
023    import java.util.Iterator;
024    import java.util.Map;
025    
026    import javax.naming.NamingException;
027    
028    import org.apache.directory.shared.i18n.I18n;
029    import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
030    import org.apache.directory.shared.ldap.message.ResultCodeEnum;
031    import org.apache.directory.shared.ldap.schema.AttributeType;
032    import org.apache.directory.shared.ldap.schema.SchemaObject;
033    import org.apache.directory.shared.ldap.schema.SchemaObjectType;
034    import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
035    
036    
037    /**
038     * An immutable wrapper of the AttributeType registry.
039     *
040     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
041     * @version $Rev: 828111 $
042     */
043    public class ImmutableAttributeTypeRegistry implements AttributeTypeRegistry
044    {
045        /** The wrapped AttributeType registry */
046        AttributeTypeRegistry immutableAttributeTypeRegistry;
047    
048    
049        /**
050         * Creates a new instance of ImmutableAttributeTypeRegistry.
051         *
052         * @param attributeTypeRegistry The wrapped AttributeType registry
053         */
054        public ImmutableAttributeTypeRegistry( AttributeTypeRegistry attributeTypeRegistry )
055        {
056            immutableAttributeTypeRegistry = attributeTypeRegistry;
057        }
058    
059    
060        /**
061         * {@inheritDoc}
062         */
063        public Map<String, OidNormalizer> getNormalizerMapping()
064        {
065            return immutableAttributeTypeRegistry.getNormalizerMapping();
066        }
067    
068    
069        /**
070         * {@inheritDoc}
071         */
072        public boolean hasDescendants( String ancestorId ) throws NamingException
073        {
074            return immutableAttributeTypeRegistry.hasDescendants( ancestorId );
075        }
076    
077    
078        /**
079         * {@inheritDoc}
080         */
081        public Iterator<AttributeType> descendants( String ancestorId ) throws NamingException
082        {
083            return immutableAttributeTypeRegistry.descendants( ancestorId );
084        }
085    
086    
087        /**
088         * {@inheritDoc}
089         */
090        public void register( AttributeType attributeType ) throws NamingException
091        {
092            throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_04275 ), ResultCodeEnum.NO_SUCH_OPERATION );
093        }
094    
095    
096        /**
097         * {@inheritDoc}
098         */
099        public void registerDescendants( AttributeType attributeType, AttributeType ancestor ) throws NamingException
100        {
101            throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_04275 ), ResultCodeEnum.NO_SUCH_OPERATION );
102        }
103    
104    
105        /**
106         * {@inheritDoc}
107         */
108        public void unregisterDescendants( AttributeType attributeType, AttributeType ancestor ) throws NamingException
109        {
110            throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_04275 ), ResultCodeEnum.NO_SUCH_OPERATION );
111        }
112    
113    
114        /**
115         * {@inheritDoc}
116         */
117        public AttributeType unregister( String numericOid ) throws NamingException
118        {
119            throw new LdapOperationNotSupportedException( "Cannot modify the AttributeTypeRegistry copy",
120                ResultCodeEnum.NO_SUCH_OPERATION );
121        }
122    
123    
124        /**
125         * {@inheritDoc}
126         */
127        public void addMappingFor( AttributeType attributeType ) throws NamingException
128        {
129            throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_04275 ), ResultCodeEnum.NO_SUCH_OPERATION );
130        }
131    
132    
133        /**
134         * {@inheritDoc}
135         */
136        public void removeMappingFor( AttributeType attributeType ) throws NamingException
137        {
138            throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_04275 ), ResultCodeEnum.NO_SUCH_OPERATION );
139        }
140    
141    
142        /**
143         * {@inheritDoc}
144         */
145        public AttributeType lookup( String oid ) throws NamingException
146        {
147            return immutableAttributeTypeRegistry.lookup( oid );
148        }
149    
150    
151        /**
152         * {@inheritDoc}
153         */
154        public String toString()
155        {
156            return immutableAttributeTypeRegistry.toString();
157        }
158    
159    
160        /**
161         * {@inheritDoc}
162         */
163        public AttributeTypeRegistry copy()
164        {
165            return ( AttributeTypeRegistry ) immutableAttributeTypeRegistry.copy();
166        }
167    
168    
169        /**
170         * {@inheritDoc}
171         */
172        public int size()
173        {
174            return immutableAttributeTypeRegistry.size();
175        }
176    
177    
178        /**
179         * {@inheritDoc}
180         */
181        public Iterator<AttributeType> iterator()
182        {
183            return immutableAttributeTypeRegistry.iterator();
184        }
185    
186    
187        /**
188         * {@inheritDoc}
189         */
190        public Iterator<String> oidsIterator()
191        {
192            return immutableAttributeTypeRegistry.oidsIterator();
193        }
194    
195    
196        /**
197         * {@inheritDoc}
198         */
199        public boolean contains( String oid )
200        {
201            return immutableAttributeTypeRegistry.contains( oid );
202        }
203    
204    
205        /**
206         * {@inheritDoc}
207         */
208        public String getOidByName( String name ) throws NamingException
209        {
210            return immutableAttributeTypeRegistry.getOidByName( name );
211        }
212    
213    
214        /**
215         * {@inheritDoc}
216         */
217        public String getSchemaName( String oid ) throws NamingException
218        {
219            return immutableAttributeTypeRegistry.getSchemaName( oid );
220        }
221    
222    
223        /**
224         * {@inheritDoc}
225         */
226        public SchemaObjectType getType()
227        {
228            return immutableAttributeTypeRegistry.getType();
229        }
230    
231    
232        /**
233         * {@inheritDoc}
234         */
235        public void renameSchema( String originalSchemaName, String newSchemaName )
236        {
237            // Do nothing
238        }
239    
240    
241        /**
242         * {@inheritDoc}
243         */
244        public void unregisterSchemaElements( String schemaName ) throws NamingException
245        {
246            throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_04275 ), ResultCodeEnum.NO_SUCH_OPERATION );
247        }
248    
249    
250        /**
251         * {@inheritDoc}
252         */
253        public SchemaObject get( String oid )
254        {
255            return immutableAttributeTypeRegistry.get( oid );
256        }
257    
258    
259        /**
260         * {@inheritDoc}
261         */
262        public void clear() throws NamingException
263        {
264            throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_04275 ), ResultCodeEnum.NO_SUCH_OPERATION );
265        }
266    
267    
268        /**
269         * {@inheritDoc}
270         */
271        public AttributeType unregister( AttributeType schemaObject ) throws NamingException
272        {
273            throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_04275 ), ResultCodeEnum.NO_SUCH_OPERATION );
274        }
275    }