directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r937902 - in /directory: apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ shared/trunk/ldap/src/main/java/org/apache/directory/shared/lda...
Date Sun, 25 Apr 2010 22:29:58 GMT
Author: elecharny
Date: Sun Apr 25 22:29:57 2010
New Revision: 937902

URL: http://svn.apache.org/viewvc?rev=937902&view=rev
Log:
Some more methods merged : toString(), getAttributes(), isValid(), hasObjectClass(String)

Modified:
    directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerEntry.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java

Modified: directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java?rev=937902&r1=937901&r2=937902&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
(original)
+++ directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
Sun Apr 25 22:29:57 2010
@@ -3821,7 +3821,7 @@ public class DefaultServerEntryTest
     {
         ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
         
-        assertEquals( "ServerEntry\n    dn[]: dc=example,dc=com\n", entry.toString() );
+        assertEquals( "Entry\n    dn: dc=example,dc=com\n", entry.toString() );
         
         Value<String> strValueTop = new StringValue( "top" );
         Value<String> strValuePerson = new StringValue( "person" );
@@ -3835,8 +3835,8 @@ public class DefaultServerEntryTest
         entry.put( "UserPassword", atPwd, binValue1, binValue2, binNullValue );
 
         String expected = 
-            "ServerEntry\n" +
-            "    dn[]: dc=example,dc=com\n" +
+            "Entry\n" +
+            "    dn: dc=example,dc=com\n" +
             "    ObjectClass: top\n" +
             "    ObjectClass: person\n" +
             "    ObjectClass: ''\n" +

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java?rev=937902&r1=937901&r2=937902&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java
Sun Apr 25 22:29:57 2010
@@ -30,7 +30,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.exception.LdapException;
@@ -703,37 +702,6 @@ public final class DefaultServerEntry ex
 
 
     /**
-     * Gets all the attributes type
-     *
-     * @return The combined set of all the attributes, including ObjectClass.
-     */
-    public Set<AttributeType> getAttributeTypes()
-    {
-        Set<AttributeType> attributeTypes = new HashSet<AttributeType>();
-        
-        for ( EntryAttribute attribute:attributes.values() )
-        {
-            attributeTypes.add( attribute.getAttributeType() );
-        }
-        
-        return attributeTypes;
-    }
-    
-    
-    /**
-     * Tells if an entry has a specific ObjectClass value
-     * 
-     * @param objectClass The ObjectClass ID we want to check
-     * @return <code>true</code> if the ObjectClass value is present 
-     * in the ObjectClass attribute
-     */
-    public boolean hasObjectClass( String objectClass )
-    {
-        return contains( OBJECT_CLASS_AT, objectClass );
-    }
-
-    
-    /**
      * Tells if an entry has a specific ObjectClass Attribute
      * 
      * @param objectClass The ObjectClass we want to check
@@ -775,54 +743,6 @@ public final class DefaultServerEntry ex
 
     
     /**
-     * Fail fast check performed to determine entry consistency according to schema
-     * characteristics.
-     *
-     * @return true if the entry, it's attributes and their values are consistent
-     * with the schema
-     */
-    public boolean isValid()
-    {
-        // @TODO Implement me !
-        throw new NotImplementedException();
-    }
-
-
-    /**
-     * Check performed to determine entry consistency according to the schema
-     * requirements of a particular objectClass.  The entry must be of that objectClass
-     * to return true: meaning if the entry's objectClass attribute does not contain
-     * the objectClass argument, then false should be returned.
-     *
-     * @param objectClass the objectClass to use while checking for validity
-     * @return true if the entry, it's attributes and their values are consistent
-     * with the objectClass
-     */
-    public boolean isValid( EntryAttribute objectClass )
-    {
-        // @TODO Implement me !
-        throw new NotImplementedException();
-    }
-
-
-    /**
-     * Check performed to determine entry consistency according to the schema
-     * requirements of a particular objectClass.  The entry must be of that objectClass
-     * to return true: meaning if the entry's objectClass attribute does not contain
-     * the objectClass argument, then false should be returned.
-     *
-     * @param objectClass the objectClass to use while checking for validity
-     * @return true if the entry, it's attributes and their values are consistent
-     * with the objectClass
-     */
-    public boolean isValid( String objectClass )
-    {
-        // @TODO Implement me !
-        throw new NotImplementedException();
-    }
-
-
-    /**
      * <p>
      * Places a new attribute with the supplied AttributeType and binary values 
      * into the attribute collection. 
@@ -2053,49 +1973,4 @@ public final class DefaultServerEntry ex
         
         return true;
     }
-        
-    /**
-     * @see Object#toString()
-     */
-    public String toString()
-    {
-        StringBuilder sb = new StringBuilder();
-        
-        sb.append( "ServerEntry\n" );
-        sb.append( "    dn" );
-        
-        if ( dn.isNormalized() )
-        {
-            sb.append( "[n]: " );
-            sb.append( dn.getName() );
-        }
-        else
-        {
-            sb.append( "[]: " );
-            sb.append( dn );
-        }
-        
-        sb.append( '\n' );
-        
-        // First dump the ObjectClass attribute
-        if ( containsAttribute( OBJECT_CLASS_AT ) )
-        {
-            EntryAttribute objectClass = get( OBJECT_CLASS_AT );
-            
-            sb.append( objectClass );
-        }
-        
-        if ( attributes.size() != 0 )
-        {
-            for ( EntryAttribute attribute:attributes.values() )
-            {
-                if ( !((EntryAttribute)attribute).getAttributeType().equals( OBJECT_CLASS_AT
) )
-                {
-                    sb.append( attribute );
-                }
-            }
-        }
-        
-        return sb.toString();
-    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java?rev=937902&r1=937901&r2=937902&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
Sun Apr 25 22:29:57 2010
@@ -22,6 +22,7 @@ package org.apache.directory.shared.ldap
 import java.io.Externalizable;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.directory.shared.ldap.exception.LdapException;
 
@@ -111,6 +112,14 @@ public interface Entry extends Cloneable
 
 
     /**
+     * Gets all the attributes type
+     *
+     * @return The combined set of all the attributes.
+     */
+    Set<AttributeType> getAttributeTypes();
+    
+    
+    /**
      * <p>
      * Put some new ClientAttribute using the User Provided ID. 
      * No value is inserted. 
@@ -135,6 +144,42 @@ public interface Entry extends Cloneable
 
 
     /**
+     * Fail fast check performed to determine entry consistency according to schema
+     * characteristics.
+     *
+     * @return true if the entry, it's attributes and their values are consistent
+     * with the schema
+     */
+    boolean isValid();
+
+
+    /**
+     * Check performed to determine entry consistency according to the schema
+     * requirements of a particular objectClass.  The entry must be of that objectClass
+     * to return true: meaning if the entry's objectClass attribute does not contain
+     * the objectClass argument, then false should be returned.
+     *
+     * @param objectClass the objectClass to use while checking for validity
+     * @return true if the entry, it's attributes and their values are consistent
+     * with the objectClass
+     */
+    boolean isValid( String objectClass );
+
+    
+    /**
+     * Check performed to determine entry consistency according to the schema
+     * requirements of a particular objectClass.  The entry must be of that objectClass
+     * to return true: meaning if the entry's objectClass attribute does not contain
+     * the objectClass argument, then false should be returned.
+     *
+     * @param objectClass the objectClass to use while checking for validity
+     * @return true if the entry, it's attributes and their values are consistent
+     * with the objectClass
+     */
+    boolean isValid( EntryAttribute objectClass );
+
+
+    /**
      * Returns an enumeration containing the zero or more attributes in the
      * collection. The behavior of the enumeration is not specified if the
      * attribute collection is changed.

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerEntry.java?rev=937902&r1=937901&r2=937902&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerEntry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerEntry.java
Sun Apr 25 22:29:57 2010
@@ -83,14 +83,6 @@ public interface ServerEntry extends Ent
 
     
     /**
-     * Gets all the attributes type
-     *
-     * @return The combined set of all the attributes.
-     */
-    Set<AttributeType> getAttributeTypes();
-    
-    
-    /**
      * Tells if an entry has a specific ObjectClass Attribute
      * 
      * @param objectClass The ObjectClass we want to check
@@ -101,42 +93,6 @@ public interface ServerEntry extends Ent
 
     
     /**
-     * Fail fast check performed to determine entry consistency according to schema
-     * characteristics.
-     *
-     * @return true if the entry, it's attributes and their values are consistent
-     * with the schema
-     */
-    boolean isValid();
-
-
-    /**
-     * Check performed to determine entry consistency according to the schema
-     * requirements of a particular objectClass.  The entry must be of that objectClass
-     * to return true: meaning if the entry's objectClass attribute does not contain
-     * the objectClass argument, then false should be returned.
-     *
-     * @param objectClass the objectClass to use while checking for validity
-     * @return true if the entry, it's attributes and their values are consistent
-     * with the objectClass
-     */
-    boolean isValid( String objectClass );
-
-    
-    /**
-     * Check performed to determine entry consistency according to the schema
-     * requirements of a particular objectClass.  The entry must be of that objectClass
-     * to return true: meaning if the entry's objectClass attribute does not contain
-     * the objectClass argument, then false should be returned.
-     *
-     * @param objectClass the objectClass to use while checking for validity
-     * @return true if the entry, it's attributes and their values are consistent
-     * with the objectClass
-     */
-    boolean isValid( EntryAttribute objectClass );
-
-
-    /**
      * <p>
      * Places a new attribute with the supplied AttributeType and binary values 
      * into the attribute collection. 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java?rev=937902&r1=937901&r2=937902&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java
Sun Apr 25 22:29:57 2010
@@ -25,12 +25,15 @@ import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
+import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.exception.LdapException;
 
 import org.apache.directory.shared.i18n.I18n;
@@ -845,6 +848,25 @@ public class DefaultClientEntry implemen
 
 
     /**
+     * {@inheritDoc}
+     */
+    public Set<AttributeType> getAttributeTypes()
+    {
+        Set<AttributeType> attributeTypes = new HashSet<AttributeType>();
+        
+        for ( EntryAttribute attribute:attributes.values() )
+        {
+            if ( attribute.getAttributeType() != null )
+            { 
+                attributeTypes.add( attribute.getAttributeType() );
+            }
+        }
+        
+        return attributeTypes;
+    }
+    
+    
+    /**
      * <p>
      * Put an attribute (represented by its ID and some binary values) into an entry. 
      * </p>
@@ -1326,6 +1348,36 @@ public class DefaultClientEntry implemen
     
 
     /**
+     * {@inheritDoc}
+     */
+    public boolean isValid()
+    {
+        // @TODO Implement me !
+        throw new NotImplementedException();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isValid( EntryAttribute objectClass )
+    {
+        // @TODO Implement me !
+        throw new NotImplementedException();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isValid( String objectClass )
+    {
+        // @TODO Implement me !
+        throw new NotImplementedException();
+    }
+
+
+    /**
      * Returns the number of attributes.
      *
      * @return the number of attributes
@@ -1433,15 +1485,19 @@ public class DefaultClientEntry implemen
 
     
     /**
-     * Tells if an entry has a specific ObjectClass value
-     * 
-     * @param objectClass The ObjectClass we want to check
-     * @return <code>true</code> if the ObjectClass value is present 
-     * in the ObjectClass attribute
+     * {@inheritDoc}
      */
     public boolean hasObjectClass( String objectClass )
     {
-        return contains( "objectclass", objectClass );
+        if ( schemaManager != null )
+        {
+            return contains( OBJECT_CLASS_AT.getOid(), objectClass );
+
+        }
+        else
+        {
+            return contains( "objectclass", objectClass );
+        }
     }
 
 
@@ -1506,22 +1562,48 @@ public class DefaultClientEntry implemen
     {
         StringBuilder sb = new StringBuilder();
         
-        sb.append( "ClientEntry\n" );
-        sb.append( "    dn: " ).append( dn.getName() ).append( '\n' );
+        sb.append( "Entry\n" );
+        sb.append( "    dn" );
+
+        if ( dn.isNormalized() )
+        {
+            sb.append( "[n]" );
+        }
+        
+        sb.append( ": " );
+        sb.append( dn.getName() );
+        sb.append( '\n' );
         
         // First dump the ObjectClass attribute
-        if ( containsAttribute( "objectClass" ) )
+        if ( schemaManager != null )
         {
-            EntryAttribute objectClass = get( "objectclass" );
-            
-            sb.append( objectClass );
+            // First dump the ObjectClass attribute
+            if ( containsAttribute( OBJECT_CLASS_AT.getOid() ) )
+            {
+                EntryAttribute objectClass = get( OBJECT_CLASS_AT );
+                
+                sb.append( objectClass );
+            }
+        }
+        else
+        {
+            if ( containsAttribute( "objectClass" ) )
+            {
+                EntryAttribute objectClass = get( "objectclass" );
+                
+                sb.append( objectClass );
+            }
         }
         
         if ( attributes.size() != 0 )
         {
             for ( EntryAttribute attribute:attributes.values() )
             {
-                if ( !attribute.getId().equals( "objectclass" ) )
+                if ( attribute.getAttributeType() != OBJECT_CLASS_AT )
+                {
+                    sb.append( attribute );
+                }
+                else if ( !attribute.getId().equals( "objectclass" ) )
                 {
                     sb.append( attribute );
                 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java?rev=937902&r1=937901&r2=937902&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java
Sun Apr 25 22:29:57 2010
@@ -1238,7 +1238,7 @@ public class DefaultClientEntryTest
     {
         Entry entry = new DefaultClientEntry( EXAMPLE_DN );
         
-        assertEquals( "ClientEntry\n    dn: dc=example,dc=com\n", entry.toString() );
+        assertEquals( "Entry\n    dn: dc=example,dc=com\n", entry.toString() );
         
         Value<String> strValueTop = new StringValue( "top" );
         Value<String> strValuePerson = new StringValue( "person" );
@@ -1252,7 +1252,7 @@ public class DefaultClientEntryTest
         entry.put( "UserPassword", binValue1, binValue2, binNullValue );
 
         String expected = 
-            "ClientEntry\n" +
+            "Entry\n" +
             "    dn: dc=example,dc=com\n" +
             "    ObjectClass: top\n" +
             "    ObjectClass: person\n" +



Mime
View raw message