directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r634921 - in /directory: apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/core/sr...
Date Sat, 08 Mar 2008 10:12:37 GMT
Author: elecharny
Date: Sat Mar  8 02:12:34 2008
New Revision: 634921

URL: http://svn.apache.org/viewvc?rev=634921&view=rev
Log:
Removed references to the ObjectClassAttribute, it was far to expensive to process (the gain
is 25% speed improvement)

Modified:
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java
    directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttribute.java

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java?rev=634921&r1=634920&r2=634921&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
(original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
Sat Mar  8 02:12:34 2008
@@ -22,6 +22,7 @@
 import org.apache.directory.shared.ldap.entry.AbstractValue;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -630,7 +631,7 @@
     {
         Value<?> value = get();
         
-        if ( value instanceof ServerBinaryValue )
+        if ( value instanceof ClientBinaryValue )
         {
             return (byte[])value.get();
         }

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java?rev=634921&r1=634920&r2=634921&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
(original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
Sat Mar  8 02:12:34 2008
@@ -66,9 +66,6 @@
     /** A map containing all the attributes for this entry */
     private Map<AttributeType, ServerAttribute> serverAttributeMap = new HashMap<AttributeType,
ServerAttribute>();
     
-    /** The objectClass container */
-    private ObjectClassAttribute objectClassAttribute;
-    
     /** The global registries */
     private final transient Registries registries;
     
@@ -104,8 +101,6 @@
                     OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT
);
                 }
             }
-            
-            setObjectClassAttribute( new ObjectClassAttribute( registries, SchemaConstants.OBJECT_CLASS_AT
) );
         }
         catch ( NamingException ne )
         {
@@ -167,12 +162,6 @@
 
         for ( AttributeType attributeType:attributeTypes )
         {
-            if ( attributeType.equals(  OBJECT_CLASS_AT ) )
-            {
-                // The ObjectClass AttributeType has already been added
-                continue;
-            }
-            
             // Add a new AttributeType without value
             set( attributeType );
         }
@@ -202,24 +191,14 @@
 
         initObjectClassAT( registries );
 
-        if ( attributeType.equals(  OBJECT_CLASS_AT ) )
+        try
         {
-            // If the AttributeType is the ObjectClass AttributeType, then
-            // we don't add it to the entry, as it has already been added
-            // before. But we have to store the upId.
-            objectClassAttribute.setUpId( upId, OBJECT_CLASS_AT );
+            put( upId, attributeType, (String)null );
         }
-        else
+        catch ( NamingException ne )
         {
-            try
-            {
-                put( upId, attributeType, (String)null );
-            }
-            catch ( NamingException ne )
-            {
-                // What do we do ???
-                LOG.error( "We have had an error while adding the '{}' AttributeType : {}",
upId, ne.getMessage() );
-            }
+            // What do we do ???
+            LOG.error( "We have had an error while adding the '{}' AttributeType : {}", upId,
ne.getMessage() );
         }
     }
 
