directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r504256 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/
Date Tue, 06 Feb 2007 19:39:01 GMT
Author: akarasulu
Date: Tue Feb  6 11:39:00 2007
New Revision: 504256

URL: http://svn.apache.org/viewvc?view=rev&rev=504256
Log:
changes ...

 o added more handling code for dealing with modify operations on the 
   subschemaSubentry:
   - modify remove operations
   - modify replace operations
 o added more javadocs
 o added delete() operations for SchemaObjects to handlers
 o added removeSchemaObject() to the SchemaSubentryModifer


Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaDitContentRuleHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaDitStructureRuleHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleUseHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNameFormHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
Tue Feb  6 11:39:00 2007
@@ -59,7 +59,7 @@
 
 
 /**
- * Document me!
+ * Parses descriptions using a number of different parsers for schema descriptions.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
@@ -73,6 +73,15 @@
     private static final String X_SCHEMA = "X-SCHEMA";
     private static final Object X_IS_HUMAN_READABLE = "X-IS-HUMAN-READABLE";
 
+    private static final Syntax[] EMPTY_SYNTAXES = new Syntax[0];
+    private static final MatchingRule[] EMPTY_MATCHING_RULES = new MatchingRule[0];
+    private static final AttributeType[] EMPTY_ATTRIBUTE_TYPES = new AttributeType[0];
+    private static final ObjectClass[] EMPTY_OBJECT_CLASSES = new ObjectClass[0];
+    private static final MatchingRuleUse[] EMPTY_MATCHING_RULE_USES = new MatchingRuleUse[0];
+    private static final DITStructureRule[] EMPTY_DIT_STRUCTURE_RULES = new DITStructureRule[0];
+    private static final DITContentRule[] EMPTY_DIT_CONTENT_RULES = new DITContentRule[0];
+    private static final NameForm[] EMPTY_NAME_FORMS = new NameForm[0];
+
     private final Registries globalRegistries;
     
     private final LdapSyntaxDescriptionSchemaParser syntaxParser =
@@ -93,14 +102,32 @@
         new NameFormDescriptionSchemaParser();
     
     
+    /**
+     * Creates a description parser.
+     * 
+     * @param globalRegistries the registries to use while creating new schema entities
+     */
     public DescriptionParsers( Registries globalRegistries )
     {
         this.globalRegistries = globalRegistries;
     }
     
-    
+
+    /**
+     * Parses a set of attributeTypeDescriptions held within an attribute into 
+     * schema entities.
+     * 
+     * @param attr the attribute containing attributeTypeDescriptions
+     * @return the set of attributeType objects for the descriptions 
+     * @throws NamingException if there are problems parsing the descriptions
+     */
     public AttributeType[] parseAttributeTypes( Attribute attr ) throws NamingException
     {
+        if ( attr == null || attr.size() == 0 )
+        {
+            return EMPTY_ATTRIBUTE_TYPES;
+        }
+        
         AttributeType[] attributeTypes = new AttributeType[attr.size()];
         
         for ( int ii = 0; ii < attr.size(); ii++ )
@@ -140,8 +167,21 @@
     }
     
     
+    /**
+     * Parses a set of objectClassDescriptions held within an attribute into 
+     * schema entities.
+     * 
+     * @param attr the attribute containing objectClassDescriptions
+     * @return the set of objectClass objects for the descriptions 
+     * @throws NamingException if there are problems parsing the descriptions
+     */
     public ObjectClass[] parseObjectClasses( Attribute attr ) throws NamingException
     {
+        if ( attr == null || attr.size() == 0 )
+        {
+            return EMPTY_OBJECT_CLASSES;
+        }
+        
         ObjectClass[] objectClasses = new ObjectClass[attr.size()];
         
         for ( int ii = 0; ii < attr.size(); ii++ )
@@ -175,8 +215,21 @@
     }
 
 
+    /**
+     * Parses a set of matchingRuleUseDescriptions held within an attribute into 
+     * schema entities.
+     * 
+     * @param attr the attribute containing matchingRuleUseDescriptions
+     * @return the set of matchingRuleUse objects for the descriptions 
+     * @throws NamingException if there are problems parsing the descriptions
+     */
     public MatchingRuleUse[] parseMatchingRuleUses( Attribute attr ) throws NamingException
     {
+        if ( attr == null || attr.size() == 0 )
+        {
+            return EMPTY_MATCHING_RULE_USES;
+        }
+        
         MatchingRuleUse[] matchingRuleUses = new MatchingRuleUse[attr.size()];
         
         for ( int ii = 0; ii < attr.size(); ii++ )
@@ -207,8 +260,21 @@
     }
 
 
