Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 2645 invoked from network); 10 Mar 2011 22:22:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Mar 2011 22:22:47 -0000 Received: (qmail 8904 invoked by uid 500); 10 Mar 2011 22:22:47 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 8852 invoked by uid 500); 10 Mar 2011 22:22:47 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 8845 invoked by uid 99); 10 Mar 2011 22:22:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Mar 2011 22:22:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Mar 2011 22:22:44 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9828723889E7; Thu, 10 Mar 2011 22:22:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1080375 - /directory/shared/branches/akarasulu/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/RegistryUtils.java Date: Thu, 10 Mar 2011 22:22:20 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110310222220.9828723889E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: akarasulu Date: Thu Mar 10 22:22:20 2011 New Revision: 1080375 URL: http://svn.apache.org/viewvc?rev=1080375&view=rev Log: forgot to add new class Added: directory/shared/branches/akarasulu/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/RegistryUtils.java Added: directory/shared/branches/akarasulu/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/RegistryUtils.java URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/RegistryUtils.java?rev=1080375&view=auto ============================================================================== --- directory/shared/branches/akarasulu/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/RegistryUtils.java (added) +++ directory/shared/branches/akarasulu/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/RegistryUtils.java Thu Mar 10 22:22:20 2011 @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.model.schema.registries; + + +import org.apache.directory.shared.ldap.model.exception.LdapException; +import org.apache.directory.shared.ldap.model.schema.MutableSchemaObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * Moving some utility methods here to clean up schema interfaces. + * + * @author Apache Directory Project + */ +public class RegistryUtils +{ + /** static class logger */ + private static final Logger LOG = LoggerFactory.getLogger( DefaultSchemaObjectRegistry.class ); + + /** A speedup for debug */ + private static final boolean DEBUG = LOG.isDebugEnabled(); + + + /** + * Modify all the SchemaObject using a schemaName when this name changes. + * + * @param originalSchemaName The original Schema name + * @param newSchemaName The new Schema name + * @throws LdapException if the schema object does not exist + */ + public void renameSchema( SchemaObjectRegistry registry, String originalSchemaName, + String newSchemaName ) throws LdapException + { + // Loop on all the SchemaObjects stored and remove those associated + // with the give schemaName + for ( T schemaObject : registry ) + { + if ( originalSchemaName.equalsIgnoreCase( schemaObject.getSchemaName() ) ) + { + schemaObject.setSchemaName( newSchemaName ); + + if ( DEBUG ) + { + LOG.debug( "Renamed {} schemaName to {}", schemaObject, newSchemaName ); + } + } + } + } +}