Package org.apache.directory.studio.ldapbrowser.core.model.impl

Examples of org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry


     * Initializes the DN builder widget with the DN of
     * the prototype entry. Called when this page becomes visible.
     */
    private void loadState()
    {
        DummyEntry newEntry = wizard.getPrototypeEntry();

        Subschema subschema = newEntry.getSubschema();
        String[] attributeNames = subschema.getAllAttributeNames();

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

        Rdn rdn = newEntry.getRdn();

        dnBuilderWidget.setInput( wizard.getSelectedConnection(), attributeNames, rdn, parentDn );
    }
View Full Code Here


    /**
     * Saves the DN of the DN builder widget to the prototype entry.
     */
    private void saveState()
    {
        DummyEntry newEntry = wizard.getPrototypeEntry();

        try
        {
            EventRegistry.suspendEventFireingInCurrentThread();

            // remove old RDN
            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.getUpValue() ) )
                            {
                                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 = 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.getUpValue();
                    String[] stringValues = rdnAttribute.getStringValues();
                    if ( !Arrays.asList( stringValues ).contains( rdnValue ) )
                    {
View Full Code Here

    {
        LdifPart[] parts = ldifRecord.getParts();

        EventRegistry.suspendEventFireingInCurrentThread();

        DummyEntry entry = new DummyEntry( new LdapDN( ldifRecord.getDnLine().getValueAsString() ), connection );

        for ( int i = 0; i < parts.length; i++ )
        {
            if ( parts[i] instanceof LdifAttrValLine )
            {
                LdifAttrValLine line = ( LdifAttrValLine ) parts[i];
                String attributeName = line.getUnfoldedAttributeDescription();
                Object value = line.getValueAsObject();
                IAttribute attribute = entry.getAttribute( attributeName );
                if ( attribute == null )
                {
                    attribute = new Attribute( entry, attributeName );
                    entry.addAttribute( attribute );
                }
                attribute.addValue( new Value( attribute, value ) );
            }
            else if ( !( parts[i] instanceof LdifDnLine ) && !( parts[i] instanceof LdifSepLine ) )
            {
                String name = parts[i].toRawString();
                name = name.replaceAll( "\n", "" );
                name = name.replaceAll( "\r", "" );
                IAttribute attribute = new Attribute( entry, name );
                attribute.addValue( new Value( attribute, parts[i] ) );
                entry.addAttribute( attribute );
                // IAttribute attribute = entry.getAttribute("");
                // if(attribute == null) {
                // attribute = new Attribute(entry, "");
                // entry.addAttribute(attribute, null);
                // }
View Full Code Here

     * Initializes the DN builder widget with the DN of
     * the prototype entry. Called when this page becomes visible.
     */
    private void loadState()
    {
        DummyEntry newEntry = wizard.getPrototypeEntry();

        Subschema subschema = newEntry.getSubschema();
        String[] attributeNames = subschema.getAllAttributeNames();

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

        Rdn rdn = newEntry.getRdn();

        dnBuilderWidget.setInput( wizard.getSelectedConnection(), attributeNames, rdn, parentDn );
    }
View Full Code Here

    /**
     * Saves the DN of the DN builder widget to the prototype entry.
     */
    private void saveState()
    {
        DummyEntry newEntry = wizard.getPrototypeEntry();

        try
        {
            EventRegistry.suspendEventFireingInCurrentThread();

            // remove old RDN
            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.getUpValue() ) )
                            {
                                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 = 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.getUpValue();
                    String[] stringValues = rdnAttribute.getStringValues();
                    if ( !Arrays.asList( stringValues ).contains( rdnValue ) )
                    {
View Full Code Here

            //            }

            availableObjectClasses.addAll( wizard.getSelectedConnection().getSchema()
                .getObjectClassDescriptions() );

            DummyEntry newEntry = wizard.getPrototypeEntry();
            IAttribute ocAttribute = newEntry.getAttribute( IAttribute.OBJECTCLASS_ATTRIBUTE );
            if ( ocAttribute != null )
            {
                String[] ocValues = ocAttribute.getStringValues();
                for ( int i = 0; i < ocValues.length; i++ )
                {
View Full Code Here

    /**
     * Saves the state of selected object classes to the entry.
     */
    private void saveState()
    {
        DummyEntry newEntry = wizard.getPrototypeEntry();

        try
        {
            EventRegistry.suspendEventFireingInCurrentThread();

            // set new objectClass values
            IAttribute ocAttribute = newEntry.getAttribute( IAttribute.OBJECTCLASS_ATTRIBUTE );
            if ( ocAttribute == null )
            {
                ocAttribute = new Attribute( newEntry, IAttribute.OBJECTCLASS_ATTRIBUTE );
                newEntry.addAttribute( ocAttribute );
            }
            IValue[] values = ocAttribute.getValues();
            for ( IValue value : values )
            {
                ocAttribute.deleteValue( value );
View Full Code Here

            try
            {
                EventRegistry.suspendEventFireingInCurrentThread();

                LdifContentRecord record = ModelConverter.entryToLdifContentRecord( templateEntries[0] );
                DummyEntry prototypeEntry = ModelConverter.ldifContentRecordToEntry( record, browserConnection );
                IAttribute[] attributes = prototypeEntry.getAttributes();
                for ( int i = 0; i < attributes.length; i++ )
                {
                    if ( !SchemaUtils.isModifyable( attributes[i].getAttributeTypeDescription() ) )
                    {
                        prototypeEntry.deleteAttribute( attributes[i] );
                    }
                }
                wizard.setPrototypeEntry( prototypeEntry );
            }
            catch ( Exception e )
            {
                e.printStackTrace();
            }
            finally
            {
                EventRegistry.resumeEventFireingInCurrentThread();
            }
        }
        else
        {
            wizard.setPrototypeEntry( new DummyEntry( new LdapDN(), wizard.getSelectedConnection() ) );
        }

        return super.getNextPage();
    }
View Full Code Here

        if ( selectedConnection != null )
        {
            originalReadOnlyFlag = selectedConnection.getConnection().isReadOnly();
            selectedConnection.getConnection().setReadOnly( true );
            prototypeEntry = new DummyEntry( new LdapDN(), selectedConnection );
        }
    }
View Full Code Here

    {
        super.setVisible( visible );

        if ( visible )
        {
            DummyEntry newEntry = wizard.getPrototypeEntry();
            try
            {
                EventRegistry.suspendEventFiringInCurrentThread();

                // remove empty must attributes
                // necessary when navigating back, modifying object classes
                // and Dn and navigation forward again.
                Collection<AttributeType> oldMusts = SchemaUtils.getMustAttributeTypeDescriptions( newEntry );
                for ( AttributeType oldMust : oldMusts )
                {
                    IAttribute attribute = newEntry.getAttribute( oldMust.getOid() );
                    if ( attribute != null )
                    {
                        IValue[] values = attribute.getValues();
                        for ( int v = 0; v < values.length; v++ )
                        {
                            if ( values[v].isEmpty() )
                            {
                                attribute.deleteValue( values[v] );
                            }
                        }
                        if ( attribute.getValueSize() == 0 )
                        {
                            newEntry.deleteAttribute( attribute );
                        }
                    }
                }

                // add must attributes
                Collection<AttributeType> newMusts = SchemaUtils.getMustAttributeTypeDescriptions( newEntry );
                for ( AttributeType newMust : newMusts )
                {
                    if ( newEntry.getAttributeWithSubtypes( newMust.getOid() ) == null )
                    {
                        String friendlyIdentifier = SchemaUtils.getFriendlyIdentifier( newMust );
                        IAttribute att = new Attribute( newEntry, friendlyIdentifier );
                        newEntry.addAttribute( att );
                        att.addEmptyValue();
                    }
                }
            }
            finally
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry

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.