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

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


    private static void applyNewRdn( Attributes attributes, Rdn oldRdn, Rdn newRdn )
    {
        // remove old RDN attributes and values
        for ( Iterator<AttributeTypeAndValue> it = oldRdn.iterator(); it.hasNext(); )
        {
            AttributeTypeAndValue atav = it.next();
            Attribute attribute = attributes.get( atav.getUpType() );
            if ( attribute != null )
            {
                attribute.remove( atav.getNormValue().getString() );
                if ( attribute.size() == 0 )
                {
                    attributes.remove( atav.getUpType() );
                }
            }
        }

        // add new RDN attributes and values
        for ( Iterator<AttributeTypeAndValue> it = newRdn.iterator(); it.hasNext(); )
        {
            AttributeTypeAndValue atav = it.next();
            Attribute attribute = attributes.get( atav.getUpType() );
            if ( attribute == null )
            {
                attribute = new BasicAttribute( atav.getUpType() );
                attributes.put( attribute );
            }
            if ( !attribute.contains( atav.getNormValue().getString() ) )
            {
                attribute.add( atav.getNormValue().getString() );
            }
        }
    }
View Full Code Here


    public boolean isRdnPart()
    {
        Iterator<AttributeTypeAndValue> atavIterator = getAttribute().getEntry().getRdn().iterator();
        while ( atavIterator.hasNext() )
        {
            AttributeTypeAndValue atav = atavIterator.next();
            if ( getAttribute().getDescription().equals( atav.getUpType() )
                && getStringValue().equals( atav.getNormValue().getString() ) )
            {
                return true;
            }
        }
        return false;
View Full Code Here

            if ( newEntry.getRdn().size() > 0 )
            {
                Iterator<AttributeTypeAndValue> atavIterator = newEntry.getRdn().iterator();
                while ( atavIterator.hasNext() )
                {
                    AttributeTypeAndValue atav = atavIterator.next();
                    IAttribute attribute = newEntry.getAttribute( atav.getUpType() );
                    if ( attribute != null )
                    {
                        IValue[] values = attribute.getValues();
                        for ( int v = 0; v < values.length; v++ )
                        {
                            if ( values[v].getStringValue().equals( atav.getNormValue().getString() ) )
                            {
                                attribute.deleteValue( values[v] );
                            }
                        }

                        // If we have removed all the values of the attribute,
                        // then we also need to remove this attribute from the
                        // entry.
                        // This test has been added to fix DIRSTUDIO-222
                        if ( attribute.getValueSize() == 0 )
                        {
                            newEntry.deleteAttribute( attribute );
                        }
                    }
                }
            }

            // set new DN
            LdapDN dn;
            if ( wizard.isNewContextEntry() )
            {
                try
                {
                    dn = new LdapDN( contextEntryDnCombo.getText() );
                }
                catch ( InvalidNameException e )
                {
                    dn = LdapDN.EMPTY_LDAPDN;
                }
            }
            else
            {
                dn = DnUtils.composeDn( dnBuilderWidget.getRdn(), dnBuilderWidget.getParentDn() );
            }
            newEntry.setDn( dn );

            // add new RDN
            if ( dn.getRdn().size() > 0 )
            {
                Iterator<AttributeTypeAndValue> atavIterator = dn.getRdn().iterator();
                while ( atavIterator.hasNext() )
                {
                    AttributeTypeAndValue atav = atavIterator.next();
                    IAttribute rdnAttribute = newEntry.getAttribute( atav.getUpType() );
                    if ( rdnAttribute == null )
                    {
                        rdnAttribute = new Attribute( newEntry, atav.getUpType() );
                        newEntry.addAttribute( rdnAttribute );
                    }
                    Object rdnValue = atav.getNormValue().getString();
                    String[] stringValues = rdnAttribute.getStringValues();
                    if ( !Arrays.asList( stringValues ).contains( rdnValue ) )
                    {
                        rdnAttribute.addValue( new Value( rdnAttribute, rdnValue ) );
                    }
View Full Code Here

            {
                int i = 0;
                Iterator<AttributeTypeAndValue> atavIterator = currentRdn.iterator();
                while ( atavIterator.hasNext() )
                {
                    AttributeTypeAndValue atav = atavIterator.next();
                    addRdnLine( rdnComposite, i );
                    rdnLineList.get( i ).rdnTypeCombo.setText( atav.getUpType() );
                    rdnLineList.get( i ).rdnValueText.setText( atav.getNormValue().getString() );
                    if ( i == 0 )
                    {
                        if ( "".equals( rdnLineList.get( i ).rdnTypeCombo ) ) //$NON-NLS-1$
                        {
                            rdnLineList.get( i ).rdnTypeCombo.setFocus();
View Full Code Here

        StringBuffer sb = new StringBuffer();

        Iterator<AttributeTypeAndValue> it = rdn.iterator();
        while ( it.hasNext() )
        {
            AttributeTypeAndValue atav = it.next();
            sb.append( getOidString( atav, schema ) );
            if ( it.hasNext() )
            {
                sb.append( '+' );
            }
View Full Code Here

        {
            Rdn rdn = entry.getRdn();
            Iterator<AttributeTypeAndValue> atavIterator = rdn.iterator();
            while ( atavIterator.hasNext() )
            {
                AttributeTypeAndValue atav = atavIterator.next();
                if ( "cn".equalsIgnoreCase( atav.getUpType() ) || "sn".equalsIgnoreCase( atav.getUpType() )
                    || "uid".equalsIgnoreCase( atav.getUpType() ) || "userid".equalsIgnoreCase( atav.getUpType() ) )
                {
                    return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_ENTRY_PERSON );
                }
                else if ( "ou".equalsIgnoreCase( atav.getUpType() ) || "o".equalsIgnoreCase( atav.getUpType() ) )
                {
                    return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_ENTRY_ORG );
                }
                else if ( "dc".equalsIgnoreCase( atav.getUpType() ) || "c".equalsIgnoreCase( atav.getUpType() )
                    || "l".equalsIgnoreCase( atav.getUpType() ) )
                {
                    return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_ENTRY_DC );
                }
            }
        }
View Full Code Here

    private static void applyNewRdn(Attributes attributes, Rdn oldRdn, Rdn newRdn)
    {
        // remove old RDN attributes and values
        for ( Iterator<AttributeTypeAndValue> it = oldRdn.iterator(); it.hasNext(); )
        {
            AttributeTypeAndValue atav = it.next();
            Attribute attribute = attributes.get( atav.getUpType() );
            if ( attribute != null )
            {
                attribute.remove( atav.getUpValue() );
                if ( attribute.size() == 0 )
                {
                    attributes.remove( atav.getUpType() );
                }
            }
        }
       
        // add new RDN attributes and values
        for ( Iterator<AttributeTypeAndValue> it = newRdn.iterator(); it.hasNext(); )
        {
            AttributeTypeAndValue atav = it.next();
            Attribute attribute = attributes.get( atav.getUpType() );
            if ( attribute == null )
            {
                attribute = new BasicAttribute( atav.getUpType() );
                attributes.put( attribute );
            }
            if ( !attribute.contains( atav.getUpValue() ) )
            {
                attribute.add( atav.getUpValue() );
            }
        }
    }
View Full Code Here

            // check if (part of) RDN is selected
            Iterator<AttributeTypeAndValue> atavIterator = value.getAttribute().getEntry().getRdn().iterator();
            while ( atavIterator.hasNext() )
            {
                AttributeTypeAndValue atav = atavIterator.next();
                if ( value.getAttribute().getDescription().equals( atav.getUpType() )
                    && value.getStringValue().equals( atav.getUpValue() ) )
                {
                    throw new Exception();
                }
            }
View Full Code Here

            {
                int i = 0;
                Iterator<AttributeTypeAndValue> atavIterator = currentRdn.iterator();
                while(atavIterator.hasNext())
                {
                    AttributeTypeAndValue atav = atavIterator.next();
                    addRdnLine( rdnComposite, i );
                    rdnLineList.get( i ).rdnTypeCombo.setText( atav.getUpType() );
                    rdnLineList.get( i ).rdnValueText.setText( ( String ) atav.getUpValue() );
                    if ( i == 0 )
                    {
                        if ( "".equals( rdnLineList.get( i ).rdnTypeCombo ) )
                        {
                            rdnLineList.get( i ).rdnTypeCombo.setFocus();
View Full Code Here

    private static void applyNewRdn(Attributes attributes, Rdn oldRdn, Rdn newRdn)
    {
        // remove old RDN attributes and values
        for ( Iterator<AttributeTypeAndValue> it = oldRdn.iterator(); it.hasNext(); )
        {
            AttributeTypeAndValue atav = it.next();
            Attribute attribute = attributes.get( atav.getUpType() );
            if ( attribute != null )
            {
                attribute.remove( atav.getUpValue() );
                if ( attribute.size() == 0 )
                {
                    attributes.remove( atav.getUpType() );
                }
            }
        }
       
        // add new RDN attributes and values
        for ( Iterator<AttributeTypeAndValue> it = newRdn.iterator(); it.hasNext(); )
        {
            AttributeTypeAndValue atav = it.next();
            Attribute attribute = attributes.get( atav.getUpType() );
            if ( attribute == null )
            {
                attribute = new BasicAttribute( atav.getUpType() );
                attributes.put( attribute );
            }
            if ( !attribute.contains( atav.getUpValue() ) )
            {
                attribute.add( atav.getUpValue() );
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.name.AttributeTypeAndValue

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.