directory-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=1295562&view=rev
Log:
Moved the removeFromRegistries() method from the SchemaObject sub-classes, to some helper
classes.

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/AttributeType.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/ObjectClass.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
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/AttributeTypeHelper.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitContentRuleHelper.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
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/ObjectClassHelper.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=1295562&r1=1295561&r2=1295562&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 13:53:10 2012
@@ -215,15 +215,6 @@ public abstract class AbstractSchemaObje
 
 
     /**
-     * {@inheritDoc}
-     */
-    public void removeFromRegistries( List<Throwable> errors, Registries registries
) throws LdapException
-    {
-        // do nothing
-    }
-
-
-    /**
      * Inject the Registries into the SchemaObject
      *
      * @param registries The Registries

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributeType.java?rev=1295562&r1=1295561&r2=1295562&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributeType.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributeType.java
Thu Mar  1 13:53:10 2012
@@ -20,11 +20,7 @@
 package org.apache.directory.shared.ldap.model.schema;
 
 
-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;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -197,58 +193,6 @@ public class AttributeType extends Abstr
 
 
     /**
-     * {@inheritDoc}
-     *
-     * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR,
SYNTAX),
-     * an exception is thrown.
-     */
-    public void removeFromRegistries( List<Throwable> errors, Registries registries
) throws LdapException
-    {
-        if ( registries != null )
-        {
-            AttributeTypeRegistry attributeTypeRegistry = registries.getAttributeTypeRegistry();
-
-            // Remove the attributeType from the oid/normalizer map
-            attributeTypeRegistry.removeMappingFor( this );
-
-            // Unregister this AttributeType into the Descendant map
-            attributeTypeRegistry.unregisterDescendants( this, superior );
-
-            /**
-             * Remove the AT references (using and usedBy) :
-             * AT -> MR (for EQUALITY, ORDERING and SUBSTR)
-             * AT -> S
-             * AT -> AT
-             */
-            if ( equality != null )
-            {
-                registries.delReference( this, equality );
-            }
-
-            if ( ordering != null )
-            {
-                registries.delReference( this, ordering );
-            }
-
-            if ( substring != null )
-            {
-                registries.delReference( this, substring );
-            }
-
-            if ( syntax != null )
-            {
-                registries.delReference( this, syntax );
-            }
-
-            if ( superior != null )
-            {
-                registries.delReference( this, superior );
-            }
-        }
-    }
-
-
-    /**
      * Gets whether or not this AttributeType is single-valued.
      *
      * @return true if only one value can exist for this AttributeType, false

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=1295562&r1=1295561&r2=1295562&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 13:53:10 2012
@@ -24,8 +24,6 @@ import java.util.List;
 
 import org.apache.directory.shared.i18n.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;
 
 
 /**
@@ -265,27 +263,6 @@ public class LdapSyntax extends Abstract
     /**
      * {@inheritDoc}
      */
