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

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


            System.out.println( "Modify DN of entry " + dn );
        }

        modifyDNRequest.setEntry( new DN( dn ) );
        modifyDNRequest.setDeleteOldRDN( entry.isDeleteOldRdn() );
        modifyDNRequest.setNewRDN( new RDN( entry.getNewRdn() ) );

        if ( StringTools.isEmpty( entry.getNewSuperior() ) == false )
        {
            modifyDNRequest.setNewSuperior( new DN( entry.getNewSuperior() ) );
        }
View Full Code Here


            while ( !monitor.isCanceled() && entries.hasMore() )
            {
                // get next entry to copy
                SearchResult sr = entries.next();
                LdapDN oldLdapDn = JNDIUtils.getDn( sr );
                Rdn oldRdn = oldLdapDn.getRdn();

                // reuse attributes of the entry to copy
                Attributes newAttributes = sr.getAttributes();

                // compose new DN
                Rdn newRdn = oldLdapDn.getRdn();
                if ( forceNewRdn != null )
                {
                    newRdn = forceNewRdn;
                }
                LdapDN newLdapDn = DnUtils.composeDn( newRdn, parentDn );

                // apply new RDN to the attributes
                applyNewRdn( newAttributes, oldRdn, newRdn );

                // ManageDsaIT control
                Control[] controls = null;
                if ( newAttributes.get( SchemaConstants.OBJECT_CLASS_AT ) != null
                    && newAttributes.get( SchemaConstants.OBJECT_CLASS_AT ).contains( SchemaConstants.REFERRAL_OC ) )
                {
                    controls = new Control[]
                        { new ManageReferralControl( false ) };
                }

                // create entry
                targetBrowserConnection.getConnection().getJNDIConnectionWrapper().createEntry( newLdapDn.getUpName(),
                    newAttributes, controls, dummyMonitor, null );

                while ( dummyMonitor.errorsReported() )
                {
                    if ( dialog != null && dummyMonitor.getException() instanceof NameAlreadyBoundException )
                    {
                        // open dialog
                        dialog.setExistingEntry( targetBrowserConnection, newLdapDn );
                        dialog.open();
                        EntryExistsCopyStrategy strategy = dialog.getStrategy();
                        //                        boolean rememberSelection = dialog.isRememberSelection();
                        if ( strategy != null )
                        {
                            dummyMonitor.reset();

                            switch ( strategy )
                            {
                                case BREAK:
                                    monitor.setCanceled( true );
                                    break;

                                case IGNORE_AND_CONTINUE:
                                    break;

                                case OVERWRITE_AND_CONTINUE:
                                    // create modification items
                                    List<ModificationItem> mis = new ArrayList<ModificationItem>();
                                    NamingEnumeration<? extends Attribute> all = newAttributes.getAll();
                                    while ( all.hasMore() )
                                    {
                                        Attribute attribute = all.next();
                                        ModificationItem mi = new ModificationItem( DirContext.REPLACE_ATTRIBUTE,
                                            attribute );
                                        mis.add( mi );
                                    }

                                    // modify entry
                                    targetBrowserConnection.getConnection().getJNDIConnectionWrapper().modifyEntry(
                                        newLdapDn.getUpName(), mis.toArray( new ModificationItem[mis.size()] ), null,
                                        dummyMonitor, null );

                                    // force reloading of attributes
                                    IEntry newEntry = targetBrowserConnection.getEntryFromCache( newLdapDn );
                                    if ( newEntry != null )
                                    {
                                        newEntry.setAttributesInitialized( false );
                                    }

                                    break;

                                case RENAME_AND_CONTINUE:
                                    Rdn renamedRdn = dialog.getRdn();

                                    // apply renamed RDN to the attributes
                                    applyNewRdn( newAttributes, newRdn, renamedRdn );

                                    // compose new DN
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Rdn getRdn()
    {
        Rdn rdn = getDn().getRdn();
        return rdn == null ? new Rdn() : rdn;
    }
View Full Code Here

        {
            return getDelegate().getRdn();
        }
        else
        {
            Rdn rdn = dn.getRdn();
            return rdn == null ? new Rdn() : rdn;
        }
    }
View Full Code Here

     * @param entry2 the second entry
     * @return a negative integer, zero, or a positive integer
     */
    private int compareRdns( IEntry entry1, IEntry entry2 )
    {
        Rdn rdn1 = entry1.getRdn();
        Rdn rdn2 = entry2.getRdn();

        if ( rdn1 == null && rdn2 == null )
        {
            return equal();
        }
        else if ( rdn1 == null && rdn2 != null )
        {
            return greaterThan();
        }
        else if ( rdn1 != null && rdn2 == null )
        {
            return lessThan();
        }
        else
        {
            return compare( rdn1.getUpName(), rdn2.getUpName() );
        }
    }
View Full Code Here

     * @param entry2 the second entry
     * @return a negative integer, zero, or a positive integer
     */
    private int compareRdnValues( IEntry entry1, IEntry entry2 )
    {
        Rdn rdn1 = entry1.getRdn();
        Rdn rdn2 = entry2.getRdn();

        if ( ( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue() ) ) //$NON-NLS-1$
            && ( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue() ) ) ) //$NON-NLS-1$
        {
            return equal();
        }
        else if ( ( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue() ) ) //$NON-NLS-1$
            && !( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue() ) ) ) //$NON-NLS-1$
        {
            return greaterThan();
        }
        else if ( !( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue() ) ) //$NON-NLS-1$
            && ( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue() ) ) ) //$NON-NLS-1$
        {
            return lessThan();
        }

        String rdn1Value = ( String ) rdn1.getUpValue();
        String rdn2Value = ( String ) rdn2.getUpValue();
        if ( rdn1Value.matches( "\\d*" ) && !rdn2Value.matches( "\\d*" ) ) //$NON-NLS-1$ //$NON-NLS-2$
        {
            // return lessThan();
            return compare( rdn1Value, rdn2Value );
        }
View Full Code Here

    protected void renameEntry( final IEntry entry )
    {
        RenameEntryDialog renameDialog = new RenameEntryDialog( getShell(), entry );
        if ( renameDialog.open() == Dialog.OK )
        {
            Rdn newRdn = renameDialog.getRdn();
            if ( newRdn != null && !newRdn.equals( entry.getRdn() ) )
            {
                new RenameEntryJob( entry, newRdn, new SimulateRenameDialogImpl( getShell() ) ).execute();
            }
        }
    }
View Full Code Here

     *
     * @throws InvalidNameException the invalid name exception
     */
    public static LdapDN composeDn( String rdn, String parent ) throws InvalidNameException
    {
        return composeDn( new Rdn( rdn ), new LdapDN( parent ) );
    }
View Full Code Here

        String s = sb.toString();
        try
        {
            if ( LdapDN.isValid( s ) )
            {
                Rdn rdn = new Rdn( sb.toString() );
                return rdn;
            }
        }
        catch ( Exception e )
        {
View Full Code Here

            else if ( DnUtils.getParent( newEntry.getDn() ) != null )
            {
                parentDn = DnUtils.getParent( newEntry.getDn() );
            }

            Rdn rdn = newEntry.getRdn();

            dnBuilderWidget.setInput( wizard.getSelectedConnection(), attributeNames, rdn, parentDn );
        }
    }
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.