@@ -290,13 +269,6 @@
 
         for ( ServerAttribute attribute:attributes )
         {
-            if ( attribute.getType().equals(  OBJECT_CLASS_AT ) )
-            {
-                // Treat the ObjectClass in a specific way
-                setObjectClassAttribute( attribute );
-                continue;
-            }
-            
             // Store a new ServerAttribute
             try
             {
@@ -385,100 +357,13 @@
     }
 
     
-    /**
-     * Stores the ObjectClassAttribute into its container.
-     *
-     * @param objectClassAttribute The instance of ObjectClassAttribute
-     * @return The previously stored ObjectClassAttribute, if any
-     */
-    private void setObjectClassAttribute( ObjectClassAttribute objectClassAttribute )
-    {
-        assert objectClassAttribute != null : "The ObjectClass Attribute should not be null";
-        
-        this.objectClassAttribute = objectClassAttribute;
-    }
-
-
-    /**
-     * Stores the ObjectClassAttribute into its container.
-     *
-     * @param objectClassAttribute The instance of ObjectClassAttribute
-     * @return The previously stored ObjectClassAttribute, if any
-     */
-    private ServerAttribute setObjectClassAttribute( ServerAttribute serverAttribute )
-    {
-        assert serverAttribute != null : "The ObjectClass Attribute should not be null";
-        
-        this.objectClassAttribute = new ObjectClassAttribute( registries );
-        ServerAttribute previous = serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute
);
-        
-        return previous;
-    }
-
-
-    private ServerAttribute removeObjectClassAttribute( ServerAttribute objectClassAttribute
) throws NamingException
-    {
-        this.objectClassAttribute = (ObjectClassAttribute)objectClassAttribute;
-
-        return serverAttributeMap.remove( OBJECT_CLASS_AT );
-    }
-
-
-    public boolean addObjectClass( ObjectClass objectClass, String alias ) throws NamingException
-    {
-        boolean exists = objectClassAttribute.addObjectClass( objectClass, alias );
-        
-        if ( !exists )
-        {
-            // The ObjectClass is a new one : update the vaules
-        }
-
-        ServerAttribute existing = serverAttributeMap.get( OBJECT_CLASS_AT );
-        
-        existing.add( alias );
-        
-        return exists;
-    }
-
-
-    public boolean addObjectClass( ObjectClass objectClass ) throws NamingException
-    {
-        return addObjectClass( objectClass, objectClass.getName() );
-    }
-
-
-    public void addObjectClass( ObjectClassAttribute objectClassAttribute ) throws NamingException
-    {
-        this.objectClassAttribute = objectClassAttribute;
-        
-        ServerAttribute currentOc = serverAttributeMap.get( objectClassAttribute.getType()
);
-        
-        if ( currentOc != null )
-        {
-            for ( Value<?> value:objectClassAttribute )
-            {
-                currentOc.add( value );
-            }
-        }
-        else
-        {
-            serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute );
-        }
-    }
-
-
-    public boolean hasObjectClass( ObjectClass objectClass )
-    {
-        return objectClassAttribute.hasObjectClass( objectClass );
-    }
-
-
     public boolean hasObjectClass( String objectClass )
     {
         try
         {
-            ObjectClass oc = registries.getObjectClassRegistry().lookup( objectClass );
-            return objectClassAttribute.hasObjectClass( oc );
+            ServerAttribute oc = serverAttributeMap.get( OBJECT_CLASS_AT );
+            
+            return oc.contains( objectClass );
         }
         catch ( NamingException ne )
         {
@@ -486,49 +371,6 @@
         }
     }
 
-
-    public Set<ObjectClass> getAbstractObjectClasses()
-    {
-        return objectClassAttribute.getAbstractObjectClasses();
-    }
-
-
-    public ObjectClass getStructuralObjectClass()
-    {
-        return objectClassAttribute.getStructuralObjectClass();
-    }
-
-
-    public Set<ObjectClass> getStructuralObjectClasses()
-    {
-        return objectClassAttribute.getStructuralObjectClasses();
-    }
-
-
-    public Set<ObjectClass> getAuxiliaryObjectClasses()
-    {
-        return objectClassAttribute.getAuxiliaryObjectClasses();
-    }
-
-
-    public Set<ObjectClass> getAllObjectClasses()
-    {
-        return objectClassAttribute.getAllObjectClasses();
-    }
-
-
-    public Set<AttributeType> getMustList()
-    {
-        return objectClassAttribute.getMustList();
-    }
-
-
-    public Set<AttributeType> getMayList()
-    {
-        return objectClassAttribute.getMayList();
-    }
-
-
     public boolean isValid()
     {
         throw new NotImplementedException();
@@ -627,30 +469,19 @@
                 throw new IllegalArgumentException( message );
             }
             
-            // The ObjectClass AT is special
-            if ( attributeType.equals( OBJECT_CLASS_AT ) )
+            if ( returnedServerAttributes == null )
             {
-                // Just do nothing but clear the ObjectClass values
-                objectClassAttribute.clear();
-                ServerAttribute newAttribute = new ObjectClassAttribute( registries );
-                serverAttributeMap.put( attributeType, newAttribute );
+                returnedServerAttributes = new ArrayList<ServerAttribute>();
             }
