directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r589966 - in /directory: apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/ apacheds/branches/bigbang/core/src/tes...
Date Tue, 30 Oct 2007 05:43:51 GMT
Author: akarasulu
Date: Mon Oct 29 22:43:50 2007
New Revision: 589966

URL: http://svn.apache.org/viewvc?rev=589966&view=rev
Log:
more added to core-entry classes ...

 o added instanceOf method to ServerValue
 o added isAncestorOf which is needed by this to AttributeType
 o added isDescendantOf which is needed by this to AttributeType
 o added field in ServerAttribute to track the user provided identifier
 o added entry methods to use the user provided identifier


Modified:
    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/ServerBinaryValue.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/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeImpl.java
    directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
    directory/apacheds/branches/bigbang/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/AbstractBootstrapProducer.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
    directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/SchemaUtilsTest.java

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=589966&r1=589965&r2=589966&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 Mon Oct 29 22:43:50 2007
@@ -18,8 +18,8 @@
  */
 package org.apache.directory.server.core.entry;
 
+
 import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -155,6 +155,69 @@
     }
 
 
+    public boolean addObjectClass( ObjectClass objectClass, String alias ) throws NamingException
+    {
+        throw new NotImplementedException();
+    }
+
+
+    public boolean addObjectClass( ObjectClass objectClass ) throws NamingException
+    {
+        if ( allObjectClasses.contains( objectClass ) )
+        {
+            return false;
+        }
+
+        ServerAttribute serverAttribute = serverAttributeMap.get( objectClassAT );
+        String name = objectClass.getName();
+
+        if ( name == null )
+        {
+            name = objectClass.getOid();
+        }
+
+        serverAttribute.add( name );
+        Set<ObjectClass> ancestors = addAncestors( objectClass, new HashSet<ObjectClass>() );
+        ancestors.add( objectClass );
+        // now create sets of the different kinds of objectClasses
+        for ( ObjectClass oc : ancestors )
+        {
+            switch ( oc.getType().getValue() )
+            {
+                case( ObjectClassTypeEnum.STRUCTURAL_VAL ):
+                    structuralObjectClasses.add( oc );
+                    break;
+                case( ObjectClassTypeEnum.AUXILIARY_VAL ):
+                    auxiliaryObjectClasses.add( oc );
+                    break;
+                case( ObjectClassTypeEnum.ABSTRACT_VAL ):
+                    abstractObjectClasses.add( oc );
+                    break;
+                default:
+                    throw new IllegalStateException( "Unrecognized objectClass type value: " + oc.getType() );
+            }
+
+            // now go through all objectClassses to collect the must an may list attributes
+            Collections.addAll( mayList, oc.getMayList() );
+            Collections.addAll( mustList, oc.getMustList() );
+        }
+
+        return true;
+    }
+
+
+    public boolean hasObjectClass( ObjectClass objectClass )
+    {
+        return allObjectClasses.contains( objectClass );
+    }
+
+
+    public Set<ObjectClass> getAbstractObjectClasses()
+    {
+        return Collections.unmodifiableSet( abstractObjectClasses );
+    }
+
+
     public ObjectClass getStructuralObjectClass()
     {
         if ( structuralObjectClasses.isEmpty() )
@@ -165,13 +228,19 @@
     }
 
 
+    public Set<ObjectClass> getStructuralObjectClasses()
+    {
+        return Collections.unmodifiableSet( structuralObjectClasses );
+    }
+
+
     public Set<ObjectClass> getAuxiliaryObjectClasses()
     {
         return Collections.unmodifiableSet( auxiliaryObjectClasses );
     }
 
 
-    public Set<ObjectClass> getObjectClasses()
+    public Set<ObjectClass> getAllObjectClasses()
     {
         return Collections.unmodifiableSet( allObjectClasses );
     }
@@ -195,6 +264,12 @@
     }
 
 