-    @SuppressWarnings("PMD.CollapsibleIfStatements")
-    // Used because of comments
-    public void removeFromRegistries( List<Throwable> errors, Registries registries
) throws LdapException
-    {
-        if ( registries != null )
-        {
-            /**
-             * Remove the Syntax references (using and usedBy) :
-             * S -> SC
-             */
-            if ( syntaxChecker != null )
-            {
-                registries.delReference( this, syntaxChecker );
-            }
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public LdapSyntax copy()
     {
         LdapSyntax copy = new LdapSyntax( oid );

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=1295562&r1=1295561&r2=1295562&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 13:53:10 2012
@@ -20,11 +20,7 @@
 package org.apache.directory.shared.ldap.model.schema;
 
 
-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.Registries;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -111,44 +107,6 @@ public class MatchingRule extends Abstra
 
 
     /**
-     * Remove the MatchingRule from the registries, updating the references to
-     * other SchemaObject.
-     * 
-     * If one of the referenced SchemaObject does not exist (),
-     * an exception is thrown.
-     *
-     * @param registries The Registries
-     * @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) :
-             * MR -> C
-             * MR -> N
-             * MR -> S
-             */
-            if ( ldapComparator != null )
-            {
-                registries.delReference( this, ldapComparator );
-            }
-
-            if ( ldapSyntax != null )
-            {
-                registries.delReference( this, ldapSyntax );
-            }
-
-            if ( normalizer != null )
-            {
-                registries.delReference( this, normalizer );
-            }
-        }
-    }
-
-
-    /**
      * Gets the LdapSyntax used by this MatchingRule.
      * 
      * @return the LdapSyntax of this MatchingRule

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/ObjectClass.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/ObjectClass.java?rev=1295562&r1=1295561&r2=1295562&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/ObjectClass.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/ObjectClass.java
Thu Mar  1 13:53:10 2012
@@ -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.ObjectClassRegistry;
-import org.apache.directory.shared.ldap.model.schema.registries.Registries;
 
 
 /**
@@ -118,58 +115,6 @@ public class ObjectClass extends Abstrac
 
 
     /**
-     * Remove the ObjectClass from the registries, updating the references to
-     * other SchemaObject.
-     *
-     * If one of the referenced SchemaObject does not exist (SUPERIORS, MAY, MUST),
-     * an exception is thrown.
-     *
-     * @param errors The errors we got while removing the ObjectClass from the registries
-     * @param registries The Registries
-     * @exception If the ObjectClass is not valid
-     */
-    public void removeFromRegistries( List<Throwable> errors, Registries registries
) throws LdapException
-    {
-        if ( registries != null )
-        {
-            ObjectClassRegistry objectClassRegistry = registries.getObjectClassRegistry();
-
-            // Unregister this ObjectClass into the Descendant map
-            objectClassRegistry.unregisterDescendants( this, superiors );
-
-            /**
-             * Remove the OC references (using and usedBy) :
-             * OC -> AT (for MAY and MUST)
-             * OC -> OC
-             */
-            if ( mayAttributeTypes != null )
-            {
-                for ( AttributeType may : mayAttributeTypes )
-                {
-                    registries.delReference( this, may );
-                }
-            }
-
-            if ( mustAttributeTypes != null )
-            {
-                for ( AttributeType must : mustAttributeTypes )
-                {
-                    registries.delReference( this, must );
-                }
-            }
-
-            if ( superiors != null )
-            {
-                for ( ObjectClass superior : superiors )
-                {
-                    registries.delReference( this, superior );
-                }
-            }
-        }
-    }
-
-
-    /**
      * @return the mayAttributeTypeOids
      */
     public List<String> getMayAttributeTypeOids()

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=1295562&r1=1295561&r2=1295562&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 13:53:10 2012
@@ -106,17 +106,6 @@ public interface SchemaObject
 
 
     /**
-     * Remove this SchemaObject from the given registries, updating the references to
-     * other SchemaObject.
-     *
-     * @param errors the errors we got
-     * @param registries The registries
-     * @throws org.apache.directory.shared.ldap.model.exception.LdapException if one of the
referenced schema objects does not exist
-     */
-    void removeFromRegistries( List<Throwable> errors, Registries registries ) throws
LdapException;
-
-
-    /**
      * Add a new name to the list of names for this SchemaObject. The name
      * is lower cased and trimmed.
      * 

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=1295562&r1=1295561&r2=1295562&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 13:53:10 2012
@@ -717,7 +717,24 @@ public class Registries implements Schem
     {
         try
         {
-            schemaObject.removeFromRegistries( errors, this );
+            switch ( schemaObject.getObjectType() )
+            {
+                case ATTRIBUTE_TYPE :
+                    AttributeTypeHelper.removeFromRegistries( (AttributeType)schemaObject,
errors, this );
+                    break;
+
+                case LDAP_SYNTAX :
+                    LdapSyntaxHelper.removeFromRegistries( (LdapSyntax)schemaObject, errors,
this );
+                    break;
+
+                case MATCHING_RULE :
+                    MatchingRuleHelper.removeFromRegistries( (MatchingRule)schemaObject,
errors, this );
+                    break;
+
+                case OBJECT_CLASS :
+                    ObjectClassHelper.removeFromRegistries( (ObjectClass)schemaObject, errors,
this );
+                    break;
+            }
         }
         catch ( LdapException ne )
         {

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/AttributeTypeHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/AttributeTypeHelper.java?rev=1295562&r1=1295561&r2=1295562&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/AttributeTypeHelper.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/AttributeTypeHelper.java
Thu Mar  1 13:53:10 2012
@@ -48,10 +48,16 @@ public class AttributeTypeHelper
     private static final Logger LOG = LoggerFactory.getLogger( AttributeTypeHelper.class
);
 
     /**
-     * {@inheritDoc}
+     * Inject the AttributeType into the Registries, updating the references to
+     * other SchemaObject
      *
      * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR,
SYNTAX),
      * an exception is thrown.
+     * 
+     * @param attributeType The AttributeType to add to the Registries
+     * @param errors The errors we got while adding the AttributeType to the Registries
+     * @param registries The Registries
+     * @exception If the AttributeType is not valid
      */
     public static void addToRegistries( AttributeType attributeType, List<Throwable>
errors, Registries registries ) throws LdapException
     {
@@ -602,4 +608,62 @@ public class AttributeTypeHelper
             LOG.info( msg );
         }
     }
