Package org.apache.directory.ldapstudio.browser.core.model

Examples of org.apache.directory.ldapstudio.browser.core.model.IEntry


                            readIn.read( connectionName );
                            connection = BrowserCorePlugin.getDefault().getConnectionManager().getConnection(
                                new String( connectionName ) );
                        }

                        IEntry entry = null;
                        if ( readIn.available() > 1 && connection != null )
                        {
                            int size = readIn.readInt();
                            byte[] dn = new byte[size];
                            readIn.read( dn );
View Full Code Here


        // get base DNs
        if( !isFetchBaseDNs() && getBaseDN() != null && !"".equals( getBaseDN().toString() ))
        {
            // only add the specified base DN
            DN dn = getBaseDN();
            IEntry entry = new BaseDNEntry( new DN( dn ), this );
            cacheEntry( entry );
            rootDSE.addChild( entry );
           
            // check if entry exists
            search = new Search( null, this, dn, ISearch.FILTER_TRUE, ISearch.NO_ATTRIBUTES, ISearch.SCOPE_OBJECT, 1, 0,
                IConnection.DEREFERENCE_ALIASES_NEVER, IConnection.HANDLE_REFERRALS_IGNORE, true, true, null );
            search( search, monitor );
        }
        else
        {
            // get naming contexts
            Set<String> namingContextSet = new HashSet<String>();
            IAttribute attribute = rootDSE.getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_NAMINGCONTEXTS );
            if ( attribute != null )
            {
                String[] values = attribute.getStringValues();
                for ( int i = 0; i < values.length; i++ )
                {
                    namingContextSet.add( values[i] );
                }
            }
            for ( String namingContext : namingContextSet )
            {
                if ( !"".equals( namingContext ) ) { //$NON-NLS-1$
                    try
                    {
                        IEntry entry = new BaseDNEntry( new DN( namingContext ), this );
                        rootDSE.addChild( entry );
                        cacheEntry( entry );
                    }
                    catch ( Exception e )
                    {
                        monitor.reportError( BrowserCoreMessages.model__error_setting_base_dn, e );
                    }
                }
                else
                {
                    // special handling of empty namingContext: perform a one-level search and add all result DNs to the set
                    search = new Search( null, this, new DN(), ISearch.FILTER_TRUE, ISearch.NO_ATTRIBUTES, ISearch.SCOPE_ONELEVEL, 0,
                        0, IConnection.DEREFERENCE_ALIASES_NEVER, IConnection.HANDLE_REFERRALS_IGNORE, false, false, null );
                    search( search, monitor );
                    ISearchResult[] results = search.getSearchResults();
                    for ( int k = 0; results != null && k < results.length; k++ )
                    {
                        ISearchResult result = results[k];
                        IEntry entry = result.getEntry();
                        rootDSE.addChild( entry );
                    }
                }
            }
        }
