directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r638228 [13/20] - in /directory/sandbox/akarasulu/bigbang/apacheds: ./ apacheds-xbean-spring/src/site/ benchmarks/src/site/ bootstrap-extract/src/site/ bootstrap-partition/src/site/ bootstrap-plugin/src/main/java/org/apache/directory/server...
Date Tue, 18 Mar 2008 06:13:18 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=638228&r1=638227&r2=638228&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 Mon Mar 17 23:12:41 2008
@@ -22,9 +22,13 @@
 
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.DefaultServerAttribute;
+import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.entry.ServerBinaryValue;
 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.entry.ServerSearchResult;
+import org.apache.directory.server.core.entry.ServerStringValue;
 import org.apache.directory.server.core.enumeration.SearchResultFilter;
 import org.apache.directory.server.core.enumeration.SearchResultFilteringEnumeration;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
@@ -46,6 +50,9 @@
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapAttributeInUseException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeIdentifierException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
@@ -64,11 +71,8 @@
 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;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.message.ServerSearchResult;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -77,7 +81,6 @@
 import org.apache.directory.shared.ldap.schema.UsageEnum;
 import org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
-import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.EmptyEnumeration;
 import org.apache.directory.shared.ldap.util.SingletonEnumeration;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -87,17 +90,11 @@
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.NoPermissionException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
 import javax.naming.directory.InvalidAttributeValueException;
-import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
 
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -122,10 +119,9 @@
     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 };
-
-
-
+            new String[] { 
+                SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, 
+                SchemaConstants.ALL_USER_ATTRIBUTES };
 
     /** Speedup for logs */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
@@ -149,10 +145,12 @@
      */
     private Registries registries;
 
+    /** A global reference to the ObjectClass attributeType */
+    private AttributeType OBJECT_CLASS;
     /**
      * the global attributeType registry
      */
-    private AttributeTypeRegistry attributeTypeRegistry;
+    private AttributeTypeRegistry atRegistry;
 
     /** A normalized form for the SubschemaSubentry DN */
     private String subschemaSubentryDnNorm;
@@ -197,25 +195,26 @@
 
         nexus = directoryService.getPartitionNexus();
         registries = directoryService.getRegistries();
-        attributeTypeRegistry = registries.getAttributeTypeRegistry();
+        atRegistry = registries.getAttributeTypeRegistry();
+        OBJECT_CLASS = atRegistry.lookup( SchemaConstants.OBJECT_CLASS_AT );
         binaryAttributeFilter = new BinaryAttributeFilter();
         topFilter = new TopFilter();
         filters.add( binaryAttributeFilter );
         filters.add( topFilter );
 
         schemaBaseDN = new LdapDN( ServerDNConstants.OU_SCHEMA_DN );
-        schemaBaseDN.normalize( attributeTypeRegistry.getNormalizerMapping() );
+        schemaBaseDN.normalize( atRegistry.getNormalizerMapping() );
         schemaService = directoryService.getSchemaService();
         schemaManager = directoryService.getSchemaService().getSchemaControl();
 
         // stuff for dealing with subentries (garbage for now)
-        ServerValue<?> subschemaSubentry = nexus.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
+        Value<?> subschemaSubentry = nexus.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
         LdapDN subschemaSubentryDn = new LdapDN( (String)(subschemaSubentry.get()) );
-        subschemaSubentryDn.normalize( attributeTypeRegistry.getNormalizerMapping() );
+        subschemaSubentryDn.normalize( atRegistry.getNormalizerMapping() );
         subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();
 
         schemaModificationAttributesDN = new LdapDN( "cn=schemaModifications,ou=schema" );
-        schemaModificationAttributesDN.normalize( attributeTypeRegistry.getNormalizerMapping() );
+        schemaModificationAttributesDN.normalize( atRegistry.getNormalizerMapping() );
 
         computeSuperiors();
 
@@ -383,9 +382,9 @@
     /**
      *
      */
-    public NamingEnumeration<SearchResult> list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws NamingException
+    public NamingEnumeration<ServerSearchResult> list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws NamingException
     {
-        NamingEnumeration<SearchResult> result = nextInterceptor.list( opContext );
+        NamingEnumeration<ServerSearchResult> result = nextInterceptor.list( opContext );
         Invocation invocation = InvocationStack.getInstance().peek();
         return new SearchResultFilteringEnumeration( result, new SearchControls(), invocation, binaryAttributeFilter, "List Schema Filter" );
     }
@@ -448,7 +447,7 @@
 	                String oid = registries.getOidRegistry().getOid( attribute );
 
             		// The attribute must be an AttributeType
