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      @Override
59      public boolean contains( int ruleId )
60      {
61          return immutableDITStructureRuleRegistry.contains( ruleId );
62      }
63  
64  
65      /**
66       * {@inheritDoc}
67       */
68      @Override
69      public Iterator<DitStructureRule> iterator()
70      {
71          return immutableDITStructureRuleRegistry.iterator();
72      }
73  
74  
75      /**
76       * {@inheritDoc}
77       */
78      @Override
79      public Iterator<Integer> ruleIdIterator()
80      {
81          return immutableDITStructureRuleRegistry.ruleIdIterator();
82      }
83  
84  
85      /**
86       * {@inheritDoc}
87       */
88      @Override
89      public String getSchemaName( int ruleId ) throws LdapException
90      {
91          return immutableDITStructureRuleRegistry.getSchemaName( ruleId );
92      }
93  
94  
95      /**
96       * {@inheritDoc}
97       */
98      @Override
99      public void register( DitStructureRule ditStructureRule ) throws LdapException
100     {
101     }
102 
103 
104     /**
105      * {@inheritDoc}
106      */
107     @Override
108     public DitStructureRule lookup( int ruleId ) throws LdapException
109     {
110         return immutableDITStructureRuleRegistry.lookup( ruleId );
111     }
112 
113 
114     /**
115      * {@inheritDoc}
116      */
117     @Override
118     public void unregister( int ruleId ) throws LdapException
119     {
120         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
121     }
122 
123 
124     /**
125      * {@inheritDoc}
126      */
127     @Override
128     public void unregisterSchemaElements( String schemaName ) throws LdapException
129     {
130         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
131     }
132 
133 
134     /**
135      * {@inheritDoc}
136      */
137     @Override
138     public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
139     {
140         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
141     }
142 
143 
144     /**
145      * {@inheritDoc}
146      */
147     @Override
148     public ImmutableDitStructureRuleRegistry copy()
149     {
150         return ( ImmutableDitStructureRuleRegistry ) immutableDITStructureRuleRegistry.copy();
151     }
152 
153 
154     /**
155      * {@inheritDoc}
156      */
157     @Override
158     public int size()
159     {
160         return immutableDITStructureRuleRegistry.size();
161     }
162 
163 
164     /**
165      * {@inheritDoc}
166      */
167     @Override
168     public boolean contains( String oid )
169     {
170         return immutableDITStructureRuleRegistry.contains( oid );
171     }
172 
173 
174     /**
175      * {@inheritDoc}
176      */
177     @Override
178     public String getOidByName( String name ) throws LdapException
179     {
180         return immutableDITStructureRuleRegistry.getOidByName( name );
181     }
182 
183 
184     /**
185      * {@inheritDoc}
186      */
187     @Override
188     public String getSchemaName( String oid ) throws LdapException
189     {
190         return immutableDITStructureRuleRegistry.getSchemaName( oid );
191     }
192 
193 
194     /**
195      * {@inheritDoc}
196      */
197     @Override
198     public SchemaObjectType getType()
199     {
200         return immutableDITStructureRuleRegistry.getType();
201     }
202 
203 
204     /**
205      * {@inheritDoc}
206      */
207     @Override
208     public DitStructureRule lookup( String oid ) throws LdapException
209     {
210         return immutableDITStructureRuleRegistry.lookup( oid );
211     }
212 
213 
214     /**
215      * {@inheritDoc}
216      */
217     @Override
218     public Iterator<String> oidsIterator()
219     {
220         return immutableDITStructureRuleRegistry.oidsIterator();
221     }
222 
223 
224     /**
225      * {@inheritDoc}
226      */
227     @Override
228     public DitStructureRule unregister( String numericOid ) throws LdapException
229     {
230         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
231     }
232 
233 
234     /**
235      * {@inheritDoc}
236      */
237     @Override
238     public DitStructureRule get( String oid )
239     {
240         return immutableDITStructureRuleRegistry.get( oid );
241     }
242 
243 
244     /**
245      * {@inheritDoc}
246      */
247     @Override
248     public void clear() throws LdapException
249     {
250         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
251     }
252 
253 
254     /**
255      * {@inheritDoc}
256      */
257     @Override
258     public DitStructureRule unregister( DitStructureRule schemaObject ) throws LdapException
259     {
260         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04278 ) );
261     }
262 }