+    /**
+     * Parses a set of ldapSyntaxDescriptions held within an attribute into 
+     * schema entities.
+     * 
+     * @param attr the attribute containing ldapSyntaxDescriptions
+     * @return the set of Syntax objects for the descriptions 
+     * @throws NamingException if there are problems parsing the descriptions
+     */
     public Syntax[] parseSyntaxes( Attribute attr ) throws NamingException
     {
+        if ( attr == null || attr.size() == 0 )
+        {
+            return EMPTY_SYNTAXES;
+        }
+        
         Syntax[] syntaxes = new Syntax[attr.size()];
         
         for ( int ii = 0; ii < attr.size(); ii++ )
@@ -238,8 +304,21 @@
     }
 
 
+    /**
+     * Parses a set of matchingRuleDescriptions held within an attribute into 
+     * schema entities.
+     * 
+     * @param attr the attribute containing matchingRuleDescriptions
+     * @return the set of matchingRule objects for the descriptions 
+     * @throws NamingException if there are problems parsing the descriptions
+     */
     public MatchingRule[] parseMatchingRules( Attribute attr ) throws NamingException
     {
+        if ( attr == null || attr.size() == 0 )
+        {
+            return EMPTY_MATCHING_RULES;
+        }
+        
         MatchingRule[] matchingRules = new MatchingRule[attr.size()];
 
         for ( int ii = 0; ii < attr.size(); ii++ )
@@ -269,8 +348,21 @@
     }
     
 
+    /**
+     * Parses a set of dITStructureRuleDescriptions held within an attribute into 
+     * schema entities.
+     * 
+     * @param attr the attribute containing dITStructureRuleDescriptions
+     * @return the set of DITStructureRule objects for the descriptions 
+     * @throws NamingException if there are problems parsing the descriptions
+     */
     public DITStructureRule[] parseDitStructureRules( Attribute attr ) throws NamingException
     {
+        if ( attr == null || attr.size() == 0 )
+        {
+            return EMPTY_DIT_STRUCTURE_RULES;
+        }
+        
         DITStructureRule[] ditStructureRules = new DITStructureRule[attr.size()];
         
         for ( int ii = 0; ii < attr.size(); ii++ )
@@ -306,8 +398,21 @@
     }
 
     
+    /**
+     * Parses a set of dITContentRuleDescriptions held within an attribute into 
+     * schema entities.
+     * 
+     * @param attr the attribute containing dITContentRuleDescriptions
+     * @return the set of DITContentRule objects for the descriptions 
+     * @throws NamingException if there are problems parsing the descriptions
+     */
     public DITContentRule[] parseDitContentRules( Attribute attr ) throws NamingException
     {
+        if ( attr == null || attr.size() == 0 )
+        {
+            return EMPTY_DIT_CONTENT_RULES;
+        }
+        
         DITContentRule[] ditContentRules = new DITContentRule[attr.size()];
         
         for ( int ii = 0; ii < attr.size(); ii++ )
@@ -342,8 +447,21 @@
     }
 
     
+    /**
+     * Parses a set of nameFormDescriptions held within an attribute into 
+     * schema entities.
+     * 
+     * @param attr the attribute containing nameFormDescriptions
+     * @return the set of NameFormRule objects for the descriptions 
+     * @throws NamingException if there are problems parsing the descriptions
+     */
     public NameForm[] parseNameForms( Attribute attr ) throws NamingException
     {
+        if ( attr == null || attr.size() == 0 )
+        {
+            return EMPTY_NAME_FORMS;
+        }
+        
         NameForm[] nameForms = new NameForm[attr.size()];
         
         for ( int ii = 0; ii < attr.size(); ii++ )
@@ -409,7 +527,7 @@
     }
     
     
