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.shared.ldap.model.schema.registries; 021 022 023import java.util.Iterator; 024import java.util.List; 025 026import org.apache.directory.shared.i18n.I18n; 027import org.apache.directory.shared.ldap.model.exception.LdapException; 028import org.apache.directory.shared.ldap.model.exception.LdapUnwillingToPerformException; 029import org.apache.directory.shared.ldap.model.message.ResultCodeEnum; 030import org.apache.directory.shared.ldap.model.schema.ObjectClass; 031import org.apache.directory.shared.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 public boolean hasDescendants( String ancestorId ) throws LdapException 060 { 061 return immutableObjectClassRegistry.hasDescendants( ancestorId ); 062 } 063 064 065 /** 066 * {@inheritDoc} 067 */ 068 public Iterator<ObjectClass> descendants( String ancestorId ) throws LdapException 069 { 070 return immutableObjectClassRegistry.descendants( ancestorId ); 071 } 072 073 074 /** 075 * {@inheritDoc} 076 */ 077 public void registerDescendants( ObjectClass objectClass, List<ObjectClass> ancestors ) throws LdapException 078 { 079 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 080 } 081 082 083 /** 084 * {@inheritDoc} 085 */ 086 public void unregisterDescendants( ObjectClass attributeType, List<ObjectClass> ancestors ) throws LdapException 087 { 088 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 089 } 090 091 092 /** 093 * {@inheritDoc} 094 */ 095 public void register( ObjectClass objectClass ) throws LdapException 096 { 097 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04284 ) ); 098 } 099 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}