You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Emmanuel Lecharny (JIRA)" <ji...@apache.org> on 2007/04/21 13:08:17 UTC

[jira] Closed: (DIRSERVER-191) LdapName.getPrefix(int) does not return prefix.

     [ https://issues.apache.org/jira/browse/DIRSERVER-191?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny closed DIRSERVER-191.
---------------------------------------


Closing all issues created in 2005 and before which are marked resolved

> LdapName.getPrefix(int) does not return prefix.
> -----------------------------------------------
>
>                 Key: DIRSERVER-191
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-191
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: ldap
>         Environment: NA
>            Reporter: Jacob S. Barrett
>         Assigned To: Alex Karasulu
>            Priority: Critical
>             Fix For: 1.5.0
>
>         Attachments: LdapName.patch, NamespaceTools.patch, NamespaceToolsTest.java, NameTest.java
>
>
> The JavaDoc for javax.naming.Name.getPrefix(int) [1] states that it returns "a name consisting of the components at indexes in the range [0,posn)."  The implementation in org.apache.ldap.common.name.LdapName returns [size() - posn, size()).  This is a suffix starting from the right like the getSuffix(int) which is a suffix from from the left.  The correct implementation should return the prefix from the left to the specified position.  Attached is the appropiate patch for LdapName.java and LdapNameTest.java.
> References:
> 1) http://java.sun.com/j2se/1.4.2/docs/api/javax/naming/Name.html#getPrefix(int)
> Patch:
> Index: shared/ldap/trunk/common/src/test/org/apache/ldap/common/name/LdapNameTest.java
> ===================================================================
> --- shared/ldap/trunk/common/src/test/org/apache/ldap/common/name/LdapNameTest.java	(revision 158112)
> +++ shared/ldap/trunk/common/src/test/org/apache/ldap/common/name/LdapNameTest.java	(working copy)
> @@ -545,10 +545,10 @@
>          Name l_name = 
>              m_parser.parse( "cn=HomeDir,cn=John,ou=Marketing,ou=East" ) ;
>          assertEquals( "", l_name.getPrefix( 0 ).toString() ) ;
> -        assertEquals( "ou=East", l_name.getPrefix( 1 ).toString() ) ;
> -        assertEquals( "ou=Marketing,ou=East", 
> +        assertEquals( "cn=HomeDir", l_name.getPrefix( 1 ).toString() ) ;
> +        assertEquals( "cn=HomeDir,cn=John", 
>              l_name.getPrefix( 2 ).toString() ) ;
> -        assertEquals( "cn=John,ou=Marketing,ou=East", 
> +        assertEquals( "cn=HomeDir,cn=John,ou=Marketing", 
>              l_name.getPrefix( 3 ).toString() ) ;
>          assertEquals( "cn=HomeDir,cn=John,ou=Marketing,ou=East", 
>              l_name.getPrefix( 4 ).toString() ) ;
> Index: shared/ldap/trunk/common/src/java/org/apache/ldap/common/name/LdapName.java
> ===================================================================
> --- shared/ldap/trunk/common/src/java/org/apache/ldap/common/name/LdapName.java	(revision 158112)
> +++ shared/ldap/trunk/common/src/java/org/apache/ldap/common/name/LdapName.java	(working copy)
> @@ -327,7 +327,7 @@
>      public Name getPrefix( int a_posn )
>      {
>          ArrayList list = new ArrayList();
> -        list.addAll( m_list.subList( size() - a_posn, size() ) );
> +        list.addAll( m_list.subList( 0, a_posn ) );
>          return new LdapName( list ) ;
>      }
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.