Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5E8BC75C2 for ; Thu, 15 Dec 2011 16:58:17 +0000 (UTC) Received: (qmail 72383 invoked by uid 500); 15 Dec 2011 16:58:17 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 72348 invoked by uid 500); 15 Dec 2011 16:58:17 -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 72341 invoked by uid 99); 15 Dec 2011 16:58:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Dec 2011 16:58:17 +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, 15 Dec 2011 16:58:12 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5544E23889EC for ; Thu, 15 Dec 2011 16:57:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1214861 - in /directory/shared/trunk/ldap: model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java schema/data/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java Date: Thu, 15 Dec 2011 16:57:50 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111215165750.5544E23889EC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Thu Dec 15 16:57:49 2011 New Revision: 1214861 URL: http://svn.apache.org/viewvc?rev=1214861&view=rev Log: Modified the Registries.add() method to take a third parameter, a flag used to tell the method to check or not the added schemaObject. This is useful to avoid generating the same errors twice Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java?rev=1214861&r1=1214860&r2=1214861&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java Thu Dec 15 16:57:49 2011 @@ -6,16 +6,16 @@ * 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. - * + * under the License. + * */ package org.apache.directory.shared.ldap.model.schema.registries; @@ -123,13 +123,13 @@ public class Registries implements Schem public static final boolean RELAXED = true; /** - * A map storing a relation between a SchemaObject and all the + * A map storing a relation between a SchemaObject and all the * referencing SchemaObjects. */ protected Map> usedBy; /** - * A map storing a relation between a SchemaObject and all the + * A map storing a relation between a SchemaObject and all the * SchemaObjects it uses. */ protected Map> using; @@ -137,7 +137,7 @@ public class Registries implements Schem /** A reference on the schema Manager */ @SuppressWarnings( { "PMD.UnusedPrivateField", "unused" }) - // False positive + // False positive private SchemaManager schemaManager; @@ -279,7 +279,7 @@ public class Registries implements Schem /** - * Get an OID from a name. As we have many possible registries, we + * Get an OID from a name. As we have many possible registries, we * have to look in all of them to get the one containing the OID. * * @param name The name we are looking at @@ -456,7 +456,7 @@ public class Registries implements Schem *
  • 6) MatchingRuleUses (depend on matchingRules and AttributeTypes) *
  • 7) DitContentRules (depend on ObjectClasses and AttributeTypes) *
  • 8) NameForms (depends on ObjectClasses and AttributeTypes) - *
  • 9) DitStructureRules (depends onNameForms and DitStructureRules) * + *
  • 9) DitStructureRules (depends onNameForms and DitStructureRules) * * * @return a list of exceptions encountered while resolving entities */ @@ -520,7 +520,7 @@ public class Registries implements Schem /** * Add the SchemaObjectReferences. This method does nothing, it's just - * a catch all. The other methods will be called for each specific + * a catch all. The other methods will be called for each specific * schemaObject * public void addCrossReferences( SchemaObject schemaObject ) @@ -530,7 +530,7 @@ public class Registries implements Schem /** - * Delete the AT references (using and usedBy) : + * Delete the AT references (using and usedBy) : * AT -> MR (for EQUALITY, ORDERING and SUBSTR) * AT -> S * AT -> AT @@ -565,10 +565,10 @@ public class Registries implements Schem /** - * Some specific controls must be checked : + * Some specific controls must be checked : * - an AT must have either a SYNTAX or a SUP. If there is no SYNTAX, then * the AT will take it's superior SYNTAX; - * - if there is no EQUALITY, ORDERING or SUBSTRING MR, and if there is + * - if there is no EQUALITY, ORDERING or SUBSTRING MR, and if there is * a SUP, then the AT will use its parent MR, if any; * - if an AT has a superior, then its usage must be the same than its * superior Usage; @@ -592,7 +592,7 @@ public class Registries implements Schem String msg = "Cannot build the AttributeType references for the object " + attributeType.getName() + ", error : " + ne.getMessage(); - Throwable error = new LdapSchemaViolationException( + Throwable error = new LdapSchemaViolationException( msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX ); errors.add( error ); LOG.info( msg ); @@ -604,7 +604,7 @@ public class Registries implements Schem // The LdapSyntax (cannot be null) //buildSyntax( errors, attributeType ); - // The equality MR. + // The equality MR. //buildEquality( errors, attributeType ); // The ORDERING MR. @@ -698,7 +698,7 @@ public class Registries implements Schem /** - * Delete the MR references (using and usedBy) : + * Delete the MR references (using and usedBy) : * MR -> C * MR -> N * MR -> S @@ -992,7 +992,7 @@ public class Registries implements Schem /** - * Check if the Comparator, Normalizer and the syntax are + * Check if the Comparator, Normalizer and the syntax are * existing for a matchingRule. */ private void resolve( MatchingRule matchingRule, List errors ) @@ -1018,7 +1018,7 @@ public class Registries implements Schem } else { - // This is an error. + // This is an error. LdapSchemaException ldapSchemaException = new LdapSchemaException( LdapSchemaExceptionCodes.OID_ALREADY_REGISTERED, I18n.err( I18n.ERR_04294, matchingRule.getOid() ) ); ldapSchemaException.setSourceObject( matchingRule ); @@ -1075,7 +1075,7 @@ public class Registries implements Schem } } - // We now have to process the superior, if it hasn't been + // We now have to process the superior, if it hasn't been // processed yet. if ( superior != null ) { @@ -1095,7 +1095,7 @@ public class Registries implements Schem } } - // Process the Syntax. If it's null, the attributeType must have + // Process the Syntax. If it's null, the attributeType must have // a Superior. String syntaxOid = attributeType.getSyntaxOid(); @@ -1183,13 +1183,13 @@ public class Registries implements Schem /** * Check the inheritance, and the existence of MatchingRules and LdapSyntax - * for an attribute + * for an attribute */ private void resolve( AttributeType attributeType, List errors ) { // This set is used to avoid having more than one error // for an AttributeType. It's mandatory when processing - // a Superior, as it may be broken and referenced more than once. + // a Superior, as it may be broken and referenced more than once. Set processed = new HashSet(); // Store the AttributeType itself in the processed, to avoid cycle @@ -1207,7 +1207,7 @@ public class Registries implements Schem { if ( processed.contains( objectClass ) ) { - // We have found a cycle. It has already been reported, + // We have found a cycle. It has already been reported, // don't add a new error, just exit. return null; } @@ -1233,7 +1233,7 @@ public class Registries implements Schem { // This set is used to avoid having more than one error // for an ObjectClass. It's mandatory when processing - // the Superiors, as they may be broken and referenced more than once. + // the Superiors, as they may be broken and referenced more than once. Set processed = new HashSet(); // Store the ObjectClass itself in the processed, to avoid cycle @@ -1294,7 +1294,7 @@ public class Registries implements Schem } } - // We now have to process the superior, if it hasn't been + // We now have to process the superior, if it hasn't been // processed yet. if ( superior != null ) { @@ -1316,7 +1316,7 @@ public class Registries implements Schem } } - // Process the MAY attributeTypes. + // Process the MAY attributeTypes. for ( String mayOid : objectClass.getMayAttributeTypeOids() ) { // Check if the MAY AttributeType is present in the registries @@ -1331,7 +1331,7 @@ public class Registries implements Schem } } - // Process the MUST attributeTypes. + // Process the MUST attributeTypes. for ( String mustOid : objectClass.getMustAttributeTypeOids() ) { // Check if the MUST AttributeType is present in the registries @@ -1353,7 +1353,7 @@ public class Registries implements Schem } catch ( LdapException ne ) { - // Do nothing. We may have a broken OC, + // Do nothing. We may have a broken OC, // but at this point, it doesn't matter. } } @@ -1362,7 +1362,7 @@ public class Registries implements Schem /** * Applies the added SchemaObject to the given register */ - public List add( List errors, SchemaObject schemaObject ) throws LdapException + public List add( List errors, SchemaObject schemaObject, boolean check ) throws LdapException { // Relax the registries boolean wasRelaxed = isRelaxed; @@ -1375,17 +1375,23 @@ public class Registries implements Schem associateWithSchema( errors, schemaObject ); // Build the SchemaObject references - buildReference( errors, schemaObject ); + if ( check ) + { + buildReference( errors, schemaObject ); + } // Lock the SchemaObject schemaObject.lock(); - if ( errors.isEmpty() ) + if ( check ) { - // Check the registries now - List checkErrors = checkRefInteg(); - - errors.addAll( checkErrors ); + if ( errors.isEmpty() ) + { + // Check the registries now + List checkErrors = checkRefInteg(); + + errors.addAll( checkErrors ); + } } // Get back to Strict mode @@ -1461,7 +1467,7 @@ public class Registries implements Schem /** - * Gets an unmodifiable Map of schema names to loaded Schema objects. + * Gets an unmodifiable Map of schema names to loaded Schema objects. * * @return the map of loaded Schema objects */ @@ -1911,7 +1917,7 @@ public class Registries implements Schem * Gets the Set of SchemaObjects referencing the given SchemaObject * * @param schemaObject The SchemaObject we are looking for - * @return The Set of referencing SchemaObject, or null + * @return The Set of referencing SchemaObject, or null */ public Set getUsedBy( SchemaObject schemaObject ) { @@ -1997,7 +2003,7 @@ public class Registries implements Schem * Gets the Set of SchemaObjects referenced by the given SchemaObject * * @param schemaObject The SchemaObject we are looking for - * @return The Set of referenced SchemaObject, or null + * @return The Set of referenced SchemaObject, or null */ public Set getUsing( SchemaObject schemaObject ) { @@ -2265,7 +2271,7 @@ public class Registries implements Schem return false; } - // Check the references : Syntax -> SyntaxChecker and SyntaxChecker -> Syntax + // Check the references : Syntax -> SyntaxChecker and SyntaxChecker -> Syntax if ( !checkReferences( syntax, syntax.getSyntaxChecker(), "SyntaxChecker" ) ) { return false; @@ -2326,19 +2332,19 @@ public class Registries implements Schem return false; } - // Check the references : MR -> S and S -> MR + // Check the references : MR -> S and S -> MR if ( !checkReferences( matchingRule, matchingRule.getSyntax(), "Syntax" ) ) { return false; } - // Check the references : MR -> N + // Check the references : MR -> N if ( !checkReferences( matchingRule, matchingRule.getNormalizer(), "Normalizer" ) ) { return false; } - // Check the references : MR -> C and C -> MR + // Check the references : MR -> C and C -> MR if ( !checkReferences( matchingRule, matchingRule.getLdapComparator(), "Comparator" ) ) { return false; @@ -2362,7 +2368,7 @@ public class Registries implements Schem return false; } - // Check the references : OC -> AT and AT -> OC (MAY) + // Check the references : OC -> AT and AT -> OC (MAY) if ( !checkReferences( objectClass, may, "AttributeType" ) ) { return false; @@ -2382,7 +2388,7 @@ public class Registries implements Schem return false; } - // Check the references : OC -> AT and AT -> OC (MUST) + // Check the references : OC -> AT and AT -> OC (MUST) if ( !checkReferences( objectClass, must, "AttributeType" ) ) { return false; @@ -2403,7 +2409,7 @@ public class Registries implements Schem return false; } - // Check the references : OC -> OC and OC -> OC (SUPERIORS) + // Check the references : OC -> OC and OC -> OC (SUPERIORS) if ( !checkReferences( objectClass, superior, "ObjectClass" ) ) { return false; @@ -2417,7 +2423,7 @@ public class Registries implements Schem for ( AttributeType attributeType : attributeTypeRegistry ) { - // Check that each AttributeType has a SYNTAX + // Check that each AttributeType has a SYNTAX if ( attributeType.getSyntax() == null ) { LOG.debug( "The AttributeType {} has no Syntax", attributeType ); @@ -2506,7 +2512,7 @@ public class Registries implements Schem return false; } - // Check the references : AT -> AT and AT -> AT (SUPERIOR) + // Check the references : AT -> AT and AT -> AT (SUPERIOR) if ( !checkReferences( attributeType, superior, "AttributeType" ) ) { return false; @@ -2647,10 +2653,10 @@ public class Registries implements Schem /** - * Tells if the Registries is permissive or if it must be checked + * Tells if the Registries is permissive or if it must be checked * against inconsistencies. * - * @return True if SchemaObjects can be added even if they break the consistency + * @return True if SchemaObjects can be added even if they break the consistency */ public boolean isRelaxed() { @@ -2661,7 +2667,7 @@ public class Registries implements Schem /** * Tells if the Registries is strict. * - * @return True if SchemaObjects cannot be added if they break the consistency + * @return True if SchemaObjects cannot be added if they break the consistency */ public boolean isStrict() { @@ -2692,7 +2698,7 @@ public class Registries implements Schem /** * Tells if the Registries accept disabled elements. * - * @return True if disabled SchemaObjects can be added + * @return True if disabled SchemaObjects can be added */ public boolean isDisabledAccepted() { @@ -2719,7 +2725,7 @@ public class Registries implements Schem * Change the Registries behavior regarding disabled SchemaObject element. * * @param disabledAccepted If false, then the Registries won't accept - * disabled SchemaObject or enabled SchemaObject from disabled schema + * disabled SchemaObject or enabled SchemaObject from disabled schema */ public void setDisabledAccepted( boolean disabledAccepted ) { Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java?rev=1214861&r1=1214860&r2=1214861&view=diff ============================================================================== --- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java (original) +++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java Thu Dec 15 16:57:49 2011 @@ -722,6 +722,7 @@ public class DefaultSchemaManager implem LOG.info( msg ); Throwable error = new LdapProtocolErrorException( msg ); errors.add( error ); + return false; } @@ -955,7 +956,7 @@ public class DefaultSchemaManager implem { if ( registries.isDisabledAccepted() || ( schema.isEnabled() && schemaObject.isEnabled() ) ) { - registries.add( errors, schemaObject ); + registries.add( errors, schemaObject, false ); } else { @@ -966,7 +967,7 @@ public class DefaultSchemaManager implem { if ( schema.isEnabled() && schemaObject.isEnabled() ) { - registries.add( errors, schemaObject ); + registries.add( errors, schemaObject, false ); } else { @@ -1812,7 +1813,7 @@ public class DefaultSchemaManager implem if ( registries.isRelaxed() ) { // Apply the addition right away - registries.add( errors, copy ); + registries.add( errors, copy, true ); return errors.isEmpty(); } @@ -1877,7 +1878,7 @@ public class DefaultSchemaManager implem } // Inject the new SchemaObject in the cloned registries - clonedRegistries.add( errors, copy ); + clonedRegistries.add( errors, copy, true ); // Remove the cloned registries clonedRegistries.clear(); @@ -1889,7 +1890,7 @@ public class DefaultSchemaManager implem copy = copy( schemaObject ); // Apply the addition to the real registries - registries.add( errors, copy ); + registries.add( errors, copy, true ); LOG.debug( "Added {} into the enabled schema {}", copy.getName(), schemaName );