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