int op = DirContext.REPLACE_ATTRIBUTE; Attribute opAttr = entry.get( SUBENTRY_OPATTRS[ii] ); if ( opAttr != null ) { opAttr = ( Attribute ) opAttr.clone(); } else { op = DirContext.ADD_ATTRIBUTE; opAttr = new LockableAttributeImpl( SUBENTRY_OPATTRS[ii] ); }
int op = DirContext.ADD_ATTRIBUTE; Attribute opAttr = new LockableAttributeImpl( SUBENTRY_OPATTRS[ii] );
    private ModificationItem[] getModsOnEntryRdnChange( Name oldName, Name newName, Attributes entry )        throws NamingException    {        Attribute objectClasses = entry.get( "objectClass" );        List modList = new ArrayList();        /*         * There are two different situations warranting action.  Firt if         * an ss evalutating to true with the old name no longer evalutates         * to true with the new name.  This would be caused by specific chop         * exclusions that effect the new name but did not effect the old         * name. In this case we must remove subentry operational attribute         * values associated with the dn of that subentry.         *         * In the second case an ss selects the entry with the new name when         * it did not previously with the old name.  Again this situation         * would be caused by chop exclusions. In this case we must add subentry         * operational attribute values with the dn of this subentry.         */        Iterator subentries = subtrees.keySet().iterator();        while ( subentries.hasNext() )        {            String subentryDn = ( String ) subentries.next();            Name apDn = new LdapName( subentryDn );            apDn.remove( apDn.size() - 1 );            SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( subentryDn );            boolean isOldNameSelected = evaluator.evaluate( ss, apDn, oldName, objectClasses );            boolean isNewNameSelected = evaluator.evaluate( ss, apDn, newName, objectClasses );            if ( isOldNameSelected == isNewNameSelected )            {                continue;            }            // need to remove references to the subentry            if ( isOldNameSelected && !isNewNameSelected )            {                for ( int ii = 0; ii < SUBENTRY_OPATTRS.length; ii++ )                {                    int op = DirContext.REPLACE_ATTRIBUTE;                    Attribute opAttr = entry.get( SUBENTRY_OPATTRS[ii] );                    if ( opAttr != null )                    {                        opAttr = ( Attribute ) opAttr.clone();                        opAttr.remove( subentryDn );                        if ( opAttr.size() < 1 )                        {                            op = DirContext.REMOVE_ATTRIBUTE;                        }                        modList.add( new ModificationItem( op, opAttr ) );                    }                }            }            // need to add references to the subentry            else if ( isNewNameSelected && !isOldNameSelected )            {                for ( int ii = 0; ii < SUBENTRY_OPATTRS.length; ii++ )                {                    int op = DirContext.REPLACE_ATTRIBUTE;                    Attribute opAttr = entry.get( SUBENTRY_OPATTRS[ii] );                    if ( opAttr != null )                    {                        opAttr = ( Attribute ) opAttr.clone();                    }                    else                    {                        op = DirContext.ADD_ATTRIBUTE;                        opAttr = new LockableAttributeImpl( SUBENTRY_OPATTRS[ii] );                    }                    opAttr.add( subentryDn );                    modList.add( new ModificationItem( op, opAttr ) );                }            }        }        ModificationItem[] mods = new ModificationItem[modList.size()];        mods = ( ModificationItem[] ) modList.toArray( mods );        return mods;    }