+    
+    
+    /**
+     * Remove the AttributeType from the registries, updating the references to
+     * other SchemaObject.
+     *
+     * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR,
SYNTAX),
+     * an exception is thrown.
+     * 
+     * @param attributeType The AttributeType to remove from the Registries
+     * @param errors The errors we got while removing the AttributeType from the Registries
+     * @param registries The Registries
+     * @exception If the AttributeType is not valid
+     */
+    public static void removeFromRegistries( AttributeType attributeType, List<Throwable>
errors, Registries registries ) throws LdapException
+    {
+        if ( registries != null )
+        {
+            AttributeTypeRegistry attributeTypeRegistry = registries.getAttributeTypeRegistry();
+
+            // Remove the attributeType from the oid/normalizer map
+            attributeTypeRegistry.removeMappingFor( attributeType );
+
+            // Unregister this AttributeType into the Descendant map
+            attributeTypeRegistry.unregisterDescendants( attributeType, attributeType.getSuperior()
);
+
+            /**
+             * Remove the AT references (using and usedBy) :
+             * AT -> MR (for EQUALITY, ORDERING and SUBSTR)
+             * AT -> S
+             * AT -> AT
+             */
+            if ( attributeType.getEquality() != null )
+            {
+                registries.delReference( attributeType, attributeType.getEquality() );
+            }
+
+            if ( attributeType.getOrdering() != null )
+            {
+                registries.delReference( attributeType, attributeType.getOrdering() );
+            }
+
+            if ( attributeType.getSubstring() != null )
+            {
+                registries.delReference( attributeType, attributeType.getSubstring() );
+            }
+
+            if ( attributeType.getSyntax() != null )
+            {
+                registries.delReference( attributeType, attributeType.getSyntax() );
+            }
+
+            if ( attributeType.getSuperior() != null )
+            {
+                registries.delReference( attributeType, attributeType.getSuperior() );
+            }
+        }
+    }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitContentRuleHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitContentRuleHelper.java?rev=1295562&r1=1295561&r2=1295562&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitContentRuleHelper.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitContentRuleHelper.java
Thu Mar  1 13:53:10 2012
@@ -44,6 +44,8 @@ public class DitContentRuleHelper
      * Inject the DitContentRule into the registries, updating the references to
      * other SchemaObject
      *
+     * @param ditContentRule The DitContentRule to add to the Registries
+     * @param errors The errors we got while adding the DitContentRule to the Registries
      * @param registries The Registries
      * @exception If the addition failed
      */

Modified: 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=1295562&r1=1295561&r2=1295562&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/LdapSyntaxHelper.java
Thu Mar  1 13:53:10 2012
@@ -44,6 +44,8 @@ public class LdapSyntaxHelper
      * Inject the LdapSyntax into the registries, updating the references to
      * other SchemaObject
      *
+     * @param ldapSyntax The LdapSyntax to add to the Registries
+     * @param errors The errors we got while adding the LdapSyntax to the Registries
      * @param registries The Registries
      * @exception If the addition failed
      */
@@ -85,4 +87,32 @@ public class LdapSyntaxHelper
             }
         }
     }
+
+
+    /**
+     * Remove the LdapSyntax from the Registries, updating the references to
+     * other SchemaObject.
+     * 
+     * If one of the referenced SchemaObject does not exist,
+     * an exception is thrown.
+     *
+     * @param ldapSyntax The LdapSyntax to remove from the Registries
+     * @param errors The errors we got while removing the LdapSyntax from the Registries
+     * @param registries The Registries
+     * @exception If the LdapSyntax is not valid
+     */
+    public static void removeFromRegistries( LdapSyntax ldapSyntax, List<Throwable>
errors, Registries registries ) throws LdapException
+    {
+        if ( registries != null )
+        {
+            /**
+             * Remove the Syntax references (using and usedBy) :
+             * S -> SC
+             */
+            if ( ldapSyntax.getSyntaxChecker() != null )
+            {
+                registries.delReference( ldapSyntax, ldapSyntax.getSyntaxChecker() );
+            }
+        }
+    }
 }

Modified: 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=1295562&r1=1295561&r2=1295562&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleHelper.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleHelper.java
Thu Mar  1 13:53:10 2012
@@ -47,9 +47,11 @@ public class MatchingRuleHelper
     private static final Logger LOG = LoggerFactory.getLogger( MatchingRuleHelper.class );
 
     /**
-     * Inject the MatchingRule into the registries, updating the references to
+     * Inject the MatchingRule into the Registries, updating the references to
      * other SchemaObject
      *
+     * @param matchingRule The MatchingRule to add to the Registries
+     * @param errors The errors we got while adding the MatchingRule to the registries
      * @param registries The Registries
      * @exception If the addition failed
      */
@@ -138,4 +140,44 @@ public class MatchingRuleHelper
             }
         }
     }
