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