directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r613608 [10/15] - in /directory/sandbox/akarasulu/bigbang/apacheds: ./ bootstrap-plugin/ bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ core-entry/ core-entry/src/main/java/org/apache/directory/server/core...
Date Sun, 20 Jan 2008 16:59:36 GMT
Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=613608&r1=613607&r2=613608&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Sun Jan 20 08:59:10 2008
@@ -22,6 +22,9 @@
 
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
+import org.apache.directory.server.core.entry.ServerValue;
 import org.apache.directory.server.core.enumeration.SearchResultFilter;
 import org.apache.directory.server.core.enumeration.SearchResultFilteringEnumeration;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
@@ -49,10 +52,18 @@
 import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
 import org.apache.directory.shared.ldap.exception.LdapNoSuchAttributeException;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
+import org.apache.directory.shared.ldap.filter.ApproximateNode;
+import org.apache.directory.shared.ldap.filter.AssertionNode;
+import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.ExtensibleNode;
+import org.apache.directory.shared.ldap.filter.GreaterEqNode;
+import org.apache.directory.shared.ldap.filter.LessEqNode;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
+import org.apache.directory.shared.ldap.filter.ScopeNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.filter.SubstringNode;
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.CascadeControl;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
@@ -108,7 +119,7 @@
 public class SchemaInterceptor extends BaseInterceptor
 {
     /** The LoggerFactory used by this Interceptor */
-    private static Logger log = LoggerFactory.getLogger( SchemaInterceptor.class );
+    private static Logger LOG = LoggerFactory.getLogger( SchemaInterceptor.class );
 
     private static final String[] SCHEMA_SUBENTRY_RETURN_ATTRIBUTES =
             new String[] { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES };
@@ -117,7 +128,7 @@
 
 
     /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
     /**
      * the root nexus to all database partitions
@@ -138,6 +149,11 @@
      */
     private Registries registries;
 
+    /**
+     * the global attributeType registry
+     */
+    private AttributeTypeRegistry attributeTypeRegistry;
+
     /** A normalized form for the SubschemaSubentry DN */
     private String subschemaSubentryDnNorm;
 
@@ -176,35 +192,36 @@
     {
         if ( IS_DEBUG )
         {
-            log.debug( "Initializing SchemaInterceptor..." );
+            LOG.debug( "Initializing SchemaInterceptor..." );
         }
 
         nexus = directoryService.getPartitionNexus();
         registries = directoryService.getRegistries();
+        attributeTypeRegistry = registries.getAttributeTypeRegistry();
         binaryAttributeFilter = new BinaryAttributeFilter();
         topFilter = new TopFilter();
         filters.add( binaryAttributeFilter );
         filters.add( topFilter );
 
         schemaBaseDN = new LdapDN( ServerDNConstants.OU_SCHEMA_DN );
-        schemaBaseDN.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+        schemaBaseDN.normalize( attributeTypeRegistry.getNormalizerMapping() );
         schemaService = directoryService.getSchemaService();
         schemaManager = directoryService.getSchemaService().getSchemaControl();
 
         // stuff for dealing with subentries (garbage for now)
-        String subschemaSubentry = ( String ) nexus.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
-        LdapDN subschemaSubentryDn = new LdapDN( subschemaSubentry );
-        subschemaSubentryDn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+        ServerValue<?> subschemaSubentry = nexus.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
+        LdapDN subschemaSubentryDn = new LdapDN( (String)(subschemaSubentry.get()) );
+        subschemaSubentryDn.normalize( attributeTypeRegistry.getNormalizerMapping() );
         subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();
 
         schemaModificationAttributesDN = new LdapDN( "cn=schemaModifications,ou=schema" );
-        schemaModificationAttributesDN.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+        schemaModificationAttributesDN.normalize( attributeTypeRegistry.getNormalizerMapping() );
 
         computeSuperiors();
 
         if ( IS_DEBUG )
         {
-            log.debug( "SchemaInterceptor Initialized !" );
+            LOG.debug( "SchemaInterceptor Initialized !" );
         }
     }
 
@@ -431,7 +448,7 @@
 	                String oid = registries.getOidRegistry().getOid( attribute );
 
             		// The attribute must be an AttributeType
-	                if ( registries.getAttributeTypeRegistry().hasAttributeType( oid ) )
+	                if ( attributeTypeRegistry.hasAttributeType( oid ) )
 	                {
 		                if ( !filteredAttrs.containsKey( oid ) )
 		                {
@@ -482,6 +499,161 @@
 
         searchCtls.setReturningAttributes( newAttributesList );
     }
+    
+    
+    private Object convert( String id, Object value ) throws NamingException
+    {
+        AttributeType at = attributeTypeRegistry.lookup( id );
+
+        if ( at.getSyntax().isHumanReadable() )
+        {
+            if ( value instanceof byte[] )
+            {
+                try
+                {
+                    String valStr = new String( (byte[])value, "UTF-8" );
+                    return valStr;
+                }
+                catch ( UnsupportedEncodingException uee )
+                {
+                    String message = "The value stored in an Human Readable attribute as a byte[] should be convertible to a String";
+                    LOG.error( message );
+                    throw new NamingException( message );
+                }
+            }
+        }
+        else
+        {
+            if ( value instanceof String )
+            {
+                try
+                {
+                    byte[] valBytes = ((String)value).getBytes( "UTF-8" );
+                    return valBytes;
+                }
+                catch ( UnsupportedEncodingException uee )
+                {
+                    String message = "The value stored in a non Human Readable attribute as a String should be convertible to a byte[]";
+                    LOG.error( message );
+                    throw new NamingException( message );
+                }
+            }
+        }
+        
+        return null;
+    }
+    
+    /**
+     * Check that the filter values are compatible with the AttributeType. Typically,
+     * a HumanReadible filter should have a String value. The substring filter should
+     * not be used with binary attributes.
+     */
+    private void checkFilter( ExprNode filter ) throws NamingException
+    {
+        if ( filter == null )
+        {
+            String message = "A filter should not be null";
+            LOG.error( message );
+            throw new NamingException( message );
+        }
+        
+        if ( filter.isLeaf() )
+        {
+            if ( filter instanceof EqualityNode )
+            {
+                EqualityNode node = ((EqualityNode)filter);
+                Object value = node.getValue();
+                
+                Object newValue = convert( node.getAttribute(), value );
+                
+                if ( newValue != null )
+                {
+                    node.setValue( newValue );
+                }
+            }
+            else if ( filter instanceof SubstringNode )
+            {
+                SubstringNode node = ((SubstringNode)filter);
+
+                if ( ! attributeTypeRegistry.lookup( node.getAttribute() ).getSyntax().isHumanReadable() )
+                {
+                    String message = "A Substring filter should be used only on Human Readable attributes";
+                    LOG.error(  message  );
+                    throw new NamingException( message );
+                }
+            }
+            else if ( filter instanceof PresenceNode )
+            {
+                // Nothing to do
+            }
+            else if ( filter instanceof GreaterEqNode )
+            {
+                GreaterEqNode node = ((GreaterEqNode)filter);
+                Object value = node.getValue();
+                
+                Object newValue = convert( node.getAttribute(), value );
+                
+                if ( newValue != null )
+                {
+                    node.setValue( newValue );
+                }
+                
+            }
+            else if ( filter instanceof LessEqNode )
+            {
+                LessEqNode node = ((LessEqNode)filter);
+                Object value = node.getValue();
+                
+                Object newValue = convert( node.getAttribute(), value );
+                
+                if ( newValue != null )
+                {
+                    node.setValue( newValue );
+                }
+            }
+            else if ( filter instanceof ExtensibleNode )
+            {
+                ExtensibleNode node = ((ExtensibleNode)filter);
+                
+                if ( ! attributeTypeRegistry.lookup( node.getAttribute() ).getSyntax().isHumanReadable() )
+                {
+                    String message = "A Extensible filter should be used only on Human Readable attributes";
+                    LOG.error(  message  );
+                    throw new NamingException( message );
+                }
+            }
+            else if ( filter instanceof ApproximateNode )
+            {
+                ApproximateNode node = ((ApproximateNode)filter);
+                Object value = node.getValue();
+                
+                Object newValue = convert( node.getAttribute(), value );
+                
+                if ( newValue != null )
+                {
+                    node.setValue( newValue );
+                }
+            }
+            else if ( filter instanceof AssertionNode )
+            {
+                // Nothing to do
+                return;
+            }
+            else if ( filter instanceof ScopeNode )
+            {
+                // Nothing to do
+                return;
+            }
+        }
+        else
+        {
+            // Recursively iterate through all the children.
+            for ( ExprNode child:((BranchNode)filter).getChildren() )
+            {
+                checkFilter( child );
+            }
+        }
+    }
 
 
     /**
@@ -497,6 +669,9 @@
         // to RFC 2251, chap. 4.5.1. Basically, all unknown attributes are removed
         // from the list
         filterAttributesToReturn( searchCtls );
+        
+        // We also have to check the H/R flag for the filter attributes
+        checkFilter( filter );
 
         String baseNormForm = ( base.isNormalized() ? base.getNormName() : base.toNormName() );
 
@@ -749,13 +924,13 @@
 
         // We must select all the ObjectClasses, except 'top',
         // but including all the inherited ObjectClasses
-        NamingEnumeration<String> ocs = (NamingEnumeration<String>)objectClasses.getAll();
+        NamingEnumeration<?> ocs = objectClasses.getAll();
         boolean hasExtensibleObject = false;
 
 
         while ( ocs.hasMoreElements() )
         {
-            String objectClassName = ocs.nextElement();
+            String objectClassName = (String)ocs.nextElement();
 
             if ( SchemaConstants.TOP_OC.equals( objectClassName ) )
             {
@@ -857,11 +1032,11 @@
         objectClassesUP.add( SchemaConstants.TOP_OC );
         
         // Construct the new list of ObjectClasses
-        NamingEnumeration<String> ocList = (NamingEnumeration<String>)objectClassAttr.getAll();
+        NamingEnumeration<?> ocList = objectClassAttr.getAll();
 
         while ( ocList.hasMoreElements() )
         {
-            String ocName = ocList.nextElement();
+            String ocName = (String)ocList.nextElement();
 
             if ( !ocName.equalsIgnoreCase( SchemaConstants.TOP_OC ) )
             {
@@ -905,7 +1080,10 @@
     {
         LdapDN oriChildName = opContext.getDn();
 
-        Attributes entry = nexus.lookup( new LookupOperationContext( oriChildName ) );
+        ServerEntry entry = ServerEntryUtils.toServerEntry( 
+            nexus.lookup( new LookupOperationContext( registries, oriChildName ) ),
+            oriChildName,
+            registries );
 
         if ( oriChildName.startsWith( schemaBaseDN ) )
         {
@@ -924,7 +1102,10 @@
     {
         LdapDN oriChildName = opContext.getDn();
         
-        Attributes entry = nexus.lookup( new LookupOperationContext( oriChildName ) );
+        ServerEntry entry = ServerEntryUtils.toServerEntry(
+            nexus.lookup( new LookupOperationContext( registries, oriChildName ) ),
+            oriChildName,
+            registries );
 
         if ( oriChildName.startsWith( schemaBaseDN ) )
         {
@@ -942,7 +1123,10 @@
         Rdn newRdn = opContext.getNewRdn();
         boolean deleteOldRn = opContext.getDelOldDn();
         
-        Attributes entry = nexus.lookup( new LookupOperationContext( name ) );
+        ServerEntry entry = ServerEntryUtils.toServerEntry(
+            nexus.lookup( new LookupOperationContext( registries, name ) ),
+            name,
+            registries );
 
         if ( name.startsWith( schemaBaseDN ) )
         {
@@ -968,7 +1152,7 @@
         }
         else
         {
-            entry = nexus.lookup( new LookupOperationContext( name ) );
+            entry = nexus.lookup( new LookupOperationContext( registries, name ) );
         }
         
         // First, we get the entry from the backend. If it does not exist, then we throw an exception
@@ -976,7 +1160,7 @@
 
         if ( entry == null )
         {
-            log.error( "No entry with this name :{}", name );
+            LOG.error( "No entry with this name :{}", name );
             throw new LdapNameNotFoundException( "The entry which name is " + name + " is not found." );
         }
         
@@ -1045,7 +1229,6 @@
         }
 
         ObjectClassRegistry ocRegistry = this.registries.getObjectClassRegistry();
-        AttributeTypeRegistry atRegistry = this.registries.getAttributeTypeRegistry();
 
         // -------------------------------------------------------------------
         // DIRSERVER-646 Fix: Replacing an unknown attribute with no values 
@@ -1055,7 +1238,7 @@
         if ( ( mods.size() == 1 ) && 
              ( mods.get( 0 ).getAttribute().size() == 0 ) && 
              ( mods.get( 0 ).getModificationOp() == DirContext.REPLACE_ATTRIBUTE ) &&
-             ! atRegistry.hasAttributeType( mods.get( 0 ).getAttribute().getID() ) )
+             ! attributeTypeRegistry.hasAttributeType( mods.get( 0 ).getAttribute().getID() ) )
         {
             return;
         }
@@ -1067,7 +1250,7 @@
             int modOp = mod.getModificationOp();
             Attribute change = mod.getAttribute();
 
-            if ( !atRegistry.hasAttributeType( change.getID() ) && 
+            if ( !attributeTypeRegistry.hasAttributeType( change.getID() ) && 
                 !objectClass.contains( SchemaConstants.EXTENSIBLE_OBJECT_OC ) )
             {
                 throw new LdapInvalidAttributeIdentifierException();
@@ -1075,7 +1258,7 @@
 
             // We will forbid modification of operational attributes which are not
             // user modifiable.
-            AttributeType attributeType = atRegistry.lookup( change.getID() );
+            AttributeType attributeType = attributeTypeRegistry.lookup( change.getID() );
             
             if ( !attributeType.isCanUserModify() )
             {
@@ -1114,7 +1297,7 @@
                 case DirContext.REMOVE_ATTRIBUTE :
                     if ( tmpEntry.get( change.getID() ) == null )
                     {
-                        log.error( "Trying to remove an non-existant attribute: " + change.getID() );
+                        LOG.error( "Trying to remove an non-existant attribute: " + change.getID() );
                         throw new LdapNoSuchAttributeException();
                     }
 
@@ -1125,7 +1308,7 @@
                         // Check that we aren't removing a MUST attribute
                         if ( isRequired( change.getID(), objectClass ) )
                         {
-                            log.error( "Trying to remove a required attribute: " + change.getID() );
+                            LOG.error( "Trying to remove a required attribute: " + change.getID() );
                             throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                         }
                     }
@@ -1135,7 +1318,7 @@
                         // if so then we have a schema violation that must be thrown
                         if ( isRequired( change.getID(), objectClass ) && isCompleteRemoval( change, entry ) )
                         {
-                            log.error( "Trying to remove a required attribute: " + change.getID() );
+                            LOG.error( "Trying to remove a required attribute: " + change.getID() );
                             throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                         }
 
@@ -1154,7 +1337,7 @@
                         // and if it's a MUST one, we should thow an exception
                         if ( ( modified.size() == 0 ) && isRequired( change.getID(), objectClass ) )
                         {
-                            log.error( "Trying to remove a required attribute: " + change.getID() );
+                            LOG.error( "Trying to remove a required attribute: " + change.getID() );
                             throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                         }
 
@@ -1261,16 +1444,24 @@
         
         if ( name.startsWith( schemaBaseDN ) )
         {
-            log.debug( "Modification attempt on schema partition {}: \n{}", name, opContext );
+            LOG.debug( "Modification attempt on schema partition {}: \n{}", name, opContext );
         
-            schemaManager.modify( name, mods, entry, targetEntry,
+            schemaManager.modify( 
+                name, 
+                mods, 
+                ServerEntryUtils.toServerEntry( entry, name, registries ), 
+                ServerEntryUtils.toServerEntry( targetEntry, name, registries ),
                 opContext.hasRequestControl( CascadeControl.CONTROL_OID ));
         }
         else if ( subschemaSubentryDnNorm.equals( name.getNormName() ) )
         {
-            log.debug( "Modification attempt on schema subentry {}: \n{}", name, opContext );
+            LOG.debug( "Modification attempt on schema subentry {}: \n{}", name, opContext );
 
-            schemaManager.modifySchemaSubentry( name, mods, entry, targetEntry,
+            schemaManager.modifySchemaSubentry( 
+                name, 
+                mods, 
+                ServerEntryUtils.toServerEntry( entry, name, registries ), 
+                ServerEntryUtils.toServerEntry( targetEntry, name, registries ),
                 opContext.hasRequestControl( CascadeControl.CONTROL_OID ) );
             return;
         }
@@ -1323,9 +1514,9 @@
             String id = list.next();
             AttributeType type = null;
 
-            if ( registries.getAttributeTypeRegistry().hasAttributeType( id ) )
+            if ( attributeTypeRegistry.hasAttributeType( id ) )
             {
-                type = registries.getAttributeTypeRegistry().lookup( id );
+                type = attributeTypeRegistry.lookup( id );
             }
             else
             {
@@ -1407,7 +1598,7 @@
         {
             String name = attrEnum.nextElement();
             
-            if ( !registries.getAttributeTypeRegistry().hasAttributeType( name ) )
+            if ( !attributeTypeRegistry.hasAttributeType( name ) )
             {
                 throw new LdapInvalidAttributeIdentifierException( name + " not found in attribute registry!" );
             }
@@ -1462,19 +1653,19 @@
     /**
      * Check that all the attributes exist in the schema for this entry.
      */
-    public void add( NextInterceptor next, AddOperationContext opContext ) throws NamingException
+    public void add( NextInterceptor next, AddOperationContext addContext ) throws NamingException
     {
-    	LdapDN name = opContext.getDn();
-        Attributes attrs = opContext.getEntry();
+    	LdapDN name = addContext.getDn();
+        Attributes entry = ServerEntryUtils.toAttributesImpl( addContext.getEntry() );
         
-    	check( name, attrs );
+    	check( name, entry );
 
         if ( name.startsWith( schemaBaseDN ) )
         {
-            schemaManager.add( name, attrs );
+            schemaManager.add( name, ServerEntryUtils.toServerEntry( entry, name, registries ) );
         }
 
-        next.add( opContext );
+        next.add( addContext );
     }
     
 
@@ -1504,7 +1695,7 @@
             String attrId = attribute.getID();
             String attrOid = registries.getOidRegistry().getOid( attrId );
 
-            AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( attrOid );
+            AttributeType attributeType = attributeTypeRegistry.lookup( attrOid );
 
             if ( !attributeType.isCollective() && ( attributeType.getUsage() == UsageEnum.USER_APPLICATIONS ) )
             {
@@ -1522,7 +1713,10 @@
     public void delete( NextInterceptor next, DeleteOperationContext opContext ) throws NamingException
     {
     	LdapDN name = opContext.getDn();
-        Attributes entry = nexus.lookup( new LookupOperationContext( name ) );
+        ServerEntry entry = ServerEntryUtils.toServerEntry( 
+            nexus.lookup( new LookupOperationContext( registries, name ) ),
+            name, 
+            registries );
         
         if ( name.startsWith( schemaBaseDN ) )
         {
@@ -1552,9 +1746,7 @@
      */
     private void assertNumberOfAttributeValuesValid( Attribute attribute ) throws InvalidAttributeValueException, NamingException
     {
-        AttributeTypeRegistry registry = this.registries.getAttributeTypeRegistry();
-
-        if ( attribute.size() > 1 && registry.lookup( attribute.getID() ).isSingleValue() )
+        if ( attribute.size() > 1 && attributeTypeRegistry.lookup( attribute.getID() ).isSingleValue() )
         {                
             throw new LdapInvalidAttributeValueException( "More than one value has been provided " +
                 "for the single-valued attribute: " + attribute.getID(), ResultCodeEnum.CONSTRAINT_VIOLATION );
@@ -1623,7 +1815,7 @@
     	if ( structuralObjectClasses.isEmpty() )
     	{
     		String message = "Entry " + dn + " does not contain a STRUCTURAL ObjectClass";
-    		log.error( message );
+    		LOG.error( message );
     		throw new LdapSchemaViolationException( message, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
     	}
     	
@@ -1654,7 +1846,7 @@
     	if ( remaining.size() > 1 )
     	{
             String message = "Entry " + dn + " contains more than one STRUCTURAL ObjectClass: " + remaining;
-            log.error( message );
+            LOG.error( message );
             throw new LdapSchemaViolationException( message, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
     	}
     }
@@ -1671,7 +1863,7 @@
         {
             Attribute attribute = attributes.nextElement();
 
-            AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( attribute.getID() );
+            AttributeType attributeType = attributeTypeRegistry.lookup( attribute.getID() );
             SyntaxChecker syntaxChecker =  registries.getSyntaxCheckerRegistry().lookup( attributeType.getSyntax().getOid() );
             
             if ( syntaxChecker instanceof AcceptAllSyntaxChecker )
@@ -1697,7 +1889,7 @@
                     String message = "Attribute value '" + 
                         (value instanceof String ? value : StringTools.dumpBytes( (byte[])value ) ) + 
                         "' for attribute '" + attribute.getID() + "' is syntactically incorrect";
-                    log.info( message );
+                    LOG.info( message );
                     
                     throw new LdapInvalidAttributeValueException( message, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
 
@@ -1706,102 +1898,138 @@
         }
     }
     
+    private boolean checkHumanReadable( Attribute attribute ) throws NamingException
+    {
+        Enumeration<?> values = attribute.getAll();
+        boolean isModified = false;
+
+        // Loop on each values
+        while ( values.hasMoreElements() )
+        {
+            Object value = values.nextElement();
+
+            if ( value instanceof String )
+            {
+                continue;
+            }
+            else if ( value instanceof byte[] )
+            {
+                // we have a byte[] value. It should be a String UTF-8 encoded
+                // Let's transform it
+                try
+                {
+                    String valStr = new String( (byte[])value, "UTF-8" );
+                    attribute.remove( value );
+                    attribute.add( valStr );
+                    isModified = true;
+                }
+                catch ( UnsupportedEncodingException uee )
+                {
+                    throw new NamingException( "The value is not a valid String" );
+                }
+            }
+            else
+            {
+                throw new NamingException( "The value stored in an Human Readable attribute is not a String" );
+            }
+        }
+        
+        return isModified;
+    }
+    
+    private boolean checkNotHumanReadable( Attribute attribute ) throws NamingException
+    {
+        Enumeration<?> values = attribute.getAll();
+        boolean isModified = false;
+
+        // Loop on each values
+        while ( values.hasMoreElements() )
+        {
+            Object value = values.nextElement();
+
+            if ( value instanceof byte[] )
+            {
+                continue;
+            }
+            else if ( value instanceof String )
+            {
+                // We have a String value. It should be a byte[]
+                // Let's transform it
+                try
+                {
+                    byte[] valBytes = ( (String)value ).getBytes( "UTF-8" );
+                    
+                    attribute.remove( value );
+                    attribute.add( valBytes );
+                    isModified = true;
+                }
+                catch ( UnsupportedEncodingException uee )
+                {
+                    String message = "The value stored in a not Human Readable attribute as a String should be convertible to a byte[]";
+                    LOG.error( message );
+                    throw new NamingException( message );
+                }
+            }
+            else
+            {
+                String message ="The value is not valid. It should be a String or a byte[]"; 
+                LOG.error( message );
+                throw new NamingException( message );
+            }
+        }
+        
+        return isModified;
+    }
+    
+    
     /**
      * Check that all the attribute's values which are Human Readable can be transformed
-     * to valid String if they are stored as byte[].
+     * to valid String if they are stored as byte[], and that non Human Readable attributes
+     * stored as String can be transformed to byte[]
      */
     private void assertHumanReadable( Attributes entry ) throws NamingException
     {
         NamingEnumeration<? extends Attribute> attributes = entry.getAll();
-        boolean isEntryModified = false;
-        Attributes cloneEntry = null;
+        boolean isModified = false;
+        
+        Attributes clonedEntry = null;
 
         // First, loop on all attributes
         while ( attributes.hasMoreElements() )
         {
             Attribute attribute = attributes.nextElement();
 
-            AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( attribute.getID() );
+            AttributeType attributeType = attributeTypeRegistry.lookup( attribute.getID() );
 
             // If the attributeType is H-R, check all of its values
             if ( attributeType.getSyntax().isHumanReadable() )
             {
-                Enumeration<?> values = attribute.getAll();
-                Attribute clone = null;
-                boolean isModified = false;
-
-                // Loop on each values
-                while ( values.hasMoreElements() )
+                isModified = checkHumanReadable( attribute );
+            }
+            else
+            {
+                isModified = checkNotHumanReadable( attribute );
+            }
+            
+            // If we have a returned attribute, then we need to store it
+            // into a new entry
+            if ( isModified )
+            {
+                if ( clonedEntry == null )
                 {
-                    Object value = values.nextElement();
-
-                    if ( value instanceof String )
-                    {
-                        continue;
-                    }
-                    else if ( value instanceof byte[] )
-                    {
-                        // Ve have a byte[] value. It should be a String UTF-8 encoded
-                        // Let's transform it
-                        try
-                        {
-                            String valStr = new String( (byte[])value, "UTF-8" );
-
-                            if ( !isModified )
-                            {
-                                // Don't create useless clones. We only clone
-                                // if we have at least one value which is a byte[]
-                                isModified = true;
-                                clone = (Attribute)attribute.clone();
-                            }
-
-                            // Swap the value into the clone
-                            clone.remove( value );
-                            clone.add( valStr );
-                        }
-                        catch ( UnsupportedEncodingException uee )
-                        {
-                            throw new NamingException( "The value is not a valid String" );
-                        }
-                    }
-                    else
-                    {
-                        throw new NamingException( "The value stored in an Human Readable attribute is not a String" );
-                    }
+                    clonedEntry = (Attributes)entry.clone();
                 }
+                
+                // Switch the attributes
+                clonedEntry.put( attribute );
 
-                // The attribute has been checked. If one of its value has been modified,
-                // we have to modify the cloned Attributes/
-                if ( isModified )
-                {
-                    if ( !isEntryModified )
-                    {
-                        // Again, let's avoid useless cloning. If no attribute is H-R
-                        // or if no H-R value is stored as a byte[], we don't have to create a clone
-                        // of the entry
-                        cloneEntry = (Attributes)entry.clone();
-                        isEntryModified = true;
-                    }
-
-                    // Swap the attribute into the cloned entry
-                    cloneEntry.remove( attribute.getID() );
-                    cloneEntry.put( clone );
-                }
+                isModified = false;
             }
         }
-
-        // At the end, we now have to switch the entries, if it has been modified
-        if ( isEntryModified )
+        
+        if ( clonedEntry != null )
         {
-            attributes = cloneEntry.getAll();
-
-            // We llop on all the attributes and modify them in the initial entry.
-            while ( attributes.hasMoreElements() )
-            {
-                Attribute attribute = (Attribute)attributes.nextElement();
-                entry.remove( attribute.getID() );
-                entry.put( attribute );
-            }
+            entry = clonedEntry;
         }
     }
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java?rev=613608&r1=613607&r2=613608&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaOperationControl.java Sun Jan 20 08:59:10 2008
@@ -34,6 +34,10 @@
 import org.apache.directory.server.core.authz.AciAuthorizationInterceptor;
 import org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor;
 import org.apache.directory.server.core.collective.CollectiveAttributeInterceptor;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
+import org.apache.directory.server.core.entry.ServerValue;
 import org.apache.directory.server.core.exception.ExceptionInterceptor;
 import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.invocation.Invocation;
@@ -55,20 +59,24 @@
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
-import org.apache.directory.shared.ldap.schema.*;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.DITContentRule;
+import org.apache.directory.shared.ldap.schema.DITStructureRule;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.MatchingRuleUse;
+import org.apache.directory.shared.ldap.schema.NameForm;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
 import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
 import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
-import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.DateUtils;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
 
@@ -133,7 +141,7 @@
     private static final java.util.Collection<String> SCHEMA_MODIFICATION_ATTRIBUTES_UPDATE_BYPASS;
 
     private final MetaSchemaHandler metaSchemaHandler;
-    private final Registries globalRegistries;
+    private final Registries registries;
     private final AttributeType objectClassAT;
     private final SchemaSubentryModifier subentryModifier;
     private final SchemaChangeHandler[] schemaObjectHandlers = new SchemaChangeHandler[11];
@@ -184,31 +192,31 @@
     }
 
 
-    public SchemaOperationControl( Registries globalRegistries, PartitionSchemaLoader loader, SchemaPartitionDao dao )
+    public SchemaOperationControl( Registries registries, PartitionSchemaLoader loader, SchemaPartitionDao dao )
         throws NamingException
     {
-        this.globalRegistries = globalRegistries;
-        this.objectClassAT = this.globalRegistries.getAttributeTypeRegistry()
+        this.registries = registries;
+        this.objectClassAT = this.registries.getAttributeTypeRegistry()
             .lookup( SchemaConstants.OBJECT_CLASS_AT );
         
-        this.metaSchemaHandler = new MetaSchemaHandler( this.globalRegistries, loader );
+        this.metaSchemaHandler = new MetaSchemaHandler( this.registries, loader );
         
-        this.schemaObjectHandlers[COMPARATOR_INDEX] = new MetaComparatorHandler( globalRegistries, loader ); 
-        this.schemaObjectHandlers[NORMALIZER_INDEX] = new MetaNormalizerHandler( globalRegistries, loader );
-        this.schemaObjectHandlers[SYNTAX_CHECKER_INDEX] = new MetaSyntaxCheckerHandler( globalRegistries, loader );
-        this.schemaObjectHandlers[SYNTAX_INDEX] = new MetaSyntaxHandler( globalRegistries, loader, dao );
-        this.schemaObjectHandlers[MATCHING_RULE_INDEX] = new MetaMatchingRuleHandler( globalRegistries, loader, dao );
-        this.schemaObjectHandlers[ATTRIBUTE_TYPE_INDEX] = new MetaAttributeTypeHandler( globalRegistries, loader, dao );
-        this.schemaObjectHandlers[OBJECT_CLASS_INDEX] = new MetaObjectClassHandler( globalRegistries, loader, dao );
-        this.schemaObjectHandlers[MATCHING_RULE_USE_INDEX] = new MetaMatchingRuleUseHandler( globalRegistries, loader );
-        this.schemaObjectHandlers[DIT_STRUCTURE_RULE_INDEX] = new MetaDitStructureRuleHandler( globalRegistries, loader ); 
-        this.schemaObjectHandlers[DIT_CONTENT_RULE_INDEX] = new MetaDitContentRuleHandler( globalRegistries, loader ); 
-        this.schemaObjectHandlers[NAME_FORM_INDEX] = new MetaNameFormHandler( globalRegistries, loader ); 
+        this.schemaObjectHandlers[COMPARATOR_INDEX] = new MetaComparatorHandler( registries, loader ); 
+        this.schemaObjectHandlers[NORMALIZER_INDEX] = new MetaNormalizerHandler( registries, loader );
+        this.schemaObjectHandlers[SYNTAX_CHECKER_INDEX] = new MetaSyntaxCheckerHandler( registries, loader );
+        this.schemaObjectHandlers[SYNTAX_INDEX] = new MetaSyntaxHandler( registries, loader, dao );
+        this.schemaObjectHandlers[MATCHING_RULE_INDEX] = new MetaMatchingRuleHandler( registries, loader, dao );
+        this.schemaObjectHandlers[ATTRIBUTE_TYPE_INDEX] = new MetaAttributeTypeHandler( registries, loader, dao );
+        this.schemaObjectHandlers[OBJECT_CLASS_INDEX] = new MetaObjectClassHandler( registries, loader, dao );
+        this.schemaObjectHandlers[MATCHING_RULE_USE_INDEX] = new MetaMatchingRuleUseHandler( registries, loader );
+        this.schemaObjectHandlers[DIT_STRUCTURE_RULE_INDEX] = new MetaDitStructureRuleHandler( registries, loader ); 
+        this.schemaObjectHandlers[DIT_CONTENT_RULE_INDEX] = new MetaDitContentRuleHandler( registries, loader ); 
+        this.schemaObjectHandlers[NAME_FORM_INDEX] = new MetaNameFormHandler( registries, loader ); 
 
         this.subentryModifier = new SchemaSubentryModifier( dao );
-        this.parsers = new DescriptionParsers( globalRegistries, dao );
+        this.parsers = new DescriptionParsers( registries, dao );
         
-        OidRegistry oidRegistry = globalRegistries.getOidRegistry();
+        OidRegistry oidRegistry = registries.getOidRegistry();
 
         String comparatorsOid = oidRegistry.getOid( SchemaConstants.COMPARATORS_AT );
         opAttr2handlerIndex.put( comparatorsOid, COMPARATOR_INDEX );
@@ -249,14 +257,14 @@
     
     private void initHandlerMaps() throws NamingException
     {
-        AttributeTypeRegistry atReg = globalRegistries.getAttributeTypeRegistry();
+        AttributeTypeRegistry atReg = registries.getAttributeTypeRegistry();
         for ( int ii = 0; ii < OP_ATTRS.length; ii++ )
         {
             AttributeType at = atReg.lookup( OP_ATTRS[ii] );
             opAttr2handlerMap.put( at.getOid(), schemaObjectHandlers[ii] );
         }
 
-        ObjectClassRegistry ocReg = globalRegistries.getObjectClassRegistry();
+        ObjectClassRegistry ocReg = registries.getObjectClassRegistry();
         for ( int ii = 0; ii < META_OBJECT_CLASSES.length; ii++ )
         {
             ObjectClass oc = ocReg.lookup( META_OBJECT_CLASSES[ii] );
@@ -267,7 +275,7 @@
     
     public Registries getGlobalRegistries()
     {
-        return globalRegistries;
+        return registries;
     }
     
     
@@ -278,13 +286,15 @@
     }
 
 
-    public void add( LdapDN name, Attributes entry ) throws NamingException
+    public void add( LdapDN name, ServerEntry entry ) throws NamingException
     {
-        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
+        ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( int ii = 0; ii < oc.size(); ii++ )
+        for ( ServerValue<?> value:oc )
         {
-            String oid = globalRegistries.getOidRegistry().getOid( ( String ) oc.get( ii ) );
+
+            String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
+            
             if ( objectClass2handlerMap.containsKey( oid ) )
             {
                 SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
@@ -294,14 +304,14 @@
             }
         }
         
-        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SCHEMA_OC, objectClassAT ) )
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
         {
             metaSchemaHandler.add( name, entry );
             updateSchemaModificationAttributes();
             return;
         }
         
-        if ( AttributeUtils.containsValue( oc, SchemaConstants.ORGANIZATIONAL_UNIT_OC, objectClassAT ) )
+        if ( oc.contains( SchemaConstants.ORGANIZATIONAL_UNIT_OC ) )
         {
             if ( name.size() != 3 )
             {
@@ -325,13 +335,14 @@
     }
     
 
-    public void delete( LdapDN name, Attributes entry, boolean doCascadeDelete ) throws NamingException
+    public void delete( LdapDN name, ServerEntry entry, boolean doCascadeDelete ) throws NamingException
     {
-        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
+        ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( int ii = 0; ii < oc.size(); ii++ )
+        for ( ServerValue<?> value:oc )
         {
-            String oid = globalRegistries.getOidRegistry().getOid( ( String ) oc.get( ii ) );
+            String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
+            
             if ( objectClass2handlerMap.containsKey( oid ) )
             {
                 SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
@@ -341,14 +352,14 @@
             }
         }
 
-        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SCHEMA_OC, objectClassAT ) )
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
         {
             metaSchemaHandler.delete( name, entry, doCascadeDelete );
             updateSchemaModificationAttributes();
             return;
         }
         
-        if ( AttributeUtils.containsValue( oc, SchemaConstants.ORGANIZATIONAL_UNIT_OC, objectClassAT ) )
+        if ( oc.contains( SchemaConstants.ORGANIZATIONAL_UNIT_OC ) )
         {
             if ( name.size() != 3 )
             {
@@ -372,14 +383,15 @@
     }
     
 
-    public void modify( LdapDN name, int modOp, Attributes mods, Attributes entry, 
-        Attributes targetEntry, boolean cascade ) throws NamingException
+    public void modify( LdapDN name, int modOp, ServerEntry mods, ServerEntry entry, 
+        ServerEntry targetEntry, boolean cascade ) throws NamingException
     {
-        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
+        ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( int ii = 0; ii < oc.size(); ii++ )
+        for ( ServerValue<?> value:oc )
         {
-            String oid = globalRegistries.getOidRegistry().getOid( ( String ) oc.get( ii ) );
+            String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
+            
             if ( objectClass2handlerMap.containsKey( oid ) )
             {
                 SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
@@ -389,7 +401,7 @@
             }
         }
 
-        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SCHEMA_OC, objectClassAT ) )
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
         {
             metaSchemaHandler.modify( name, modOp, mods, entry, targetEntry, cascade );
             updateSchemaModificationAttributes();
@@ -400,14 +412,14 @@
     }
 
 
-    public void modify( LdapDN name, List<ModificationItemImpl> mods, Attributes entry, Attributes targetEntry,
+    public void modify( LdapDN name, List<ModificationItemImpl> mods, ServerEntry entry, ServerEntry targetEntry,
         boolean doCascadeModify ) throws NamingException
     {
-        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
+        ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( int ii = 0; ii < oc.size(); ii++ )
+        for ( ServerValue<?> value:oc )
         {
-            String oid = globalRegistries.getOidRegistry().getOid( ( String ) oc.get( ii ) );
+            String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
             
             if ( objectClass2handlerMap.containsKey( oid ) )
             {
@@ -418,7 +430,7 @@
             }
         }
 
-        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SCHEMA_OC, objectClassAT ) )
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
         {
             metaSchemaHandler.modify( name, mods, entry, targetEntry, doCascadeModify );
             updateSchemaModificationAttributes();
@@ -431,14 +443,15 @@
     }
 
 
-    public void modifyRn( LdapDN name, Rdn newRdn, boolean deleteOldRn, Attributes entry, boolean doCascadeModify ) 
+    public void modifyRn( LdapDN name, Rdn newRdn, boolean deleteOldRn, ServerEntry entry, boolean doCascadeModify ) 
         throws NamingException
     {
-        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
+        ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( int ii = 0; ii < oc.size(); ii++ )
+        for ( ServerValue<?> value:oc )
         {
-            String oid = globalRegistries.getOidRegistry().getOid( ( String ) oc.get( ii ) );
+            String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
+            
             if ( objectClass2handlerMap.containsKey( oid ) )
             {
                 SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
@@ -448,7 +461,7 @@
             }
         }
 
-        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SCHEMA_OC, objectClassAT ) )
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
         {
             metaSchemaHandler.rename( name, entry, newRdn, doCascadeModify );
             updateSchemaModificationAttributes();
@@ -459,14 +472,14 @@
     }
 
 
-    public void replace( LdapDN oriChildName, LdapDN newParentName, Attributes entry, 
+    public void replace( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry, 
         boolean cascade ) throws NamingException
     {
-        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
+        ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( int ii = 0; ii < oc.size(); ii++ )
+        for ( ServerValue<?> value:oc )
         {
-            String oid = globalRegistries.getOidRegistry().getOid( ( String ) oc.get( ii ) );
+            String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
             
             if ( objectClass2handlerMap.containsKey( oid ) )
             {
@@ -477,7 +490,7 @@
             }
         }
 
-        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SCHEMA_OC, objectClassAT ) )
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
         {
             metaSchemaHandler.replace( oriChildName, newParentName, entry, cascade );
             updateSchemaModificationAttributes();
@@ -489,13 +502,14 @@
 
 
     public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRn, boolean deleteOldRn,
-        Attributes entry, boolean cascade ) throws NamingException
+        ServerEntry entry, boolean cascade ) throws NamingException
     {
-        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
+        ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( int ii = 0; ii < oc.size(); ii++ )
+        for ( ServerValue<?> value:oc )
         {
-            String oid = globalRegistries.getOidRegistry().getOid( ( String ) oc.get( ii ) );
+            String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
+            
             if ( objectClass2handlerMap.containsKey( oid ) )
             {
                 SchemaChangeHandler handler = objectClass2handlerMap.get( oid );
@@ -505,7 +519,7 @@
             }
         }
 
-        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SCHEMA_OC, objectClassAT ) )
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
         {
             metaSchemaHandler.move( oriChildName, newParentName, newRn, deleteOldRn, entry, cascade );
             updateSchemaModificationAttributes();
@@ -529,21 +543,28 @@
      * to effect all dependents on the changed entity
      * @throws NamingException if the operation fails
      */
-    public void modifySchemaSubentry( LdapDN name, List<ModificationItemImpl> mods, Attributes subentry, 
-        Attributes targetSubentry, boolean doCascadeModify ) throws NamingException 
+    public void modifySchemaSubentry( LdapDN name, List<ModificationItemImpl> mods, ServerEntry subentry, 
+        ServerEntry targetSubentry, boolean doCascadeModify ) throws NamingException 
     {
         for ( ModificationItem mod : mods )
         {
-            String opAttrOid = globalRegistries.getOidRegistry().getOid( mod.getAttribute().getID() );
+            String opAttrOid = registries.getOidRegistry().getOid( mod.getAttribute().getID() );
             
+            AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( 
+                mod.getAttribute().getID() );
+        
+            ServerAttribute serverAttribute = 
+                ServerEntryUtils.toServerAttribute( mod.getAttribute(), attributeType );
+
             switch ( mod.getModificationOp() )
             {
                 case( DirContext.ADD_ATTRIBUTE ):
-                    modifyAddOperation( opAttrOid, mod.getAttribute(), doCascadeModify );
+
+                    modifyAddOperation( opAttrOid, serverAttribute, doCascadeModify );
                     break;
                     
                 case( DirContext.REMOVE_ATTRIBUTE ):
-                    modifyRemoveOperation( opAttrOid, mod.getAttribute(), doCascadeModify );
+                    modifyRemoveOperation( opAttrOid, serverAttribute, doCascadeModify );
                     break; 
                     
                 case( DirContext.REPLACE_ATTRIBUTE ):
@@ -580,30 +601,31 @@
      * to effect all dependents on the changed entity
      * @throws NamingException if the modify fails
      */
-    public void modifySchemaSubentry( LdapDN name, int modOp, Attributes mods, Attributes subentry, 
-        Attributes targetSubentry, boolean doCascadeModify ) throws NamingException
+    public void modifySchemaSubentry( LdapDN name, int modOp, ServerEntry mods, ServerEntry subentry, 
+        ServerEntry targetSubentry, boolean doCascadeModify ) throws NamingException
     {
-        NamingEnumeration<String> ids = mods.getIDs();
+        Set<AttributeType> attributeTypes = mods.getAttributeTypes();
+        
         switch ( modOp )
         {
             case( DirContext.ADD_ATTRIBUTE ):
-                while ( ids.hasMore() )
+                for ( AttributeType attributeType:attributeTypes )
                 {
-                    String id = ids.next();
-                    AttributeType opAttrAT = globalRegistries.getAttributeTypeRegistry().lookup( id );
-                    modifyAddOperation( opAttrAT.getOid(), 
-                        AttributeUtils.getAttribute( mods, opAttrAT ), doCascadeModify );
+                    modifyAddOperation( attributeType.getOid(), 
+                        mods.get( attributeType ), doCascadeModify );
                 }
+            
                 break;
+                
             case( DirContext.REMOVE_ATTRIBUTE ):
-                while ( ids.hasMore() )
+                for ( AttributeType attributeType:attributeTypes )
                 {
-                    String id = ids.next();
-                    AttributeType opAttrAT = globalRegistries.getAttributeTypeRegistry().lookup( id );
-                    modifyRemoveOperation( opAttrAT.getOid(), 
-                        AttributeUtils.getAttribute( mods, opAttrAT ), doCascadeModify );
+                    modifyRemoveOperation( attributeType.getOid(), 
+                        mods.get( attributeType ), doCascadeModify );
                 }
+            
                 break;
+                
             case( DirContext.REPLACE_ATTRIBUTE ):
                 throw new LdapOperationNotSupportedException( 
                     "Modify REPLACE operations on schema subentries are not allowed: " +
@@ -611,9 +633,11 @@
                     "that reside in schema operational attributes.  Instead use \na " +
                     "targeted combination of modify ADD and REMOVE operations.", 
                     ResultCodeEnum.UNWILLING_TO_PERFORM );
+            
             default:
                 throw new IllegalStateException( "Undefined modify operation: " + modOp );
         }
+        
         updateSchemaModificationAttributes();
     }
 
@@ -639,11 +663,12 @@
      * @throws NamingException if there are problems updating the registries and the
      * schema partition
      */
-    private void modifyRemoveOperation( String opAttrOid, Attribute mods, boolean doCascadeModify ) 
+    private void modifyRemoveOperation( String opAttrOid, ServerAttribute mods, boolean doCascadeModify ) 
         throws NamingException
     {
         int index = opAttr2handlerIndex.get( opAttrOid );
         SchemaChangeHandler handler = opAttr2handlerMap.get( opAttrOid );
+        
         switch( index )
         {
             case( COMPARATOR_INDEX ):
@@ -653,7 +678,7 @@
                 for ( ComparatorDescription comparatorDescription : comparatorDescriptions )
                 {
                     comparatorHandler.delete( comparatorDescription.getNumericOid(), doCascadeModify );
-                    subentryModifier.delete( comparatorDescription );
+                    subentryModifier.delete( registries, comparatorDescription );
                 }
                 break;
             case( NORMALIZER_INDEX ):
@@ -663,7 +688,7 @@
                 for ( NormalizerDescription normalizerDescription : normalizerDescriptions )
                 {
                     normalizerHandler.delete( normalizerDescription.getNumericOid(), doCascadeModify );
-                    subentryModifier.delete( normalizerDescription );
+                    subentryModifier.delete( registries, normalizerDescription );
                 }
                 break;
             case( SYNTAX_CHECKER_INDEX ):
@@ -673,7 +698,7 @@
                 for ( SyntaxCheckerDescription syntaxCheckerDescription : syntaxCheckerDescriptions )
                 {
                     syntaxCheckerHandler.delete( syntaxCheckerDescription.getNumericOid(), doCascadeModify );
-                    subentryModifier.delete( syntaxCheckerDescription );
+                    subentryModifier.delete( registries, syntaxCheckerDescription );
                 }
                 break;
             case( SYNTAX_INDEX ):
@@ -683,7 +708,7 @@
                 for ( Syntax syntax : syntaxes )
                 {
                     syntaxHandler.delete( syntax, doCascadeModify );
-                    subentryModifier.deleteSchemaObject( syntax );
+                    subentryModifier.deleteSchemaObject( registries, syntax );
                 }
                 break;
             case( MATCHING_RULE_INDEX ):
@@ -693,7 +718,7 @@
                 for ( MatchingRule mr : mrs )
                 {
                     matchingRuleHandler.delete( mr, doCascadeModify );
-                    subentryModifier.deleteSchemaObject( mr );
+                    subentryModifier.deleteSchemaObject( registries, mr );
                 }
                 break;
             case( ATTRIBUTE_TYPE_INDEX ):
@@ -703,7 +728,7 @@
                 for ( AttributeType at : ats )
                 {
                     atHandler.delete( at, doCascadeModify );
-                    subentryModifier.deleteSchemaObject( at );
+                    subentryModifier.deleteSchemaObject( registries, at );
                 }
                 break;
             case( OBJECT_CLASS_INDEX ):
@@ -713,7 +738,7 @@
                 for ( ObjectClass oc : ocs )
                 {
                     ocHandler.delete( oc, doCascadeModify );
-                    subentryModifier.deleteSchemaObject( oc );
+                    subentryModifier.deleteSchemaObject( registries, oc );
                 }
                 break;
             case( MATCHING_RULE_USE_INDEX ):
@@ -723,7 +748,7 @@
                 for ( MatchingRuleUse mru : mrus )
                 {
                     mruHandler.delete( mru, doCascadeModify );
-                    subentryModifier.deleteSchemaObject( mru );
+                    subentryModifier.deleteSchemaObject( registries, mru );
                 }
                 break;
             case( DIT_STRUCTURE_RULE_INDEX ):
@@ -733,7 +758,7 @@
                 for ( DITStructureRule dsr : dsrs )
                 {
                     dsrHandler.delete( dsr, doCascadeModify );
-                    subentryModifier.deleteSchemaObject( dsr );
+                    subentryModifier.deleteSchemaObject( registries, dsr );
                 }
                 break;
             case( DIT_CONTENT_RULE_INDEX ):
@@ -743,7 +768,7 @@
                 for ( DITContentRule dcr : dcrs )
                 {
                     dcrHandler.delete( dcr, doCascadeModify );
-                    subentryModifier.deleteSchemaObject( dcr );
+                    subentryModifier.deleteSchemaObject( registries, dcr );
                 }
                 break;
             case( NAME_FORM_INDEX ):
@@ -753,7 +778,7 @@
                 for ( NameForm nf : nfs )
                 {
                     nfHandler.delete( nf, doCascadeModify );
-                    subentryModifier.deleteSchemaObject( nf );
+                    subentryModifier.deleteSchemaObject( registries, nf );
                 }
                 break;
             default:
@@ -772,7 +797,7 @@
      * @throws NamingException if there are problems updating the registries and the
      * schema partition
      */
-    private void modifyAddOperation( String opAttrOid, Attribute mods, boolean doCascadeModify ) throws NamingException
+    private void modifyAddOperation( String opAttrOid, ServerAttribute mods, boolean doCascadeModify ) throws NamingException
     {
         if ( doCascadeModify )
         {
@@ -790,7 +815,7 @@
                 for ( ComparatorDescription comparatorDescription : comparatorDescriptions )
                 {
                     comparatorHandler.add( comparatorDescription );
-                    subentryModifier.add( comparatorDescription );
+                    subentryModifier.add( registries, comparatorDescription );
                 }
                 break;
             case( NORMALIZER_INDEX ):
@@ -800,7 +825,7 @@
                 for ( NormalizerDescription normalizerDescription : normalizerDescriptions )
                 {
                     normalizerHandler.add( normalizerDescription );
-                    subentryModifier.add( normalizerDescription );
+                    subentryModifier.add( registries, normalizerDescription );
                 }
                 break;
             case( SYNTAX_CHECKER_INDEX ):
@@ -810,7 +835,7 @@
                 for ( SyntaxCheckerDescription syntaxCheckerDescription : syntaxCheckerDescriptions )
                 {
                     syntaxCheckerHandler.add( syntaxCheckerDescription );
-                    subentryModifier.add( syntaxCheckerDescription );
+                    subentryModifier.add( registries, syntaxCheckerDescription );
                 }
                 break;
             case( SYNTAX_INDEX ):
@@ -820,7 +845,7 @@
                 for ( Syntax syntax : syntaxes )
                 {
                     syntaxHandler.add( syntax );
-                    subentryModifier.addSchemaObject( syntax );
+                    subentryModifier.addSchemaObject( registries, syntax );
                 }
                 break;
             case( MATCHING_RULE_INDEX ):
@@ -830,7 +855,7 @@
                 for ( MatchingRule mr : mrs )
                 {
                     matchingRuleHandler.add( mr );
-                    subentryModifier.addSchemaObject( mr );
+                    subentryModifier.addSchemaObject( registries, mr );
                 }
                 break;
             case( ATTRIBUTE_TYPE_INDEX ):
@@ -840,7 +865,7 @@
                 for ( AttributeType at : ats )
                 {
                     atHandler.add( at );
-                    subentryModifier.addSchemaObject( at );
+                    subentryModifier.addSchemaObject( registries, at );
                 }
                 break;
             case( OBJECT_CLASS_INDEX ):
@@ -850,7 +875,7 @@
                 for ( ObjectClass oc : ocs )
                 {
                     ocHandler.add( oc );
-                    subentryModifier.addSchemaObject( oc );
+                    subentryModifier.addSchemaObject( registries, oc );
                 }
                 break;
             case( MATCHING_RULE_USE_INDEX ):
@@ -860,7 +885,7 @@
                 for ( MatchingRuleUse mru : mrus )
                 {
                     mruHandler.add( mru );
-                    subentryModifier.addSchemaObject( mru );
+                    subentryModifier.addSchemaObject( registries, mru );
                 }
                 break;
             case( DIT_STRUCTURE_RULE_INDEX ):
@@ -870,7 +895,7 @@
                 for ( DITStructureRule dsr : dsrs )
                 {
                     dsrHandler.add( dsr );
-                    subentryModifier.addSchemaObject( dsr );
+                    subentryModifier.addSchemaObject( registries, dsr );
                 }
                 break;
             case( DIT_CONTENT_RULE_INDEX ):
@@ -880,7 +905,7 @@
                 for ( DITContentRule dcr : dcrs )
                 {
                     dcrHandler.add( dcr );
-                    subentryModifier.addSchemaObject( dcr );
+                    subentryModifier.addSchemaObject( registries, dcr );
                 }
                 break;
             case( NAME_FORM_INDEX ):
@@ -890,7 +915,7 @@
                 for ( NameForm nf : nfs )
                 {
                     nfHandler.add( nf );
-                    subentryModifier.addSchemaObject( nf );
+                    subentryModifier.addSchemaObject( registries, nf );
                 }
                 break;
             default:
@@ -926,9 +951,9 @@
             new AttributeImpl( ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT, modifiersName ) ) );
         
         LdapDN name = new LdapDN( "cn=schemaModifications,ou=schema" );
-        name.normalize( globalRegistries.getAttributeTypeRegistry().getNormalizerMapping() );
+        name.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
         
-        invocation.getProxy().modify( new ModifyOperationContext( name, mods, true ),
+        invocation.getProxy().modify( new ModifyOperationContext( registries, name, mods, true ),
                 SCHEMA_MODIFICATION_ATTRIBUTES_UPDATE_BYPASS );
     }
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java?rev=613608&r1=613607&r2=613608&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java Sun Jan 20 08:59:10 2008
@@ -29,6 +29,7 @@
 
 import org.apache.directory.server.constants.MetaSchemaConstants;
 import org.apache.directory.server.constants.ServerDNConstants;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
@@ -100,6 +101,7 @@
 
 
     private final Partition partition;
+    private final Registries registries;
     private final SchemaEntityFactory factory;
     private final OidRegistry oidRegistry;
     private final AttributeTypeRegistry attrRegistry;
@@ -130,12 +132,13 @@
      * @param bootstrapRegistries the bootstrap registries that were used to start up the schema partition
      * @throws NamingException if there are problems initializing this schema partion dao
      */
-    public SchemaPartitionDao( Partition partition, Registries bootstrapRegistries ) throws NamingException
+    public SchemaPartitionDao( Partition partition, Registries registries ) throws NamingException
     {
         this.partition = partition;
-        this.factory = new SchemaEntityFactory( bootstrapRegistries );
-        this.oidRegistry = bootstrapRegistries.getOidRegistry();
-        this.attrRegistry = bootstrapRegistries.getAttributeTypeRegistry();
+        this.registries = registries;
+        this.factory = new SchemaEntityFactory( registries );
+        this.oidRegistry = registries.getOidRegistry();
+        this.attrRegistry = registries.getAttributeTypeRegistry();
         
         this.M_NAME_OID = oidRegistry.getOid( MetaSchemaConstants.M_NAME_AT );
         this.CN_OID = oidRegistry.getOid( SchemaConstants.CN_AT );
@@ -159,11 +162,16 @@
     public Map<String,Schema> getSchemas() throws NamingException
     {
         Map<String,Schema> schemas = new HashMap<String,Schema>();
-        NamingEnumeration list = listSchemas();
+        NamingEnumeration<SearchResult> list = listSchemas();
+        
         while( list.hasMore() )
         {
-            SearchResult sr = ( SearchResult ) list.next();
-            Schema schema = factory.getSchema( sr.getAttributes() ); 
+            SearchResult sr = list.next();
+            Schema schema = factory.getSchema( 
+                ServerEntryUtils.toServerEntry( 
+                    sr.getAttributes(),
+                    LdapDN.EMPTY_LDAPDN,
+                    registries ) ); 
             schemas.put( schema.getSchemaName(), schema );
         }
         
@@ -174,10 +182,11 @@
     public Set<String> getSchemaNames() throws NamingException
     {
         Set<String> schemaNames = new HashSet<String>();
-        NamingEnumeration list = listSchemas();
+        NamingEnumeration<SearchResult> list = listSchemas();
+        
         while( list.hasMore() )
         {
-            SearchResult sr = ( SearchResult ) list.next();
+            SearchResult sr = list.next();
             schemaNames.add( ( String ) sr.getAttributes().get( SchemaConstants.CN_AT ).get() );
         }
         
@@ -185,7 +194,7 @@
     }
     
 
-    private NamingEnumeration listSchemas() throws NamingException
+    private NamingEnumeration<SearchResult> listSchemas() throws NamingException
     {
         LdapDN base = new LdapDN( ServerDNConstants.OU_SCHEMA_DN );
         base.normalize( attrRegistry.getNormalizerMapping() );
@@ -194,7 +203,7 @@
         searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         searchControls.setReturningAttributes( SCHEMA_ATTRIBUTES );
         return partition.search( 
-            new SearchOperationContext( base, AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
+            new SearchOperationContext( registries, base, AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
     }
 
 
@@ -202,7 +211,11 @@
     {
         LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
         dn.normalize( attrRegistry.getNormalizerMapping() );
-        return factory.getSchema( partition.lookup( new LookupOperationContext( dn ) ) );
+        return factory.getSchema( 
+            ServerEntryUtils.toServerEntry( 
+                partition.lookup( new LookupOperationContext( registries, dn ) ),
+                dn,
+                registries ) );
     }
 
 
@@ -226,7 +239,7 @@
 
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(),
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                     AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             
             if ( ! ne.hasMore() )
@@ -273,7 +286,7 @@
         try
         {
             ne = partition.search( new SearchOperationContext(
-                    partition.getSuffixDn(), AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
+                registries, partition.getSuffixDn(), AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             
             if ( ! ne.hasMore() )
             {
@@ -318,7 +331,7 @@
 
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(),
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                     AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             
             if ( ! ne.hasMore() )
@@ -364,7 +377,7 @@
 
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(),
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                     AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             
             if ( ! ne.hasMore() )
@@ -410,7 +423,7 @@
 
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(), AliasDerefMode.DEREF_ALWAYS,
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(), AliasDerefMode.DEREF_ALWAYS,
                         filter, searchControls ) );
             
             if ( ! ne.hasMore() )
@@ -505,7 +518,7 @@
         
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(),
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                     AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             
             if ( ! ne.hasMore() )
@@ -565,7 +578,7 @@
     {
         LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
         dn.normalize( attrRegistry.getNormalizerMapping() );
-        Attributes entry = partition.lookup( new LookupOperationContext( dn ) );
+        Attributes entry = partition.lookup( new LookupOperationContext( registries, dn ) );
         Attribute disabledAttr = AttributeUtils.getAttribute( entry, disabledAttributeType );
         List<ModificationItemImpl> mods = new ArrayList<ModificationItemImpl>( 3 );
         
@@ -591,7 +604,7 @@
         mods.add( new ModificationItemImpl( DirContext.ADD_ATTRIBUTE,
             new AttributeImpl( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ) ) );
         
-        partition.modify( new ModifyOperationContext( dn, mods ) );
+        partition.modify( new ModifyOperationContext( registries, dn, mods ) );
     }
 
 
@@ -624,7 +637,7 @@
         
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(),
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                     AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             while( ne.hasMore() )
             {
@@ -673,7 +686,7 @@
         
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(),
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                      AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             while( ne.hasMore() )
             {
@@ -701,7 +714,7 @@
         // (& (m-oid=*) (m-name=*) )
         filter.addNode( new PresenceNode( M_OID_OID ) );
         filter.addNode( new PresenceNode( M_NAME_OID ) );
-        return partition.search( new SearchOperationContext( partition.getSuffixDn(),
+        return partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                  AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
     }
 
@@ -750,7 +763,7 @@
         
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(),
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                     AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             while( ne.hasMore() )
             {
@@ -798,7 +811,7 @@
         
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(),
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                     AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             while( ne.hasMore() )
             {
@@ -840,7 +853,7 @@
         
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(),
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                      AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             while( ne.hasMore() )
             {
@@ -920,7 +933,7 @@
         
         try
         {
-            ne = partition.search( new SearchOperationContext( partition.getSuffixDn(),
+            ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                     AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
             while( ne.hasMore() )
             {

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=613608&r1=613607&r2=613608&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Sun Jan 20 08:59:10 2008
@@ -373,7 +373,7 @@
         if ( schemaSubentry == null )
         {
             generateSchemaSubentry( schemaPartition.lookup(
-                    new LookupOperationContext( schemaModificationAttributesDN ) ) );
+                    new LookupOperationContext( registries, schemaModificationAttributesDN ) ) );
         }
 
         return new ImmutableAttributesWrapper( schemaSubentry );
@@ -391,7 +391,7 @@
         if ( schemaSubentry == null )
         {
             generateSchemaSubentry( schemaPartition.lookup(
-                    new LookupOperationContext( schemaModificationAttributesDN ) ) );
+                    new LookupOperationContext( registries, schemaModificationAttributesDN ) ) );
         }
 
         return ( Attributes ) schemaSubentry.clone();
@@ -423,14 +423,13 @@
             // Check if we need an update by looking at timestamps on disk
             // ---------------------------------------------------------------
 
-            Attributes mods = schemaPartition.lookup( new LookupOperationContext( schemaModificationAttributesDN ) );
-            Attribute modifyTimeDisk = mods.get( SchemaConstants.MODIFY_TIMESTAMP_AT );
-
-            Attribute modifyTimeMemory = null;
-
-            // @todo enable this optimization at some point but for now it
-            // is causing some problems so I will just turn it off
-
+            Attributes mods = schemaPartition.lookup( new LookupOperationContext( registries, schemaModificationAttributesDN ) );
+// @todo enable this optimization at some point but for now it
+// is causing some problems so I will just turn it off
+//          Attribute modifyTimeDisk = mods.get( SchemaConstants.MODIFY_TIMESTAMP_AT );
+//
+//          Attribute modifyTimeMemory = null;
+//
 //            if ( schemaSubentry != null )
 //            {
 //                modifyTimeMemory = schemaSubentry.get( SchemaConstants.MODIFY_TIMESTAMP_AT );

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java?rev=613608&r1=613607&r2=613608&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java Sun Jan 20 08:59:10 2008
@@ -31,6 +31,8 @@
 import org.apache.directory.server.core.authn.AuthenticationInterceptor;
 import org.apache.directory.server.core.authz.AciAuthorizationInterceptor;
 import org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.exception.ExceptionInterceptor;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
@@ -38,6 +40,7 @@
 import org.apache.directory.server.core.partition.PartitionNexusProxy;
 import org.apache.directory.server.core.referral.ReferralInterceptor;
 import org.apache.directory.server.schema.bootstrap.Schema;
+import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.utils.AttributesFactory;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
@@ -140,62 +143,66 @@
     }
     
 
-    public void addSchemaObject( SchemaObject obj ) throws NamingException
+    public void addSchemaObject( Registries registries, SchemaObject obj ) throws NamingException
     {
         PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
         Schema schema = dao.getSchema( obj.getSchema() );
         LdapDN dn = getDn( obj );
         Attributes attrs = factory.getAttributes( obj, schema );
-        proxy.add( new AddOperationContext( dn, attrs, true ), BYPASS );
+        ServerEntry entry = ServerEntryUtils.toServerEntry( attrs, dn, registries );
+
+        proxy.add( new AddOperationContext( registries, dn, entry, true ), BYPASS );
     }
 
 
-    public void deleteSchemaObject( SchemaObject obj ) throws NamingException
+    public void deleteSchemaObject( Registries registries, SchemaObject obj ) throws NamingException
     {
         PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
         LdapDN dn = getDn( obj );
-        proxy.delete( new DeleteOperationContext( dn, true ), BYPASS );
+        proxy.delete( new DeleteOperationContext( registries, dn, true ), BYPASS );
     }
 
     
-    public void delete( NormalizerDescription normalizerDescription ) throws NamingException
+    public void delete( Registries registries, NormalizerDescription normalizerDescription ) throws NamingException
     {
         String schemaName = getSchema( normalizerDescription );
         PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
         LdapDN dn = new LdapDN( "m-oid=" + normalizerDescription.getNumericOid() + ",ou=normalizers,cn=" 
             + schemaName + ",ou=schema" );
-        proxy.delete( new DeleteOperationContext( dn, true ), BYPASS );
+        proxy.delete( new DeleteOperationContext( registries, dn, true ), BYPASS );
     }
 
 
-    public void delete( SyntaxCheckerDescription syntaxCheckerDescription ) throws NamingException
+    public void delete( Registries registries, SyntaxCheckerDescription syntaxCheckerDescription ) throws NamingException
     {
         String schemaName = getSchema( syntaxCheckerDescription );
         PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
         LdapDN dn = new LdapDN( "m-oid=" + syntaxCheckerDescription.getNumericOid() + ",ou=syntaxCheckers,cn=" 
             + schemaName + ",ou=schema" );
-        proxy.delete( new DeleteOperationContext( dn, true ), BYPASS );
+        proxy.delete( new DeleteOperationContext( registries, dn, true ), BYPASS );
     }
 
 
-    public void delete( ComparatorDescription comparatorDescription ) throws NamingException
+    public void delete( Registries registries, ComparatorDescription comparatorDescription ) throws NamingException
     {
         String schemaName = getSchema( comparatorDescription );
         PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
         LdapDN dn = new LdapDN( "m-oid=" + comparatorDescription.getNumericOid() + ",ou=comparators,cn=" 
             + schemaName + ",ou=schema" );
-        proxy.delete( new DeleteOperationContext( dn, true ), BYPASS );
+        proxy.delete( new DeleteOperationContext( registries, dn, true ), BYPASS );
     }
 
 
-    public void add( ComparatorDescription comparatorDescription ) throws NamingException
+    public void add( Registries registries, ComparatorDescription comparatorDescription ) throws NamingException
     {
         String schemaName = getSchema( comparatorDescription );   
         PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
         LdapDN dn = new LdapDN( "m-oid=" + comparatorDescription.getNumericOid() + ",ou=comparators,cn=" 
             + schemaName + ",ou=schema" );
         Attributes attrs = getAttributes( comparatorDescription );
-        proxy.add( new AddOperationContext( dn, attrs, true ), BYPASS );
+        ServerEntry entry = ServerEntryUtils.toServerEntry( attrs, dn, registries );
+
+        proxy.add( new AddOperationContext( registries, dn, entry, true ), BYPASS );
     }
     
     
@@ -222,14 +229,16 @@
     }
 
 
-    public void add( NormalizerDescription normalizerDescription ) throws NamingException
+    public void add( Registries registries, NormalizerDescription normalizerDescription ) throws NamingException
     {
         String schemaName = getSchema( normalizerDescription );
         PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
         LdapDN dn = new LdapDN( "m-oid=" + normalizerDescription.getNumericOid() + ",ou=normalizers,cn=" 
             + schemaName + ",ou=schema" );
         Attributes attrs = getAttributes( normalizerDescription );
-        proxy.add( new AddOperationContext( dn, attrs, true ), BYPASS );
+        ServerEntry entry = ServerEntryUtils.toServerEntry( attrs, dn, registries );
+
+        proxy.add( new AddOperationContext( registries, dn, entry, true ), BYPASS );
     }
     
     
@@ -256,14 +265,15 @@
     }
 
 
-    public void add( SyntaxCheckerDescription syntaxCheckerDescription ) throws NamingException
+    public void add( Registries registries, SyntaxCheckerDescription syntaxCheckerDescription ) throws NamingException
     {
         String schemaName = getSchema( syntaxCheckerDescription );
         PartitionNexusProxy proxy = InvocationStack.getInstance().peek().getProxy();
         LdapDN dn = new LdapDN( "m-oid=" + syntaxCheckerDescription.getNumericOid() + ",ou=syntaxCheckers,cn=" 
             + schemaName + ",ou=schema" );
         Attributes attrs = getAttributes( syntaxCheckerDescription );
-        proxy.add( new AddOperationContext( dn, attrs, true ), BYPASS );
+        ServerEntry entry = ServerEntryUtils.toServerEntry( attrs, dn, registries );
+        proxy.add( new AddOperationContext( registries, dn, entry, true ), BYPASS );
     }
     
     

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/sp/LdapClassLoader.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/sp/LdapClassLoader.java?rev=613608&r1=613607&r2=613608&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/sp/LdapClassLoader.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/sp/LdapClassLoader.java Sun Jan 20 08:59:10 2008
@@ -85,6 +85,12 @@
             while( searchContexts.hasMore() )
             {
                 currentSearchContextName = ( String ) searchContexts.next();
+                
+                if ( currentSearchContextName == null )
+                {
+                    continue;
+                }
+                
                 currentSearchContext = ( ServerLdapContext ) RootDSE.lookup( currentSearchContextName );
                 
                 javaClassEntries = currentSearchContext.search( LdapDN.EMPTY_LDAPDN, filter, controls );

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/sp/StoredProcEngine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/sp/StoredProcEngine.java?rev=613608&r1=613607&r2=613608&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/sp/StoredProcEngine.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/sp/StoredProcEngine.java Sun Jan 20 08:59:10 2008
@@ -22,9 +22,10 @@
 package org.apache.directory.server.core.sp;
 
 import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
 import javax.naming.ldap.LdapContext;
 
+import org.apache.directory.server.core.entry.ServerEntry;
+
 
 /**
  * An abstraction over stored procedure execution depending on the type of the language supported.
@@ -48,7 +49,7 @@
      * <p>
      * This method should be called before an attempt to invoke a stored procedure via this Engine.
      */
-    public void setSPUnitEntry( final Attributes spUnit );
+    public void setSPUnitEntry( final ServerEntry spUnit );
     
     
     /**



Mime
View raw message