+    public boolean isValid( ObjectClass objectClass )
+    {
+        throw new NotImplementedException();
+    }
+
+
     public ServerAttribute get( AttributeType attributeType )
     {
         return serverAttributeMap.get( attributeType );
@@ -212,6 +287,18 @@
     }
 
 
+    public ServerAttribute put( String upId, AttributeType attributeType ) throws NamingException
+    {
+        throw new NotImplementedException();
+    }
+
+
+    public ServerAttribute put( AttributeType attributeType ) throws NamingException
+    {
+        throw new NotImplementedException();
+    }
+
+
     public ServerAttribute remove( ServerAttribute serverAttribute ) throws NamingException
     {
         if ( serverAttribute.getType().equals( objectClassAT ) )
@@ -224,8 +311,27 @@
 
     public ServerAttribute put( AttributeType attributeType, ServerValue<?> val ) throws NamingException
     {
-        ServerAttribute serverAttribute = new ServerAttribute( attributeType );
-        serverAttribute.add( val );
+        ServerAttribute existing = serverAttributeMap.get( attributeType );
+
+        if ( existing != null )
+        {
+            return put( existing.getUpId(), attributeType, val );
+        }
+        else
+        {
+            String name = attributeType.getName();
+            if ( name == null )
+            {
+                name = attributeType.getOid();
+            }
+            return put( name, attributeType, val );
+        }
+    }
+
+
+    public ServerAttribute put( String upId, AttributeType attributeType, ServerValue<?> val ) throws NamingException
+    {
+        ServerAttribute serverAttribute = new ServerAttribute( upId, attributeType, val );
 
         if ( attributeType.equals( objectClassAT ) )
         {
@@ -238,8 +344,27 @@
 
     public ServerAttribute put( AttributeType attributeType, String val ) throws NamingException
     {
-        ServerAttribute serverAttribute = new ServerAttribute( attributeType );
-        serverAttribute.add( val );
+        ServerAttribute existing = serverAttributeMap.get( attributeType );
+
+        if ( existing != null )
+        {
+            return put( existing.getUpId(), attributeType, val );
+        }
+        else
+        {
+            String name = attributeType.getName();
+            if ( name == null )
+            {
+                name = attributeType.getOid();
+            }
+            return put( name, attributeType, val );
+        }
+    }
+
+
+    public ServerAttribute put( String upId, AttributeType attributeType, String val ) throws NamingException
+    {
+        ServerAttribute serverAttribute = new ServerAttribute( upId, attributeType, val );
 
         if ( attributeType.equals( objectClassAT ) )
         {
@@ -252,8 +377,27 @@
 
     public ServerAttribute put( AttributeType attributeType, byte[] val ) throws NamingException
     {
-        ServerAttribute serverAttribute = new ServerAttribute( attributeType );
-        serverAttribute.add( val );
+        ServerAttribute existing = serverAttributeMap.get( attributeType );
+
+        if ( existing != null )
+        {
+            return put( existing.getUpId(), attributeType, val );
+        }
+        else
+        {
+            String name = attributeType.getName();
+            if ( name == null )
+            {
+                name = attributeType.getOid();
+            }
+            return put( name, attributeType, val );
+        }
+    }
+
+
+    public ServerAttribute put( String upId, AttributeType attributeType, byte[] val ) throws NamingException
+    {
+        ServerAttribute serverAttribute = new ServerAttribute( upId, attributeType, val );
 
         if ( attributeType.equals( objectClassAT ) )
         {
@@ -264,15 +408,16 @@
     }
 
 
-    public ServerAttribute remove( OID oid ) throws NamingException
+    public ServerAttribute remove( AttributeType attributeType ) throws NamingException
     {
-        AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( oid.toString() );
-        ServerAttribute serverAttribute = serverAttributeMap.remove( attributeType );
         if ( attributeType.equals( objectClassAT ) )
         {
-            return setObjectClassAttribute( new ServerAttribute( objectClassAT) );
+            return setObjectClassAttribute( new ServerAttribute( objectClassAT ) );
+        }
+        else
+        {
+            return serverAttributeMap.remove( attributeType );
         }
-        return serverAttribute;
     }
 
 

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=589966&r1=589965&r2=589966&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 Mon Oct 29 22:43:50 2007
@@ -37,7 +37,7 @@
 {
     private HashSet<ServerValue<?>> values = new HashSet<ServerValue<?>>();
     private AttributeType attributeType;
-
+    private String upId;
 
     // maybe have some additional convenience constructors which take
     // an initial value as a string or a byte[]
@@ -46,6 +46,155 @@
     public ServerAttribute( AttributeType attributeType )
     {
         this.attributeType = attributeType;
+        setUpId( null, attributeType );
+    }
+
+
+    public ServerAttribute( String upId, AttributeType attributeType )
+    {
+        this.attributeType = attributeType;
+        setUpId( upId, attributeType );
+    }
+
+
+    /**
+     * Doc me more!
+     *
+     * If the value does not correspond to the same attributeType, then it's
+     * wrapped value is copied into a new ServerValue which uses the specified
+     * attributeType.
+     *
+     * @param attributeType
+     * @param val
+     * @throws NamingException
+     */
+    public ServerAttribute( AttributeType attributeType, ServerValue<?> val ) throws NamingException
+    {
+        this( null, attributeType, val );
+    }
+
+
+    /**
+     * Doc me more!
+     *
+     * If the value does not correspond to the same attributeType, then it's
+     * wrapped value is copied into a new ServerValue which uses the specified
+     * attributeType.
+     *
+     * @param upId
+     * @param attributeType
+     * @param val
+     * @throws NamingException
+     */
+    public ServerAttribute( String upId, AttributeType attributeType, ServerValue<?> val ) throws NamingException
+    {
+        this.attributeType = attributeType;
+        if ( val == null )
+        {
+            if ( attributeType.getSyntax().isHumanReadable() )
+            {
+                values.add( new ServerStringValue( attributeType ) );
+            }
+            else
+            {
+                values.add( new ServerBinaryValue( attributeType ) );
+            }
+        }
+        else
+        {
+            if ( attributeType.equals( val.getAttributeType() ) )
+            {
+                values.add( val );
+            }
+            else if ( val instanceof ServerStringValue )
+            {
+                values.add( new ServerStringValue( attributeType, ( String ) val.get() ) );
+            }
+            else if ( val instanceof ServerBinaryValue )
+            {
+                values.add( new ServerBinaryValue( attributeType, ( byte[] ) val.get() ) );
+            }
+            else
+            {
+                throw new IllegalStateException( "Unknown value type: " + val.getClass().getName() );
+            }
+
+            values.add( val );
+        }
+        setUpId( upId, attributeType );
+    }
+
+
+    public ServerAttribute( AttributeType attributeType, String val ) throws NamingException
+    {
+        this( null, attributeType, val );
+    }
+
+
+    public ServerAttribute( String upId, AttributeType attributeType, String val ) throws NamingException
+    {
+        this.attributeType = attributeType;
+        if ( val == null )
+        {
+            if ( attributeType.getSyntax().isHumanReadable() )
+            {
+                values.add( new ServerStringValue( attributeType ) );
+            }
+            else
+            {
+                values.add( new ServerBinaryValue( attributeType ) );
+            }
+        }
+        else
+        {
+            values.add( new ServerStringValue( attributeType, val ) );
+        }
+        setUpId( upId, attributeType );
+    }
+
+
+    public ServerAttribute( AttributeType attributeType, byte[] val ) throws NamingException
+    {
+        this( null, attributeType, val );
+    }
+
+
+    public ServerAttribute( String upId, AttributeType attributeType, byte[] val ) throws NamingException
+    {
+        this.attributeType = attributeType;
+        if ( val == null )
+        {
+            if ( attributeType.getSyntax().isHumanReadable() )
+            {
+                values.add( new ServerStringValue( attributeType ) );
+            }
+            else
+            {
+                values.add( new ServerBinaryValue( attributeType ) );
+            }
+        }
+        else
+        {
+            values.add( new ServerBinaryValue( attributeType, val ) );
+        }
+        setUpId( upId, attributeType );
+    }
+
+
+    private void setUpId( String upId, AttributeType attributeType )
+    {
+        if ( upId == null )
+        {
+            String name = attributeType.getName();
+            if ( name == null )
+            {
+                this.upId = attributeType.getOid();
+            }
+            else
+            {
+                this.upId = name;
+            }
+        }
     }
 
 
@@ -57,6 +206,23 @@
     public AttributeType getType()
     {
         return attributeType;
+    }
+
+
+    /**
+     * 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
+     */
+    public String getUpId()
+    {
+        return upId;
     }
 
 

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java Mon Oct 29 22:43:50 2007
@@ -176,7 +176,6 @@
      * change. Syntax checks only result on the first check, and when the wrapped
      * value changes.
      *
-     * @todo can go into a base class
      * @see ServerValue#isValid()
      */
     public final boolean isValid() throws NamingException
@@ -232,6 +231,32 @@
     }
 
 
+    public AttributeType getAttributeType()
+    {
+        return attributeType;
+    }
+
+
+    /**
+     * @see ServerValue#instanceOf(AttributeType)
+     */
+    public boolean instanceOf( AttributeType attributeType ) throws NamingException
+    {
+        if ( this.attributeType.equals( attributeType ) )
+        {
+            return true;
+        }
+
+        //noinspection RedundantIfStatement
+        if ( this.attributeType.isDescentantOf( attributeType ) )
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+
     // -----------------------------------------------------------------------
     // Object Methods
     // -----------------------------------------------------------------------
@@ -331,7 +356,6 @@
      * available: SUBSTR, and ORDERING.  If a matchingRule cannot be found null is
      * returned.
      *
-     * @todo can go into a base class
      * @return a matchingRule or null if one cannot be found for the attributeType
      * @throws NamingException if resolution of schema entities fail
      */
@@ -357,7 +381,6 @@
      * Gets a normalizer using getMatchingRule() to resolve the matchingRule
      * that the normalizer is extracted from.
      *
-     * @todo can go into a base class
      * @return a normalizer associated with the attributeType or null if one cannot be found
      * @throws NamingException if resolution of schema entities fail
      */
@@ -378,7 +401,6 @@
      * Gets a comparator using getMatchingRule() to resolve the matching
      * that the comparator is extracted from.
      *
-     * @todo can go into a base class
      * @return a comparator associated with the attributeType or null if one cannot be found
      * @throws NamingException if resolution of schema entities fail
      */

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=589966&r1=589965&r2=589966&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 Mon Oct 29 22:43:50 2007
@@ -19,7 +19,6 @@
 package org.apache.directory.server.core.entry;
 
 
-import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
@@ -42,6 +41,41 @@
 
 
     /**
+     * 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 );
+
+
+    /**
      * 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
@@ -54,6 +88,18 @@
 
 
     /**
+     * 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.
@@ -64,13 +110,23 @@
 
 
     /**
+     * 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> getObjectClasses();
+    Set<ObjectClass> getAllObjectClasses();
 
 
     /**
@@ -101,53 +157,92 @@
     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( ObjectClass objectClass );
+
+
     // -----------------------------------------------------------------------
     // Container (get/put/remove) Methods
     // -----------------------------------------------------------------------
 
 
     /**
-     * Returns the attribute with the specified OID. The return value
-     * is <code>null</code> if no match is found.
+     * Returns the attribute with the specified attributeType. The return
+     * value is <code>null</code> if no match is found.
      *
      * @param attributeType the type of the attribute
-     * @return the attribute with the specified OID
+     * @return the attribute of the specified type
      */
     ServerAttribute get( AttributeType attributeType );
 
 
     /**
-     * Places a non-null attribute in the attribute collection. If there is
-     * already an attribute with the same OID as the new attribute, the old one
-     * is removed from the collection and is returned by this method. If there
-     * was no attribute with the same OID the return value is <code>null</code>.
-     *
-     * @param attribute the attribute to be put
-     * @return the old attribute with the same OID, if exists; otherwise
-     *         <code>null</code>
+     * Places a non-null attribute into this ServerEntry. If there an attribute
+     * of the same exists, the existing one is removed from the set and is
+     * returned by this method. If there was no attribute of the same type the
+     * return value is <code>null</code>.
+     *
+     * @param attribute the attribute to be put into this ServerEntry
+     * @return the existing attribute of the same type if it exists; otherwise
+     * <code>null</code>
      */
     ServerAttribute put( ServerAttribute attribute ) throws NamingException;
 
+    // no value put'ters
+
+    ServerAttribute put( String upId, AttributeType attributeType ) throws NamingException;
+
+    ServerAttribute put( AttributeType attributeType ) throws NamingException;
+
 
     /**
-     * Places a new attribute with the supplied OID and value into the attribute
-     * collection. If there is already an attribute with the same OID, the old
-     * one is removed from the collection and is returned by this method. If
-     * there was no attribute with the same OID the return value is
-     * <code>null</code>.
+     * Places a new attribute of the supplied type and value into the attribute
+     * collection. The identifier used for the attribute is the first alias found
+     * from the attributeType and if no aliases are available then the
+     * attributeType's numric OID is used instead.  If there is already an attribute
+     * of the same type, the old attribute is removed from the collection and is
+     * returned by this method.  The user provided identifier of the existing
+     * attribute will be used for the new one.  If there was no attribute with the same
+     * type the return value is <code>null</code>.
      *
-     * This method provides a mechanism to put an attribute with a
-     * <code>null</code> value: the value of <code>obj</code> may be
-     * <code>null</code>.
+     * This method provides a mechanism to put an attribute with a <code>null</code>
+     * value: the value of <code>val</code> may be <code>null</code>.
      *
      * @param attributeType the type of the new attribute to be put
      * @param val the value of the new attribute to be put
-     * @return the old attribute with the same OID, if exists; otherwise
+     * @return the old attribute of the same type, if exists; otherwise
      *         <code>null</code>
-     * @throws NamingException if there are failures
+     * @throws NamingException if there are resolution issues
      */
     ServerAttribute put( AttributeType attributeType, ServerValue<?> val ) throws NamingException;
 
+    /**
+     * Places a new attribute with the supplied attributeType and value into this
+     * ServerEntry. If there already exists attribute of the same type, the existing
+     * one is removed from this ServerEntry and is returned. If there was no existing
+     * attribute the <code>null</code> is returned instead.
+     *
+     * This method provides a mechanism to put an attribute with a <code>null</code>
+     * value: the value of <code>obj</code> may be <code>null</code>.
+     *
+     * @param upId the user provided identifier for the new attribute
+     * @param attributeType the type of the new attribute to be put
+     * @param val the value of the new attribute to be put
+     * @return the old attribute of the same type, if exists; otherwise
+     *         <code>null</code>
+     * @throws NamingException if there are failures
+     */
+    ServerAttribute put( String upId, AttributeType attributeType, ServerValue<?> val ) throws NamingException;
+
 
     /**
      * Places a new attribute with the supplied OID and value into the attribute
@@ -169,6 +264,9 @@
     ServerAttribute put( AttributeType attributeType, String val ) throws NamingException;
 
 
+    ServerAttribute put( String upId, AttributeType attributeType, String val ) throws NamingException;
+
+
     /**
      * Places a new attribute with the supplied OID and value into the attribute
      * collection. If there is already an attribute with the same OID, the old
@@ -189,14 +287,17 @@
     ServerAttribute put( AttributeType attributeType, byte[] val ) throws NamingException;
 
 
+    ServerAttribute put( String upId, AttributeType attributeType, byte[] val ) throws NamingException;
+
+
     /**
      * Removes the attribute with the specified alias. The removed attribute is
      * returned by this method. If there is no attribute with the specified OID,
      * the return value is <code>null</code>.
      *
-     * @param oid the numeric object identifier of the attribute to be removed
+     * @param attributeType the type of the attribute to be removed
      * @return the removed attribute, if exists; otherwise <code>null</code>
      * @throws NamingException if there are failures
      */
-    ServerAttribute remove( OID oid ) throws NamingException;
+    ServerAttribute remove( AttributeType attributeType ) throws NamingException;
 }

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java Mon Oct 29 22:43:50 2007
@@ -223,4 +223,30 @@
     {
         throw new NotImplementedException();
     }
+
+
+    public AttributeType getAttributeType()
+    {
+        return attributeType;
+    }
+
+
+    /**
+     * @see ServerValue#instanceOf(AttributeType)
+     */
+    public boolean instanceOf( AttributeType attributeType ) throws NamingException
+    {
+        if ( this.attributeType.equals( attributeType ) )
+        {
+            return true;
+        }
+
+        //noinspection RedundantIfStatement
+        if ( this.attributeType.isDescentantOf( attributeType ) )
+        {
+            return true;
+        }
+
+        return false;
+    }
 }

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java Mon Oct 29 22:43:50 2007
@@ -176,7 +176,6 @@
      * change. Syntax checks only result on the first check, and when the wrapped
      * value changes.
      *
-     * @todo can go into a base class
      * @see ServerValue#isValid()
      */
     public final boolean isValid() throws NamingException
@@ -231,6 +230,32 @@
     }
 
 
+    public AttributeType getAttributeType()
+    {
+        return attributeType;
+    }
+
+
+    /**
+     * @see ServerValue#instanceOf(AttributeType)
+     */
+    public boolean instanceOf( AttributeType attributeType ) throws NamingException
+    {
+        if ( this.attributeType.equals( attributeType ) )
+        {
+            return true;
+        }
+
+        //noinspection RedundantIfStatement
+        if ( this.attributeType.isDescentantOf( attributeType ) )
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+
     // -----------------------------------------------------------------------
     // Object Methods
     // -----------------------------------------------------------------------
@@ -327,7 +352,6 @@
      * available: SUBSTR, and ORDERING.  If a matchingRule cannot be found null is
      * returned.
      *
-     * @todo can go into a base class
      * @return a matchingRule or null if one cannot be found for the attributeType
      * @throws NamingException if resolution of schema entities fail
      */
@@ -353,7 +377,6 @@
      * Gets a normalizer using getMatchingRule() to resolve the matchingRule
      * that the normalizer is extracted from.
      *
-     * @todo can go into a base class
      * @return a normalizer associated with the attributeType or null if one cannot be found
      * @throws NamingException if resolution of schema entities fail
      */
@@ -374,7 +397,6 @@
      * Gets a comparator using getMatchingRule() to resolve the matching
      * that the comparator is extracted from.
      *
-     * @todo can go into a base class
      * @return a comparator associated with the attributeType or null if one cannot be found
      * @throws NamingException if resolution of schema entities fail
      */

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java Mon Oct 29 22:43:50 2007
@@ -20,6 +20,7 @@
 
 
 import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
 
 import javax.naming.NamingException;
 
@@ -87,4 +88,10 @@
      * if this ServerValue is less than the supplied ServerValue.
      */
     int compareTo( ServerValue<T> value );
+
+
+    AttributeType getAttributeType();
+
+    
+    boolean instanceOf( AttributeType attributeType ) throws NamingException;
 }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeImpl.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeImpl.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeImpl.java Mon Oct 29 22:43:50 2007
@@ -23,7 +23,6 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.schema.AbstractAttributeType;
@@ -152,7 +151,7 @@
         
         return registries.getMatchingRuleRegistry().lookup( substrOid );
     }
-    
+
 
     /**
      * Recursively gets the substring matchingRule if one exists within the attribute heirarchy.

Modified: directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java (original)
+++ directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java Mon Oct 29 22:43:50 2007
@@ -183,6 +183,18 @@
                 }
 
 
+                public boolean isAncestorOf( AttributeType descendant ) throws NamingException
+                {
+                    return false;
+                }
+
+
+                public boolean isDescentantOf( AttributeType ancestor ) throws NamingException
+                {
+                    return false;
+                }
+
+
                 public boolean isObsolete()
                 {
                     return false;
@@ -444,6 +456,18 @@
                 public MatchingRule getSubstr() throws NamingException
                 {
                     return null;
+                }
+
+
+                public boolean isAncestorOf( AttributeType descendant ) throws NamingException
+                {
+                    return false;
+                }
+
+
+                public boolean isDescentantOf( AttributeType ancestor ) throws NamingException
+                {
+                    return false;
                 }
 
 

Modified: directory/apacheds/branches/bigbang/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/AbstractBootstrapProducer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/AbstractBootstrapProducer.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/AbstractBootstrapProducer.java (original)
+++ directory/apacheds/branches/bigbang/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/AbstractBootstrapProducer.java Mon Oct 29 22:43:50 2007
@@ -24,7 +24,6 @@
 
 import javax.naming.NamingException;
 
-import org.apache.directory.server.schema.bootstrap.ProducerTypeEnum;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.ComparatorRegistry;
 import org.apache.directory.server.schema.registries.MatchingRuleRegistry;
@@ -312,6 +311,18 @@
             }
 
             return null;
+        }
+
+
+        public boolean isAncestorOf( AttributeType attributeType ) throws NamingException
+        {
+            return false;
+        }
+
+
+        public boolean isDescentantOf( AttributeType attributeType ) throws NamingException
+        {
+            return false;
         }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java Mon Oct 29 22:43:50 2007
@@ -35,6 +35,7 @@
  */
 public class BinaryValue implements Value<byte[]>
 {
+    @SuppressWarnings ( { "unchecked" } )
     private static final Comparator<byte[]> BYTE_ARRAY_COMPARATOR = new ByteArrayComparator();
     /** the wrapped binary value */
     private byte[] wrapped;
@@ -85,9 +86,16 @@
     }
 
 
-    public void set( byte[] wrapped )
+    /**
+     * Sets this value's wrapped value to a copy of the src array.
+     *
+     * @param src the source byte array to use as the wrapped value
+     */
+    public void set( byte[] src )
     {
-        this.wrapped = wrapped;
+        byte[] dest = new byte[ src.length];
+        System.arraycopy( src, 0, dest, 0, dest.length );
+        this.wrapped = dest;
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java Mon Oct 29 22:43:50 2007
@@ -20,6 +20,7 @@
 package org.apache.directory.shared.ldap.schema;
 
 
+import javax.naming.NamingException;
 import java.io.Serializable;
 
 
@@ -121,6 +122,7 @@
     // M U T A T O R S
     // ------------------------------------------------------------------------
 
+
     /**
      * Sets whether or not an attribute of this AttributeType single valued or
      * multi-valued.
@@ -181,5 +183,61 @@
     protected void setLength( int length )
     {
         this.length = length;
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Additional Methods
+    // -----------------------------------------------------------------------
+
+
+    public boolean isAncestorOf( AttributeType attributeType ) throws NamingException
+    {
+        //noinspection SimplifiableIfStatement
+        if ( attributeType == null || equals( attributeType ) )
+        {
+            return false;
+        }
+
+        return isAncestorOrEqual( this, attributeType );
+    }
+
+
+    public boolean isDescentantOf( AttributeType attributeType ) throws NamingException
+    {
+        //noinspection SimplifiableIfStatement
+        if ( attributeType == null || equals( attributeType ) )
+        {
+            return false;
+        }
+
+        return isAncestorOrEqual( attributeType, this );
+    }
+
+
+    /**
+     * Recursive method which checks to see if a descendant is really an ancestor or if the two
+     * are equal.
+     *
+     * @param ancestor the possible ancestor of the descendant
+     * @param descendant the possible descendant of the ancestor
+     * @return true if the ancestor equals the descendant or if the descendant is really
+     * a subtype of the ancestor. otherwise false
+     * @throws NamingException if there are issues with superior attribute resolution
+     */
+    private boolean isAncestorOrEqual( AttributeType ancestor, AttributeType descendant ) throws NamingException
+    {
+        if ( ancestor == null || descendant == null )
+        {
+            return false;
+        }
+
+        //noinspection SimplifiableIfStatement
+        if ( ancestor.equals( descendant ) )
+        {
+            return true;
+        }
+
+        return isAncestorOrEqual( ancestor, descendant.getSuperior() );
     }
 }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java Mon Oct 29 22:43:50 2007
@@ -35,7 +35,7 @@
     protected final String oid;
 
     /** whether or not this SchemaObject is active */
-    protected boolean isObsolete = false;
+    protected boolean isObsolete;
 
     /** a human readable identifiers for this SchemaObject */
     protected String[] names = ArrayUtils.EMPTY_STRING_ARRAY;
@@ -275,6 +275,7 @@
     // Object overloads
     // ------------------------------------------------------------------------
 
+
     /**
      * Based on the hashCode of the oid property.
      * 
@@ -301,6 +302,7 @@
             return true;
         }
 
+        //noinspection SimplifiableIfStatement
         if ( obj instanceof SchemaObject )
         {
             return oid.equals( ( ( SchemaObject ) obj ).getOid() );

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java Mon Oct 29 22:43:50 2007
@@ -220,4 +220,26 @@
      *             if there is a failure to resolve the matchingRule
      */
     MatchingRule getSubstr() throws NamingException;
+
+
+    /**
+     * Checks to see if this AttributeType is the ancestor of another
+     * attributeType.
+     *
+     * @param descendant the perspective descendant to check
+     * @return true if the descendant is truely a derived from this AttributeType
+     * @throws NamingException if there are problems resolving superior types
+     */
+    boolean isAncestorOf( AttributeType descendant ) throws NamingException;
+
+
+    /**
+     * Checks to see if this AttributeType is the descendant of another
+     * attributeType.
+     *
+     * @param ancestor the perspective ancestor to check
+     * @return true if this AttributeType truely descends from the ancestor
+     * @throws NamingException if there are problems resolving superior types
+     */
+    boolean isDescentantOf( AttributeType ancestor ) throws NamingException;
 }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/SchemaUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/SchemaUtilsTest.java?rev=589966&r1=589965&r2=589966&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/SchemaUtilsTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/SchemaUtilsTest.java Mon Oct 29 22:43:50 2007
@@ -26,17 +26,6 @@
 import junit.framework.TestCase;
 
 import org.apache.directory.shared.ldap.NotImplementedException;
-import org.apache.directory.shared.ldap.schema.AbstractAttributeType;
-import org.apache.directory.shared.ldap.schema.AbstractMatchingRule;
-import org.apache.directory.shared.ldap.schema.AbstractSyntax;
-import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.DefaultObjectClass;
-import org.apache.directory.shared.ldap.schema.MatchingRule;
-import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.schema.ObjectClass;
-import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
-import org.apache.directory.shared.ldap.schema.SchemaUtils;
-import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 
 
@@ -192,7 +181,8 @@
 
     static class SyntaxImpl extends AbstractSyntax
     {
-        public final static long serialVersionUID = 1L;
+        @SuppressWarnings ( { "AnalyzingVariableNaming" } )
+        public static final long serialVersionUID = 1L;
         
         protected SyntaxImpl(String oid)
         {
@@ -272,6 +262,18 @@
         public MatchingRule getSubstr() throws NamingException
         {
             return substr;
+        }
+
+
+        public boolean isAncestorOf( AttributeType attributeType ) throws NamingException
+        {
+            return false;
+        }
+
+
+        public boolean isDescentantOf( AttributeType attributeType ) throws NamingException
+        {
+            return false;
         }
     }
 



Mime
View raw message