-    String getSchema( AbstractSchemaDescription desc ) 
+    private String getSchema( AbstractSchemaDescription desc ) 
     {
         List<String> values = desc.getExtensions().get( X_SCHEMA );
         

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandler.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandler.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandler.java
Tue Feb  6 11:39:00 2007
@@ -106,8 +106,8 @@
 
     public void delete( LdapDN name, Attributes entry ) throws NamingException
     {
-        Schema schema = getSchema( name );
-        AttributeType at = factory.getAttributeType( entry, targetRegistries, schema.getSchemaName()
);
+        String schemaName = getSchemaName( name );
+        AttributeType at = factory.getAttributeType( entry, targetRegistries, schemaName
);
         Set<SearchResult> dependees = dao.listAttributeTypeDependents( at );
         if ( dependees != null && dependees.size() > 0 )
         {
@@ -118,6 +118,13 @@
                 ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
         
+        delete( at );
+    }
+
+
+    public void delete( AttributeType at ) throws NamingException
+    {
+        Schema schema = loader.getSchema( at.getSchema() );
         if ( ! schema.isDisabled() )
         {
             attributeTypeRegistry.unregister( at.getOid() );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaDitContentRuleHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaDitContentRuleHandler.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaDitContentRuleHandler.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaDitContentRuleHandler.java
Tue Feb  6 11:39:00 2007
@@ -106,7 +106,13 @@
     }
 
 
-    public void add( DITContentRule dcr )
+    public void add( DITContentRule dcr ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void delete( DITContentRule dcr ) throws NamingException
     {
         // TODO Auto-generated method stub
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaDitStructureRuleHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaDitStructureRuleHandler.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaDitStructureRuleHandler.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaDitStructureRuleHandler.java
Tue Feb  6 11:39:00 2007
@@ -106,7 +106,13 @@
     }
 
 
-    public void add( DITStructureRule dsr )
+    public void add( DITStructureRule dsr ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void delete( DITStructureRule dsr ) throws NamingException
     {
         // TODO Auto-generated method stub
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java
Tue Feb  6 11:39:00 2007
@@ -91,8 +91,8 @@
 
     public void delete( LdapDN name, Attributes entry ) throws NamingException
     {
-        Schema schema = getSchema( name );
-        MatchingRule mr = factory.getMatchingRule( entry, targetRegistries, schema.getSchemaName()
);
+        String schemaName = getSchemaName( name );
+        MatchingRule mr = factory.getMatchingRule( entry, targetRegistries, schemaName );
         Set<SearchResult> dependees = dao.listMatchingRuleDependents( mr );
         if ( dependees != null && dependees.size() > 0 )
         {
@@ -103,6 +103,13 @@
                 ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
         
+        delete( mr );
+    }
+
+
+    public void delete( MatchingRule mr ) throws NamingException
+    {
+        Schema schema = loader.getSchema( mr.getSchema() );
         if ( ! schema.isDisabled() )
         {
             matchingRuleRegistry.unregister( mr.getOid() );
@@ -110,7 +117,7 @@
         unregisterOids( mr.getOid() );
     }
 
-
+    
     public void rename( LdapDN name, Attributes entry, String newRdn ) throws NamingException
     {
         Schema schema = getSchema( name );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleUseHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleUseHandler.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleUseHandler.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleUseHandler.java
Tue Feb  6 11:39:00 2007
@@ -100,7 +100,13 @@
     }
 
 
-    public void add( MatchingRuleUse mru )
+    public void add( MatchingRuleUse mru ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void delete( MatchingRuleUse mru ) throws NamingException
     {
         // TODO Auto-generated method stub
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNameFormHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNameFormHandler.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNameFormHandler.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNameFormHandler.java
Tue Feb  6 11:39:00 2007
@@ -106,7 +106,13 @@
     }
 
 
-    public void add( NameForm nf )
+    public void add( NameForm nf ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void delete( NameForm nf ) throws NamingException
     {
         // TODO Auto-generated method stub
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java
Tue Feb  6 11:39:00 2007
@@ -91,8 +91,8 @@
 
     public void delete( LdapDN name, Attributes entry ) throws NamingException
     {
-        Schema schema = getSchema( name );
-        ObjectClass oc = factory.getObjectClass( entry, targetRegistries, schema.getSchemaName()
);
+        String schemaName = getSchemaName( name );
+        ObjectClass oc = factory.getObjectClass( entry, targetRegistries, schemaName );
         Set<SearchResult> dependees = dao.listObjectClassDependents( oc );
         if ( dependees != null && dependees.size() > 0 )
         {
@@ -102,6 +102,14 @@
                 + getOids( dependees ), 
                 ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
+
+        delete( oc );
+    }
+
+
+    public void delete( ObjectClass oc ) throws NamingException
+    {
+        Schema schema = loader.getSchema( oc.getSchema() );
         
         if ( ! schema.isDisabled() )
         {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxHandler.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxHandler.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxHandler.java
Tue Feb  6 11:39:00 2007
@@ -103,17 +103,26 @@
                 ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
         
-        Schema schema = getSchema( name );
+        
+        String schemaName = getSchemaName( name );
+        Syntax syntax = factory.getSyntax( entry, targetRegistries, schemaName );
+        delete( syntax );
+    }
+
+
+    public void delete( Syntax syntax ) throws NamingException
+    {
+        Schema schema = loader.getSchema( syntax.getSchema() );
         if ( ! schema.isDisabled() )
         {
-            syntaxRegistry.unregister( oid );
+            syntaxRegistry.unregister( syntax.getOid() );
         }
 
         // no matter what we remove OID for deleted syntaxes
-        unregisterOids( oid );
+        unregisterOids( syntax.getOid() );
     }
 
-
+    
     public void rename( LdapDN name, Attributes entry, String newRdn ) throws NamingException
     {
         String oldOid = getOid( entry );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
Tue Feb  6 11:39:00 2007
@@ -25,6 +25,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -479,20 +480,83 @@
             switch ( mod.getModificationOp() )
             {
                 case( DirContext.ADD_ATTRIBUTE ):
-                    modifyAddOperation( opAttrOid, mod );
+                    modifyAddOperation( opAttrOid, mod.getAttribute() );
                     break;
                 case( DirContext.REMOVE_ATTRIBUTE ):
+                    modifyRemoveOperation( opAttrOid, mod.getAttribute() );
                     break; 
                 case( DirContext.REPLACE_ATTRIBUTE ):
+                    AttributeType opAttrType = globalRegistries.getAttributeTypeRegistry().lookup(
opAttrOid );
+                    Attribute original = AttributeUtils.getAttribute( subentry, opAttrType
);
+                    modifyReplaceOperation( opAttrOid, mod.getAttribute(), original );
                     break;
                 default:
                     throw new IllegalStateException( "Undefined modify operation: " + mod.getModificationOp()
);
             }
         }
     }
+    
+    
+    /**
+     * Translates modify operations on schema subentries into one or more operations 
+     * on meta schema entities within the ou=schema partition and updates the registries
+     * accordingly.  This uses direct access to the partition to bypass all interceptors.
+     * 
+     * @param name the name of the subentry
+     * @param modOp the modification operation performed on the subentry
+     * @param mods the modification operations performed on the subentry
+     * @param subentry the attributes of the subentry
+     * @param targetSubentry the target subentry after being modified
+     */
+    public void modifySchemaSubentry( LdapDN name, int modOp, Attributes mods, Attributes
subentry, 
+        Attributes targetSubentry ) throws NamingException
+    {
+        NamingEnumeration<String> ids = mods.getIDs();
+        switch ( modOp )
+        {
+            case( DirContext.ADD_ATTRIBUTE ):
+                while ( ids.hasMore() )
+                {
+                    String id = ids.next();
+                    AttributeType opAttrAT = globalRegistries.getAttributeTypeRegistry().lookup(
id );
+                    modifyAddOperation( opAttrAT.getOid(), AttributeUtils.getAttribute( mods,
opAttrAT ) );
+                }
+                break;
+            case( DirContext.REMOVE_ATTRIBUTE ):
+                while ( ids.hasMore() )
+                {
+                    String id = ids.next();
+                    AttributeType opAttrAT = globalRegistries.getAttributeTypeRegistry().lookup(
id );
+                    modifyRemoveOperation( opAttrAT.getOid(), AttributeUtils.getAttribute(
mods, opAttrAT ) );
+                }
+                break;
+            case( DirContext.REPLACE_ATTRIBUTE ):
+                while ( ids.hasMore() )
+                {
+                    String id = ids.next();
+                    AttributeType opAttrAT = globalRegistries.getAttributeTypeRegistry().lookup(
id );
+                    Attribute modified = AttributeUtils.getAttribute( mods, opAttrAT );
+                    Attribute original = AttributeUtils.getAttribute( subentry, opAttrAT
);
+                    modifyReplaceOperation( opAttrAT.getOid(), modified, original );
+                }
+                break;
+            default:
+                throw new IllegalStateException( "Undefined modify operation: " + modOp );
+        }
+    }
 
 
-    private void modifyAddOperation( String opAttrOid, ModificationItemImpl mod ) throws
NamingException
+    /**
+     * Handles modify replace operations on the schema subentry.
+     * 
+     * @param opAttrOid the numeric id of the operational attribute being modified
+     * @param mods the attribute with the modifications
+     * @param original the original values for the operational attribute being modified
+     * @throws NamingException if there are problems updating the registries or the 
+     * schema partition
+     */
+    private void modifyReplaceOperation( String opAttrOid, Attribute mods, Attribute original
) 
+        throws NamingException
     {
         int index = opAttr2handlerIndex.get( opAttrOid ).intValue();
         SchemaChangeHandler handler = opAttr2handlerMap.get( opAttrOid );
@@ -506,9 +570,16 @@
                 break;
             case( SYNTAX_INDEX ):
                 MetaSyntaxHandler syntaxHandler = ( MetaSyntaxHandler ) handler;
-                Syntax[] syntaxes = parsers.parseSyntaxes( mod.getAttribute() );
+                Syntax[] removedSyntaxes = parsers.parseSyntaxes( original );
+                Syntax[] addedSyntaxes = parsers.parseSyntaxes( mods );
                 
-                for ( Syntax syntax : syntaxes )
+                for ( Syntax syntax : removedSyntaxes )
+                {
+                    syntaxHandler.delete( syntax );
+                    subentryModifier.deleteSchemaObject( syntax );
+                }
+                
+                for ( Syntax syntax : addedSyntaxes )
                 {
                     syntaxHandler.add( syntax );
                     subentryModifier.addSchemaObject( syntax );
@@ -516,9 +587,16 @@
                 break;
             case( MATCHING_RULE_INDEX ):
                 MetaMatchingRuleHandler matchingRuleHandler = ( MetaMatchingRuleHandler )
handler;
-                MatchingRule[] mrs = parsers.parseMatchingRules( mod.getAttribute() );
+                MatchingRule[] removedMrs = parsers.parseMatchingRules( original );
+                MatchingRule[] addedMrs = parsers.parseMatchingRules( mods );
                 
-                for ( MatchingRule mr : mrs )
+                for ( MatchingRule mr : removedMrs )
+                {
+                    matchingRuleHandler.delete( mr );
+                    subentryModifier.deleteSchemaObject( mr );
+                }
+                
+                for ( MatchingRule mr : addedMrs )
                 {
                     matchingRuleHandler.add( mr );
                     subentryModifier.addSchemaObject( mr );
@@ -526,9 +604,16 @@
                 break;
             case( ATTRIBUTE_TYPE_INDEX ):
                 MetaAttributeTypeHandler atHandler = ( MetaAttributeTypeHandler ) handler;
-                AttributeType[] ats = parsers.parseAttributeTypes( mod.getAttribute() );
+                AttributeType[] removedAts = parsers.parseAttributeTypes( original );
+                AttributeType[] addedAts = parsers.parseAttributeTypes( mods );
                 
-                for ( AttributeType at : ats )
+                for ( AttributeType at : removedAts )
+                {
+                    atHandler.delete( at );
+                    subentryModifier.deleteSchemaObject( at );
+                }
+                
+                for ( AttributeType at : addedAts )
                 {
                     atHandler.add( at );
                     subentryModifier.addSchemaObject( at );
@@ -536,9 +621,16 @@
                 break;
             case( OBJECT_CLASS_INDEX ):
                 MetaObjectClassHandler ocHandler = ( MetaObjectClassHandler ) handler;
-                ObjectClass[] ocs = parsers.parseObjectClasses( mod.getAttribute() );
+                ObjectClass[] removedOcs = parsers.parseObjectClasses( original );
+                ObjectClass[] addedOcs = parsers.parseObjectClasses( mods );
 
-                for ( ObjectClass oc : ocs )
+                for ( ObjectClass oc : removedOcs )
+                {
+                    ocHandler.delete( oc );
+                    subentryModifier.deleteSchemaObject( oc );
+                }
+                
+                for ( ObjectClass oc : addedOcs )
                 {
                     ocHandler.add( oc );
                     subentryModifier.addSchemaObject( oc );
@@ -546,9 +638,16 @@
                 break;
             case( MATCHING_RULE_USE_INDEX ):
                 MetaMatchingRuleUseHandler mruHandler = ( MetaMatchingRuleUseHandler ) handler;
-                MatchingRuleUse[] mrus = parsers.parseMatchingRuleUses( mod.getAttribute()
);
+                MatchingRuleUse[] removedMrus = parsers.parseMatchingRuleUses( original );
+                MatchingRuleUse[] addedMrus = parsers.parseMatchingRuleUses( mods );
                 
-                for ( MatchingRuleUse mru : mrus )
+                for ( MatchingRuleUse mru : removedMrus )
+                {
+                    mruHandler.delete( mru );
+                    subentryModifier.deleteSchemaObject( mru );
+                }
+                
+                for ( MatchingRuleUse mru : addedMrus )
                 {
                     mruHandler.add( mru );
                     subentryModifier.addSchemaObject( mru );
@@ -556,9 +655,16 @@
                 break;
             case( DIT_STRUCTURE_RULE_INDEX ):
                 MetaDitStructureRuleHandler dsrHandler = ( MetaDitStructureRuleHandler )
handler;
-                DITStructureRule[] dsrs = parsers.parseDitStructureRules( mod.getAttribute()
);
+                DITStructureRule[] removedDsrs = parsers.parseDitStructureRules( original
);
+                DITStructureRule[] addedDsrs = parsers.parseDitStructureRules( mods );
                 
-                for ( DITStructureRule dsr : dsrs )
+                for ( DITStructureRule dsr : removedDsrs )
+                {
+                    dsrHandler.delete( dsr );
+                    subentryModifier.deleteSchemaObject( dsr );
+                }
+                
+                for ( DITStructureRule dsr : addedDsrs )
                 {
                     dsrHandler.add( dsr );
                     subentryModifier.addSchemaObject( dsr );
@@ -566,9 +672,16 @@
                 break;
             case( DIT_CONTENT_RULE_INDEX ):
                 MetaDitContentRuleHandler dcrHandler = ( MetaDitContentRuleHandler ) handler;
-                DITContentRule[] dcrs = parsers.parseDitContentRules( mod.getAttribute()
);
+                DITContentRule[] removedDcrs = parsers.parseDitContentRules( original );
+                DITContentRule[] addedDcrs = parsers.parseDitContentRules( mods );
                 
-                for ( DITContentRule dcr : dcrs )
+                for ( DITContentRule dcr : removedDcrs )
+                {
+                    dcrHandler.delete( dcr );
+                    subentryModifier.deleteSchemaObject( dcr );
+                }
+                
+                for ( DITContentRule dcr : addedDcrs )
                 {
                     dcrHandler.add( dcr );
                     subentryModifier.addSchemaObject( dcr );
@@ -576,9 +689,16 @@
                 break;
             case( NAME_FORM_INDEX ):
                 MetaNameFormHandler nfHandler = ( MetaNameFormHandler ) handler;
-                NameForm[] nfs = parsers.parseNameForms( mod.getAttribute() );
+                NameForm[] removedNfs = parsers.parseNameForms( original );
+                NameForm[] addedNfs = parsers.parseNameForms( mods );
                 
-                for ( NameForm nf : nfs )
+                for ( NameForm nf : removedNfs )
+                {
+                    nfHandler.delete( nf );
+                    subentryModifier.deleteSchemaObject( nf );
+                }
+                
+                for ( NameForm nf : addedNfs )
                 {
                     nfHandler.add( nf );
                     subentryModifier.addSchemaObject( nf );
@@ -588,32 +708,216 @@
                 throw new IllegalStateException( "Unknown index into handler array: " + index
);
         }
     }
+
+
+    /**
+     * Handles the modify remove operation on the subschemaSubentry for schema entities.

+     * 
+     * @param opAttrOid the numeric id of the operational attribute modified
+     * @param mods the attribute with the modifications
+     * @throws NamingException if there are problems updating the registries and the 
+     * schema partition
+     */
+    private void modifyRemoveOperation( String opAttrOid, Attribute mods ) throws NamingException
+    {
+        int index = opAttr2handlerIndex.get( opAttrOid ).intValue();
+        SchemaChangeHandler handler = opAttr2handlerMap.get( opAttrOid );
+        switch( index )
+        {
+            case( COMPARATOR_INDEX ):
+                break;
+            case( NORMALIZER_INDEX ):
+                break;
+            case( SYNTAX_CHECKER_INDEX ):
+                break;
+            case( SYNTAX_INDEX ):
+                MetaSyntaxHandler syntaxHandler = ( MetaSyntaxHandler ) handler;
+                Syntax[] syntaxes = parsers.parseSyntaxes( mods );
+                
+                for ( Syntax syntax : syntaxes )
+                {
+                    syntaxHandler.delete( syntax );
+                    subentryModifier.deleteSchemaObject( syntax );
+                }
+                break;
+            case( MATCHING_RULE_INDEX ):
+                MetaMatchingRuleHandler matchingRuleHandler = ( MetaMatchingRuleHandler )
handler;
+                MatchingRule[] mrs = parsers.parseMatchingRules( mods );
+                
+                for ( MatchingRule mr : mrs )
+                {
+                    matchingRuleHandler.delete( mr );
+                    subentryModifier.deleteSchemaObject( mr );
+                }
+                break;
+            case( ATTRIBUTE_TYPE_INDEX ):
+                MetaAttributeTypeHandler atHandler = ( MetaAttributeTypeHandler ) handler;
+                AttributeType[] ats = parsers.parseAttributeTypes( mods );
+                
+                for ( AttributeType at : ats )
+                {
+                    atHandler.delete( at );
+                    subentryModifier.deleteSchemaObject( at );
+                }
+                break;
+            case( OBJECT_CLASS_INDEX ):
+                MetaObjectClassHandler ocHandler = ( MetaObjectClassHandler ) handler;
+                ObjectClass[] ocs = parsers.parseObjectClasses( mods );
+
+                for ( ObjectClass oc : ocs )
+                {
+                    ocHandler.delete( oc );
+                    subentryModifier.deleteSchemaObject( oc );
+                }
+                break;
+            case( MATCHING_RULE_USE_INDEX ):
+                MetaMatchingRuleUseHandler mruHandler = ( MetaMatchingRuleUseHandler ) handler;
+                MatchingRuleUse[] mrus = parsers.parseMatchingRuleUses( mods );
+                
+                for ( MatchingRuleUse mru : mrus )
+                {
+                    mruHandler.delete( mru );
+                    subentryModifier.deleteSchemaObject( mru );
+                }
+                break;
+            case( DIT_STRUCTURE_RULE_INDEX ):
+                MetaDitStructureRuleHandler dsrHandler = ( MetaDitStructureRuleHandler )
handler;
+                DITStructureRule[] dsrs = parsers.parseDitStructureRules( mods );
+                
+                for ( DITStructureRule dsr : dsrs )
+                {
+                    dsrHandler.delete( dsr );
+                    subentryModifier.deleteSchemaObject( dsr );
+                }
+                break;
+            case( DIT_CONTENT_RULE_INDEX ):
+                MetaDitContentRuleHandler dcrHandler = ( MetaDitContentRuleHandler ) handler;
+                DITContentRule[] dcrs = parsers.parseDitContentRules( mods );
+                
+                for ( DITContentRule dcr : dcrs )
+                {
+                    dcrHandler.delete( dcr );
+                    subentryModifier.deleteSchemaObject( dcr );
+                }
+                break;
+            case( NAME_FORM_INDEX ):
+                MetaNameFormHandler nfHandler = ( MetaNameFormHandler ) handler;
+                NameForm[] nfs = parsers.parseNameForms( mods );
+                
+                for ( NameForm nf : nfs )
+                {
+                    nfHandler.delete( nf );
+                    subentryModifier.deleteSchemaObject( nf );
+                }
+                break;
+            default:
+                throw new IllegalStateException( "Unknown index into handler array: " + index
);
+        }
+    }
     
     
     /**
-     * Translates modify operations on schema subentries into one or more operations 
-     * on meta schema entities within the ou=schema partition and updates the registries
-     * accordingly.  This uses direct access to the partition to bypass all interceptors.
+     * Handles the modify add operation on the subschemaSubentry for schema entities. 
      * 
-     * @param name the name of the subentry
-     * @param modOp the modification operation performed on the subentry
-     * @param mods the modification operations performed on the subentry
-     * @param subentry the attributes of the subentry
-     * @param targetSubentry the target subentry after being modified
+     * @param opAttrOid the numeric id of the operational attribute modified
+     * @param mods the attribute with the modifications
+     * @throws NamingException if there are problems updating the registries and the 
+     * schema partition
      */
-    public void modifySchemaSubentry( LdapDN name, int modOp, Attributes mods, Attributes
subentry, 
-        Attributes targetSubentry ) throws NamingException
+    private void modifyAddOperation( String opAttrOid, Attribute mods ) throws NamingException
     {
-        switch ( modOp )
+        int index = opAttr2handlerIndex.get( opAttrOid ).intValue();
+        SchemaChangeHandler handler = opAttr2handlerMap.get( opAttrOid );
+        switch( index )
         {
-            case( DirContext.ADD_ATTRIBUTE ):
+            case( COMPARATOR_INDEX ):
                 break;
-            case( DirContext.REMOVE_ATTRIBUTE ):
+            case( NORMALIZER_INDEX ):
                 break;
-            case( DirContext.REPLACE_ATTRIBUTE ):
+            case( SYNTAX_CHECKER_INDEX ):
+                break;
+            case( SYNTAX_INDEX ):
+                MetaSyntaxHandler syntaxHandler = ( MetaSyntaxHandler ) handler;
+                Syntax[] syntaxes = parsers.parseSyntaxes( mods );
+                
+                for ( Syntax syntax : syntaxes )
+                {
+                    syntaxHandler.add( syntax );
+                    subentryModifier.addSchemaObject( syntax );
+                }
+                break;
+            case( MATCHING_RULE_INDEX ):
+                MetaMatchingRuleHandler matchingRuleHandler = ( MetaMatchingRuleHandler )
handler;
+                MatchingRule[] mrs = parsers.parseMatchingRules( mods );
+                
+                for ( MatchingRule mr : mrs )
+                {
+                    matchingRuleHandler.add( mr );
+                    subentryModifier.addSchemaObject( mr );
+                }
+                break;
+            case( ATTRIBUTE_TYPE_INDEX ):
+                MetaAttributeTypeHandler atHandler = ( MetaAttributeTypeHandler ) handler;
+                AttributeType[] ats = parsers.parseAttributeTypes( mods );
+                
+                for ( AttributeType at : ats )
+                {
+                    atHandler.add( at );
+                    subentryModifier.addSchemaObject( at );
+                }
+                break;
+            case( OBJECT_CLASS_INDEX ):
+                MetaObjectClassHandler ocHandler = ( MetaObjectClassHandler ) handler;
+                ObjectClass[] ocs = parsers.parseObjectClasses( mods );
+
+                for ( ObjectClass oc : ocs )
+                {
+                    ocHandler.add( oc );
+                    subentryModifier.addSchemaObject( oc );
+                }
+                break;
+            case( MATCHING_RULE_USE_INDEX ):
+                MetaMatchingRuleUseHandler mruHandler = ( MetaMatchingRuleUseHandler ) handler;
+                MatchingRuleUse[] mrus = parsers.parseMatchingRuleUses( mods );
+                
+                for ( MatchingRuleUse mru : mrus )
+                {
+                    mruHandler.add( mru );
+                    subentryModifier.addSchemaObject( mru );
+                }
+                break;
+            case( DIT_STRUCTURE_RULE_INDEX ):
+                MetaDitStructureRuleHandler dsrHandler = ( MetaDitStructureRuleHandler )
handler;
+                DITStructureRule[] dsrs = parsers.parseDitStructureRules( mods );
+                
+                for ( DITStructureRule dsr : dsrs )
+                {
+                    dsrHandler.add( dsr );
+                    subentryModifier.addSchemaObject( dsr );
+                }
+                break;
+            case( DIT_CONTENT_RULE_INDEX ):
+                MetaDitContentRuleHandler dcrHandler = ( MetaDitContentRuleHandler ) handler;
+                DITContentRule[] dcrs = parsers.parseDitContentRules( mods );
+                
+                for ( DITContentRule dcr : dcrs )
+                {
+                    dcrHandler.add( dcr );
+                    subentryModifier.addSchemaObject( dcr );
+                }
+                break;
+            case( NAME_FORM_INDEX ):
+                MetaNameFormHandler nfHandler = ( MetaNameFormHandler ) handler;
+                NameForm[] nfs = parsers.parseNameForms( mods );
+                
+                for ( NameForm nf : nfs )
+                {
+                    nfHandler.add( nf );
+                    subentryModifier.addSchemaObject( nf );
+                }
                 break;
             default:
-                throw new IllegalStateException( "Undefined modify operation: " + modOp );
+                throw new IllegalStateException( "Unknown index into handler array: " + index
);
         }
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java?view=diff&rev=504256&r1=504255&r2=504256
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java
Tue Feb  6 11:39:00 2007
@@ -127,4 +127,12 @@
         Attributes attrs = factory.getAttributes( obj, schema );
         proxy.add( dn, attrs, BYPASS );
     }
+
+
+    public void deleteSchemaObject( SchemaObject obj ) throws NamingException
+    {
+        PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
+        LdapDN dn = getDn( obj );
+        proxy.delete( dn, BYPASS );
+    }
 }



Mime
View raw message