-            else
-            {
-                if ( returnedServerAttributes == null )
-                {
-                    returnedServerAttributes = new ArrayList<ServerAttribute>();
-                }
-
-                if ( serverAttributeMap.containsKey( attributeType ) )
-                {
-                    // Add the removed serverAttribute to the list
-                    returnedServerAttributes.add( serverAttributeMap.remove( attributeType
) );
-                }
 
-                ServerAttribute newAttribute = new DefaultServerAttribute( attributeType
);
-                serverAttributeMap.put( attributeType, newAttribute );
+            if ( serverAttributeMap.containsKey( attributeType ) )
+            {
+                // Add the removed serverAttribute to the list
+                returnedServerAttributes.add( serverAttributeMap.remove( attributeType )
);
             }
+
+            ServerAttribute newAttribute = new DefaultServerAttribute( attributeType );
+            serverAttributeMap.put( attributeType, newAttribute );
         }
         
         return returnedServerAttributes;
@@ -682,49 +513,11 @@
                 throw new IllegalArgumentException( message );
             }
             
-            if ( serverAttribute.getType().equals( OBJECT_CLASS_AT ) )
-            {
-                ServerAttribute removed = null;
-                
-                // The objectClass attributeType is special 
-                if ( serverAttribute instanceof ObjectClassAttribute )
-                {
-                    removed = this.objectClassAttribute;
-
-                    this.objectClassAttribute = (ObjectClassAttribute)serverAttribute;
-                    serverAttributeMap.put( OBJECT_CLASS_AT, serverAttribute );
-                    previous.add( removed );
-                }
-                else
-                {
-                    // Here, the attributeType is ObjectClass, but the Attribute itself is

-                    // not a instance of the ObjectClassAttribute. We will store all of
-                    // its values into a new instance of ObjectClassAttribute. 
-                    if ( serverAttribute.getType().getSyntax().isHumanReadable() )
-                    {
-                        ObjectClassAttribute objectClassAttribute = new ObjectClassAttribute(
registries, serverAttribute );
-                        this.objectClassAttribute = objectClassAttribute;
-                        removed = serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute
);
-                    }
-                    else
-                    {
-                        // The attribute must be a String
-                        String message = "Only String values supported for objectClass attribute";
-                        LOG.error(  message  );
-                        throw new UnsupportedOperationException( message );
-                    }
-
-                    previous.add( removed );
-                }
-            }
-            else
+            ServerAttribute removed = serverAttributeMap.put( serverAttribute.getType(),
serverAttribute );
+            
+            if ( removed != null )
             {
-                ServerAttribute removed = serverAttributeMap.put( serverAttribute.getType(),
serverAttribute );
-                
-                if ( removed != null )
-                {
-                    previous.add( removed );
-                }
+                previous.add( removed );
             }
         }
         
@@ -776,11 +569,6 @@
         
         for ( ServerAttribute serverAttribute:serverAttributes )
         {
-            if ( serverAttribute.getType().equals( OBJECT_CLASS_AT ) )
-            {
-                removeObjectClassAttribute( new ObjectClassAttribute( registries ) );
-            }
-
             if ( serverAttributeMap.containsKey( serverAttribute.getType() ) )
             {
                 serverAttributeMap.remove( serverAttribute.getType() );
@@ -824,21 +612,9 @@
         upId = getUpId( upId, attributeType );
         attributeType = getAttributeType( upId, attributeType );
 
-        if ( attributeType.equals( OBJECT_CLASS_AT ) )
-        {
-            // Create a new ObjectclassAttribute and return the previous one
-            ServerAttribute previous = this.objectClassAttribute;
-            
-            objectClassAttribute = new ObjectClassAttribute( registries, upId, values );
-            serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute );
-            return previous;
-        }
-        else
-        {
-            // We simply have to set the current attribute values
-            ServerAttribute serverAttribute = new DefaultServerAttribute( upId, attributeType,
values );
-            return serverAttributeMap.put( attributeType, serverAttribute );
-        }
+        // We simply have to set the current attribute values
+        ServerAttribute serverAttribute = new DefaultServerAttribute( upId, attributeType,
values );
+        return serverAttributeMap.put( attributeType, serverAttribute );
     }
 
 
@@ -894,22 +670,9 @@
 
         ServerAttribute serverAttribute = new DefaultServerAttribute( upId, attributeType
);
 
