View Javadoc
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.i18n.I18n;
26  import org.apache.directory.api.ldap.model.exception.LdapException;
27  import org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException;
28  import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
29  import org.apache.directory.api.ldap.model.schema.DitStructureRule;
30  import org.apache.directory.api.ldap.model.schema.SchemaObjectType;
31  
32  
33  /**
34   * An immutable wrapper of the DitStructureRule registry.
35   *
36   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
37   */
38  public class ImmutableDitStructureRuleRegistry implements DitStructureRuleRegistry
39  {
40      /** The wrapped DitStructureRule registry */
41      DitStructureRuleRegistry immutableDITStructureRuleRegistry;
42  
43  
44      /**
45       * Creates a new instance of ImmutableDitStructureRuleRegistry.
46       *
47       * @param ditStructureRuleRegistry The wrapped DitStructureRule registry
48       */
49      public ImmutableDitStructureRuleRegistry( DitStructureRuleRegistry ditStructureRuleRegistry )
50      {
51          immutableDITStructureRuleRegistry = ditStructureRuleRegistry;
52      }
53  
54  
55      /**
56       * {@inheritDoc}
57       */
58      public boolean contains( int ruleId )
59      {
60          return immutableDITStructureRuleRegistry.contains( ruleId );
61      }
62  
63  
64      /**
65       * {@inheritDoc}
66       */
67      public Iterator<DitStructureRule> iterator()
68      {
69          return immutableDITStructureRuleRegistry.iterator();
70      }
71  
72  
73      /**
74       * {@inheritDoc}
75       */
76      public Iterator<Integer> ruleIdIterator()
77      {
78          return immutableDITStructureRuleRegistry.ruleIdIterator();
79      }
80  
81  
82      /**
83       * {@inheritDoc}
84       */
85      public String getSchemaName( int ruleId ) throws LdapException
86      {
87          return immutableDITStructureRuleRegistry.getSchemaName( ruleId );
88      }
89  
90  
91      /**
92       * {@inheritDoc}
93       */
94      public void register( DitStructureRule ditStructureRule ) throws LdapException
95      {
96      }
97  
98  
99      /**
100      * {@inheritDoc}
101      */
102     public DitStructureRule lookup( int ruleId ) throws LdapException
103     {
104         return immutableDITStructureRuleRegistry.lookup( ruleId );
105     }
106 
107 
108     /**
109      * {@inheritDoc}
110      */
111     public void unregister( int ruleId ) throws LdapException
112     {
113         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
114     }
115 
116 
117     /**
118      * {@inheritDoc}
119      */
120     public void unregisterSchemaElements( String schemaName ) throws LdapException
121     {
122         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
123     }
124 
125 
126     /**
127      * {@inheritDoc}
128      */
129     public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
130     {
131         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
132     }
133 
134 
135     /**
136      * {@inheritDoc}
137      */
138     public ImmutableDitStructureRuleRegistry copy()
139     {
140         return ( ImmutableDitStructureRuleRegistry ) immutableDITStructureRuleRegistry.copy();
141     }
142 
143 
144     /**
145      * {@inheritDoc}
146      */
147     public int size()
148     {
149         return immutableDITStructureRuleRegistry.size();
150     }
151 
152 
153     /**
154      * {@inheritDoc}
155      */
156     public boolean contains( String oid )
157     {
158         return immutableDITStructureRuleRegistry.contains( oid );
159     }
160 
161 
162     /**
163      * {@inheritDoc}
164      */
165     public String getOidByName( String name ) throws LdapException
166     {
167         return immutableDITStructureRuleRegistry.getOidByName( name );
168     }
169 
170 
171     /**
172      * {@inheritDoc}
173      */
174     public String getSchemaName( String oid ) throws LdapException
175     {
176         return immutableDITStructureRuleRegistry.getSchemaName( oid );
177     }
178 
179 
180     /**
181      * {@inheritDoc}
182      */
183     public SchemaObjectType getType()
184     {
185         return immutableDITStructureRuleRegistry.getType();
186     }
187 
188 
189     /**
190      * {@inheritDoc}
191      */
192     public DitStructureRule lookup( String oid ) throws LdapException
193     {
194         return immutableDITStructureRuleRegistry.lookup( oid );
195     }
196 
197 
198     /**
199      * {@inheritDoc}
200      */
201     public Iterator<String> oidsIterator()
202     {
203         return immutableDITStructureRuleRegistry.oidsIterator();
204     }
205 
206 
207     /**
208      * {@inheritDoc}
209      */
210     public DitStructureRule unregister( String numericOid ) throws LdapException
211     {
212         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
213     }
214 
215 
216     /**
217      * {@inheritDoc}
218      */
219     public DitStructureRule get( String oid )
220     {
221         return immutableDITStructureRuleRegistry.get( oid );
222     }
223 
224 
225     /**
226      * {@inheritDoc}
227      */
228     public void clear() throws LdapException
229     {
230         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
231     }
232 
233 
234     /**
235      * {@inheritDoc}
236      */
237     public DitStructureRule unregister( DitStructureRule schemaObject ) throws LdapException
238     {
239         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
240     }
241 }