Examples of LdifChangeModifyRecord


Examples of org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord

                LdifChangeAddRecord record = ( LdifChangeAddRecord ) element;
                return getUniqueAttrValLineArray( record.getAttrVals() );
            }
            else if ( element instanceof LdifChangeModifyRecord )
            {
                LdifChangeModifyRecord record = ( LdifChangeModifyRecord ) element;
                return record.getModSpecs();
            }
            else if ( element instanceof LdifChangeModDnRecord )
            {
                return new Object[0];
            }
View Full Code Here

Examples of org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord

        {
            if ( selectedConnection.getConnection() != null )
            {
                selectedConnection.getConnection().setReadOnly( originalReadOnlyFlag );

                LdifChangeModifyRecord record = Utils.computeDiff( selectedEntry, prototypeEntry );
                if ( record != null )
                {
                    ExecuteLdifRunnable runnable = new ExecuteLdifRunnable( selectedConnection, record
                        .toFormattedString( LdifFormatParameters.DEFAULT ), false, false );
                    IStatus status = RunnableContextRunner.execute( runnable, getContainer(), true );
                    if ( !status.isOK() )
                    {
                        selectedConnection.getConnection().setReadOnly( true );
View Full Code Here

Examples of org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord

     * @return the change modify record or null if there is no difference
     *         between the two entries
     */
    public static LdifChangeModifyRecord computeDiff( IEntry t0, IEntry t1 )
    {
        LdifChangeModifyRecord record = LdifChangeModifyRecord.create( t0.getDn().getUpName() );

        // check which attributes/values must be deleted
        for ( IAttribute oldAttr : t0.getAttributes() )
        {
            String oldAttrDesc = oldAttr.getDescription();
            IAttribute newAttr = t1.getAttribute( oldAttrDesc );
            if ( newAttr == null )
            {
                // delete whole attribute
                LdifModSpec modSpec = LdifModSpec.createDelete( oldAttrDesc );
                modSpec.finish( LdifModSpecSepLine.create() );
                record.addModSpec( modSpec );
            }
            else if ( oldAttr.getValueSize() == 1 && newAttr.getValueSize() == 1 )
            {
                // check later: replace
            }
            else
            {
                Set<String> newValues = new HashSet<String>( Arrays.asList( newAttr.getStringValues() ) );
                for ( IValue oldValue : oldAttr.getValues() )
                {
                    if ( !newValues.contains( oldValue.getStringValue() ) && !oldValue.isEmpty() )
                    {
                        LdifModSpec modSpec = LdifModSpec.createDelete( oldAttrDesc );
                        if ( oldAttr.isBinary() )
                        {
                            modSpec.addAttrVal( LdifAttrValLine.create( oldAttrDesc, oldValue.getBinaryValue() ) );
                        }
                        else
                        {
                            modSpec.addAttrVal( LdifAttrValLine.create( oldAttrDesc, oldValue.getStringValue() ) );
                        }
                        modSpec.finish( LdifModSpecSepLine.create() );
                        record.addModSpec( modSpec );
                    }
                }
            }
        }

        // check which attributes/values must be added
        for ( IAttribute newAttr : t1.getAttributes() )
        {
            String newAttrDesc = newAttr.getDescription();
            IAttribute oldAttr = t0.getAttribute( newAttrDesc );
            if ( oldAttr == null )
            {
                // add whole attribute
                LdifModSpec modSpec = LdifModSpec.createAdd( newAttrDesc );
                for ( IValue newValue : newAttr.getValues() )
                {
                    if ( !newValue.isEmpty() )
                    {
                        if ( newAttr.isBinary() )
                        {
                            modSpec.addAttrVal( LdifAttrValLine.create( newAttrDesc, newValue.getBinaryValue() ) );
                        }
                        else
                        {
                            modSpec.addAttrVal( LdifAttrValLine.create( newAttrDesc, newValue.getStringValue() ) );
                        }
                    }
                }
                modSpec.finish( LdifModSpecSepLine.create() );
                if ( modSpec.isValid() )
                {
                    record.addModSpec( modSpec );
                }
            }
            else if ( oldAttr.getValueSize() == 1 && newAttr.getValueSize() == 1 )
            {
                // check later: replace
            }
            else
            {
                Set<String> oldValues = new HashSet<String>( Arrays.asList( oldAttr.getStringValues() ) );
                for ( IValue newValue : newAttr.getValues() )
                {
                    if ( !oldValues.contains( newValue.getStringValue() ) && !newValue.isEmpty() )
                    {
                        LdifModSpec modSpec = LdifModSpec.createAdd( newAttrDesc );
                        if ( newAttr.isBinary() )
                        {
                            modSpec.addAttrVal( LdifAttrValLine.create( newAttrDesc, newValue.getBinaryValue() ) );
                        }
                        else
                        {
                            modSpec.addAttrVal( LdifAttrValLine.create( newAttrDesc, newValue.getStringValue() ) );
                        }
                        modSpec.finish( LdifModSpecSepLine.create() );
                        record.addModSpec( modSpec );
                    }
                }
            }
        }

        // check which attributes/values must be replaced
        for ( IAttribute newAttr : t1.getAttributes() )
        {
            String newAttrDesc = newAttr.getDescription();
            IAttribute oldAttr = t0.getAttribute( newAttrDesc );
            if ( oldAttr != null && oldAttr.getValueSize() == 1 && newAttr.getValueSize() == 1
                && !oldAttr.getValues()[0].getStringValue().equals( newAttr.getValues()[0].getStringValue() ) )
            {
                LdifModSpec modSpec = LdifModSpec.createReplace( newAttrDesc );
                if ( newAttr.isBinary() )
                {
                    modSpec.addAttrVal( LdifAttrValLine.create( newAttrDesc, newAttr.getValues()[0].getBinaryValue() ) );
                }
                else
                {
                    modSpec.addAttrVal( LdifAttrValLine.create( newAttrDesc, newAttr.getValues()[0].getStringValue() ) );
                }
                modSpec.finish( LdifModSpecSepLine.create() );
                record.addModSpec( modSpec );
            }
        }

        record.finish( LdifSepLine.create() );

        // check for changes: if there are no changes the record does not include
        // any modifications and so it is not valid.
        return record.isValid() ? record : null;
    }
View Full Code Here

Examples of org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord

                LdifChangeAddRecord record = ( LdifChangeAddRecord ) element;
                return getUniqueAttrValLineArray( record.getAttrVals() );
            }
            else if ( element instanceof LdifChangeModifyRecord )
            {
                LdifChangeModifyRecord record = ( LdifChangeModifyRecord ) element;
                return record.getModSpecs();
            }
            else if ( element instanceof LdifChangeModDnRecord )
            {
                return new Object[0];
            }
View Full Code Here

Examples of org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord

            browserConnection.getConnection().getJNDIConnectionWrapper().deleteEntry( dn,
                ReferralHandlingMethod.IGNORE, getControls( changeDeleteRecord ), monitor, null );
        }
        else if ( record instanceof LdifChangeModifyRecord )
        {
            LdifChangeModifyRecord modifyRecord = ( LdifChangeModifyRecord ) record;
            LdifModSpec[] modSpecs = modifyRecord.getModSpecs();
            ModificationItem[] mis = new ModificationItem[modSpecs.length];
            for ( int ii = 0; ii < modSpecs.length; ii++ )
            {
                LdifModSpecTypeLine modSpecType = modSpecs[ii].getModSpecType();
                LdifAttrValLine[] attrVals = modSpecs[ii].getAttrVals();
View Full Code Here

Examples of org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord

                    }
                    parseChangeDeleteRecord( record );
                }
                else if ( changeTypeLine.isModify() )
                {
                    record = new LdifChangeModifyRecord( dnLine );
                    append( record, partList );
                    record.setChangeType( changeTypeLine );
                    if ( !changeTypeLine.isValid() )
                    {
                        this.cleanupLine( record );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.