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