directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r938064 - in /directory: apacheds/trunk/core-entry/src/main/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 Mon, 26 Apr 2010 14:39:45 GMT
Author: elecharny
Date: Mon Apr 26 14:39:45 2010
New Revision: 938064

URL: http://svn.apache.org/viewvc?rev=938064&view=rev
Log:
Migrated the contains(String) and containAttributes() methods to ClientEntry

Modified:
    directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.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

Modified: directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java?rev=938064&r1=938063&r2=938064&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java
(original)
+++ directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java
Mon Apr 26 14:39:45 2010
@@ -781,5 +781,16 @@ public class ClonedServerEntry implement
             
             return clientEntry;
         }
+
+        public boolean contains( String upId ) throws LdapException
+        {
+            return false;
+        }
+    }
+
+
+    public boolean contains( String upId ) throws LdapException
+    {
+        return clonedEntry.contains( upId );
     }
 }

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=938064&r1=938063&r2=938064&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
Mon Apr 26 14:39:45 2010
@@ -418,78 +418,6 @@ public final class DefaultServerEntry ex
     // API
     //-------------------------------------------------------------------------
     /**
-     * <p>
-     * Checks if an entry contains a list of attributes.
-     * </p>
-     * <p>
-     * If the list is null or empty, this method will return <code>true</code>
-     * if the entry has no attribute, <code>false</code> otherwise.
-     * </p>
-     *
-     * @param attributes The Attributes to look for
-     * @return <code>true</code> if all the attributes are found within 
-     * the entry, <code>false</code> if at least one of them is not present.
-     * @throws LdapException If the attribute does not exist
-     */
-    public boolean contains( EntryAttribute... attributes ) throws LdapException
-    {
-        for ( EntryAttribute entryAttribute:attributes )
-        {
-            if ( entryAttribute == null )
-            {
-                return this.attributes.size() == 0;
-            }
-            
-            if ( !this.attributes.containsKey( ((EntryAttribute)entryAttribute).getAttributeType().getOid()
) )
-            {
-                return false;
-            }
-        }
-        
-        return true;
-    }
-
-
-    /**
-     * Checks if an entry contains a specific AttributeType.
-     *
-     * @param attributeType The AttributeType to look for.
-     * @return <code>true</code> if the attribute is found within the entry.
-     */
-    public boolean containsAttribute( AttributeType attributeType )
-    {
-        return attributes.containsKey( attributeType.getOid() );
-    }
-
-    
-    /**
-     * Checks if an entry contains some specific attributes.
-     *
-     * @param attributes The Attributes to look for.
-     * @return <code>true</code> if the attributes are all found within the entry.
-     */
-    public boolean containsAttribute( String... attributes )
-    {
-        for ( String attribute:attributes )
-        {
-            try
-            {
-                if ( !this.attributes.containsKey( getAttributeType( attribute ).getOid()
) )
-                {
-                    return false;
-                }
-            }
-            catch ( LdapException ne )
-            {
-                return false;
-            }
-        }
-        
-        return true;
-    }
-
-
-    /**
      * Tells if an entry has a specific ObjectClass Attribute
      * 
      * @param objectClass The ObjectClass we want to check
@@ -1559,18 +1487,6 @@ public final class DefaultServerEntry ex
     
 
     /**
-     * @see java.io.Externalizable#writeExternal(ObjectOutput)
-     * 
-     * We can't use this method for a ServerEntry, as we have to feed the entry
-     * with an registries reference
-     */
-    public void writeExternal( ObjectOutput out ) throws IOException
-    {
-        throw new IllegalStateException( I18n.err( I18n.ERR_04469 ) );
-    }
-    
-    
-    /**
      * Serialize a server entry.
      * 
      * The structure is the following :
@@ -1624,18 +1540,6 @@ public final class DefaultServerEntry ex
 
     
     /**
-     * @see java.io.Externalizable#readExternal(ObjectInput)
-     * 
-     * We can't use this method for a ServerEntry, as we have to feed the entry
-     * with an registries reference
-     */
-    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
-    {
-        throw new IllegalStateException( I18n.err( I18n.ERR_04468 ) );
-    }
-    
-    
-    /**
      * Deserialize a server entry. 
      * 
      * @param in The buffer containing the serialized serverEntry

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=938064&r1=938063&r2=938064&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
Mon Apr 26 14:39:45 2010
@@ -528,9 +528,18 @@ public interface Entry extends Cloneable
 
 
     // -----------------------------------------------------------------------
-    // Container (get/put/remove) Methods
+    // Container (contains/get/put/remove) Methods
     // -----------------------------------------------------------------------
     /**
+     * Checks that the current Entry contain an AttributeType given its ID
+     * 
+     * @param upId the AttributeType ID
+     * @throws LdapException If the attribute does not exists
+     */
+    public boolean contains( String upId ) throws LdapException;
+    
+    
+    /**
      * Checks if an entry contains an attribute with some given binary values.
      *
      * @param attributeType The Attribute we are looking for.
@@ -567,6 +576,15 @@ public interface Entry extends Cloneable
 
 
     /**
+     * Checks if an entry contains a specific AttributeType.
+     *
+     * @param attributeType The AttributeType to look for.
+     * @return <code>true</code> if the attribute is found within the entry.
+     */
+    boolean containsAttribute( AttributeType attributeType );
+
+    
+    /**
      * <p>
      * Checks if an entry contains a list of attributes.
      * </p>

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=938064&r1=938063&r2=938064&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
Mon Apr 26 14:39:45 2010
@@ -35,15 +35,6 @@ import org.apache.directory.shared.ldap.
 public interface ServerEntry extends Entry
 {
     /**
-     * Checks if an entry contains a specific AttributeType.
-     *
-     * @param attributeType The AttributeType to look for.
-     * @return <code>true</code> if the attribute is found within the entry.
-     */
-    boolean containsAttribute( AttributeType attributeType );
-
-    
-    /**
      * Tells if an entry has a specific ObjectClass Attribute
      * 
      * @param objectClass The ObjectClass we want to check

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=938064&r1=938063&r2=938064&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
Mon Apr 26 14:39:45 2010
@@ -650,22 +650,42 @@ public class DefaultClientEntry implemen
      */
     public boolean contains( EntryAttribute... attributes ) throws LdapException
     {
-        for ( EntryAttribute attribute:attributes )
+        if ( schemaManager == null )
         {
-            if ( attribute == null )
+            for ( EntryAttribute attribute:attributes )
             {
-                return this.attributes.size() == 0;
+                if ( attribute == null )
+                {
+                    return this.attributes.size() == 0;
+                }
+                
+                if ( !this.attributes.containsKey( attribute.getId() ) )
+                {
+                    return false;
+                }
             }
-            
-            if ( !this.attributes.containsKey( attribute.getId() ) )
+        }
+        else
+        {
+            for ( EntryAttribute entryAttribute:attributes )
             {
-                return false;
+                if ( entryAttribute == null )
+                {
+                    return this.attributes.size() == 0;
+                }
+                
+                AttributeType attributeType = entryAttribute.getAttributeType();
+                
+                if ( ( entryAttribute == null ) || !this.attributes.containsKey( attributeType.getOid()
) )
+                {
+                    return false;
+                }
             }
         }
         
         return true;
     }
