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