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 */ 020package org.apache.directory.api.ldap.model.schema.registries; 021 022 023import java.util.Iterator; 024import java.util.List; 025 026import org.apache.directory.api.i18n.I18n; 027import org.apache.directory.api.ldap.model.exception.LdapException; 028import org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException; 029import org.apache.directory.api.ldap.model.message.ResultCodeEnum; 030import org.apache.directory.api.ldap.model.schema.ObjectClass; 031import org.apache.directory.api.ldap.model.schema.SchemaObjectType; 032 033 034/** 035 * An immutable wrapper of the ObjectClass registry. 036 * 037 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 038 */ 039public class ImmutableObjectClassRegistry implements ObjectClassRegistry, Cloneable 040{ 041 /** The wrapped ObjectClass registry */ 042 private ObjectClassRegistry immutableObjectClassRegistry; 043 044 045 /** 046 * Creates a new instance of ImmutableAttributeTypeRegistry. 047 * 048 * @param ocRegistry The wrapped Attrib uteType registry 049 */ 050 public ImmutableObjectClassRegistry( ObjectClassRegistry ocRegistry ) 051 { 052 immutableObjectClassRegistry = ocRegistry; 053 } 054 055 056 /** 057 * {@inheritDoc} 058 */ 059 @Override 060 public boolean hasDescendants( String ancestorId ) throws LdapException 061 { 062 return immutableObjectClassRegistry.hasDescendants( ancestorId ); 063 } 064 065 066 /** 067 * {@inheritDoc} 068 */ 069 @Override 070 public Iterator<ObjectClass> descendants( String ancestorId ) throws LdapException 071 { 072 return immutableObjectClassRegistry.descendants( ancestorId ); 073 } 074 075 076 /** 077 * {@inheritDoc} 078 */ 079 @Override 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 @Override 090 public void unregisterDescendants( ObjectClass attributeType, List<ObjectClass> ancestors ) throws LdapException 091 { 092 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 093 } 094 095 096 /** 097 * {@inheritDoc} 098 */ 099 @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}