-        if ( attributeType.equals( OBJECT_CLASS_AT ) )
-        {
-            // If the AttributeType is the ObjectClass AttributeType, then
-            // we don't add it to the entry, as it has already been added
-            // before. But we have to store the upId.
-            ServerAttribute previous = objectClassAttribute;
-            objectClassAttribute = new ObjectClassAttribute( registries, upId, values );
-            serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute );
-            return previous;
-        }
-        else
-        {
-            // We simply have to set the current attribute values
-            serverAttribute.put( values );
-            return serverAttributeMap.put( attributeType, serverAttribute );
-        }
+        // We simply have to set the current attribute values
+        serverAttribute.put( values );
+        return serverAttributeMap.put( attributeType, serverAttribute );
     }
 
 
@@ -1011,7 +774,7 @@
     {
         serverAttributeMap.clear();
 
-        setObjectClassAttribute( new ObjectClassAttribute( registries ) );
+        //setObjectClassAttribute( new ObjectClassAttribute( registries ) );
     }
 
 
@@ -1056,9 +819,6 @@
             // Clone the DN
             clone.dn = (LdapDN)dn.clone();
             
-            // Clone the ObjectClassAttribute
-            clone.objectClassAttribute = objectClassAttribute.clone();
-            
             // clone the ServerAttribute Map
             clone.serverAttributeMap = (Map<AttributeType, ServerAttribute>)(((HashMap<AttributeType,
ServerAttribute>)serverAttributeMap).clone());
             
@@ -1265,60 +1025,6 @@
     
     
     /**
-     * Add a new ObjectClass, with its upId. If the upId is null,
-     * default to "objectClass".
-     * 
-     * Updates the objectClassAttribute and the serverAttributeMap.
-     */
-    private void addObjectClass( String upId, String... values ) throws NamingException,
InvalidAttributeValueException
-    {
-        ServerAttribute attribute = serverAttributeMap.get( OBJECT_CLASS_AT );
-        
-        if ( objectClassAttribute == null )
-        {
-            objectClassAttribute = new ObjectClassAttribute( registries, upId, values );
-            serverAttributeMap.put(  OBJECT_CLASS_AT, objectClassAttribute );
-        }
-        else
-        {
-            objectClassAttribute.add( values );
-            
-            if ( attribute == null )
-            {
-                serverAttributeMap.put(  OBJECT_CLASS_AT, objectClassAttribute ); 
-            }
-            else
-            {
-                attribute.add( values );
-            }
-        }
-    }
-    
-    
-    /**
-     * Add a new ObjectClass, with its upId. If the upId is null,
-     * default to "objectClass".
-     * 
-     * Updates the objectClassAttribute and the serverAttributeMap.
-     */
-    private void addObjectClass( String upId, Value<?>... values ) throws NamingException,
InvalidAttributeValueException
-    {
-        ServerAttribute attribute = serverAttributeMap.get( OBJECT_CLASS_AT );
-        
-        if ( objectClassAttribute == null )
-        {
-            objectClassAttribute = new ObjectClassAttribute( registries, upId, values );
-            serverAttributeMap.put( OBJECT_CLASS_AT, attribute );
-        }
-        else
-        {
-            objectClassAttribute.add( values );
-            attribute.add( values );
-        }
-    }
-    
-    
-    /**
      * Add a new ServerAttribute, with its upId. If the upId is null,
      * default to the AttributeType name.
      * 
@@ -1384,21 +1090,6 @@
      *  - if the attribute already exists, we add the value (no duplicate)
      *  - or we just add a new attribute to the Map
      *-----------------------------------------------------------------------*/