+
+
+    /**
+     * Remove the MatchingRule from the Registries, updating the references to
+     * other SchemaObject.
+     * 
+     * If one of the referenced SchemaObject does not exist,
+     * an exception is thrown.
+     *
+     * @param matchingRule The MatchingRule to remove from the Registries
+     * @param errors The errors we got while removing the MatchingRule from the registries
+     * @param registries The Registries
+     * @exception If the MatchingRule is not valid
+     */
+    public static void removeFromRegistries( MatchingRule matchingRule, List<Throwable>
errors, Registries registries ) throws LdapException
+    {
+        if ( registries != null )
+        {
+            /**
+             * Remove the MR references (using and usedBy) :
+             * MR -> C
+             * MR -> N
+             * MR -> S
+             */
+            if ( matchingRule.getLdapComparator() != null )
+            {
+                registries.delReference( matchingRule, matchingRule.getLdapComparator() );
+            }
+
+            if ( matchingRule.getSyntax() != null )
+            {
+                registries.delReference( matchingRule, matchingRule.getSyntax() );
+            }
+
+            if ( matchingRule.getNormalizer() != null )
+            {
+                registries.delReference( matchingRule, matchingRule.getNormalizer() );
+            }
+        }
+    }
 }

Modified: 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=1295562&r1=1295561&r2=1295562&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleUseHelper.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/MatchingRuleUseHelper.java
Thu Mar  1 13:53:10 2012
@@ -43,6 +43,8 @@ public class MatchingRuleUseHelper
      * Inject the MatchingRuleUse into the registries, updating the references to
      * other SchemaObject
      *
+     * @param matchingRuleUse The MatchingRuleUse to add to the Registries
+     * @param errors The errors we got while adding the MatchingRuleUse to the Registries
      * @param registries The Registries
      * @exception If the addition failed
      */

Modified: 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=1295562&r1=1295561&r2=1295562&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/NameFormHelper.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/NameFormHelper.java
Thu Mar  1 13:53:10 2012
@@ -44,10 +44,12 @@ public class NameFormHelper
      * Inject the NameForm into the registries, updating the references to
      * other SchemaObject
      *
+     * @param nameForm The NameForm to add to the Registries
+     * @param errors The errors we got while adding the NameForm to the Registries
      * @param registries The Registries
      * @exception If the addition failed
      */
-    public static void addToRegistries( NameForm nameForm, List<Throwable> errors,
 Registries registries ) throws LdapException
+    public static void addToRegistries( NameForm nameForm, List<Throwable> errors,
Registries registries ) throws LdapException
     {
         if ( registries != null )
         {

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/ObjectClassHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/ObjectClassHelper.java?rev=1295562&r1=1295561&r2=1295562&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/ObjectClassHelper.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/ObjectClassHelper.java
Thu Mar  1 13:53:10 2012
@@ -49,7 +49,8 @@ public class ObjectClassHelper
      * Inject the ObjectClass into the registries, updating the references to
      * other SchemaObject
      *
-     * @param errors The errors we got while adding the ObjectClass to the registries
+     * @param objectClass The ObjectClass to add to the Registries
+     * @param errors The errors we got while adding the ObjectClass to the Registries
      * @param registries The Registries
      * @throws Exception on failure
      */
@@ -347,4 +348,57 @@ public class ObjectClassHelper
             }
         }
     }
+    
+    
+    /**
+     * Remove the ObjectClass from the registries, updating the references to
+     * other SchemaObject.
+     *
+     * If one of the referenced SchemaObject does not exist (SUPERIORS, MAY, MUST),
+     * an exception is thrown.
+     *
+     * @param objectClass The ObjectClass to remove fro the registries
+     * @param errors The errors we got while removing the ObjectClass from the registries
+     * @param registries The Registries
+     * @exception If the ObjectClass is not valid
+     */
+    public static void removeFromRegistries( ObjectClass objectClass, List<Throwable>
errors, Registries registries ) throws LdapException
+    {
+        if ( registries != null )
+        {
+            ObjectClassRegistry objectClassRegistry = registries.getObjectClassRegistry();
+
+            // Unregister this ObjectClass into the Descendant map
+            objectClassRegistry.unregisterDescendants( objectClass, objectClass.getSuperiors()
);
+
+            /**
+             * Remove the OC references (using and usedBy) :
+             * OC -> AT (for MAY and MUST)
+             * OC -> OC
+             */
+            if ( objectClass.getMayAttributeTypes() != null )
+            {
+                for ( AttributeType may : objectClass.getMayAttributeTypes() )
+                {
+                    registries.delReference( objectClass, may );
+                }
+            }
+
+            if ( objectClass.getMustAttributeTypes() != null )
+            {
+                for ( AttributeType must : objectClass.getMustAttributeTypes() )
+                {
+                    registries.delReference( objectClass, must );
+                }
+            }
+
+            if ( objectClass.getSuperiors() != null )
+            {
+                for ( ObjectClass superior : objectClass.getSuperiors() )
+                {
+                    registries.delReference( objectClass, superior );
+                }
+            }
+        }
+    }
 }



Mime
View raw message