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