directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r961740 - in /directory: apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/ apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ shared/trunk/ldap/src/main/java/org/apache/directory/shared/l...
Date Thu, 08 Jul 2010 12:45:09 GMT
Author: elecharny
Date: Thu Jul  8 12:45:09 2010
New Revision: 961740

URL: http://svn.apache.org/viewvc?rev=961740&view=rev
Log:
o Removed the unused methods isSibling, inferLdapName, isDescendant and hasCompositeComponents
from the NamespaceTools class
o Fixed some Javadoc
o Using DN.isChild() instead of NamespaceTools.isDescendant()

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/NamespaceToolsTest.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java?rev=961740&r1=961739&r2=961740&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java
Thu Jul  8 12:45:09 2010
@@ -69,15 +69,12 @@ public class SubtreeEvaluator
     public boolean evaluate( SubtreeSpecification subtree, DN apDn, DN entryDn, Entry entry
)
         throws LdapException
     {
-        // TODO: Try to make this cast unnecessary.
-        DN dnEntryDn = (DN) entryDn;
-        
         /* =====================================================================
          * NOTE: Regarding the overall approach, we try to narrow down the
          * possibilities by slowly pruning relative names off of the entryDn.
          * For example we check first if the entry is a descendant of the AP.
          * If so we use the relative name thereafter to calculate if it is
-         * a descendant of the base.  This means shorter names to compare and
+         * a descendant of the base. This means shorter names to compare and
          * less work to do while we continue to deduce inclusion by the subtree
          * specification.
          * =====================================================================
@@ -90,7 +87,7 @@ public class SubtreeEvaluator
          */
         DN apRelativeRdn;
         
-        if ( !NamespaceTools.isDescendant( apDn, entryDn ) )
+        if ( !entryDn.isChildOf( apDn ) )
         {
             return false;
         }
@@ -119,7 +116,7 @@ public class SubtreeEvaluator
         {
             baseRelativeRdn = new DN();
         }
-        else if ( !NamespaceTools.isDescendant( subtree.getBase(), apRelativeRdn ) )
+        else if ( !apRelativeRdn.isChildOf( subtree.getBase() ) )
         {
             return false;
         }
@@ -160,7 +157,7 @@ public class SubtreeEvaluator
         {
             DN chopBefore = list.next();
             
-            if ( NamespaceTools.isDescendant( chopBefore, baseRelativeRdn ) )
+            if ( baseRelativeRdn.isChildOf( chopBefore ) )
             {
                 return false;
             }
@@ -172,7 +169,7 @@ public class SubtreeEvaluator
         {
             DN chopAfter = ( DN ) list.next();
             
-            if ( NamespaceTools.isDescendant( chopAfter, baseRelativeRdn ) && !chopAfter.equals(
baseRelativeRdn ) )
+            if ( baseRelativeRdn.isChildOf( chopAfter ) && !chopAfter.equals( baseRelativeRdn
) )
             {
                 return false;
             }
@@ -185,7 +182,7 @@ public class SubtreeEvaluator
          */
         if ( subtree.getRefinement() != null )
         {
-            return evaluator.evaluate( subtree.getRefinement(), dnEntryDn, entry );
+            return evaluator.evaluate( subtree.getRefinement(), entryDn, entry );
         }
 
         /*

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=961740&r1=961739&r2=961740&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
Thu Jul  8 12:45:09 2010
@@ -53,7 +53,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
-import org.apache.directory.shared.ldap.util.NamespaceTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -1780,7 +1779,7 @@ public abstract class AbstractStore<E, I
          */
         while ( !ancestorDn.equals( suffixDn ) && null != ancestorId )
         {
-            if ( !NamespaceTools.isDescendant( ancestorDn, normalizedAliasTargetDn ) )
+            if ( !normalizedAliasTargetDn.isChildOf( ancestorDn ) )
             {
                 subAliasIdx.add( ancestorId, targetId );
             }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java?rev=961740&r1=961739&r2=961740&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
Thu Jul  8 12:45:09 2010
@@ -653,7 +653,7 @@ public class DN implements Cloneable, Se
 
     /**
      * Tells if a DN is a child of another DN.<br>
-     * For instance, <b>dc=example, dc=com</b> is a child
+     * For instance, <b>dc=example, dc=apache, dc=com</b> is a child
      * of <b>dc=com</b>
      * 
      * @param dn The parent

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java?rev=961740&r1=961739&r2=961740&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
Thu Jul  8 12:45:09 2010
@@ -67,39 +67,6 @@ public class NamespaceTools
 
 
     /**
-     * Checks to see if two names are siblings.
-     * 
-     * @param name1 the first name
-     * @param name2 the second name
-     * @return true if the names are siblings, false otherwise.
-     */
-    public static boolean isSibling( DN name1, DN name2 ) throws LdapInvalidDnException
-    {
-        if ( name1.size() == name2.size() )
-        {
-            DN parentDn = ( DN ) name1.clone();
-            parentDn.remove( name1.size() - 1 );
-            return name2.isChildOf( parentDn );
-        }
-
-        return false;
-    }
-
-
-    /**
-     * Tests to see if a candidate entry is a descendant of a base.
-     * 
-     * @param ancestor the base ancestor
-     * @param descendant the candidate to test for descendancy
-     * @return true if the candidate is a descendant
-     */
-    public static boolean isDescendant( DN ancestor, DN descendant )
-    {
-        return descendant.isChildOf( ancestor );
-    }
-
-
-    /**
      * Gets the relative name between an ancestor and a potential descendant.
      * Both name arguments must be normalized. The returned name is also
      * normalized.
@@ -135,42 +102,6 @@ public class NamespaceTools
 
 
     /**
-     * Uses the algorithm in <a href="http://www.faqs.org/rfcs/rfc2247.html">RFC
-     * 2247</a> to infer an LDAP name from a Kerberos realm name or a DNS
-     * domain name.
-     * 
-     * @param realm the realm or domain name
-     * @return the LDAP name for the realm or domain
-     */
-    public static String inferLdapName( String realm )
-    {
-        if ( StringTools.isEmpty( realm ) )
-        {
-            return "";
-        }
-
-        StringBuffer buf = new StringBuffer( realm.length() );
-        buf.append( "dc=" );
-
-        int start = 0, end = 0;
-
-        // Replace all the '.' by ",dc=". The comma is added because
-        // the string is not supposed to start with a dot, so another
-        // dc=XXXX already exists in any cases.
-        // The realm is also not supposed to finish with a '.'
-        while ( ( end = realm.indexOf( '.', start ) ) != -1 )
-        {
-            buf.append( realm.substring( start, end ) ).append( ",dc=" );
-            start = end + 1;
-
-        }
-
-        buf.append( realm.substring( start ) );
-        return buf.toString();
-    }
-
-
-    /**
      * Gets the '+' appended components of a composite name component.
      * 
      * @param compositeNameComponent a single name component not a whole name
@@ -229,32 +160,4 @@ public class NamespaceTools
 
         return comps.toArray( EMPTY_STRING_ARRAY );
     }
-
-
-    /**
-     * Checks to see if a name has name complex name components in it.
-     * 
-     * @param name The name to check 
-     * @return <code>true</code> if the name has composite components
-     * @throws LdapInvalidDnException If the name is invalid
-     */
-    public static boolean hasCompositeComponents( String name ) throws LdapInvalidDnException
-    {
-        for ( int ii = name.length() - 1; ii >= 0; ii-- )
-        {
-            if ( name.charAt( ii ) == '+' )
-            {
-                if ( ii == 0 )
-                {
-                    throw new LdapInvalidDnException( I18n.err( I18n.ERR_04418, name ) );
-                }
-                if ( name.charAt( ii - 1 ) != '\\' )
-                {
-                    return true;
-                }
-            }
-        }
-
-        return false;
-    }
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/NamespaceToolsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/NamespaceToolsTest.java?rev=961740&r1=961739&r2=961740&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/NamespaceToolsTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/NamespaceToolsTest.java
Thu Jul  8 12:45:09 2010
@@ -21,8 +21,6 @@ package org.apache.directory.shared.ldap
 
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 
 import org.apache.directory.junit.tools.Concurrent;
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
@@ -42,51 +40,6 @@ import org.junit.runner.RunWith;
 public class NamespaceToolsTest
 {
     @Test
-    public void testNullRealm()
-    {
-        assertEquals( "", NamespaceTools.inferLdapName( null ) );
-    }
-
-
-    @Test
-    public void testEmptyRealm()
-    {
-        assertEquals( "", NamespaceTools.inferLdapName( "" ) );
-    }
-
-
-    @Test
-    public void testSingleElemRealm()
-    {
-        assertEquals( "dc=test", NamespaceTools.inferLdapName( "test" ) );
-    }
-
-
-    @Test
-    public void testTwoElemsRealm()
-    {
-        assertEquals( "dc=test,dc=com", NamespaceTools.inferLdapName( "test.com" ) );
-    }
-
-
-    @Test
-    public void testFullRealm()
-    {
-        assertEquals( "dc=CS,dc=UCL,dc=AC,dc=UK", NamespaceTools.inferLdapName( "CS.UCL.AC.UK"
) );
-    }
-
-
-    @Test
-    public void testHasCompositeComponents() throws LdapException
-    {
-        assertTrue( NamespaceTools.hasCompositeComponents( "givenName=Alex+sn=Karasulu" )
);
-        assertTrue( NamespaceTools.hasCompositeComponents( "givenName=Alex+sn=Karasulu+age=13"
) );
-        assertFalse( NamespaceTools.hasCompositeComponents( "cn=One\\+Two" ) );
-        assertFalse( NamespaceTools.hasCompositeComponents( "cn=Alex" ) );
-    }
-
-
-    @Test
     public void testGetCompositeComponents() throws LdapException
     {
         String[] args = NamespaceTools.getCompositeComponents( "givenName=Alex+sn=Karasulu"
);



Mime
View raw message