You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2005/06/27 00:28:05 UTC
svn commit: r201917 -
/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java
Author: akarasulu
Date: Sun Jun 26 15:28:03 2005
New Revision: 201917
URL: http://svn.apache.org/viewcvs?rev=201917&view=rev
Log:
corrected a horribly defective method which computes the relative dn with respect to a ancestor and a descendant
Modified:
directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java
Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java?rev=201917&r1=201916&r2=201917&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java Sun Jun 26 15:28:03 2005
@@ -406,31 +406,29 @@
/**
- * Gets the relative name between a context and the distinguished name of a
- * descendant context below the base.
+ * Gets the relative name between an ancestor and a potential descendant. Both name
+ * arguments must be normalized. The returned name is also normalized.
*
- * @param base the context containing the entry referred to by the dn
- * @param dn the distinguished name of the descendant context
- * @return the relatve name between the base and the descendant entry
- * @throws javax.naming.NamingException if the base is not an ancestor of the entry
- * specified by the dn parameter
+ * @param ancestor the normalized distinguished name of the ancestor context
+ * @param descendant the normalized distinguished name of the descendant context
+ * @return the relatve normalized name between the ancestor and the descendant contexts
+ * @throws javax.naming.NamingException if the contexts are not related in the
+ * ancestual sense
*/
- public static Name getRelativeName( Context base, String dn ) throws NamingException
+ public static Name getRelativeName( LdapName ancestor, LdapName descendant ) throws NamingException
{
- LdapName rdn = new LdapName( dn );
+ LdapName rdn = new LdapName( descendant.toString() );
- LdapName baseDn = new LdapName( base.getNameInNamespace() );
-
- if ( rdn.startsWith( baseDn ) )
+ if ( rdn.startsWith( ancestor ) )
{
- for ( int ii = 0; ii < baseDn.size(); ii++ )
+ for ( int ii = 0; ii < ancestor.size(); ii++ )
{
rdn.remove( 0 );
}
}
else
{
- NamingException e = new NamingException( dn + " is not a subordinate of context:" + baseDn.toString() );
+ NamingException e = new NamingException( descendant + " is not ancestually related to context:" + ancestor );
throw e;
}