-    
+
     
     /**
      * {@inheritDoc}
@@ -679,6 +699,18 @@ public class DefaultClientEntry implemen
         
         String id = getId( upId );
         
+        if ( schemaManager != null )
+        {
+            try
+            {
+                return containsAttribute( schemaManager.lookupAttributeTypeRegistry( id )
);
+            }
+            catch ( LdapException le )
+            {
+                return false;
+            }
+        }
+        
         return attributes.containsKey( id );
     }
 
@@ -686,6 +718,61 @@ public class DefaultClientEntry implemen
     /**
      * {@inheritDoc}
      */
+    public boolean containsAttribute( String... attributes )
+    {
+        if ( schemaManager == null )
+        {
+            for ( String attribute:attributes )
+            {
+                String id = getId( attribute );
+        
+                if ( !this.attributes.containsKey( id ) )
+                {
+                    return false;
+                }
+            }
+            
+            return true;
+        }
+        else
+        {
+            for ( String attribute:attributes )
+            {
+                try
+                {
+                    if ( !containsAttribute( schemaManager.lookupAttributeTypeRegistry( attribute
) ) )
+                    {
+                        return false;
+                    }
+                }
+                catch ( LdapException ne )
+                {
+                    return false;
+                }
+            }
+        
+            return true;
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean containsAttribute( AttributeType attributeType )
+    {
+        if ( attributeType == null )
+        {
+            return false;
+        }
+        
+        return attributes.containsKey( attributeType.getOid() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
     public boolean contains( AttributeType attributeType, byte[]... values )
     {
         if ( attributeType == null )
@@ -860,25 +947,6 @@ public class DefaultClientEntry implemen
     
     
     /**
-     * {@inheritDoc}
-     */
-    public boolean containsAttribute( String... attributes )
-    {
-        for ( String attribute:attributes )
-        {
-            String id = getId( attribute );
-    
-            if ( !this.attributes.containsKey( id ) )
-            {
-                return false;
-            }
-        }
-        
-        return true;
-    }
-
-    
-    /**
      * <p>
      * Returns the attribute with the specified alias. The return value
      * is <code>null</code> if no match is found.  
@@ -1545,7 +1613,25 @@ public class DefaultClientEntry implemen
             // Read each attribute
             EntryAttribute attribute = (DefaultEntryAttribute)in.readObject();
             
-            attributes.put( attribute.getId(), attribute );
+            if ( schemaManager != null )
+            {
+                try
+                {
+                    AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry(
attribute.getId() );
+
+                    attributes.put( attributeType.getOid(), attribute );
+                }
+                catch (LdapException le  )
+                {
+                    String message = le.getLocalizedMessage();
+                    LOG.error( message );
+                    throw new IOException( message );
+                }
+            }
+            else
+            {
+                attributes.put( attribute.getId(), attribute );
+            }
         }
     }
     



Mime
View raw message