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

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


        {
            throw new NamingException( I18n.err( I18n.ERR_313, lide.getMessage() ) );
        }


        RDN oldRdn = oldDn.getRdn();
        RDN newRdn = newDn.getRdn();
        boolean delOldRdn = true;

        /*
         * Attempt to use the java.naming.ldap.deleteRDN environment property
         * to get an override for the deleteOldRdn option to modifyRdn. 
         */
        if ( null != env.get( DELETE_OLD_RDN_PROP ) )
        {
            String delOldRdnStr = ( String ) env.get( DELETE_OLD_RDN_PROP );
            delOldRdn = !delOldRdnStr.equalsIgnoreCase( "false" ) && !delOldRdnStr.equalsIgnoreCase( "no" )
                && !delOldRdnStr.equals( "0" );
        }

        /*
         * We need to determine if this rename operation corresponds to a simple
         * RDN name change or a move operation.  If the two names are the same
         * except for the RDN then it is a simple modifyRdn operation.  If the
         * names differ in size or have a different baseDN then the operation is
         * a move operation.  Furthermore if the RDN in the move operation
         * changes it is both an RDN change and a move operation.
         */
        if ( oldParent.equals( newParent ) )
        {
            try
            {
                doRename( oldDn, newRdn, delOldRdn );
            }
            catch ( Exception e )
            {
                JndiUtils.wrap( e );
            }
        }
        else
        {
            if ( newRdn.equals( oldRdn ) )
            {
                try
                {
                    doMove( oldDn, newParent );
                }
View Full Code Here



    public void rename( NextInterceptor next, RenameOperationContext opContext ) throws Exception
    {
        DN oldDn = opContext.getDn();
        RDN newRdn = opContext.getNewRdn();
        boolean deleteOldRn = opContext.getDelOldDn();
        ServerEntry entry =  (ServerEntry)opContext.getEntry().getClonedEntry();

        /*
         *  Note: This is only a consistency checks, to the ensure that all
         *  mandatory attributes are available after deleting the old RDN.
         *  The real modification is done in the XdbmStore class.
         *  - TODO: this check is missing in the moveAndRename() method
         */
        if ( deleteOldRn )
        {
            ServerEntry tmpEntry = ( ServerEntry ) entry.clone();
            RDN oldRDN = oldDn.getRdn();

            // Delete the old RDN means we remove some attributes and values.
            // We must make sure that after this operation all must attributes
            // are still present in the entry.
            for ( AVA atav : oldRDN )
View Full Code Here

        if ( dn.size() < 2 )
        {
            throw new LdapException( I18n.err( I18n.ERR_276 ) );
        }
       
        RDN rdn = dn.getRdn( 1 );
        return ( String ) rdn.getNormValue();
    }
View Full Code Here

        if ( dn == null || entry == null )
        {
            return;
        }

        RDN rdn = dn.getRdn();

        // Loop on all the AVAs
        for ( AVA ava : rdn )
        {
            Value<?> value = ava.getNormValue();
View Full Code Here

        {
            return ( DirContext ) super.createSubcontext( name );
        }

        DN target = buildTarget( DN.fromName( name ) );
        RDN rdn = target.getRdn( target.size() - 1 );

        attrs = AttributeUtils.toCaseInsensitive( attrs );
        Attributes attributes = ( Attributes ) attrs.clone();

        if ( rdn.size() == 1 )
        {
            String rdnAttribute = rdn.getUpType();
            String rdnValue = ( String ) rdn.getNormValue();

            // Add the RDN attribute
            boolean doRdnPut = attributes.get( rdnAttribute ) == null;
            doRdnPut = doRdnPut || attributes.get( rdnAttribute ).size() == 0;

            // TODO Fix DIRSERVER-832
            doRdnPut = doRdnPut || !attributes.get( rdnAttribute ).contains( rdnValue );

            if ( doRdnPut )
            {
                attributes.put( rdnAttribute, rdnValue );
            }
        }
        else
        {
            for ( Iterator<AVA> ii = rdn.iterator(); ii.hasNext(); /**/)
            {
                AVA atav = ii.next();

                // Add the RDN attribute
                boolean doRdnPut = attributes.get( atav.getNormType() ) == null;
View Full Code Here

    {
        DN newDn = new DN();
       
        for ( int ii = 0; ii < dn.size(); ii++ )
        {
            RDN rdn = dn.getRdn( ii );
            if ( rdn.size() == 0 )
            {
                newDn.add( new RDN() );
                continue;
            }
            else if ( rdn.size() == 1 )
            {
                String name = schemaManager.lookupAttributeTypeRegistry( rdn.getNormType() ).getName();
                String value = rdn.getAtav().getNormValue().getString();
                newDn.add( new RDN( name, name, value, value ) );
                continue;
            }

            // below we only process multi-valued rdns
            StringBuffer buf = new StringBuffer();
       
            for ( Iterator<AVA> atavs = rdn.iterator(); atavs.hasNext(); /**/ )
            {
                AVA atav = atavs.next();
                String type = schemaManager.lookupAttributeTypeRegistry( rdn.getNormType() ).getName();
                buf.append( type ).append( '=' ).append( atav.getNormValue() );
               
                if ( atavs.hasNext() )
                {
                    buf.append( '+' );
                }
            }
           
            newDn.add( new RDN(buf.toString()) );
        }
       
        return newDn;
    }
View Full Code Here

        CoreSession session = injectEntries();

        DN childDn1 = new DN( "dc=child1,ou=test,ou=system" );
        childDn1.normalize( schemaManager.getNormalizerMapping() );
       
        RDN newRdn = new RDN( SchemaConstants.DC_AT + "=" + "renamedChild1" );
        RenameOperationContext renameOpCtx = new RenameOperationContext( session, childDn1, newRdn, true );
        partition.rename( renameOpCtx );
       
        assertFalse( new File( wkdir, "ou=test,ou=system/dc=child1" ).exists() );
        assertFalse( new File( wkdir, "ou=test,ou=system/dc=child1.ldif" ).exists() );
View Full Code Here

        CoreSession session = injectEntries();

        DN childDn1 = new DN( "dc=child1,ou=test,ou=system" );
        childDn1.normalize( schemaManager.getNormalizerMapping() );
       
        RDN newRdn = new RDN( SchemaConstants.DC_AT + "=" + "renamedChild1" );
        RenameOperationContext renameOpCtx = new RenameOperationContext( session, childDn1, newRdn, false );
        partition.rename( renameOpCtx );
       
        assertFalse( new File( wkdir, "ou=test,ou=system/dc=child1" ).exists() );
        assertFalse( new File( wkdir, "ou=test,ou=system/dc=child1.ldif" ).exists() );
View Full Code Here

        childDn1.normalize( schemaManager.getNormalizerMapping() );

        DN childDn2 = new DN( "dc=child2,ou=test,ou=system" );
        childDn2.normalize( schemaManager.getNormalizerMapping() );

        RDN newRdn = new RDN( SchemaConstants.DC_AT + "=" + "movedChild1" );
        MoveAndRenameOperationContext moveAndRenameOpCtx = new MoveAndRenameOperationContext( session, childDn1, childDn2, newRdn, true );
        partition.moveAndRename( moveAndRenameOpCtx );
       
        assertFalse( new File( wkdir, "ou=test,ou=system/dc=child1" ).exists() );
        assertFalse( new File( wkdir, "ou=test,ou=system/dc=child1.ldif" ).exists() );
View Full Code Here

        childDn1.normalize( schemaManager.getNormalizerMapping() );

        DN childDn2 = new DN( "dc=child2,ou=test,ou=system" );
        childDn2.normalize( schemaManager.getNormalizerMapping() );

        RDN newRdn = new RDN( SchemaConstants.DC_AT + "=" + "movedChild1" );
        MoveAndRenameOperationContext moveAndRenameOpCtx = new MoveAndRenameOperationContext( session, childDn1, childDn2, newRdn, false );
        partition.moveAndRename( moveAndRenameOpCtx );
       
        assertFalse( new File( wkdir, "ou=test,ou=system/dc=child1" ).exists() );
        assertFalse( new File( wkdir, "ou=test,ou=system/dc=child1.ldif" ).exists() );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.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.