-
-    /**
-     * Add some Values to the current Entry.
-     *
-     * @param upId The user provided ID of the attribute we want to add 
-     * some values to
-     * @param values The list of Values to add
-     * @throws NamingException
-     *
-    public void add( String upId, Value<?>... values ) throws NamingException
-    {
-        
-    }
-    
-    
     /**
      * Add an attribute (represented by its ID and some String values) into an 
      * entry.
@@ -1418,27 +1109,19 @@
             throw new IllegalArgumentException( message );
         }
         
-        if ( attributeType.equals( OBJECT_CLASS_AT ) )
+        ServerAttribute attribute = serverAttributeMap.get( attributeType );
+        
+        if ( attribute != null )
         {
-            // This is an objectClass, call the appropriate method
-            addObjectClass( null, values );
+            // This Attribute already exist, we add the values 
+            // into it
+            attribute.add( values );
         }
         else
         {
-            ServerAttribute attribute = serverAttributeMap.get( attributeType );
-            
-            if ( attribute != null )
-            {
-                // This Attribute already exist, we add the values 
-                // into it
-                attribute.add( values );
-            }
-            else
-            {
-                // We have to create a new Attribute and set the values
-                // and the upId
-                createAttribute( null, attributeType, values );
-            }
+            // We have to create a new Attribute and set the values
+            // and the upId
+            createAttribute( null, attributeType, values );
         }
     }
 
@@ -1505,25 +1188,17 @@
             throw new IllegalArgumentException( message );
         }
         
-        if ( attributeType.equals( OBJECT_CLASS_AT ) )
+        ServerAttribute attribute = serverAttributeMap.get( attributeType );
+    
+        if ( attribute != null )
         {
-            // This is an objectClass, call the appropriate method
-            addObjectClass( null, values );
+            // This Attribute already exist, we add the values 
+            // into it
+            attribute.add( values );
         }
         else
         {
-            ServerAttribute attribute = serverAttributeMap.get( attributeType );
-        
-            if ( attribute != null )
-            {
-                // This Attribute already exist, we add the values 
-                // into it
-                attribute.add( values );
-            }
-            else
-            {
-                createAttribute( null, attributeType, values );
-            }
+            createAttribute( null, attributeType, values );
         }
     }
 
@@ -1587,28 +1262,20 @@
         
         upId = getUpId( upId, attributeType );
 
-        if ( attributeType.equals( OBJECT_CLASS_AT ) )
+        ServerAttribute attribute = serverAttributeMap.get( attributeType );
+        
+        if ( attribute != null )
         {
-            // This is an objectClass, call the appropriate method
-            addObjectClass( upId, values );
+            // This Attribute already exist, we add the values 
+            // into it
+            attribute.add( values );
+            attribute.setUpId( upId, attributeType );
         }
         else
         {
-            ServerAttribute attribute = serverAttributeMap.get( attributeType );
-            
-            if ( attribute != null )
-            {
-                // This Attribute already exist, we add the values 
-                // into it
-                attribute.add( values );
-                attribute.setUpId( upId, attributeType );
-            }
-            else
-            {
-                // We have to create a new Attribute and set the values
-                // and the upId
-                createAttribute( upId, attributeType, values );
-            }
+            // We have to create a new Attribute and set the values
+            // and the upId
+            createAttribute( upId, attributeType, values );
         }
     }
 
@@ -1672,26 +1339,18 @@
         
         upId = getUpId( upId, attributeType );
         
-        if ( attributeType.equals( OBJECT_CLASS_AT ) )
+        ServerAttribute attribute = serverAttributeMap.get( attributeType );
+    
+        if ( attribute != null )
         {
-            // This is an objectClass, call the appropriate method
-            addObjectClass( upId, values );
+            // This Attribute already exist, we add the values 
+            // into it
+            attribute.add( values );
+            attribute.setUpId( upId, attributeType );
         }
         else
         {
-            ServerAttribute attribute = serverAttributeMap.get( attributeType );
-        
-            if ( attribute != null )
-            {
-                // This Attribute already exist, we add the values 
-                // into it
-                attribute.add( values );
-                attribute.setUpId( upId, attributeType );
-            }
-            else
-            {
-                createAttribute( upId, attributeType, values );
-            }
+            createAttribute( upId, attributeType, values );
         }
     }
 
@@ -1784,13 +1443,6 @@
      */
     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
     {
-        /*if ( in.available() == 0 )
-        {
-            String message = "Cannot read an null Attribute";
-            LOG.error( message );
-            throw new IOException( message );
-        }*/
-
         // Read the DN
         LdapDN dn = (LdapDN)in.readObject();
         
@@ -1905,11 +1557,6 @@
         sb.append( "DefaultEntryServer\n" );
         sb.append( "    dn: " ).append( dn ).append( '\n' );
         
-        if ( objectClassAttribute != null )
-        {
-            sb.append( objectClassAttribute );
-        }
-
         if ( serverAttributeMap.size() != 0 )
         {
             for ( ServerAttribute attribute:serverAttributeMap.values() )

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java?rev=634921&r1=634920&r2=634921&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java
(original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java
Sat Mar  8 02:12:34 2008
@@ -20,8 +20,7 @@
 
 
 import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientAttribute;
 
 import javax.naming.NamingException;
 import javax.naming.directory.InvalidAttributeValueException;
@@ -34,7 +33,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface ServerAttribute extends EntryAttribute<Value<?>>
+public interface ServerAttribute extends ClientAttribute
 {
     /**
      * Gets the attribute type associated with this ServerAttribute.
@@ -43,19 +42,6 @@
      */
     AttributeType getType();
 
-    /**
-     * Get's the user provided identifier for this entry.  This is the value
-     * that will be used as the identifier for the attribute within the
-     * entry.  If this is a commonName attribute for example and the user
-     * provides "COMMONname" instead when adding the entry then this is
-     * the format the user will have that entry returned by the directory
-     * server.  To do so we store this value as it was given and track it
-     * in the attribute using this property.
-     *
-     * @return the user provided identifier for this attribute
-     */
-    String getUpId();
-    
     
     /**
      * Set the user provided ID. If we have none, the upId is assigned
@@ -72,35 +58,6 @@
      */
     public void setUpId( String upId, AttributeType attributeType );
 
-    
-    /**
-     * Checks to see if this attribute is valid along with the values it contains.
-     *
-     * @return true if the attribute and it's values are valid, false otherwise
-     * @throws NamingException if there is a failure to check syntaxes of values
-     */
-    boolean isValid() throws NamingException;
-    
-    
-    /**
-     * Get the String value, if and only if the value is known to be a String,
-     * otherwise a InvalidAttributeValueException will be thrown
-     *
-     * @return The value as a String
-     * @throws InvalidAttributeValueException If the value is a byte[]
-     */
-    String getString() throws InvalidAttributeValueException;
-
-
-    /**
-     * Get the byte[] value, if and only if the value is known to be Binary,
-     * otherwise a InvalidAttributeValueException will be thrown
-     *
-     * @return The value as a String
-     * @throws InvalidAttributeValueException If the value is a String
-     */
-    byte[] getBytes() throws InvalidAttributeValueException;
-    
     
     /**
      * Check if the current attribute type is of the expected attributeType 

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java?rev=634921&r1=634920&r2=634921&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java
(original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java
Sat Mar  8 02:12:34 2008
@@ -41,43 +41,6 @@
     // -----------------------------------------------------------------------
     // Schema Related Methods
     // -----------------------------------------------------------------------
-
-
-    /**
-     * Adds an objectClass to the objectClass attribute of this ServerEntry using
-     * a specific alias name with the case provided by the user.
-     *
-     * @param objectClass the objectClass to add to this ServerEntry
-     * @param alias the optional user provided alias to use
-     * @return true if the objectClass is added, false otherwise
-     * @throws NamingException if there are problems resolving entities while
-     * adding the objectClass and its ancestors
-     */
-    boolean addObjectClass( ObjectClass objectClass, String alias ) throws NamingException;
-
-
-    /**
-     * Adds an objectClass to the objectClass attribute of this ServerEntry using
-     * the first alias it can find.  If no alias name exists the numeric OID of the
-     * objectClass is added as a value to the objectClass attribute.
-     *
-     * @param objectClass the objectClass to add to this ServerEntry
-     * @return true if the objectClass is added, false otherwise
-     * @throws NamingException if there are problems resolving entities while
-     * adding the objectClass and its ancestors
-     */
-    boolean addObjectClass( ObjectClass objectClass ) throws NamingException;
-
-
-    /**
-     * Checks to see if this entry is of the objectClass.
-     *
-     * @param objectClass the objectClass to check for in this ServerEntry
-     * @return true if this entry is of the objectClass, false otherwise
-     */
-    boolean hasObjectClass( ObjectClass objectClass );
-
-
     /**
      * Checks to see if this entry is of the objectClass.
      *
@@ -85,78 +48,6 @@
      * @return true if this entry is of the objectClass, false otherwise
      */
     boolean hasObjectClass( String objectClass );
-
-
-    /**
-     * Gets the first structural objectClass that it can find within the entry.
-     * If the entry is inconsistent and contains no objectClass attribute then
-     * null is returned.  If the entry is inconsistent and contains more than
-     * one structural objectClass which is illegal, then the first to be found
-     * will be returned.
-     *
-     * @return the first structural objectClass found in this entry
-     */
-    ObjectClass getStructuralObjectClass();
-
-
-    /**
-     * Gets all the structural objectClasses that are found within the entry
-     * even though such a condition is considered invalid.  Only one structural
-     * objectClass can be present within a valid entry.  The entry can also be
-     * inconsistent by having no structural objectClasses then an empty set is
-     * returned.
-     *
-     * @return all the structural objectClasses found in this entry
-     */
-    Set<ObjectClass> getStructuralObjectClasses();
-
-
-    /**
-     * Gets all the auxiliary objectClasses that it can find within the entry.
-     * If the entry is inconsistent and contains no objectClass attribute then
-     * the empty set is returned.
-     *
-     * @return the set of auxiliary objectClasses found in this entry
-     */
-    Set<ObjectClass> getAuxiliaryObjectClasses();
-
-
-    /**
-     * Gets all the abstract objectClasses that it can find within the entry.
-     * If the entry is inconsistent and contains no objectClass attribute then
-     * the empty set is returned.
-     *
-     * @return the set of abstract objectClasses found in this entry
-     */
-    Set<ObjectClass> getAbstractObjectClasses();
-
-
-    /**
-     * Gets the objectClasses associated with this entry. If there is no
-     * objectClass attribute contained within this entry then an empty set
-     * is returned.
-     *
-     * @return the objectClasses which govern the structure of this entry
-     */
-    Set<ObjectClass> getAllObjectClasses();
-
-
-    /**
-     * Gets the combinded set of all required attributes for this entry across
-     * all objectClasses.
-     *
-     * @return the combinded set of all required attributes
-     */
-    Set<AttributeType> getMustList();
-
-
-    /**
-     * Gets the combined set of all optional attributes for this entry across
-     * all objectClasses.
-     *
-     * @return the combined set of all optional attributes
-     */
-    Set<AttributeType> getMayList();
 
     
     /**

Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java?rev=634921&r1=634920&r2=634921&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
(original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
Sat Mar  8 02:12:34 2008
@@ -102,10 +102,9 @@
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
         
-        ObjectClassAttribute oc = new ObjectClassAttribute( registries );
-        oc.add( "top", "person", "inetOrgPerson", "organizationalPerson" );
+        AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT
);
         
-        entry.addObjectClass( oc );
+        entry.put( "objectClass", OBJECT_CLASS_AT, "top", "person", "inetOrgPerson", "organizationalPerson"
);
         entry.put( "cn", registries.getAttributeTypeRegistry().lookup( "cn" ), "test" );
         
         Attributes attributes = ServerEntryUtils.toAttributesImpl( entry );
@@ -139,11 +138,9 @@
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries,dn );
         
-        ObjectClassAttribute oc = new ObjectClassAttribute( registries );
-        oc.add( "top", "person", "inetOrgPerson", "organizationalPerson" );
+        AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT
);
         
-        entry.addObjectClass( oc );
-        //entry.put( "cn", registries.getAttributeTypeRegistry().lookup( "cn" ), "test" );
+        entry.put( "objectClass", OBJECT_CLASS_AT, "top", "person", "inetOrgPerson", "organizationalPerson"
);
         
         Attributes attributes = ServerEntryUtils.toBasicAttributes( entry );
         
@@ -425,12 +422,11 @@
         
         // test an ObjectClass replacement
         AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT
);
-        ServerAttribute oc = new ObjectClassAttribute( registries, "OBJECTCLASS", "person",
"inetorgperson" );
+        ServerAttribute oc = new DefaultServerAttribute( "OBJECTCLASS", OBJECT_CLASS_AT,
"person", "inetorgperson" );
         List<ServerAttribute> oldOc = entry.put( oc );
         
         assertNotNull( oldOc );
-        assertEquals( 1, oldOc.size() );
-        assertEquals( null, oldOc.get( 0 ).get() );
+        assertEquals( 0, oldOc.size() );
         
         assertNotNull( entry.get( "objectClass" ) );
 
@@ -1748,7 +1744,6 @@
         
         byte[] b1 = StringTools.getBytesUtf8( "test1" );
         byte[] b2 = StringTools.getBytesUtf8( "test2" );
-        byte[] b3 = StringTools.getBytesUtf8( "test3" );
 
         Value<String> test1 = new ServerStringValue( atCN, "test1" );
         Value<String> test2 = new ServerStringValue( atCN, "test2" );

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=634921&r1=634920&r2=634921&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
(original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
Sat Mar  8 02:12:34 2008
@@ -1481,7 +1481,7 @@
 
             entry.remove( SchemaConstants.OBJECT_CLASS_AT );
 
-            ServerAttribute newOc = new ObjectClassAttribute( registries );
+            ServerAttribute newOc = new DefaultServerAttribute( oc.getType() );
 
             for ( ObjectClass currentOC:objectClasses )
             {

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java?rev=634921&r1=634920&r2=634921&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java
Sat Mar  8 02:12:34 2008
@@ -23,6 +23,7 @@
 import org.apache.directory.shared.ldap.entry.Value;
 
 import javax.naming.NamingException;
+import javax.naming.directory.InvalidAttributeValueException;
 
 
 /**
@@ -35,24 +36,30 @@
 public interface ClientAttribute extends EntryAttribute<Value<?>>
 {
     /**
-     * Get's the user provided identifier for this entry.  This is the value
-     * that will be used as the identifier for the attribute within the
-     * entry.  If this is a commonName attribute for example and the user
-     * provides "COMMONname" instead when adding the entry then this is
-     * the format the user will have that entry returned by the directory
-     * server.  To do so we store this value as it was given and track it
-     * in the attribute using this property.
+     * Checks to see if this attribute is valid along with the values it contains.
      *
-     * @return the user provided identifier for this attribute
+     * @return true if the attribute and it's values are valid, false otherwise
+     * @throws NamingException if there is a failure to check syntaxes of values
      */
-    String getUpId();
+    boolean isValid() throws NamingException;
 
+
+    /**
+     * Get the byte[] value, if and only if the value is known to be Binary,
+     * otherwise a InvalidAttributeValueException will be thrown
+     *
+     * @return The value as a String
+     * @throws InvalidAttributeValueException If the value is a String
+     */
+    byte[] getBytes() throws InvalidAttributeValueException;
+    
     
     /**
-     * Checks to see if this attribute is valid along with the values it contains.
+     * Get the String value, if and only if the value is known to be a String,
+     * otherwise a InvalidAttributeValueException will be thrown
      *
-     * @return true if the attribute and it's values are valid, false otherwise
-     * @throws NamingException if there is a failure to check syntaxes of values
+     * @return The value as a String
+     * @throws InvalidAttributeValueException If the value is a byte[]
      */
-    boolean isValid() throws NamingException;
+    String getString() throws InvalidAttributeValueException;
 }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttribute.java?rev=634921&r1=634920&r2=634921&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttribute.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttribute.java
Sat Mar  8 02:12:34 2008
@@ -170,6 +170,54 @@
 
 
     /**
+     * Get the byte[] value, if and only if the value is known to be Binary,
+     * otherwise a InvalidAttributeValueException will be thrown
+     *
+     * @return The value as a String
+     * @throws InvalidAttributeValueException If the value is a String
+     */
+    public byte[] getBytes() throws InvalidAttributeValueException
+    {
+        Value<?> value = get();
+        
+        if ( value instanceof ClientBinaryValue )
+        {
+            return (byte[])value.get();
+        }
+        else
+        {
+            String message = "The value is expected to be a byte[]";
+            LOG.error( message );
+            throw new InvalidAttributeValueException( message );
+        }
+    }
+
+
+    /**
+     * Get the String value, if and only if the value is known to be a String,
+     * otherwise a InvalidAttributeValueException will be thrown
+     *
+     * @return The value as a String
+     * @throws InvalidAttributeValueException If the value is a byte[]
+     */
+    public String getString() throws InvalidAttributeValueException
+    {
+        Value<?> value = get();
+        
+        if ( value instanceof ClientStringValue )
+        {
+            return (String)value.get();
+        }
+        else
+        {
+            String message = "The value is expected to be a String";
+            LOG.error( message );
+            throw new InvalidAttributeValueException( message );
+        }
+    }
+
+
+    /**
      * Get's the attribute identifier. Its value is the same than the
      * user provided ID.
      *



Mime
View raw message