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