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

Examples of org.apache.directory.studio.ldapbrowser.core.model.DN


    public IWizardPage getNextPage()
    {
        if ( templateButton.getSelection() )
        {
            final IBrowserConnection browserConnection = entryWidget.getBrowserConnection();
            final DN dn = entryWidget.getDn();
            final IEntry[] templateEntries = new IEntry[1];

            if ( browserConnection == null )
            {
                getShell().getDisplay().syncExec( new Runnable()
                {
                    public void run()
                    {
                        MessageDialog.openError( getShell(), "Error", "No connection" );
                    }
                } );
                return null;
            }
            if ( dn == null )
            {
                getShell().getDisplay().syncExec( new Runnable()
                {
                    public void run()
                    {
                        MessageDialog.openError( getShell(), "Error", "No dn" );
                    }
                } );
                return null;
            }

            // check if selected DN exists
            ReadEntryJob readEntryJob = new ReadEntryJob( browserConnection, dn );
            RunnableContextJobAdapter.execute( readEntryJob, getContainer(), false );
            templateEntries[0] = readEntryJob.getReadEntry();
            if ( templateEntries[0] == null )
            {
                getShell().getDisplay().syncExec( new Runnable()
                {
                    public void run()
                    {
                        MessageDialog.openError( getShell(), "Error", "Entry " + dn.toString() + " doesn't exists" );
                    }
                } );
                return null;
            }

            // init attributes
            if ( !templateEntries[0].isAttributesInitialized() )
            {
                InitializeAttributesJob job = new InitializeAttributesJob( templateEntries, false );
                RunnableContextJobAdapter.execute( job, getContainer() );
            }

            // clone entry and remove non-modifyable attributes
            try
            {
                EventRegistry.suspendEventFireingInCurrentThread();

                LdifContentRecord record = ModelConverter.entryToLdifContentRecord( templateEntries[0] );
                DummyEntry prototypeEntry = ModelConverter.ldifContentRecordToEntry( record, new DummyConnection( browserConnection.getSchema() ) );
                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 DN(), new DummyConnection( wizard.getSelectedConnection().getSchema() ) ) );
        }

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

TOP

Related Classes of org.apache.directory.studio.ldapbrowser.core.model.DN

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.