Package org.apache.directory.shared.ldap.model.name

Examples of org.apache.directory.shared.ldap.model.name.Rdn


        {
            throw new IllegalArgumentException( I18n.err( I18n.ERR_12079 ) );
        }

        parentDn = entry.getDn();
        Rdn oldRdn = parentDn.getRdn();

        newDn = parentDn;
        newDn = newDn.getParent();
        newDn = newDn.add( newRdn );

        List<LdifEntry> entries = new ArrayList<LdifEntry>( 1 );
        LdifEntry reverted = new LdifEntry();

        // Start with the cases here
        if ( newRdn.size() == 1 )
        {
            // We have a simple new Rdn, something like A=a
            if ( ( oldRdn.size() == 1 ) && ( oldRdn.equals( newRdn ) ) )
            {
                // We have a simple old Rdn, something like A=a
                // If the values overlap, we can't rename the entry, just get out
                // with an error
                throw new LdapInvalidDnException( I18n.err( I18n.ERR_12080 ) );
            }

            reverted = revertEntry( entry, newDn, newSuperior, oldRdn, newRdn );

            entries.add( reverted );
        }
        else
        {
            // We have a composite new Rdn, something like A=a+B=b
            if ( oldRdn.size() == 1 )
            {
                // The old Rdn is simple
                boolean overlapping = false;
                boolean existInEntry = false;

                // Does it overlap ?
                // Is the new Rdn AVAs contained into the entry?
                for ( Ava atav : newRdn )
                {
                    if ( atav.equals( oldRdn.getAva() ) )
                    {
                        // They overlap
                        overlapping = true;
                    }
                    else
View Full Code Here


                }

                // Check the newRdn value
                try
                {
                    Rdn thisNewRdn = new Rdn( newRdn );
                    Rdn entryNewRdn = new Rdn( otherEntry.newRdn );

                    if ( !thisNewRdn.equals( entryNewRdn ) )
                    {
                        return false;
                    }
View Full Code Here

    @Test
    public void testReverseModifyDNMove() throws LdapException
    {
        Dn dn = new Dn( "cn=john doe, dc=example, dc=com" );
        Dn newSuperior = new Dn( "ou=system" );
        Rdn rdn = new Rdn( "cn=john doe" );

        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
        attrs.get( "objectClass" ).add( "uidObject" );
        attrs.put( "cn", "john doe" );
        attrs.put( "cn", "jack doe" );
        attrs.put( "sn", "doe" );
        attrs.put( "uid", "jdoe" );

        LdifEntry reversed = LdifRevertor.reverseMove( newSuperior, dn );

        assertNotNull( reversed );
       
        assertEquals( "cn=john doe,ou=system", reversed.getDn().getName() );
        assertEquals( ChangeType.ModDn, reversed.getChangeType() );
        assertFalse( reversed.isDeleteOldRdn() );
        assertEquals( rdn.getName(), reversed.getNewRdn() );
        assertEquals( "dc=example, dc=com", Strings.trim(reversed.getNewSuperior()) );
        assertNull( reversed.getEntry() );
    }
View Full Code Here

     */
    @Test
    public void test11ReverseRenameSimpleSimpleNotOverlappingKeepOldRdnDontExistInEntry() throws LdapException
    {
        Dn dn = new Dn( "cn=test,ou=system" );
        Rdn oldRdn = new Rdn( "cn=test" );
        Rdn newRdn = new Rdn( "cn=joe" );

        Entry entry = new DefaultEntry( dn );
        entry.put( "cn", "test" );
        entry.put( "objectClass", "person", "top" );
        entry.put( "sn", "this is a test" );
View Full Code Here

     */
    @Test
    public void test12ReverseRenameSimpleSimpleNotOverlappingKeepOldRdnExistInEntry() throws LdapException
    {
        Dn dn = new Dn( "cn=test,ou=system" );
        Rdn oldRdn = new Rdn( "cn=test" );
        Rdn newRdn = new Rdn( "cn=small" );

        Entry entry = new DefaultEntry( dn );
        entry.put( "cn", "test", "small" );
        entry.put( "objectClass", "person", "top" );
        entry.put( "sn", "this is a test" );
View Full Code Here

     */
    @Test
    public void test21ReverseRenameSimpleSimpleNotOverlappingDeleteOldRdnDontExistInEntry() throws LdapException
    {
        Dn dn = new Dn( "cn=test,ou=system" );
        Rdn oldRdn = new Rdn( "cn=test" );
        Rdn newRdn = new Rdn( "cn=joe" );

        Entry entry = new DefaultEntry( dn );
        entry.put( "cn", "test" );
        entry.put( "objectClass", "person", "top" );
        entry.put( "sn", "this is a test" );
View Full Code Here

     */
    @Test
    public void test22ReverseRenameSimpleSimpleNotOverlappingDeleteOldRdnExistInEntry() throws LdapException
    {
        Dn dn = new Dn( "cn=test,ou=system" );
        Rdn oldRdn = new Rdn( "cn=test" );
        Rdn newRdn = new Rdn( "cn=small" );

        Entry entry = new DefaultEntry( dn );
        entry.put( "cn", "test", "small" );
        entry.put( "objectClass", "person", "top" );
        entry.put( "sn", "this is a test" );
View Full Code Here

     */
    @Test
    public void test3ReverseRenameCompositeSimpleNotOverlappingKeepOldRdnDontExistInEntry() throws LdapException
    {
        Dn dn = new Dn( "cn=small+cn=test,ou=system" );
        Rdn oldRdn = new Rdn( "cn=small+cn=test" );
        Rdn newRdn = new Rdn( "cn=joe" );

        Entry entry = new DefaultEntry( dn );
        entry.put( "cn", "test", "small" );
        entry.put( "objectClass", "person", "top" );
        entry.put( "sn", "this is a test" );
View Full Code Here

     */
    @Test
    public void test3ReverseRenameCompositeSimpleNotOverlappingKeepOldRdnExistsInEntry() throws LdapException
    {
        Dn dn = new Dn( "cn=small+cn=test,ou=system" );
        Rdn oldRdn = new Rdn( "cn=small+cn=test" );
        Rdn newRdn = new Rdn( "cn=big" );

        Entry entry = new DefaultEntry( dn );
        entry.put( "cn", "test", "small", "big" );
        entry.put( "objectClass", "person", "top" );
        entry.put( "sn", "this is a test" );
View Full Code Here

     */
    @Test
    public void test4ReverseRenameCompositeSimpleNotOverlappingDeleteOldRdnDontExistsInEntry() throws LdapException
    {
        Dn dn = new Dn( "cn=small+cn=test,ou=system" );
        Rdn oldRdn = new Rdn( "cn=small+cn=test" );
        Rdn newRdn = new Rdn( "cn=joe" );

        Entry entry = new DefaultEntry( dn );
        entry.put( "cn", "test", "small" );
        entry.put( "objectClass", "person", "top" );
        entry.put( "sn", "this is a test" );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.name.Rdn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.