View Full Code Here

        monitor.beginTask( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__rename_entry_task, new String[]
            { this.oldEntry.getDn().toString() } ), 3 );
        monitor.reportProgress( " " ); //$NON-NLS-1$
        monitor.worked( 1 );

        IEntry parent = oldEntry.getParententry();
        DN newDn = new DN( newRdn, parent.getDn() );

        // rename in directory
        // TODO: use manual/simulated rename, if rename of subtree is not
        // supported
        connection.rename( oldEntry, newDn, deleteOldRdn, monitor );

        if ( !monitor.errorsReported() )
        {
            // rename in parent
            parent.deleteChild( oldEntry );
            this.newEntry = connection.getEntry( newDn, monitor );
            parent.addChild( newEntry );
            parent.setHasMoreChildren( false );

            newEntry.setHasChildrenHint( oldEntry.hasChildren() );
            if ( oldEntry.isChildrenInitialized() )
            {
                InitializeChildrenJob.initializeChildren( newEntry, monitor );
View Full Code Here

        int num = 0;
        for ( int i = 0; !monitor.isCanceled() && !monitor.errorsReported() && i < entriesToDelete.length; i++ )
        {

            IEntry entryToDelete = entriesToDelete[i];
            IConnection connection = entryToDelete.getConnection();

            // delete from directory
            // TODO: use TreeDelete Control, if available
            int errorStatusSize1 = monitor.getErrorStatus( "" ).getChildren().length; //$NON-NLS-1$
            num = deleteEntryRecursive( entryToDelete, false, num, monitor );
            int errorStatusSize2 = monitor.getErrorStatus( "" ).getChildren().length; //$NON-NLS-1$
            deletedEntriesSet.add( entryToDelete );

            if ( errorStatusSize1 == errorStatusSize2 )
            {
                // delete from parent
                entryToDelete.getParententry().deleteChild( entryToDelete );
                entriesToUpdateSet.add( entryToDelete.getParententry() );

                // delete from searches
                ISearch[] searches = connection.getSearchManager().getSearches();
                for ( int j = 0; j < searches.length; j++ )
                {
                    ISearch search = searches[j];
                    if ( search.getSearchResults() != null )
                    {
                        ISearchResult[] searchResults = search.getSearchResults();
                        for ( int k = 0; k < searchResults.length; k++ )
                        {
                            ISearchResult result = searchResults[k];
                            if ( entryToDelete.equals( result.getEntry() ) )
                            {
                                ISearchResult[] newsrs = new ISearchResult[searchResults.length - 1];
                                System.arraycopy( searchResults, 0, newsrs, 0, k );
                                System.arraycopy( searchResults, k + 1, newsrs, k, searchResults.length - k - 1 );
                                search.setSearchResults( newsrs );
View Full Code Here

                entry.getConnection().search( search, monitor );

                ISearchResult[] srs = search.getSearchResults();
                for ( int i = 0; !monitor.isCanceled() && srs != null && i < srs.length; i++ )
                {
                    IEntry childEntry = srs[i].getEntry();
                    numberOfDeletedEntries = this.deleteEntryRecursive( childEntry, true, numberOfDeletedEntries,
                        monitor );
                    numberInBatch++;
                }
            }
View Full Code Here

    protected void runNotification()
    {
        for ( Iterator it = deletedEntriesSet.iterator(); it.hasNext(); )
        {
            IEntry entry = ( IEntry ) it.next();
            EventRegistry.fireEntryUpdated( new EntryDeletedEvent( entry.getConnection(), entry ), this );
        }
        for ( Iterator it = entriesToUpdateSet.iterator(); it.hasNext(); )
        {
            IEntry parent = ( IEntry ) it.next();
            EventRegistry.fireEntryUpdated( new ChildrenInitializedEvent( parent ), this );
        }
        for ( Iterator it = searchesToUpdateSet.iterator(); it.hasNext(); )
        {
            ISearch search = ( ISearch ) it.next();
View Full Code Here

        // check argument
        if ( o == null || !( o instanceof IEntry ) )
        {
            return false;
        }
        IEntry e = ( IEntry ) o;

        // compare dn and connection
        return this.getDn() == null ? e.getDn() == null : ( this.getDn().equals( e.getDn() ) && this.getConnection()
            .equals( e.getConnection() ) );
    }
View Full Code Here

    IEntry getEntry( DN dn, ExtendedProgressMonitor monitor )
    {
        try
        {
            // first check cache
            IEntry entry = connection.getEntryFromCache( dn );
            if ( entry != null )
            {
                return entry;
            }
View Full Code Here

                            LdifContentRecord record = ( LdifContentRecord ) container;
                            DN dn = new DN( record.getDnLine().getValueAsString() );

                            // get entry from cache or create it
                            IEntry entry = connection.getEntryFromCache( dn );
                            if ( entry == null )
                            {
                                entry = createAndCacheEntry( dn );
                            }
View Full Code Here

    }


    private IEntry createAndCacheEntry( DN dn ) throws ModelModificationException
    {
        IEntry entry = null;

        // build tree to parent
        LinkedList parentDnList = new LinkedList();
        DN parentDN = dn;
        while ( parentDN != null && connection.getEntryFromCache( parentDN ) == null )
        {
            parentDnList.addFirst( parentDN );
            parentDN = parentDN.getParentDn();
        }
        for ( Iterator it = parentDnList.iterator(); it.hasNext(); )
        {
            DN aDN = ( DN ) it.next();
            if ( aDN.getParentDn() == null )
            {
                entry = new BaseDNEntry( aDN, connection );
                connection.cacheEntry( entry );
            }
            else if ( connection.getEntryFromCache( aDN.getParentDn() ) != null )
            {
                IEntry parentEntry = connection.getEntryFromCache( aDN.getParentDn() );
                entry = new Entry( parentEntry, aDN.getRdn() );
                entry.setDirectoryEntry( true );

                parentEntry.addChild( entry );
                // parentEntry.setAttributesInitialized(false, this);

                parentEntry.setChildrenInitialized( true );
                parentEntry.setHasMoreChildren( true );
                parentEntry.setHasChildrenHint( true );

                connection.cacheEntry( entry );
            }
            else
            {
View Full Code Here

TOP

Related Classes of org.apache.directory.ldapstudio.browser.core.model.IEntry

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.