Examples of DummyEntry


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

        if ( wizard.getSelectedConnection() != null )
        {
            availableObjectClasses.addAll( wizard.getSelectedConnection().getSchema().getObjectClassDescriptions() );

            DummyEntry newEntry = wizard.getPrototypeEntry();
            IAttribute ocAttribute = newEntry.getAttribute( SchemaConstants.OBJECT_CLASS_AT );
            if ( ocAttribute != null )
            {
                for ( IValue ocValue : ocAttribute.getValues() )
                {
                    if ( !ocValue.isEmpty() )
View Full Code Here

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

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

        try
        {
            EventRegistry.suspendEventFiringInCurrentThread();

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

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

    {
        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<AttributeTypeDescription> oldMusts = SchemaUtils.getMustAttributeTypeDescriptions( newEntry );
                for ( AttributeTypeDescription oldMust : oldMusts )
                {
                    IAttribute attribute = newEntry.getAttribute( oldMust.getNumericOid() );
                    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<AttributeTypeDescription> newMusts = SchemaUtils.getMustAttributeTypeDescriptions( newEntry );
                for ( AttributeTypeDescription newMust : newMusts )
                {
                    if ( newEntry.getAttributeWithSubtypes( newMust.getNumericOid() ) == null )
                    {
                        String friendlyIdentifier = SchemaUtils.getFriendlyIdentifier( newMust );
                        IAttribute att = new Attribute( newEntry, friendlyIdentifier );
                        newEntry.addAttribute( att );
                        att.addEmptyValue();
                    }
                }
            }
            finally
View Full Code Here

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();

        if ( wizard.isNewContextEntry() )
        {
            IAttribute attribute = wizard.getSelectedConnection().getRootDSE().getAttribute(
                SchemaConstants.NAMING_CONTEXTS_AT );
            if ( attribute != null )
            {
                String[] values = attribute.getStringValues();

                // content proposals
                contextEntryDnComboCPA.setContentProposalProvider( new ListContentProposalProvider( values ) );

                // fill namingContext values into combo
                contextEntryDnCombo.setItems( values );

                // preset combo text
                if ( Arrays.asList( values ).contains( newEntry.getDn().getUpName() ) )
                {
                    contextEntryDnCombo.setText( newEntry.getDn().getUpName() );
                }
            }
        }
        else
        {
            Collection<AttributeTypeDescription> atds = SchemaUtils.getAllAttributeTypeDescriptions( newEntry );
            String[] attributeNames = SchemaUtils.getNames( atds ).toArray( ArrayUtils.EMPTY_STRING_ARRAY );

            LdapDN parentDn = null;
            if ( wizard.getSelectedEntry() != null && newEntry.getDn().equals( wizard.getSelectedEntry().getDn() )
                && DnUtils.getParent( newEntry.getDn() ) != null )
            {
                parentDn = DnUtils.getParent( newEntry.getDn() );
            }
            else if ( wizard.getSelectedEntry() != null )
            {
                parentDn = wizard.getSelectedEntry().getDn();
            }
            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

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

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

        try
        {
            EventRegistry.suspendEventFiringInCurrentThread();

            // 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.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 ) )
                    {
View Full Code Here

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

            try
            {
                EventRegistry.suspendEventFiringInCurrentThread();

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

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

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

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

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

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

        EventRegistry.suspendEventFiringInCurrentThread();

        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 );
            }
        }

        EventRegistry.resumeEventFiringInCurrentThread();
View Full Code Here

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

            //            }

            availableObjectClasses.addAll( Arrays.asList( 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

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

    /**
     * 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 ( int i = 0; i < values.length; i++ )
            {
                ocAttribute.deleteValue( values[i] );
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.