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.List; 025 026 import org.apache.directory.shared.ldap.exception.LdapException; 027 028 import org.apache.directory.shared.i18n.I18n; 029 import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException; 030 import org.apache.directory.shared.ldap.message.ResultCodeEnum; 031 import org.apache.directory.shared.ldap.schema.ObjectClass; 032 import org.apache.directory.shared.ldap.schema.SchemaObject; 033 import org.apache.directory.shared.ldap.schema.SchemaObjectType; 034 035 036 /** 037 * An immutable wrapper of the ObjectClass registry. 038 * 039 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 040 * @version $Rev: 828111 $ 041 */ 042 public class ImmutableObjectClassRegistry implements ObjectClassRegistry, Cloneable 043 { 044 /** The wrapped ObjectClass registry */ 045 private ObjectClassRegistry immutableObjectClassRegistry; 046 047 048 /** 049 * Creates a new instance of ImmutableAttributeTypeRegistry. 050 * 051 * @param atRegistry The wrapped Attrib uteType registry 052 */ 053 public ImmutableObjectClassRegistry( ObjectClassRegistry ocRegistry ) 054 { 055 immutableObjectClassRegistry = ocRegistry; 056 } 057 058 059 /** 060 * {@inheritDoc} 061 */ 062 public boolean hasDescendants( String ancestorId ) throws LdapException 063 { 064 return immutableObjectClassRegistry.hasDescendants( ancestorId ); 065 } 066 067 068 /** 069 * {@inheritDoc} 070 */ 071 public Iterator<ObjectClass> descendants( String ancestorId ) throws LdapException 072 { 073 return immutableObjectClassRegistry.descendants( ancestorId ); 074 } 075 076 077 /** 078 * {@inheritDoc} 079 */ 080 public void registerDescendants( ObjectClass objectClass, List<ObjectClass> ancestors ) throws LdapException 081 { 082 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 083 } 084 085 086 /** 087 * {@inheritDoc} 088 */ 089 public void unregisterDescendants( ObjectClass attributeType, List<ObjectClass> ancestors ) throws LdapException 090 { 091 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 092 } 093 094 095 /** 096 * {@inheritDoc} 097 */ 098 public void register( ObjectClass objectClass ) throws LdapException 099 { 100 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 101 } 102 103 104 /** 105 * {@inheritDoc} 106 */ 107 public ObjectClass unregister( String numericOid ) throws LdapException 108 { 109 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 110 } 111 112 113 /** 114 * Clone the ObjectClassRegistry 115 */ 116 public ImmutableObjectClassRegistry copy() 117 { 118 return ( ImmutableObjectClassRegistry ) immutableObjectClassRegistry.copy(); 119 } 120 121 122 /** 123 * {@inheritDoc} 124 */ 125 public int size() 126 { 127 return immutableObjectClassRegistry.size(); 128 } 129 130 131 /** 132 * {@inheritDoc} 133 */ 134 public boolean contains( String oid ) 135 { 136 return immutableObjectClassRegistry.contains( oid ); 137 } 138 139 140 /** 141 * {@inheritDoc} 142 */ 143 public String getOidByName( String name ) throws LdapException 144 { 145 return immutableObjectClassRegistry.getOidByName( name ); 146 } 147 148 149 /** 150 * {@inheritDoc} 151 */ 152 public String getSchemaName( String oid ) throws LdapException 153 { 154 return immutableObjectClassRegistry.getSchemaName( oid ); 155 } 156 157 158 /** 159 * {@inheritDoc} 160 */ 161 public SchemaObjectType getType() 162 { 163 return immutableObjectClassRegistry.getType(); 164 } 165 166 167 /** 168 * {@inheritDoc} 169 */ 170 public Iterator<ObjectClass> iterator() 171 { 172 return immutableObjectClassRegistry.iterator(); 173 } 174 175 176 /** 177 * {@inheritDoc} 178 */ 179 public ObjectClass lookup( String oid ) throws LdapException 180 { 181 return immutableObjectClassRegistry.lookup( oid ); 182 } 183 184 185 /** 186 * {@inheritDoc} 187 */ 188 public Iterator<String> oidsIterator() 189 { 190 return immutableObjectClassRegistry.oidsIterator(); 191 } 192 193 194 /** 195 * {@inheritDoc} 196 */ 197 public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException 198 { 199 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 200 } 201 202 203 /** 204 * {@inheritDoc} 205 */ 206 public void unregisterSchemaElements( String schemaName ) throws LdapException 207 { 208 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 209 } 210 211 212 /** 213 * {@inheritDoc} 214 */ 215 public SchemaObject get( String oid ) 216 { 217 return immutableObjectClassRegistry.get( oid ); 218 } 219 220 221 /** 222 * {@inheritDoc} 223 */ 224 public void clear() throws LdapException 225 { 226 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 227 } 228 229 230 /** 231 * {@inheritDoc} 232 */ 233 public ObjectClass unregister( ObjectClass schemaObject ) throws LdapException 234 { 235 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 236 } 237 }