directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1295427 - in /directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema: ./ registries/ registries/helper/
Date Thu, 01 Mar 2012 06:40:26 GMT
Author: elecharny
Date: Thu Mar  1 06:40:26 2012
New Revision: 1295427

URL: http://svn.apache.org/viewvc?rev=1295427&view=rev
Log:
Moved the addToRegistries() method out of all the SchemaObject classes to helper classes.

Added:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitStructureRuleHelper.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleHelper.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleUseHelper.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/NameFormHelper.java
Modified:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AbstractSchemaObject.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/LdapSyntax.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRule.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRuleUse.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/NameForm.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaObject.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AbstractSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AbstractSchemaObject.java?rev=1295427&r1=1295426&r2=1295427&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AbstractSchemaObject.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AbstractSchemaObject.java
Thu Mar  1 06:40:26 2012
@@ -217,15 +217,6 @@ public abstract class AbstractSchemaObje
     /**
      * {@inheritDoc}
      */
-    public void addToRegistries( List<Throwable> errors, Registries registries ) throws
LdapException
-    {
-        // do nothing
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public void removeFromRegistries( List<Throwable> errors, Registries registries
) throws LdapException
     {
         // do nothing

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/LdapSyntax.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/LdapSyntax.java?rev=1295427&r1=1295426&r2=1295427&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/LdapSyntax.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/LdapSyntax.java
Thu Mar  1 06:40:26 2012
@@ -26,7 +26,6 @@ import org.apache.directory.shared.i18n.
 import org.apache.directory.shared.ldap.model.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.schema.registries.Registries;
-import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker;
 
 
 /**
@@ -266,34 +265,6 @@ public class LdapSyntax extends Abstract
     /**
      * {@inheritDoc}
      */
-    public void addToRegistries( List<Throwable> errors, Registries registries ) throws
LdapException
-    {
-        if ( registries != null )
-        {
-            try
-            {
-                // Gets the associated SyntaxChecker
-                syntaxChecker = registries.getSyntaxCheckerRegistry().lookup( oid );
-            }
-            catch ( LdapException ne )
-            {
-                // No SyntaxChecker ? Associate the Syntax to a catch all SyntaxChecker
-                syntaxChecker = new OctetStringSyntaxChecker( oid );
-            }
-
-            // Add the references for S :
-            // S -> SC
-            if ( syntaxChecker != null )
-            {
-                registries.addReference( this, syntaxChecker );
-            }
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     @SuppressWarnings("PMD.CollapsibleIfStatements")
     // Used because of comments
     public void removeFromRegistries( List<Throwable> errors, Registries registries
) throws LdapException

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRule.java?rev=1295427&r1=1295426&r2=1295427&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRule.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRule.java
Thu Mar  1 06:40:26 2012
@@ -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;
 
@@ -24,10 +24,6 @@ import java.util.List;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.exception.LdapSchemaException;
-import org.apache.directory.shared.ldap.model.exception.LdapSchemaExceptionCodes;
-import org.apache.directory.shared.ldap.model.schema.comparators.ComparableComparator;
-import org.apache.directory.shared.ldap.model.schema.normalizers.NoOpNormalizer;
 import org.apache.directory.shared.ldap.model.schema.registries.Registries;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -44,13 +40,13 @@ import org.slf4j.LoggerFactory;
  * 
  * <pre>
  *  4.1.3. Matching Rules
- *  
+ * 
  *    Matching rules are used by servers to compare attribute values against
  *    assertion values when performing Search and Compare operations.  They
  *    are also used to identify the value to be added or deleted when
  *    modifying entries, and are used when comparing a purported
  *    distinguished name with the name of an entry.
- *  
+ * 
  *    A matching rule specifies the syntax of the assertion value.
  * 
  *    Each matching rule is identified by an object identifier (OID) and,
@@ -115,99 +111,21 @@ public class MatchingRule extends Abstra
 
 
     /**
-     * Inject the MatchingRule into the registries, updating the references to
-     * other SchemaObject
-     *
-     * @param registries The Registries
-     * @exception If the addition failed
-     */
-    @SuppressWarnings(
-        { "unchecked", "rawtypes" })
-    public void addToRegistries( List<Throwable> errors, Registries registries ) throws
LdapException
-    {
-        if ( registries != null )
-        {
-            try
-            {
-                // Gets the associated Comparator 
-                ldapComparator = ( LdapComparator<? super Object> ) registries.getComparatorRegistry().lookup(
oid );
-            }
-            catch ( LdapException ne )
-            {
-                // Default to a catch all comparator
-                ldapComparator = new ComparableComparator( oid );
-            }
-
-            try
-            {
-                // Gets the associated Normalizer
-                normalizer = registries.getNormalizerRegistry().lookup( oid );
-            }
-            catch ( LdapException ne )
-            {
-                // Default to the NoOp normalizer
-                normalizer = new NoOpNormalizer( oid );
-            }
-
-            try
-            {
-                // Get the associated LdapSyntax
-                ldapSyntax = registries.getLdapSyntaxRegistry().lookup( ldapSyntaxOid );
-            }
-            catch ( LdapException ne )
-            {
-                // The Syntax is a mandatory element, it must exist.
-                String msg = I18n.err( I18n.ERR_04317 );
-
-                LdapSchemaException ldapSchemaException = new LdapSchemaException(
-                    LdapSchemaExceptionCodes.MR_NONEXISTENT_SYNTAX, msg, ne );
-                ldapSchemaException.setSourceObject( this );
-                ldapSchemaException.setRelatedId( ldapSyntaxOid );
-                errors.add( ldapSchemaException );
-                LOG.info( msg );
-            }
-
-            /**
-             * Add the MR references (using and usedBy) : 
-             * MR -> C
-             * MR -> N
-             * MR -> S
-             */
-            if ( ldapComparator != null )
-            {
-                registries.addReference( this, ldapComparator );
-            }
-
-            if ( normalizer != null )
-            {
-                registries.addReference( this, normalizer );
-            }
-
-            if ( ldapSyntax != null )
-            {
-                registries.addReference( this, ldapSyntax );
-            }
-
-        }
-    }
-
-
-    /**
      * Remove the MatchingRule from the registries, updating the references to
      * other SchemaObject.
      * 
-     * If one of the referenced SchemaObject does not exist (), 
+     * If one of the referenced SchemaObject does not exist (),
      * an exception is thrown.
      *
      * @param registries The Registries
-     * @exception If the MatchingRule is not valid 
+     * @exception If the MatchingRule is not valid
      */
     public void removeFromRegistries( List<Throwable> errors, Registries registries
) throws LdapException
     {
         if ( registries != null )
         {
             /**
-             * Remove the MR references (using and usedBy) : 
+             * Remove the MR references (using and usedBy) :
              * MR -> C
              * MR -> N
              * MR -> S

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRuleUse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRuleUse.java?rev=1295427&r1=1295426&r2=1295427&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRuleUse.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRuleUse.java
Thu Mar  1 06:40:26 2012
@@ -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;
 
@@ -24,9 +24,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.shared.ldap.model.schema.registries.Registries;
 
 
 /**
@@ -38,7 +35,7 @@ import org.apache.directory.shared.ldap.
  * <pre>
  *  Values of the matchingRuleUse list the attributes which are suitable
  *  for use with an extensible matching rule.
- *  
+ * 
  *    Matching rule use descriptions are written according to the following
  *    ABNF:
  * 
@@ -49,7 +46,7 @@ import org.apache.directory.shared.ldap.
  *          [ SP &quot;OBSOLETE&quot; ]         ; not active
  *          SP &quot;APPLIES&quot; SP oids      ; attribute types
  *          extensions WSP RPAREN     ; extensions
- *  
+ * 
  *    where:
  *      [numericoid] is the object identifier of the matching rule
  *          associated with this matching rule use description;
@@ -62,13 +59,13 @@ import org.apache.directory.shared.ldap.
  *      [extensions] describe extensions.
  * 
  *  The matchingRule within the MatchingRuleUse definition can be used by an
- *  extensible match assertion if the assertion is based on the attributes 
- *  listed within the MatchingRuleUse definition.  If an extensible match 
- *  assertion is based on attributes other than those listed within the 
+ *  extensible match assertion if the assertion is based on the attributes
+ *  listed within the MatchingRuleUse definition.  If an extensible match
+ *  assertion is based on attributes other than those listed within the
  *  MatchingRuleUse definition then the assertion is deemed undefined.
- *  
+ * 
  *  Also according to 3.3.20 of [SYNTAXES] (ldapbis working group):
- *  
+ * 
  *  A value of the Matching Rule Use Description syntax indicates the
  *  attribute types to which a matching rule may be applied in an
  *  extensibleMatch search filter [PROT].  The LDAP-specific encoding of
@@ -108,37 +105,6 @@ public class MatchingRuleUse extends Abs
 
 
     /**
-     * Inject the MatchingRuleUse into the registries, updating the references to
-     * other SchemaObject
-     *
-     * @param registries The Registries
-     * @exception If the addition failed
-     */
-    public void addToRegistries( Registries registries ) throws LdapException
-    {
-        if ( locked )
-        {
-            throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName()
) );
-        }
-
-        if ( registries != null )
-        {
-            AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
-
-            if ( applicableAttributeOids != null )
-            {
-                applicableAttributes = new ArrayList<AttributeType>( applicableAttributeOids.size()
);
-
-                for ( String oid : applicableAttributeOids )
-                {
-                    applicableAttributes.add( atRegistry.lookup( oid ) );
-                }
-            }
-        }
-    }
-
-
-    /**
      * @return The matchingRule's list of AttributeType OIDs the MRU applies to
      */
     public List<String> getApplicableAttributeOids()
@@ -281,7 +247,7 @@ public class MatchingRuleUse extends Abs
      */
     @Override
     @SuppressWarnings("PMD.UnusedLocalVariable")
-    // Remove me when the TODO is fixed 
+    // Remove me when the TODO is fixed
     public boolean equals( Object o )
     {
         if ( !super.equals( o ) )

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/NameForm.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/NameForm.java?rev=1295427&r1=1295426&r2=1295427&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/NameForm.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/NameForm.java
Thu Mar  1 06:40:26 2012
@@ -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;
 
@@ -26,8 +26,6 @@ import java.util.List;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.shared.ldap.model.schema.registries.Registries;
 
 
 /**
@@ -41,7 +39,7 @@ import org.apache.directory.shared.ldap.
  * 
  * <pre>
  *  4.1.7.2. Name Forms
- *  
+ * 
  *   A name form &quot;specifies a permissible Rdn for entries of a particular
  *   structural object class.  A name form identifies a named object
  *   class and one or more attribute types to be used for naming (i.e.
@@ -135,43 +133,6 @@ public class NameForm extends AbstractSc
 
 
     /**
-     * Inject the NameForm into the registries, updating the references to
-     * other SchemaObject
-     *
-     * @param registries The Registries
-     */
-    public void addToRegistries( Registries registries ) throws LdapException
-    {
-        if ( registries != null )
-        {
-            AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
-
-            structuralObjectClass = registries.getObjectClassRegistry().lookup( structuralObjectClassOid
);
-
-            if ( mayAttributeTypeOids != null )
-            {
-                mayAttributeTypes = new ArrayList<AttributeType>( mayAttributeTypeOids.size()
);
-
-                for ( String oid : mayAttributeTypeOids )
-                {
-                    mayAttributeTypes.add( atRegistry.lookup( oid ) );
-                }
-            }
-
-            if ( mustAttributeTypeOids != null )
-            {
-                mustAttributeTypes = new ArrayList<AttributeType>( mustAttributeTypeOids.size()
);
-
-                for ( String oid : mustAttributeTypeOids )
-                {
-                    mustAttributeTypes.add( atRegistry.lookup( oid ) );
-                }
-            }
-        }
-    }
-
-
-    /**
      * Gets the STRUCTURAL ObjectClass this name form specifies naming
      * attributes for.
      * 
@@ -515,7 +476,7 @@ public class NameForm extends AbstractSc
      */
     @Override
     @SuppressWarnings("PMD.UnusedLocalVariable")
-    // Remove me when the TODO is fixed 
+    // Remove me when the TODO is fixed
     public boolean equals( Object o )
     {
         if ( !super.equals( o ) )

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaObject.java?rev=1295427&r1=1295426&r2=1295427&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaObject.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/SchemaObject.java
Thu Mar  1 06:40:26 2012
@@ -106,17 +106,6 @@ public interface SchemaObject
 
 
     /**
-     * Inject this SchemaObject into the given registries, updating the references to
-     * other SchemaObject
-     *
-     * @param errors the errors we got
-     * @param registries the registries
-     * @throws LdapException if one of the referenced schema objects does not exist
-     */
-    void addToRegistries( List<Throwable> errors, Registries registries ) throws LdapException;
-
-
-    /**
      * Remove this SchemaObject from the given registries, updating the references to
      * other SchemaObject.
      *

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=1295427&r1=1295426&r2=1295427&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 Mar  1 06:40:26 2012
@@ -54,6 +54,10 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.shared.ldap.model.schema.registries.helper.AttributeTypeHelper;
 import org.apache.directory.shared.ldap.model.schema.registries.helper.DitContentRuleHelper;
+import org.apache.directory.shared.ldap.model.schema.registries.helper.LdapSyntaxHelper;
+import org.apache.directory.shared.ldap.model.schema.registries.helper.MatchingRuleHelper;
+import org.apache.directory.shared.ldap.model.schema.registries.helper.MatchingRuleUseHelper;
+import org.apache.directory.shared.ldap.model.schema.registries.helper.NameFormHelper;
 import org.apache.directory.shared.ldap.model.schema.registries.helper.ObjectClassHelper;
 import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
@@ -673,12 +677,24 @@ public class Registries implements Schem
                     DitContentRuleHelper.addToRegistries( (DitContentRule)schemaObject, errors,
this );
                     break;
                     
-                case OBJECT_CLASS :
-                    ObjectClassHelper.addToRegistries( (ObjectClass)schemaObject, errors,
this );
+                case LDAP_SYNTAX :
+                    LdapSyntaxHelper.addToRegistries( (LdapSyntax)schemaObject, errors, this
);
                     break;
                     
-                default :
-                    schemaObject.addToRegistries( errors, this );
+                case MATCHING_RULE :
+                    MatchingRuleHelper.addToRegistries( (MatchingRule)schemaObject, errors,
this );
+                    break;
+                    
+                case MATCHING_RULE_USE :
+                    MatchingRuleUseHelper.addToRegistries( (MatchingRuleUse)schemaObject,
errors, this );
+                    break;
+                    
+                case NAME_FORM :
+                    NameFormHelper.addToRegistries( (NameForm)schemaObject, errors, this
);
+                    break;
+                    
+                case OBJECT_CLASS :
+                    ObjectClassHelper.addToRegistries( (ObjectClass)schemaObject, errors,
this );
                     break;
             }
         }
@@ -873,7 +889,7 @@ public class Registries implements Schem
         // or to the OctetString SyntaxChecker
         try
         {
-            syntax.addToRegistries( errors, this );
+            LdapSyntaxHelper.addToRegistries( syntax, errors, this );
         }
         catch ( LdapException e )
         {
@@ -891,14 +907,6 @@ public class Registries implements Schem
     private void resolve( Normalizer normalizer, List<Throwable> errors )
     {
         // This is currently doing nothing.
-        try
-        {
-            normalizer.addToRegistries( errors, this );
-        }
-        catch ( LdapException e )
-        {
-            errors.add( e );
-        }
     }
 
 
@@ -911,16 +919,8 @@ public class Registries implements Schem
     private void resolve( LdapComparator<?> comparator, List<Throwable> errors
)
     {
         // This is currently doing nothing.
-        try
-        {
-            comparator.addToRegistries( errors, this );
-        }
-        catch ( LdapException e )
-        {
-            errors.add( e );
-        }
     }
-
+    
 
     /**
      * Attempts to resolve the SyntaxChecker
@@ -931,14 +931,6 @@ public class Registries implements Schem
     private void resolve( SyntaxChecker syntaxChecker, List<Throwable> errors )
     {
         // This is currently doing nothing.
-        try
-        {
-            syntaxChecker.addToRegistries( errors, this );
-        }
-        catch ( LdapException e )
-        {
-            errors.add( e );
-        }
     }
 
 

Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitStructureRuleHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitStructureRuleHelper.java?rev=1295427&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitStructureRuleHelper.java
(added)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitStructureRuleHelper.java
Thu Mar  1 06:40:26 2012
@@ -0,0 +1,35 @@
+/*
+ *  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.helper;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An helper class used to store all the methods associated with an DitStructureRule
+ * in relation with the Registries and SchemaManager.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DitStructureRuleHelper
+{
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( DitStructureRuleHelper.class
);
+}

Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/LdapSyntaxHelper.java?rev=1295427&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
(added)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
Thu Mar  1 06:40:26 2012
@@ -0,0 +1,88 @@
+/*
+ *  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.helper;
+
+import java.util.List;
+
+import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.shared.ldap.model.schema.registries.Registries;
+import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An helper class used to store all the methods associated with an LdapSyntax
+ * in relation with the Registries and SchemaManager.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapSyntaxHelper
+{
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( LdapSyntaxHelper.class );
+
+    /**
+     * Inject the LdapSyntax into the registries, updating the references to
+     * other SchemaObject
+     *
+     * @param registries The Registries
+     * @exception If the addition failed
+     */
+    public static void addToRegistries( LdapSyntax ldapSyntax, List<Throwable> errors,
 Registries registries ) throws LdapException
+    {
+        if ( registries != null )
+        {
+            try
+            {
+                ldapSyntax.unlock();
+    
+                if ( registries != null )
+                {
+                    SyntaxChecker syntaxChecker = null;
+                    
+                    try
+                    {
+                        // Gets the associated SyntaxChecker
+                        syntaxChecker = registries.getSyntaxCheckerRegistry().lookup( ldapSyntax.getOid()
);
+                    }
+                    catch ( LdapException ne )
+                    {
+                        // No SyntaxChecker ? Associate the Syntax to a catch all SyntaxChecker
+                        syntaxChecker = new OctetStringSyntaxChecker( ldapSyntax.getOid()
);
+                    }
+
+                    // Add the references for S :
+                    // S -> SC
+                    if ( syntaxChecker != null )
+                    {
+                        registries.addReference( ldapSyntax, syntaxChecker );
+                        ldapSyntax.setSyntaxChecker( syntaxChecker );
+                    }
+                }
+            }
+            finally
+            {
+                ldapSyntax.lock();
+            }
+        }
+    }
+}

Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleHelper.java?rev=1295427&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleHelper.java
(added)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleHelper.java
Thu Mar  1 06:40:26 2012
@@ -0,0 +1,141 @@
+/*
+ *  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.helper;
+
+import java.util.List;
+
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapSchemaException;
+import org.apache.directory.shared.ldap.model.exception.LdapSchemaExceptionCodes;
+import org.apache.directory.shared.ldap.model.schema.LdapComparator;
+import org.apache.directory.shared.ldap.model.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.model.schema.MatchingRule;
+import org.apache.directory.shared.ldap.model.schema.Normalizer;
+import org.apache.directory.shared.ldap.model.schema.comparators.ComparableComparator;
+import org.apache.directory.shared.ldap.model.schema.normalizers.NoOpNormalizer;
+import org.apache.directory.shared.ldap.model.schema.registries.Registries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An helper class used to store all the methods associated with an MatchingRule
+ * in relation with the Registries and SchemaManager.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MatchingRuleHelper
+{
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( MatchingRuleHelper.class );
+
+    /**
+     * Inject the MatchingRule into the registries, updating the references to
+     * other SchemaObject
+     *
+     * @param registries The Registries
+     * @exception If the addition failed
+     */
+    public static void addToRegistries( MatchingRule matchingRule, List<Throwable>
errors,  Registries registries ) throws LdapException
+    {
+        if ( registries != null )
+        {
+            try
+            {
+                matchingRule.unlock();
+                
+                if ( registries != null )
+                {
+                    LdapComparator<?> ldapComparator = null;
+                    Normalizer normalizer = null;
+                    LdapSyntax ldapSyntax = null;
+                    
+                    try
+                    {
+                        // Gets the associated Comparator
+                        ldapComparator = registries.getComparatorRegistry().lookup( matchingRule.getOid()
);
+                    }
+                    catch ( LdapException ne )
+                    {
+                        // Default to a catch all comparator
+                        ldapComparator = new ComparableComparator( matchingRule.getOid()
);
+                    }
+
+                    try
+                    {
+                        // Gets the associated Normalizer
+                        normalizer = registries.getNormalizerRegistry().lookup( matchingRule.getOid()
);
+                    }
+                    catch ( LdapException ne )
+                    {
+                        // Default to the NoOp normalizer
+                        normalizer = new NoOpNormalizer( matchingRule.getOid() );
+                    }
+
+                    try
+                    {
+                        // Get the associated LdapSyntax
+                        ldapSyntax = registries.getLdapSyntaxRegistry().lookup( matchingRule.getSyntaxOid()
);
+                    }
+                    catch ( LdapException ne )
+                    {
+                        // The Syntax is a mandatory element, it must exist.
+                        String msg = I18n.err( I18n.ERR_04317 );
+
+                        LdapSchemaException ldapSchemaException = new LdapSchemaException(
+                            LdapSchemaExceptionCodes.MR_NONEXISTENT_SYNTAX, msg, ne );
+                        ldapSchemaException.setSourceObject( matchingRule );
+                        ldapSchemaException.setRelatedId( matchingRule.getSyntaxOid() );
+                        errors.add( ldapSchemaException );
+                        LOG.info( msg );
+                    }
+
+                    /**
+                     * Add the MR references (using and usedBy) :
+                     * MR -> C
+                     * MR -> N
+                     * MR -> S
+                     */
+                    if ( ldapComparator != null )
+                    {
+                        registries.addReference( matchingRule, ldapComparator );
+                        matchingRule.setLdapComparator( ldapComparator );
+                    }
+
+                    if ( normalizer != null )
+                    {
+                        registries.addReference( matchingRule, normalizer );
+                        matchingRule.setNormalizer( normalizer );
+                    }
+
+                    if ( ldapSyntax != null )
+                    {
+                        registries.addReference( matchingRule, ldapSyntax );
+                        matchingRule.setSyntax( ldapSyntax );
+                    }
+                }
+            }
+            finally
+            {
+                matchingRule.lock();
+            }
+        }
+    }
+}

Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleUseHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleUseHelper.java?rev=1295427&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleUseHelper.java
(added)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleUseHelper.java
Thu Mar  1 06:40:26 2012
@@ -0,0 +1,72 @@
+/*
+ *  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.helper;
+
+import java.util.List;
+
+import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.schema.MatchingRuleUse;
+import org.apache.directory.shared.ldap.model.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.model.schema.registries.Registries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An helper class used to store all the methods associated with a MatchingRuleUse
+ * in relation with the Registries and SchemaManager.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MatchingRuleUseHelper
+{
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( MatchingRuleUseHelper.class
);
+
+    /**
+     * Inject the MatchingRuleUse into the registries, updating the references to
+     * other SchemaObject
+     *
+     * @param registries The Registries
+     * @exception If the addition failed
+     */
+    public static void addToRegistries( MatchingRuleUse matchingRuleUse, List<Throwable>
errors,  Registries registries ) throws LdapException
+    {
+        if ( registries != null )
+        {
+            try
+            {
+                matchingRuleUse.unlock();
+    
+                AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
+                
+                matchingRuleUse.getApplicableAttributes().clear();
+
+                for ( String oid : matchingRuleUse.getApplicableAttributeOids() )
+                {
+                    matchingRuleUse.getApplicableAttributes().add( atRegistry.lookup( oid
) );
+                }
+            }
+            finally
+            {
+                matchingRuleUse.lock();
+            }
+        }
+    }
+}

Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/NameFormHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/NameFormHelper.java?rev=1295427&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/NameFormHelper.java
(added)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/NameFormHelper.java
Thu Mar  1 06:40:26 2012
@@ -0,0 +1,83 @@
+/*
+ *  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.helper;
+
+import java.util.List;
+
+import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.schema.NameForm;
+import org.apache.directory.shared.ldap.model.schema.ObjectClass;
+import org.apache.directory.shared.ldap.model.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.model.schema.registries.Registries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An helper class used to store all the methods associated with an NameForm
+ * in relation with the Registries and SchemaManager.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class NameFormHelper
+{
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( NameFormHelper.class );
+
+    /**
+     * Inject the NameForm into the registries, updating the references to
+     * other SchemaObject
+     *
+     * @param registries The Registries
+     * @exception If the addition failed
+     */
+    public static void addToRegistries( NameForm nameForm, List<Throwable> errors,
 Registries registries ) throws LdapException
+    {
+        if ( registries != null )
+        {
+            try
+            {
+                nameForm.unlock();
+    
+                AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
+
+                ObjectClass structuralObjectClass = registries.getObjectClassRegistry().lookup(
nameForm.getStructuralObjectClassOid() );
+                nameForm.setStructuralObjectClass( structuralObjectClass );
+                
+                nameForm.getMayAttributeTypes().clear();
+                
+                for ( String oid : nameForm.getMayAttributeTypeOids() )
+                {
+                    nameForm.getMayAttributeTypes().add( atRegistry.lookup( oid ) );
+                }
+
+                nameForm.getMustAttributeTypes().clear();
+                
+                for ( String oid : nameForm.getMustAttributeTypeOids() )
+                {
+                    nameForm.getMustAttributeTypes().add( atRegistry.lookup( oid ) );
+                }
+            }
+            finally
+            {
+                nameForm.lock();
+            }
+        }
+    }
+}



Mime
View raw message