-	                if ( attributeTypeRegistry.hasAttributeType( oid ) )
+	                if ( atRegistry.hasAttributeType( oid ) )
 	                {
 		                if ( !filteredAttrs.containsKey( oid ) )
 		                {
@@ -503,7 +502,7 @@
     
     private Object convert( String id, Object value ) throws NamingException
     {
-        AttributeType at = attributeTypeRegistry.lookup( id );
+        AttributeType at = atRegistry.lookup( id );
 
         if ( at.getSyntax().isHumanReadable() )
         {
@@ -575,7 +574,7 @@
             {
                 SubstringNode node = ((SubstringNode)filter);
 
-                if ( ! attributeTypeRegistry.lookup( node.getAttribute() ).getSyntax().isHumanReadable() )
+                if ( ! atRegistry.lookup( node.getAttribute() ).getSyntax().isHumanReadable() )
                 {
                     String message = "A Substring filter should be used only on Human Readable attributes";
                     LOG.error(  message  );
@@ -615,7 +614,7 @@
             {
                 ExtensibleNode node = ((ExtensibleNode)filter);
                 
-                if ( ! attributeTypeRegistry.lookup( node.getAttribute() ).getSyntax().isHumanReadable() )
+                if ( ! atRegistry.lookup( node.getAttribute() ).getSyntax().isHumanReadable() )
                 {
                     String message = "A Extensible filter should be used only on Human Readable attributes";
                     LOG.error(  message  );
@@ -659,7 +658,7 @@
     /**
      *
      */
-    public NamingEnumeration<SearchResult> search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws NamingException
+    public NamingEnumeration<ServerSearchResult> search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws NamingException
     {
         LdapDN base = opContext.getDn();
         SearchControls searchCtls = opContext.getSearchControls();
@@ -675,10 +674,10 @@
 
         String baseNormForm = ( base.isNormalized() ? base.getNormName() : base.toNormName() );
 
-        // Deal with the normal case : searching for a normal value (not subSchemaSubEntry
+        // Deal with the normal case : searching for a normal value (not subSchemaSubEntry)
         if ( !subschemaSubentryDnNorm.equals( baseNormForm ) )
         {
-            NamingEnumeration<SearchResult> result = nextInterceptor.search( opContext );
+            NamingEnumeration<ServerSearchResult> result = nextInterceptor.search( opContext );
 
             Invocation invocation = InvocationStack.getInstance().peek();
 
@@ -720,7 +719,7 @@
                 }
                 else
                 {
-                    return new EmptyEnumeration<SearchResult>();
+                    return new EmptyEnumeration<ServerSearchResult>();
                 }
 
                 String nodeOid = registries.getOidRegistry().getOid( node.getAttribute() );
@@ -732,13 +731,13 @@
                     && ( node instanceof EqualityNode ) )
                 {
                     // call.setBypass( true );
-                    Attributes attrs = schemaService.getSubschemaEntry( searchCtls.getReturningAttributes() );
-                    SearchResult result = new ServerSearchResult( base.toString(), null, attrs );
-                    return new SingletonEnumeration<SearchResult>( result );
+                    ServerEntry serverEntry = schemaService.getSubschemaEntry( searchCtls.getReturningAttributes() );
+                    ServerSearchResult result = new ServerSearchResult( base, null, serverEntry );
+                    return new SingletonEnumeration<ServerSearchResult>( result );
                 }
                 else
                 {
-                    return new EmptyEnumeration<SearchResult>();
+                    return new EmptyEnumeration<ServerSearchResult>();
                 }
             }
             else if ( filter instanceof PresenceNode )
@@ -749,24 +748,24 @@
                 if ( node.getAttribute().equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
                 {
                     // call.setBypass( true );
-                    Attributes attrs = schemaService.getSubschemaEntry( searchCtls.getReturningAttributes() );
-                    SearchResult result = new ServerSearchResult( base.toString(), null, attrs, false );
-                    return new SingletonEnumeration<SearchResult>( result );
+                    ServerEntry serverEntry = schemaService.getSubschemaEntry( searchCtls.getReturningAttributes() );
+                    ServerSearchResult result = new ServerSearchResult( base, null, serverEntry, false );
+                    return new SingletonEnumeration<ServerSearchResult>( result );
                 }
             }
         }
 
         // In any case not handled previously, just return an empty result
-        return new EmptyEnumeration<SearchResult>();
+        return new EmptyEnumeration<ServerSearchResult>();
     }
 
 
     /**
      * Search for an entry, using its DN. Binary attributes and ObjectClass attribute are removed.
      */
-    public Attributes lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) throws NamingException
+    public ServerEntry lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) throws NamingException
     {
-        Attributes result = nextInterceptor.lookup( opContext );
+        ServerEntry result = nextInterceptor.lookup( opContext );
         
         if ( result == null )
         {
@@ -810,7 +809,7 @@
      * @return true if the objectClass values require the attribute, false otherwise
      * @throws NamingException if the attribute is not recognized
      */
-    private boolean isRequired( String attrId, Attribute objectClass ) throws NamingException
+    private boolean isRequired( String attrId, ServerAttribute objectClasses ) throws NamingException
     {
         OidRegistry oidRegistry = registries.getOidRegistry();
         ObjectClassRegistry registry = registries.getObjectClassRegistry();
@@ -822,9 +821,9 @@
 
         String attrOid = oidRegistry.getOid( attrId );
         
-        for ( int ii = 0; ii < objectClass.size(); ii++ )
+        for ( Value<?> objectClass:objectClasses )
         {
-            ObjectClass ocSpec = registry.lookup( ( String ) objectClass.get( ii ) );
+            ObjectClass ocSpec = registry.lookup( ( String ) objectClass.get() );
             
             for ( AttributeType must:ocSpec.getMustList() )
             {
@@ -848,7 +847,7 @@
      * @return
      * @throws NamingException
      */
-    private boolean isCompleteRemoval( Attribute change, Attributes entry ) throws NamingException
+    private boolean isCompleteRemoval( ServerAttribute change, ServerEntry entry ) throws NamingException
     {
         // if change size is 0 then all values are deleted then we're in trouble
         if ( change.size() == 0 )
@@ -860,11 +859,11 @@
         // values in the modify request may not be in the entry.  we need to
         // remove the values from a cloned version of the attribute and see
         // if nothing is left.
-        Attribute changedEntryAttr = ( Attribute ) entry.get( change.getID() ).clone();
+        ServerAttribute changedEntryAttr = ( ServerAttribute ) entry.get( change.getUpId() ).clone();
         
-        for ( int jj = 0; jj < change.size(); jj++ )
+        for ( Value<?> value:change )
         {
-            changedEntryAttr.remove( change.get( jj ) );
+            changedEntryAttr.remove( value );
         }
 
         return changedEntryAttr.size() == 0;
@@ -879,11 +878,12 @@
      * @return
      * @throws NamingException
      */
-    private Attribute getResultantObjectClasses( int modOp, Attribute changes, Attribute existing ) throws NamingException
+    private ServerAttribute getResultantObjectClasses( ModificationOperation modOp, ServerAttribute changes, ServerAttribute existing ) throws NamingException
     {
         if ( ( changes == null ) && ( existing == null ) )
         {
-            return new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+            return new DefaultServerAttribute( SchemaConstants.OBJECT_CLASS_AT,
+                OBJECT_CLASS );
         }
 
         if ( changes == null )
@@ -891,25 +891,35 @@
             return existing;
         }
 
-        if ( (existing == null ) && ( modOp == DirContext.ADD_ATTRIBUTE ) )
+        if ( ( existing == null ) && ( modOp == ModificationOperation.ADD_ATTRIBUTE ) )
         {
             return changes;
         }
         else if ( existing == null )
         {
-            return new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+            return new DefaultServerAttribute( SchemaConstants.OBJECT_CLASS_AT, OBJECT_CLASS );
         }
 
         switch ( modOp )
         {
-            case ( DirContext.ADD_ATTRIBUTE  ):
-                return AttributeUtils.getUnion( existing, changes );
+            case ADD_ATTRIBUTE :
+                for ( Value<?> value:changes )
+                {
+                    existing.add( value );
+                }
             
-            case ( DirContext.REPLACE_ATTRIBUTE  ):
-                return ( Attribute ) changes.clone();
+                return existing;
+            
+            case REPLACE_ATTRIBUTE :
+                return ( ServerAttribute ) changes.clone();
+            
+            case REMOVE_ATTRIBUTE :
+                for ( Value<?> value:changes )
+                {
+                    existing.remove( value );
+                }
             
-            case ( DirContext.REMOVE_ATTRIBUTE  ):
-                return AttributeUtils.getDifference( existing, changes );
+                return existing;
             
             default:
                 throw new InternalError( "" );
@@ -917,20 +927,18 @@
     }
 
 
-    private boolean getObjectClasses( Attribute objectClasses, List<ObjectClass> result ) throws NamingException
+    private boolean getObjectClasses( ServerAttribute objectClasses, List<ObjectClass> result ) throws NamingException
     {
         Set<String> ocSeen = new HashSet<String>();
         ObjectClassRegistry registry = registries.getObjectClassRegistry();
 
         // We must select all the ObjectClasses, except 'top',
         // but including all the inherited ObjectClasses
-        NamingEnumeration<?> ocs = objectClasses.getAll();
         boolean hasExtensibleObject = false;
 
-
-        while ( ocs.hasMoreElements() )
+        for ( Value<?> objectClass:objectClasses )
         {
-            String objectClassName = (String)ocs.nextElement();
+            String objectClassName = (String)objectClass.get();
 
             if ( SchemaConstants.TOP_OC.equals( objectClassName ) )
             {
@@ -944,7 +952,7 @@
 
             ObjectClass oc = registry.lookup( objectClassName );
 
-            // Add all unseen objectclasses to the list, except 'top'
+            // Add all unseen objectClasses to the list, except 'top'
             if ( !ocSeen.contains( oc.getOid() ) )
             {
                 ocSeen.add( oc.getOid() );
@@ -958,14 +966,15 @@
         return hasExtensibleObject;
     }
 
-    private Set<String> getAllMust( NamingEnumeration<String> objectClasses ) throws NamingException
+    
+    private Set<String> getAllMust( ServerAttribute objectClasses ) throws NamingException
     {
         Set<String> must = new HashSet<String>();
 
         // Loop on all objectclasses
-        while ( objectClasses.hasMoreElements() )
+        for ( Value<?> value:objectClasses )
         {
-            String ocName = objectClasses.nextElement();
+            String ocName = (String)value.get();
             ObjectClass oc = registries.getObjectClassRegistry().lookup( ocName );
 
             AttributeType[] types = oc.getMustList();
@@ -983,7 +992,7 @@
         return must;
     }
 
-    private Set<String> getAllAllowed( NamingEnumeration<String> objectClasses, Set<String> must ) throws NamingException
+    private Set<String> getAllAllowed( ServerAttribute objectClasses, Set<String> must ) throws NamingException
     {
         Set<String> allowed = new HashSet<String>( must );
 
@@ -991,9 +1000,9 @@
         allowed.add( registries.getOidRegistry().getOid( SchemaConstants.OBJECT_CLASS_AT ) );
 
         // Loop on all objectclasses
-        while ( objectClasses.hasMoreElements() )
+        for ( Value<?> objectClass:objectClasses )
         {
-            String ocName = objectClasses.nextElement();
+            String ocName = (String)objectClass.get();
             ObjectClass oc = registries.getObjectClassRegistry().lookup( ocName );
 
             AttributeType[] types = oc.getMayList();
@@ -1022,7 +1031,7 @@
      * @param objectClassAttr the objectClass attribute to modify
      * @throws NamingException if there are problems 
      */
-    private void alterObjectClasses( Attribute objectClassAttr ) throws NamingException
+    private void alterObjectClasses( ServerAttribute objectClassAttr ) throws NamingException
     {
         Set<String> objectClasses = new HashSet<String>();
         Set<String> objectClassesUP = new HashSet<String>();
@@ -1032,11 +1041,9 @@
         objectClassesUP.add( SchemaConstants.TOP_OC );
         
         // Construct the new list of ObjectClasses
-        NamingEnumeration<?> ocList = objectClassAttr.getAll();
-
-        while ( ocList.hasMoreElements() )
+        for ( Value<?> ocValue:objectClassAttr )
         {
-            String ocName = (String)ocList.nextElement();
+            String ocName = (String)ocValue.get();
 
             if ( !ocName.equalsIgnoreCase( SchemaConstants.TOP_OC ) )
             {
@@ -1080,10 +1087,7 @@
     {
         LdapDN oriChildName = opContext.getDn();
 
-        ServerEntry entry = ServerEntryUtils.toServerEntry( 
-            nexus.lookup( new LookupOperationContext( registries, oriChildName ) ),
-            oriChildName,
-            registries );
+        ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, oriChildName ) );
 
         if ( oriChildName.startsWith( schemaBaseDN ) )
         {
@@ -1102,10 +1106,7 @@
     {
         LdapDN oriChildName = opContext.getDn();
         
-        ServerEntry entry = ServerEntryUtils.toServerEntry(
-            nexus.lookup( new LookupOperationContext( registries, oriChildName ) ),
-            oriChildName,
-            registries );
+        ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, oriChildName ) );
 
         if ( oriChildName.startsWith( schemaBaseDN ) )
         {
@@ -1123,10 +1124,7 @@
         Rdn newRdn = opContext.getNewRdn();
         boolean deleteOldRn = opContext.getDelOldDn();
         
-        ServerEntry entry = ServerEntryUtils.toServerEntry(
-            nexus.lookup( new LookupOperationContext( registries, name ) ),
-            name,
-            registries );
+        ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, name ) );
 
         if ( name.startsWith( schemaBaseDN ) )
         {
@@ -1140,9 +1138,9 @@
 
     public void modify( NextInterceptor next, ModifyOperationContext opContext ) throws NamingException
     {
-        Attributes entry;
+        ServerEntry entry;
         LdapDN name = opContext.getDn();
-        List<ModificationItemImpl> mods = opContext.getModItems();
+        List<Modification> mods = opContext.getModItems();
 
         // handle operations against the schema subentry in the schema service
         // and never try to look it up in the nexus below
@@ -1156,7 +1154,12 @@
         }
         
         // First, we get the entry from the backend. If it does not exist, then we throw an exception
-        Attributes targetEntry = SchemaUtils.getTargetEntry( mods, entry );
+        ServerEntry targetEntry = ServerEntryUtils.toServerEntry( 
+            SchemaUtils.getTargetEntry( 
+                ServerEntryUtils.toModificationItemImpl( mods ), 
+                ServerEntryUtils.toAttributesImpl( entry ) ),
+            name,
+            registries );
 
         if ( entry == null )
         {
@@ -1166,19 +1169,19 @@
         
         // We will use this temporary entry to check that the modifications
         // can be applied as atomic operations
-        Attributes tmpEntry = ( Attributes ) entry.clone();
+        ServerEntry tmpEntry = ( ServerEntry ) entry.clone();
         
         Set<String> modset = new HashSet<String>();
-        ModificationItem objectClassMod = null;
+        Modification objectClassMod = null;
         
         // Check that we don't have two times the same modification.
         // This is somehow useless, as modification operations are supposed to
         // be atomic, so we may have a sucession of Add, DEL, ADD operations
         // for the same attribute, and this will be legal.
         // @TODO : check if we can remove this test.
-        for ( ModificationItem mod:mods )
+        for ( Modification mod:mods )
         {
-            if ( mod.getAttribute().getID().equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) )
+            if ( mod.getAttribute().getId().equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) )
             {
                 objectClassMod = mod;
             }
@@ -1187,7 +1190,7 @@
             if ( mod.getAttribute().size() == 0 )
             {
                 // not ok for add but ok for replace and delete
-                if ( mod.getModificationOp() == DirContext.ADD_ATTRIBUTE )
+                if ( mod.getOperation() == ModificationOperation.ADD_ATTRIBUTE )
                 {
                     throw new LdapInvalidAttributeValueException( "No value is not a valid value for an attribute.", 
                         ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
@@ -1195,15 +1198,15 @@
             }
 
             StringBuffer keybuf = new StringBuffer();
-            keybuf.append( mod.getModificationOp() );
-            keybuf.append( mod.getAttribute().getID() );
+            keybuf.append( mod.getOperation() );
+            keybuf.append( mod.getAttribute().getId() );
 
-            for ( int jj = 0; jj < mod.getAttribute().size(); jj++ )
+            for ( Value<?> value:(ServerAttribute)mod.getAttribute() )
             {
-                keybuf.append( mod.getAttribute().get( jj ) );
+                keybuf.append( value.get() );
             }
             
-            if ( !modset.add( keybuf.toString() ) && ( mod.getModificationOp() == DirContext.ADD_ATTRIBUTE ) )
+            if ( !modset.add( keybuf.toString() ) && ( mod.getOperation() == ModificationOperation.ADD_ATTRIBUTE ) )
             {
                 throw new LdapAttributeInUseException( "found two copies of the following modification item: " +
                  mod );
@@ -1211,7 +1214,7 @@
         }
         
         // Get the objectClass attribute.
-        Attribute objectClass;
+        ServerAttribute objectClass;
 
         if ( objectClassMod == null )
         {
@@ -1219,12 +1222,15 @@
 
             if ( objectClass == null )
             {
-                objectClass = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+                objectClass = new DefaultServerAttribute( SchemaConstants.OBJECT_CLASS_AT,
+                    OBJECT_CLASS );
             }
         }
         else
         {
-            objectClass = getResultantObjectClasses( objectClassMod.getModificationOp(), objectClassMod.getAttribute(),
+            objectClass = getResultantObjectClasses( 
+                objectClassMod.getOperation(), 
+                (ServerAttribute)objectClassMod.getAttribute(),
                 entry.get( SchemaConstants.OBJECT_CLASS_AT ) );
         }
 
@@ -1237,20 +1243,20 @@
         
         if ( ( mods.size() == 1 ) && 
              ( mods.get( 0 ).getAttribute().size() == 0 ) && 
-             ( mods.get( 0 ).getModificationOp() == DirContext.REPLACE_ATTRIBUTE ) &&
-             ! attributeTypeRegistry.hasAttributeType( mods.get( 0 ).getAttribute().getID() ) )
+             ( mods.get( 0 ).getOperation() == ModificationOperation.REPLACE_ATTRIBUTE ) &&
+             ! atRegistry.hasAttributeType( mods.get( 0 ).getAttribute().getId() ) )
         {
             return;
         }
         
         // Now, apply the modifications on the cloned entry before applying it on the
         // real object.
-        for ( ModificationItem mod:mods )
+        for ( Modification mod:mods )
         {
-            int modOp = mod.getModificationOp();
-            Attribute change = mod.getAttribute();
+            ModificationOperation modOp = mod.getOperation();
+            ServerAttribute change = (ServerAttribute)mod.getAttribute();
 
-            if ( !attributeTypeRegistry.hasAttributeType( change.getID() ) && 
+            if ( !atRegistry.hasAttributeType( change.getUpId() ) && 
                 !objectClass.contains( SchemaConstants.EXTENSIBLE_OBJECT_OC ) )
             {
                 throw new LdapInvalidAttributeIdentifierException();
@@ -1258,35 +1264,32 @@
 
             // We will forbid modification of operational attributes which are not
             // user modifiable.
-            AttributeType attributeType = attributeTypeRegistry.lookup( change.getID() );
+            AttributeType attributeType = atRegistry.lookup( change.getUpId() );
             
             if ( !attributeType.isCanUserModify() )
             {
-                throw new NoPermissionException( "Cannot modify the attribute '" + change.getID() + "'" );
+                throw new NoPermissionException( "Cannot modify the attribute '" + change.getUpId() + "'" );
             }
             
             switch ( modOp )
             {
-                case DirContext.ADD_ATTRIBUTE :
-                    Attribute attr = tmpEntry.get( change.getID() );
+                case ADD_ATTRIBUTE :
+                    ServerAttribute attr = tmpEntry.get( change.getUpId() );
                     
                     if ( attr != null ) 
                     {
-                        NamingEnumeration<?> values = change.getAll();
-                        
-                        while ( values.hasMoreElements() )
+                        for ( Value<?> value:change )
                         {
-                            attr.add( values.nextElement() );
+                            attr.add( value );
                         }
                     }
                     else
                     {
-                        attr = new AttributeImpl( change.getID() );
-                        NamingEnumeration<?> values = change.getAll();
+                        attr = new DefaultServerAttribute( change.getUpId(), attributeType );
                         
-                        while ( values.hasMoreElements() )
+                        for ( Value<?> value:change )
                         {
-                            attr.add( values.nextElement() );
+                            attr.add( value );
                         }
                         
                         tmpEntry.put( attr );
@@ -1294,10 +1297,10 @@
                     
                     break;
 
-                case DirContext.REMOVE_ATTRIBUTE :
-                    if ( tmpEntry.get( change.getID() ) == null )
+                case REMOVE_ATTRIBUTE :
+                    if ( tmpEntry.get( change.getUpId() ) == null )
                     {
-                        LOG.error( "Trying to remove an non-existant attribute: " + change.getID() );
+                        LOG.error( "Trying to remove an non-existant attribute: " + change.getUpId() );
                         throw new LdapNoSuchAttributeException();
                     }
 
@@ -1306,9 +1309,9 @@
                     {
                         // No value : we have to remove the entire attribute
                         // Check that we aren't removing a MUST attribute
-                        if ( isRequired( change.getID(), objectClass ) )
+                        if ( isRequired( change.getUpId(), objectClass ) )
                         {
-                            LOG.error( "Trying to remove a required attribute: " + change.getID() );
+                            LOG.error( "Trying to remove a required attribute: " + change.getUpId() );
                             throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                         }
                     }
@@ -1316,28 +1319,26 @@
                     {
                         // for required attributes we need to check if all values are removed
                         // if so then we have a schema violation that must be thrown
-                        if ( isRequired( change.getID(), objectClass ) && isCompleteRemoval( change, entry ) )
+                        if ( isRequired( change.getUpId(), objectClass ) && isCompleteRemoval( change, entry ) )
                         {
-                            LOG.error( "Trying to remove a required attribute: " + change.getID() );
+                            LOG.error( "Trying to remove a required attribute: " + change.getUpId() );
                             throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                         }
 
                         // Now remove the attribute and all its values
-                        Attribute modified = tmpEntry.remove( change.getID() );
+                        ServerAttribute modified = tmpEntry.remove( change.getUpId() ).get(0);
                         
                         // And inject back the values except the ones to remove
-                        NamingEnumeration<?> values = change.getAll();
-                        
-                        while ( values.hasMoreElements() )
+                        for ( Value<?> value:change )
                         {
-                            modified.remove( values.next() );
+                            modified.remove( value );
                         }
                         
                         // ok, done. Last check : if the attribute does not content any more value;
                         // and if it's a MUST one, we should thow an exception
-                        if ( ( modified.size() == 0 ) && isRequired( change.getID(), objectClass ) )
+                        if ( ( modified.size() == 0 ) && isRequired( change.getUpId(), objectClass ) )
                         {
-                            LOG.error( "Trying to remove a required attribute: " + change.getID() );
+                            LOG.error( "Trying to remove a required attribute: " + change.getUpId() );
                             throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                         }
 
@@ -1354,27 +1355,25 @@
                         .preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, modOp, change, objectClass );
                     break;
                         
-                case DirContext.REPLACE_ATTRIBUTE :
+                case REPLACE_ATTRIBUTE :
                     SchemaChecker.preventRdnChangeOnModifyReplace( name, modOp, change, 
                         registries.getOidRegistry() );
                     SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, modOp, change );
                     
-                    attr = tmpEntry.get( change.getID() );
+                    attr = tmpEntry.get( change.getUpId() );
                     
                     if ( attr != null )
                     {
-                        tmpEntry.remove( change.getID() );
+                        tmpEntry.remove( change.getUpId() );
                     }
                     
-                    attr = new AttributeImpl( change.getID() );
-                    
-                    NamingEnumeration<?> values = change.getAll();
+                    attr = new DefaultServerAttribute( change.getUpId(), attributeType );
                     
-                    if ( values.hasMoreElements() ) 
+                    if ( change.size() != 0 ) 
                     {
-                        while ( values.hasMoreElements() )
+                        for ( Value<?> value:change )
                         {
-                            attr.add( values.nextElement() );
+                            attr.add( value );
                         }
 
                         tmpEntry.put( attr );
@@ -1390,48 +1389,48 @@
         // the objectClass attribute with it's hierarchy of ancestors 
         if ( objectClassMod != null )
         {
-            Attribute alteredObjectClass = ( Attribute ) objectClass.clone();
+            ServerAttribute alteredObjectClass = ( ServerAttribute ) objectClass.clone();
             alterObjectClasses( alteredObjectClass );
 
             if ( !alteredObjectClass.equals( objectClass ) )
             {
-                Attribute ocMods = objectClassMod.getAttribute();
+                ServerAttribute ocMods = (ServerAttribute)objectClassMod.getAttribute();
                 
-                switch ( objectClassMod.getModificationOp() )
+                switch ( objectClassMod.getOperation() )
                 {
-                    case ( DirContext.ADD_ATTRIBUTE  ):
+                    case ADD_ATTRIBUTE :
                         if ( ocMods.contains( SchemaConstants.TOP_OC ) )
                         {
                             ocMods.remove( SchemaConstants.TOP_OC );
                         }
                     
-                        for ( int ii = 0; ii < alteredObjectClass.size(); ii++ )
+                        for ( Value<?> value:alteredObjectClass ) 
                         {
-                            if ( !objectClass.contains( alteredObjectClass.get( ii ) ) )
+                            if ( !objectClass.contains( value ) )
                             {
-                                ocMods.add( alteredObjectClass.get( ii ) );
+                                ocMods.add( value );
                             }
                         }
                         
                         break;
                         
-                    case ( DirContext.REMOVE_ATTRIBUTE  ):
-                        for ( int ii = 0; ii < alteredObjectClass.size(); ii++ )
+                    case REMOVE_ATTRIBUTE :
+                        for ( Value<?> value:alteredObjectClass ) 
                         {
-                            if ( !objectClass.contains( alteredObjectClass.get( ii ) ) )
+                            if ( !objectClass.contains( value ) )
                             {
-                                ocMods.remove( alteredObjectClass.get( ii ) );
+                                ocMods.remove( value );
                             }
                         }
                     
                         break;
                         
-                    case ( DirContext.REPLACE_ATTRIBUTE  ):
-                        for ( int ii = 0; ii < alteredObjectClass.size(); ii++ )
+                    case REPLACE_ATTRIBUTE :
+                        for ( Value<?> value:alteredObjectClass ) 
                         {
-                            if ( !objectClass.contains( alteredObjectClass.get( ii ) ) )
+                            if ( !objectClass.contains( value ) )
                             {
-                                ocMods.add( alteredObjectClass.get( ii ) );
+                                ocMods.add( value );
                             }
                         }
                     
@@ -1449,8 +1448,8 @@
             schemaManager.modify( 
                 name, 
                 mods, 
-                ServerEntryUtils.toServerEntry( entry, name, registries ), 
-                ServerEntryUtils.toServerEntry( targetEntry, name, registries ),
+                entry,
+                targetEntry,
                 opContext.hasRequestControl( CascadeControl.CONTROL_OID ));
         }
         else if ( subschemaSubentryDnNorm.equals( name.getNormName() ) )
@@ -1460,8 +1459,8 @@
             schemaManager.modifySchemaSubentry( 
                 name, 
                 mods, 
-                ServerEntryUtils.toServerEntry( entry, name, registries ), 
-                ServerEntryUtils.toServerEntry( targetEntry, name, registries ),
+                entry,
+                targetEntry,
                 opContext.hasRequestControl( CascadeControl.CONTROL_OID ) );
             return;
         }
@@ -1470,10 +1469,10 @@
     }
 
 
-    private void filterObjectClass( Attributes entry ) throws NamingException
+    private void filterObjectClass( ServerEntry entry ) throws NamingException
     {
         List<ObjectClass> objectClasses = new ArrayList<ObjectClass>();
-        Attribute oc = entry.get( SchemaConstants.OBJECT_CLASS_AT );
+        ServerAttribute oc = entry.get( SchemaConstants.OBJECT_CLASS_AT );
         
         if ( oc != null )
         {
@@ -1481,18 +1480,11 @@
 
             entry.remove( SchemaConstants.OBJECT_CLASS_AT );
 
-            Attribute newOc = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+            ServerAttribute newOc = new DefaultServerAttribute( oc.getAttributeType() );
 
-            for ( Object currentOC:objectClasses )
+            for ( ObjectClass currentOC:objectClasses )
             {
-                if ( currentOC instanceof String )
-                {
-                    newOc.add( currentOC );
-                }
-                else
-                {
-                    newOc.add( ( (ObjectClass)currentOC ).getName() );
-                }
+                newOc.add( currentOC.getName() );
             }
 
             newOc.add( SchemaConstants.TOP_OC );
@@ -1501,49 +1493,36 @@
     }
 
 
-    private void filterBinaryAttributes( Attributes entry ) throws NamingException
+    private void filterBinaryAttributes( ServerEntry entry ) throws NamingException
     {
         /*
          * start converting values of attributes to byte[]s which are not
          * human readable and those that are in the binaries set
          */
-        NamingEnumeration<String> list = entry.getIDs();
-
-        while ( list.hasMore() )
+        for ( ServerAttribute attribute:entry )
         {
-            String id = list.next();
-            AttributeType type = null;
-
-            if ( attributeTypeRegistry.hasAttributeType( id ) )
-            {
-                type = attributeTypeRegistry.lookup( id );
-            }
-            else
-            {
-                continue;
-            }
-
-            if ( !type.getSyntax().isHumanReadable() )
+            if ( !attribute.getAttributeType().getSyntax().isHumanReadable() )
             {
-                Attribute attribute = entry.get( id );
-                Attribute binary = new AttributeImpl( id );
-
-                for ( int i = 0; i < attribute.size(); i++ )
+                List<Value<?>> binaries = new ArrayList<Value<?>>();
+                
+                for ( Value<?> value:attribute )
                 {
-                    Object value = attribute.get( i );
+                    Object attrValue = value.get();
                 
-                    if ( value instanceof String )
+                    if ( attrValue instanceof String )
                     {
-                        binary.add( i, StringTools.getBytesUtf8( ( String ) value ) );
+                        binaries.add( new ServerBinaryValue( attribute.getAttributeType(), 
+                            StringTools.getBytesUtf8( ( String ) attrValue ) ) );
                     }
                     else
                     {
-                        binary.add( i, value );
+                        binaries.add( new ServerBinaryValue( attribute.getAttributeType(),
+                            (byte[])attrValue ) );
                     }
                 }
-
-                entry.remove( id );
-                entry.put( binary );
+                
+                attribute.clear();
+                attribute.put( binaries );
             }
         }
     }
@@ -1559,23 +1538,25 @@
      */
     private class BinaryAttributeFilter implements SearchResultFilter
     {
-        public boolean accept( Invocation invocation, SearchResult result, SearchControls controls )
+        public boolean accept( Invocation invocation, ServerSearchResult result, SearchControls controls )
             throws NamingException
         {
-            filterBinaryAttributes( result.getAttributes() );
+            filterBinaryAttributes( result.getServerEntry() );
             return true;
         }
     }
 
+    
     /**
      * Filters objectClass attribute to inject top when not present.
      */
     private class TopFilter implements SearchResultFilter
     {
-        public boolean accept( Invocation invocation, SearchResult result, SearchControls controls )
+        public boolean accept( Invocation invocation, ServerSearchResult result, SearchControls controls )
             throws NamingException
         {
-            filterObjectClass( result.getAttributes() );
+            filterObjectClass( result.getServerEntry() );
+            
             return true;
         }
     }
@@ -1586,21 +1567,17 @@
      * 
      * We also check the syntaxes
      */
-    private void check( LdapDN dn, Attributes entry ) throws NamingException
+    private void check( LdapDN dn, ServerEntry entry ) throws NamingException
     {
-        NamingEnumeration<String> attrEnum = entry.getIDs();
-
         // ---------------------------------------------------------------
         // First, make sure all attributes are valid schema defined attributes
         // ---------------------------------------------------------------
 
-        while ( attrEnum.hasMoreElements() )
+        for ( AttributeType attributeType:entry.getAttributeTypes() )
         {
-            String name = attrEnum.nextElement();
-            
-            if ( !attributeTypeRegistry.hasAttributeType( name ) )
+            if ( !atRegistry.hasAttributeType( attributeType.getName() ) )
             {
-                throw new LdapInvalidAttributeIdentifierException( name + " not found in attribute registry!" );
+                throw new LdapInvalidAttributeIdentifierException( attributeType.getName() + " not found in attribute registry!" );
             }
         }
 
@@ -1611,14 +1588,14 @@
         // 3-1) Except if the extensibleObject ObjectClass is used
         // 3-2) or if the AttributeType is COLLECTIVE
         // 4) We also check that for H-R attributes, we have a valid String in the values
-        Attribute objectClassAttr = entry.get( SchemaConstants.OBJECT_CLASS_AT );
+        ServerAttribute objectClassAttr = entry.get( SchemaConstants.OBJECT_CLASS_AT );
         
         // Protect the server against a null objectClassAttr
         // It can be the case if the user forgot to add it to the entry ...
         // In this case, we create an new one, empty
         if ( objectClassAttr == null )
         {
-            objectClassAttr = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+            objectClassAttr = new DefaultServerAttribute( SchemaConstants.OBJECT_CLASS_AT, OBJECT_CLASS );
         }
         
         List<ObjectClass> ocs = new ArrayList<ObjectClass>();
@@ -1626,8 +1603,8 @@
         alterObjectClasses( objectClassAttr );
         
         // Now we can process the MUST and MAY attributes
-        Set<String> must = getAllMust( (NamingEnumeration<String>)objectClassAttr.getAll() );
-        Set<String> allowed = getAllAllowed( (NamingEnumeration<String>)objectClassAttr.getAll(), must );
+        Set<String> must = getAllMust( objectClassAttr );
+        Set<String> allowed = getAllAllowed( objectClassAttr, must );
 
         boolean hasExtensibleObject = getObjectClasses( objectClassAttr, ocs );
 
@@ -1656,13 +1633,13 @@
     public void add( NextInterceptor next, AddOperationContext addContext ) throws NamingException
     {
     	LdapDN name = addContext.getDn();
-        Attributes entry = ServerEntryUtils.toAttributesImpl( addContext.getEntry() );
+        ServerEntry entry = addContext.getEntry();
         
     	check( name, entry );
 
         if ( name.startsWith( schemaBaseDN ) )
         {
-            schemaManager.add( name, ServerEntryUtils.toServerEntry( entry, name, registries ) );
+            schemaManager.add( name, entry );
         }
 
         next.add( addContext );
@@ -1676,33 +1653,29 @@
      * @return true if the objectClass values require the attribute, false otherwise
      * @throws NamingException if the attribute is not recognized
      */
-    private void assertAllAttributesAllowed( LdapDN dn, Attributes attributes, Set<String> allowed ) throws NamingException
+    private void assertAllAttributesAllowed( LdapDN dn, ServerEntry entry, Set<String> allowed ) throws NamingException
     {
         // Never check the attributes if the extensibleObject objectClass is
         // declared for this entry
-        Attribute objectClass = attributes.get( SchemaConstants.OBJECT_CLASS_AT );
+        ServerAttribute objectClass = entry.get( SchemaConstants.OBJECT_CLASS_AT );
 
-        if ( AttributeUtils.containsValueCaseIgnore( objectClass, SchemaConstants.EXTENSIBLE_OBJECT_OC ) )
+        if ( objectClass.contains( SchemaConstants.EXTENSIBLE_OBJECT_OC ) )
         {
             return;
         }
 
-        NamingEnumeration<? extends Attribute> attrs = attributes.getAll();
-
-        while ( attrs.hasMoreElements() )
+        for ( ServerAttribute attribute:entry )
         {
-            Attribute attribute = attrs.nextElement();
-            String attrId = attribute.getID();
-            String attrOid = registries.getOidRegistry().getOid( attrId );
+            String attrOid = attribute.getAttributeType().getOid();
 
-            AttributeType attributeType = attributeTypeRegistry.lookup( attrOid );
+            AttributeType attributeType = attribute.getAttributeType();
 
             if ( !attributeType.isCollective() && ( attributeType.getUsage() == UsageEnum.USER_APPLICATIONS ) )
             {
                 if ( !allowed.contains( attrOid ) )
                 {
                     throw new LdapSchemaViolationException( "Attribute " +
-                        attribute.getID() + " not declared in objectClasses of entry " + dn.getUpName(),
+                        attribute.getUpId() + " not declared in objectClasses of entry " + dn.getUpName(),
                         ResultCodeEnum.OBJECT_CLASS_VIOLATION );
                 }
             }
@@ -1713,13 +1686,10 @@
     public void delete( NextInterceptor next, DeleteOperationContext opContext ) throws NamingException
     {
     	LdapDN name = opContext.getDn();
-        ServerEntry entry = ServerEntryUtils.toServerEntry( 
-            nexus.lookup( new LookupOperationContext( registries, name ) ),
-            name, 
-            registries );
         
         if ( name.startsWith( schemaBaseDN ) )
         {
+            ServerEntry entry = nexus.lookup( new LookupOperationContext( registries, name ) );
             schemaManager.delete( name, entry, opContext.hasRequestControl( CascadeControl.CONTROL_OID ) );
         }
         
@@ -1730,13 +1700,10 @@
     /**
      * Checks to see number of values of an attribute conforms to the schema
      */
-    private void assertNumberOfAttributeValuesValid( Attributes attributes ) throws InvalidAttributeValueException, NamingException
+    private void assertNumberOfAttributeValuesValid( ServerEntry entry ) throws InvalidAttributeValueException, NamingException
     {
-        NamingEnumeration<? extends Attribute> list = attributes.getAll();
-        
-        while ( list.hasMore() )
+        for ( ServerAttribute attribute:entry )
         {
-            Attribute attribute = list.next();
             assertNumberOfAttributeValuesValid( attribute );
         }
     }
@@ -1744,30 +1711,24 @@
     /**
      * Checks to see numbers of values of attributes conforms to the schema
      */
-    private void assertNumberOfAttributeValuesValid( Attribute attribute ) throws InvalidAttributeValueException, NamingException
+    private void assertNumberOfAttributeValuesValid( ServerAttribute attribute ) throws InvalidAttributeValueException, NamingException
     {
-        if ( attribute.size() > 1 && attributeTypeRegistry.lookup( attribute.getID() ).isSingleValue() )
+        if ( attribute.size() > 1 && attribute.getAttributeType().isSingleValue() )
         {                
             throw new LdapInvalidAttributeValueException( "More than one value has been provided " +
-                "for the single-valued attribute: " + attribute.getID(), ResultCodeEnum.CONSTRAINT_VIOLATION );
+                "for the single-valued attribute: " + attribute.getUpId(), ResultCodeEnum.CONSTRAINT_VIOLATION );
         }
     }
 
     /**
      * Checks to see the presence of all required attributes within an entry.
      */
-    private void assertRequiredAttributesPresent( LdapDN dn, Attributes entry, Set<String> must )
+    private void assertRequiredAttributesPresent( LdapDN dn, ServerEntry entry, Set<String> must )
         throws NamingException
     {
-        NamingEnumeration<? extends Attribute> attributes = entry.getAll();
-
-        while ( attributes.hasMoreElements() && ( must.size() > 0 ) )
+        for ( ServerAttribute attribute:entry )
         {
-            Attribute attribute = attributes.nextElement();
-            
-            String oid = registries.getOidRegistry().getOid( attribute.getID() );
-
-            must.remove( oid );
+            must.remove( attribute.getAttributeType().getOid() );
         }
 
         if ( must.size() != 0 )
@@ -1854,71 +1815,64 @@
     /**
      * Check the entry attributes syntax, using the syntaxCheckers
      */
-    private void assertSyntaxes( Attributes entry ) throws NamingException
+    private void assertSyntaxes( ServerEntry entry ) throws NamingException
     {
-        NamingEnumeration<? extends Attribute> attributes = entry.getAll();
-
         // First, loop on all attributes
-        while ( attributes.hasMoreElements() )
+        for ( ServerAttribute attribute:entry )
         {
-            Attribute attribute = attributes.nextElement();
-
-            AttributeType attributeType = attributeTypeRegistry.lookup( attribute.getID() );
-            SyntaxChecker syntaxChecker =  registries.getSyntaxCheckerRegistry().lookup( attributeType.getSyntax().getOid() );
+            AttributeType attributeType = attribute.getAttributeType();
+            SyntaxChecker syntaxChecker =  attributeType.getSyntax().getSyntaxChecker();
             
             if ( syntaxChecker instanceof AcceptAllSyntaxChecker )
             {
                 // This is a speedup : no need to check the syntax of any value
-                // if all the sytanxes are accepted...
+                // if all the syntaxes are accepted...
                 continue;
             }
             
-            NamingEnumeration<?> values = attribute.getAll();
-
             // Then loop on all values
-            while ( values.hasMoreElements() )
+            for ( Value<?> value:attribute )
             {
-                Object value = values.nextElement();
-                
                 try
                 {
-                    syntaxChecker.assertSyntax( value );
+                    syntaxChecker.assertSyntax( value.get() );
                 }
                 catch ( NamingException ne )
                 {
                     String message = "Attribute value '" + 
-                        (value instanceof String ? value : StringTools.dumpBytes( (byte[])value ) ) + 
-                        "' for attribute '" + attribute.getID() + "' is syntactically incorrect";
+                        (value instanceof ServerStringValue ? value.get() : StringTools.dumpBytes( (byte[])value.get() ) ) + 
+                        "' for attribute '" + attribute.getUpId() + "' is syntactically incorrect";
                     LOG.info( message );
                     
                     throw new LdapInvalidAttributeValueException( message, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
-
                 }
             }
         }
     }
     
-    private boolean checkHumanReadable( Attribute attribute ) throws NamingException
+    /**
+     * Check a String attribute to see if there is some byte[] value in it.
+     * 
+     * If this is the case, try to change it to a String value.
+     */
+    private boolean checkHumanReadable( ServerAttribute attribute ) throws NamingException
     {
-        Enumeration<?> values = attribute.getAll();
         boolean isModified = false;
 
         // Loop on each values
-        while ( values.hasMoreElements() )
+        for ( Value<?> value:attribute )
         {
-            Object value = values.nextElement();
-
-            if ( value instanceof String )
+            if ( value instanceof ServerStringValue )
             {
                 continue;
             }
-            else if ( value instanceof byte[] )
+            else if ( value instanceof ServerBinaryValue )
             {
                 // 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" );
+                    String valStr = new String( (byte[])value.get(), "UTF-8" );
                     attribute.remove( value );
                     attribute.add( valStr );
                     isModified = true;
@@ -1937,27 +1891,29 @@
         return isModified;
     }
     
-    private boolean checkNotHumanReadable( Attribute attribute ) throws NamingException
+    /**
+     * Check a binary attribute to see if there is some String value in it.
+     * 
+     * If this is the case, try to change it to a binary value.
+     */
+    private boolean checkNotHumanReadable( ServerAttribute attribute ) throws NamingException
     {
-        Enumeration<?> values = attribute.getAll();
         boolean isModified = false;
 
         // Loop on each values
-        while ( values.hasMoreElements() )
+        for ( Value<?> value:attribute )
         {
-            Object value = values.nextElement();
-
-            if ( value instanceof byte[] )
+            if ( value instanceof ServerBinaryValue )
             {
                 continue;
             }
-            else if ( value instanceof String )
+            else if ( value instanceof ServerStringValue )
             {
                 // We have a String value. It should be a byte[]
                 // Let's transform it
                 try
                 {
-                    byte[] valBytes = ( (String)value ).getBytes( "UTF-8" );
+                    byte[] valBytes = ( (String)value.get() ).getBytes( "UTF-8" );
                     
                     attribute.remove( value );
                     attribute.add( valBytes );
@@ -1972,12 +1928,12 @@
             }
             else
             {
-                String message ="The value is not valid. It should be a String or a byte[]"; 
+                String message = "The value is not valid. It should be a String or a byte[]"; 
                 LOG.error( message );
                 throw new NamingException( message );
             }
         }
-        
+
         return isModified;
     }
     
@@ -1987,19 +1943,16 @@
      * 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
+    private void assertHumanReadable( ServerEntry entry ) throws NamingException
     {
-        NamingEnumeration<? extends Attribute> attributes = entry.getAll();
         boolean isModified = false;
         
-        Attributes clonedEntry = null;
+        ServerEntry clonedEntry = null;
 
-        // First, loop on all attributes
-        while ( attributes.hasMoreElements() )
+        // Loops on all attributes
+        for ( ServerAttribute attribute:entry )
         {
-            Attribute attribute = attributes.nextElement();
-
-            AttributeType attributeType = attributeTypeRegistry.lookup( attribute.getID() );
+            AttributeType attributeType = attribute.getAttributeType();
 
             // If the attributeType is H-R, check all of its values
             if ( attributeType.getSyntax().isHumanReadable() )
@@ -2017,7 +1970,7 @@
             {
                 if ( clonedEntry == null )
                 {
-                    clonedEntry = (Attributes)entry.clone();
+                    clonedEntry = (ServerEntry)entry.clone();
                 }
                 
                 // Switch the attributes

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=638228&r1=638227&r2=638228&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 Mon Mar 17 23:12:41 2008
@@ -34,10 +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.DefaultServerAttribute;
 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.entry.ServerModification;
 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;
@@ -51,11 +51,12 @@
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
@@ -78,7 +79,6 @@
 
 import javax.naming.NamingException;
 import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
 
 
 /**
@@ -290,7 +290,7 @@
     {
         ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( ServerValue<?> value:oc )
+        for ( Value<?> value:oc )
         {
 
             String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
@@ -339,7 +339,7 @@
     {
         ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( ServerValue<?> value:oc )
+        for ( Value<?> value:oc )
         {
             String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
             
@@ -383,12 +383,12 @@
     }
     
 
-    public void modify( LdapDN name, int modOp, ServerEntry mods, ServerEntry entry, 
+    public void modify( LdapDN name, ModificationOperation modOp, ServerEntry mods, ServerEntry entry, 
         ServerEntry targetEntry, boolean cascade ) throws NamingException
     {
         ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( ServerValue<?> value:oc )
+        for ( Value<?> value:oc )
         {
             String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
             
@@ -412,12 +412,12 @@
     }
 
 
-    public void modify( LdapDN name, List<ModificationItemImpl> mods, ServerEntry entry, ServerEntry targetEntry,
+    public void modify( LdapDN name, List<Modification> mods, ServerEntry entry, ServerEntry targetEntry,
         boolean doCascadeModify ) throws NamingException
     {
         ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( ServerValue<?> value:oc )
+        for ( Value<?> value:oc )
         {
             String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
             
@@ -448,7 +448,7 @@
     {
         ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( ServerValue<?> value:oc )
+        for ( Value<?> value:oc )
         {
             String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
             
@@ -477,7 +477,7 @@
     {
         ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( ServerValue<?> value:oc )
+        for ( Value<?> value:oc )
         {
             String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
             
@@ -506,7 +506,7 @@
     {
         ServerAttribute oc = entry.get( objectClassAT );
         
-        for ( ServerValue<?> value:oc )
+        for ( Value<?> value:oc )
         {
             String oid = registries.getOidRegistry().getOid( ( String ) value.get() );
             
@@ -543,31 +543,27 @@
      * to effect all dependents on the changed entity
      * @throws NamingException if the operation fails
      */
-    public void modifySchemaSubentry( LdapDN name, List<ModificationItemImpl> mods, ServerEntry subentry, 
+    public void modifySchemaSubentry( LdapDN name, List<Modification> mods, ServerEntry subentry, 
         ServerEntry targetSubentry, boolean doCascadeModify ) throws NamingException 
     {
-        for ( ModificationItem mod : mods )
+        for ( Modification mod : mods )
         {
-            String opAttrOid = registries.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 );
+            ServerAttribute serverAttribute = (ServerAttribute)mod.getAttribute();
 
-            switch ( mod.getModificationOp() )
+            switch ( mod.getOperation() )
             {
-                case( DirContext.ADD_ATTRIBUTE ):
+                case ADD_ATTRIBUTE :
 
                     modifyAddOperation( opAttrOid, serverAttribute, doCascadeModify );
                     break;
                     
-                case( DirContext.REMOVE_ATTRIBUTE ):
+                case REMOVE_ATTRIBUTE :
                     modifyRemoveOperation( opAttrOid, serverAttribute, doCascadeModify );
                     break; 
                     
-                case( DirContext.REPLACE_ATTRIBUTE ):
+                case REPLACE_ATTRIBUTE :
                     throw new LdapOperationNotSupportedException( 
                         "Modify REPLACE operations on schema subentries are not allowed: " +
                         "it's just silly to destroy and recreate so many \nschema entities " +
@@ -576,7 +572,7 @@
                         ResultCodeEnum.UNWILLING_TO_PERFORM );
                 
                 default:
-                    throw new IllegalStateException( "Undefined modify operation: " + mod.getModificationOp() );
+                    throw new IllegalStateException( "Undefined modify operation: " + mod.getOperation() );
             }
         }
         
@@ -942,13 +938,19 @@
         String modifiersName = ctx.getPrincipal().getJndiName().getNormName();
         String modifyTimestamp = DateUtils.getGeneralizedTime();
         
-        List<ModificationItemImpl> mods = new ArrayList<ModificationItemImpl>( 2 );
-        
-        mods.add( new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, 
-            new AttributeImpl( ApacheSchemaConstants.SCHEMA_MODIFY_TIMESTAMP_AT, modifyTimestamp ) ) );
+        List<Modification> mods = new ArrayList<Modification>( 2 );
         
-        mods.add( new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE,
-            new AttributeImpl( ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT, modifiersName ) ) );
+        mods.add( new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, 
+            new DefaultServerAttribute( 
+                ApacheSchemaConstants.SCHEMA_MODIFY_TIMESTAMP_AT,
+                registries.getAttributeTypeRegistry().lookup( ApacheSchemaConstants.SCHEMA_MODIFY_TIMESTAMP_AT ),
+                modifyTimestamp ) ) );
+        
+        mods.add( new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE,
+            new DefaultServerAttribute( 
+                ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT, 
+                registries.getAttributeTypeRegistry().lookup( ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT ),
+                modifiersName ) ) );
         
         LdapDN name = new LdapDN( "cn=schemaModifications,ou=schema" );
         name.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );

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=638228&r1=638227&r2=638228&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 Mon Mar 17 23:12:41 2008
@@ -29,7 +29,11 @@
 
 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.entry.DefaultServerAttribute;
+import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerModification;
+import org.apache.directory.server.core.entry.ServerSearchResult;
 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;
@@ -39,6 +43,7 @@
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.EqualityNode;
@@ -46,27 +51,21 @@
 import org.apache.directory.shared.ldap.filter.OrNode;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
-import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.syntax.NumericOidSyntaxChecker;
-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.SearchControls;
-import javax.naming.directory.SearchResult;
 
 
 /**
@@ -90,7 +89,7 @@
 public class SchemaPartitionDao
 {
     /** static class logger */
-    private static final Logger LOG = LoggerFactory.getLogger( SchemaPartitionDao.class );
+    private final Logger LOG = LoggerFactory.getLogger( getClass() );
     private static final NumericOidSyntaxChecker NUMERIC_OID_CHECKER = new NumericOidSyntaxChecker();
     private static final String[] SCHEMA_ATTRIBUTES = new String[] { 
         SchemaConstants.CREATORS_NAME_AT, 
@@ -162,16 +161,12 @@
     public Map<String,Schema> getSchemas() throws NamingException
     {
         Map<String,Schema> schemas = new HashMap<String,Schema>();
-        NamingEnumeration<SearchResult> list = listSchemas();
+        NamingEnumeration<ServerSearchResult> list = listSchemas();
         
         while( list.hasMore() )
         {
-            SearchResult sr = list.next();
-            Schema schema = factory.getSchema( 
-                ServerEntryUtils.toServerEntry( 
-                    sr.getAttributes(),
-                    LdapDN.EMPTY_LDAPDN,
-                    registries ) ); 
+        	ServerSearchResult sr = list.next();
+            Schema schema = factory.getSchema( sr.getServerEntry() );
             schemas.put( schema.getSchemaName(), schema );
         }
         
@@ -182,19 +177,19 @@
     public Set<String> getSchemaNames() throws NamingException
     {
         Set<String> schemaNames = new HashSet<String>();
-        NamingEnumeration<SearchResult> list = listSchemas();
+        NamingEnumeration<ServerSearchResult> list = listSchemas();
         
         while( list.hasMore() )
         {
-            SearchResult sr = list.next();
-            schemaNames.add( ( String ) sr.getAttributes().get( SchemaConstants.CN_AT ).get() );
+        	ServerSearchResult sr = list.next();
+            schemaNames.add( sr.getServerEntry().get( SchemaConstants.CN_AT ).getString() );
         }
         
         return schemaNames;
     }
     
 
-    private NamingEnumeration<SearchResult> listSchemas() throws NamingException
+    private NamingEnumeration<ServerSearchResult> listSchemas() throws NamingException
     {
         LdapDN base = new LdapDN( ServerDNConstants.OU_SCHEMA_DN );
         base.normalize( attrRegistry.getNormalizerMapping() );
@@ -212,10 +207,7 @@
         LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
         dn.normalize( attrRegistry.getNormalizerMapping() );
         return factory.getSchema( 
-            ServerEntryUtils.toServerEntry( 
-                partition.lookup( new LookupOperationContext( registries, dn ) ),
-                dn,
-                registries ) );
+            partition.lookup( new LookupOperationContext( registries, dn ) ) );
     }
 
 
@@ -235,7 +227,7 @@
         
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
 
         try
         {
@@ -281,7 +273,7 @@
         
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
 
         try
         {
@@ -327,7 +319,7 @@
         
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
 
         try
         {
@@ -373,7 +365,7 @@
         
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
 
         try
         {
@@ -419,7 +411,7 @@
         
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
 
         try
         {
@@ -484,8 +476,8 @@
     
     public LdapDN findDn( String entityName ) throws NamingException
     {
-        SearchResult sr = find( entityName );
-        LdapDN dn = new LdapDN( sr.getName() );
+    	ServerSearchResult sr = find( entityName );
+        LdapDN dn = sr.getDn();
         dn.normalize( attrRegistry.getNormalizerMapping() );
         return dn;
     }
@@ -505,7 +497,7 @@
      * @throws NamingException if more than one entity has the name, or if there 
      * are underlying data access problems
      */
-    public SearchResult find( String entityName ) throws NamingException
+    public ServerSearchResult find( String entityName ) throws NamingException
     {
         BranchNode filter = new OrNode();
         SimpleNode nameAVA = new EqualityNode( M_NAME_OID, entityName.toLowerCase() );
@@ -514,7 +506,7 @@
         filter.addNode( oidAVA );
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
         
         try
         {
@@ -526,7 +518,7 @@
                 return null;
             }
             
-            SearchResult sr = ne.next();
+            ServerSearchResult sr = ne.next();
             if ( ne.hasMore() )
             {
                 throw new NamingException( "Got more than one result for the entity name: " + entityName );
@@ -578,9 +570,9 @@
     {
         LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
         dn.normalize( attrRegistry.getNormalizerMapping() );
-        Attributes entry = partition.lookup( new LookupOperationContext( registries, dn ) );
-        Attribute disabledAttr = AttributeUtils.getAttribute( entry, disabledAttributeType );
-        List<ModificationItemImpl> mods = new ArrayList<ModificationItemImpl>( 3 );
+        ServerEntry entry = partition.lookup( new LookupOperationContext( registries, dn ) );
+        ServerAttribute disabledAttr = entry.get( disabledAttributeType );
+        List<Modification> mods = new ArrayList<Modification>( 3 );
         
         if ( disabledAttr == null )
         {
@@ -588,21 +580,35 @@
             return;
         }
         
-        boolean isDisabled = ( ( String ) disabledAttr.get() ).equalsIgnoreCase( "TRUE" );
+        boolean isDisabled = disabledAttr.contains( "TRUE" );
         if ( ! isDisabled )
         {
             LOG.warn( "Does not make sense: you're trying to enable {} schema which is already enabled", schemaName );
             return;
         }
         
-        mods.add( new ModificationItemImpl( DirContext.REMOVE_ATTRIBUTE, 
-            new AttributeImpl( MetaSchemaConstants.M_DISABLED_AT ) ) );
-        
-        mods.add( new ModificationItemImpl( DirContext.ADD_ATTRIBUTE,
-            new AttributeImpl( SchemaConstants.MODIFIERS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN ) ) );
-        
-        mods.add( new ModificationItemImpl( DirContext.ADD_ATTRIBUTE,
-            new AttributeImpl( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ) ) );
+        mods.add( 
+            new ServerModification( 
+                DirContext.REMOVE_ATTRIBUTE, 
+                new DefaultServerAttribute( 
+                    MetaSchemaConstants.M_DISABLED_AT ,
+                    attrRegistry.lookup(MetaSchemaConstants.M_DISABLED_AT) ) ) );
+        
+        mods.add( 
+            new ServerModification( 
+                DirContext.ADD_ATTRIBUTE,
+                new DefaultServerAttribute( 
+                    SchemaConstants.MODIFIERS_NAME_AT, 
+                    attrRegistry.lookup( SchemaConstants.MODIFIERS_NAME_AT ),
+                    ServerDNConstants.ADMIN_SYSTEM_DN ) ) );
+        
+        mods.add( 
+            new ServerModification( 
+                DirContext.ADD_ATTRIBUTE,
+                new DefaultServerAttribute( 
+                    SchemaConstants.MODIFY_TIMESTAMP_AT, 
+                    attrRegistry.lookup( SchemaConstants.MODIFY_TIMESTAMP_AT ),
+                    DateUtils.getGeneralizedTime() ) ) );
         
         partition.modify( new ModifyOperationContext( registries, dn, mods ) );
     }
@@ -616,9 +622,9 @@
      * @return the set of matchingRules and attributeTypes depending on a syntax
      * @throws NamingException if the dao fails to perform search operations
      */
-    public Set<SearchResult> listSyntaxDependents( String numericOid ) throws NamingException
+    public Set<ServerSearchResult> listSyntaxDependents( String numericOid ) throws NamingException
     {
-        Set<SearchResult> set = new HashSet<SearchResult>( );
+        Set<ServerSearchResult> set = new HashSet<ServerSearchResult>( );
         BranchNode filter = new AndNode();
         
         // subfilter for (| (objectClass=metaMatchingRule) (objectClass=metaAttributeType))  
@@ -633,7 +639,7 @@
 
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
         
         try
         {
@@ -656,9 +662,9 @@
     }
 
 
-    public Set<SearchResult> listMatchingRuleDependents( MatchingRule mr ) throws NamingException
+    public Set<ServerSearchResult> listMatchingRuleDependents( MatchingRule mr ) throws NamingException
     {
-        Set<SearchResult> set = new HashSet<SearchResult>( );
+        Set<ServerSearchResult> set = new HashSet<ServerSearchResult>( );
         BranchNode filter = new AndNode();
         
         // ( objectClass = metaAttributeType )
@@ -682,7 +688,7 @@
 
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
         
         try
         {
@@ -705,7 +711,7 @@
     }
 
 
-    public NamingEnumeration<SearchResult> listAllNames() throws NamingException
+    public NamingEnumeration<ServerSearchResult> listAllNames() throws NamingException
     {
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
@@ -719,7 +725,7 @@
     }
 
 
-    public Set<SearchResult> listAttributeTypeDependents( AttributeType at ) throws NamingException
+    public Set<ServerSearchResult> listAttributeTypeDependents( AttributeType at ) throws NamingException
     {
         /*
          * Right now the following inefficient filter is being used:
@@ -739,7 +745,7 @@
          * )
          */
         
-        Set<SearchResult> set = new HashSet<SearchResult>( );
+        Set<ServerSearchResult> set = new HashSet<ServerSearchResult>( );
         BranchNode filter = new AndNode();
         
         // ( objectClass = metaAttributeType )
@@ -759,7 +765,7 @@
 
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
         
         try
         {
@@ -789,7 +795,7 @@
      * @return a set of SearchResults over the schemas whose m-dependency attribute contains schemaName
      * @throws NamingException if there is a problem while searching the schema partition
      */
-    public Set<SearchResult> listSchemaDependents( String schemaName ) throws NamingException
+    public Set<ServerSearchResult> listSchemaDependents( String schemaName ) throws NamingException
     {
         /*
          * The following filter is being used:
@@ -797,7 +803,7 @@
          * ( & ( objectClass = metaSchema ) ( m-dependencies = $schemaName ) )
          */
         
-        Set<SearchResult> set = new HashSet<SearchResult>( );
+        Set<ServerSearchResult> set = new HashSet<ServerSearchResult>( );
         BranchNode filter = new AndNode();
         
         filter.addNode( new EqualityNode( OBJECTCLASS_OID, 
@@ -807,7 +813,7 @@
 
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
         
         try
         {
@@ -837,9 +843,9 @@
      * @return a set of SearchResults over the schemas whose m-dependency attribute contains schemaName
      * @throws NamingException if there is a problem while searching the schema partition
      */
-    public Set<SearchResult> listEnabledSchemaDependents( String schemaName ) throws NamingException
+    public Set<ServerSearchResult> listEnabledSchemaDependents( String schemaName ) throws NamingException
     {
-        Set<SearchResult> set = new HashSet<SearchResult>( );
+        Set<ServerSearchResult> set = new HashSet<ServerSearchResult>( );
         BranchNode filter = new AndNode();
         
         filter.addNode( new EqualityNode( OBJECTCLASS_OID, 
@@ -849,16 +855,17 @@
         
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
         
         try
         {
             ne = partition.search( new SearchOperationContext( registries, partition.getSuffixDn(),
                      AliasDerefMode.DEREF_ALWAYS, filter, searchControls ) );
+            
             while( ne.hasMore() )
             {
-                SearchResult sr = ne.next();
-                Attribute disabled = AttributeUtils.getAttribute( sr.getAttributes(), disabledAttributeType );
+            	ServerSearchResult sr = ne.next();
+                ServerAttribute disabled = sr.getServerEntry().get( disabledAttributeType );
                 
                 if ( disabled == null )
                 {
@@ -882,7 +889,7 @@
     }
 
 
-    public Set<SearchResult> listObjectClassDependents( ObjectClass oc ) throws NamingException
+    public Set<ServerSearchResult> listObjectClassDependents( ObjectClass oc ) throws NamingException
     {
         /*
          * Right now the following inefficient filter is being used:
@@ -908,7 +915,7 @@
          * )
          */
         
-        Set<SearchResult> set = new HashSet<SearchResult>( );
+        Set<ServerSearchResult> set = new HashSet<ServerSearchResult>( );
         BranchNode filter = new AndNode();
         
         BranchNode or = new OrNode();
@@ -929,7 +936,7 @@
 
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> ne = null;
+        NamingEnumeration<ServerSearchResult> ne = null;
         
         try
         {



Mime
View raw message