Package org.apache.directory.studio.connection.core.jobs

Examples of org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor


    /**
     * Test failed binds to the server.
     */
    public void testBindFailures()
    {
        StudioProgressMonitor monitor = null;
        ConnectionParameter connectionParameter = null;
        Connection connection = null;
        JNDIConnectionWrapper connectionWrapper = null;

        // simple auth without principal and credential
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "localhost", ldapServer.getIpPort(),
            EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, null, null, null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        connectionWrapper.bind( monitor );
        assertFalse( connectionWrapper.isConnected() );
        assertNotNull( monitor.getException() );
        assertTrue( monitor.getException() instanceof NamingException );

        // simple auth with invalid principal and credential
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "localhost", ldapServer.getIpPort(),
            EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "bar", null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        connectionWrapper.bind( monitor );
        assertFalse( connectionWrapper.isConnected() );
        assertNotNull( monitor.getException() );
        assertTrue( monitor.getException() instanceof AuthenticationException );
    }
View Full Code Here


    /**
     * Test searching.
     */
    public void testSearch()
    {
        StudioProgressMonitor monitor = null;
        ConnectionParameter connectionParameter = null;
        Connection connection = null;
        JNDIConnectionWrapper connectionWrapper = null;

        // simple auth without principal and credential
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "localhost", ldapServer.getIpPort(),
            EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "secret", null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        connectionWrapper.bind( monitor );
        assertTrue( connectionWrapper.isConnected() );
        assertNull( monitor.getException() );

        SearchControls searchControls = new SearchControls();
        NamingEnumeration<SearchResult> result = connectionWrapper.search( "ou=system", "objectClass=*",
            searchControls, AliasDereferencingMethod.NEVER, ReferralHandlingMethod.IGNORE, null, monitor, null );
        assertNotNull( result );
View Full Code Here

    }


    private StudioProgressMonitor getProgressMonitor()
    {
        StudioProgressMonitor monitor = new StudioProgressMonitor( new NullProgressMonitor() );
        return monitor;
    }
View Full Code Here

                {} ), 3 );
        monitor.reportProgress( " " ); //$NON-NLS-1$
        monitor.worked( 1 );

        // use a dummy monitor to be able to handle exceptions
        StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );

        int numAdd = 0;
        int numDel = 0;
        boolean isSimulatedRename = false;
        LdapDN parentDn = newParent.getDn();

        for ( int i = 0; i < oldEntries.length; i++ )
        {
            dummyMonitor.reset();

            IEntry oldEntry = oldEntries[i];
            LdapDN oldDn = oldEntry.getDn();
            LdapDN newDn = DnUtils.composeDn( oldDn.getRdn(), parentDn );

            // try to move entry
            RenameEntryJob.renameEntry( browserConnection, oldEntry, newDn, dummyMonitor );

            // do a simulated rename, if renaming of a non-leaf entry is not supported.
            if ( dummyMonitor.errorsReported() )
            {
                if ( dialog != null && dummyMonitor.getException() instanceof ContextNotEmptyException )
                {
                    // open dialog
                    if ( numAdd == 0 )
                    {
                        dialog.setEntryInfo( browserConnection, oldDn, newDn );
                        dialog.open();
                        isSimulatedRename = dialog.isSimulateRename();
                    }

                    if ( isSimulatedRename )
                    {
                        // do simulated rename operation
                        dummyMonitor.reset();

                        numAdd = CopyEntriesJob.copyEntry( oldEntry, newParent, null, SearchControls.SUBTREE_SCOPE,
                            numAdd, null, dummyMonitor, monitor );

                        if ( !dummyMonitor.errorsReported() )
                        {
                            dummyMonitor.reset();
                            numDel = DeleteEntriesJob.optimisticDeleteEntryRecursive( browserConnection, oldDn, numDel,
                                dummyMonitor, monitor );
                        }
                    }
                    else
                    {
                        // no simulated rename operation
                        // report the exception to the real monitor
                        Throwable exception = dummyMonitor.getException();
                        monitor.reportError( exception );
                    }
                }
                else
                {
                    // we have another exception
                    // report it to the real monitor
                    Throwable exception = dummyMonitor.getException();
                    monitor.reportError( exception );
                }
            }

            // update model
            if ( !dummyMonitor.errorsReported() )
            {
                // uncache old entry
                browserConnection.uncacheEntryRecursive( oldEntry );

                // remove old entry from old parent
View Full Code Here

                { Integer.toString( entriesToDelete.length ) } ), 2 + entriesToDelete.length );
        monitor.reportProgress( " " ); //$NON-NLS-1$
        monitor.worked( 1 );

        int num = 0;
        StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
        for ( int i = 0; !monitor.isCanceled() && !monitor.errorsReported() && i < entriesToDelete.length; i++ )
        {
            IEntry entryToDelete = entriesToDelete[i];
            IBrowserConnection browserConnection = entryToDelete.getBrowserConnection();
View Full Code Here

        LdapDN oldDn = oldEntry.getDn();
        LdapDN parentDn = DnUtils.getParent( oldDn );
        LdapDN newDn = DnUtils.composeDn( newRdn, parentDn );

        // use a dummy monitor to be able to handle exceptions
        StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );

        // try to rename entry
        renameEntry( browserConnection, oldEntry, newDn, dummyMonitor );

        // do a simulated rename, if renaming of a non-leaf entry is not supported.
        if ( dummyMonitor.errorsReported() )
        {
            if ( dialog != null && dummyMonitor.getException() instanceof ContextNotEmptyException )
            {
                // open dialog
                dialog.setEntryInfo( browserConnection, oldDn, newDn );
                dialog.open();
                boolean isSimulatedRename = dialog.isSimulateRename();

                if ( isSimulatedRename )
                {
                    // do simulated rename operation
                    dummyMonitor.reset();
                    CopyEntriesJob.copyEntry( oldEntry, oldEntry.getParententry(), newRdn,
                        SearchControls.SUBTREE_SCOPE, 0, null, dummyMonitor, monitor );

                    if ( !dummyMonitor.errorsReported() )
                    {
                        dummyMonitor.reset();
                        DeleteEntriesJob.optimisticDeleteEntryRecursive( browserConnection, oldDn, 0, dummyMonitor,
                            monitor );
                    }
                }
                else
                {
                    // no simulated rename operation
                    // report the exception to the real monitor
                    Throwable exception = dummyMonitor.getException();
                    monitor.reportError( exception );
                }
            }
            else
            {
                // we have another exception
                // report it to the real monitor
                Throwable exception = dummyMonitor.getException();
                monitor.reportError( exception );
            }
        }

        // update model
View Full Code Here

        final StudioProgressMonitor[] spm = new StudioProgressMonitor[1];
        IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress()
        {
            public void run( IProgressMonitor monitor ) throws InterruptedException
            {
                spm[0] = new StudioProgressMonitor( monitor );

                // ensure that connections are opened
                Connection[] connections = runnable.getConnections();
                if ( connections != null )
                {
View Full Code Here

    /**
     * Test failed binds to the server.
     */
    public void testBindFailures()
    {
        StudioProgressMonitor monitor = null;
        ConnectionParameter connectionParameter = null;
        Connection connection = null;
        JNDIConnectionWrapper connectionWrapper = null;

        // simple auth without principal and credential
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "localhost", ldapService.getIpPort(),
            EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, null, null, null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        connectionWrapper.bind( monitor );
        assertFalse( connectionWrapper.isConnected() );
        assertNotNull( monitor.getException() );
        assertTrue( monitor.getException() instanceof NamingException );

        // simple auth with invalid principal and credential
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "localhost", ldapService.getIpPort(),
            EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "bar", null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        connectionWrapper.bind( monitor );
        assertFalse( connectionWrapper.isConnected() );
        assertNotNull( monitor.getException() );
        assertTrue( monitor.getException() instanceof AuthenticationException );
    }
View Full Code Here

    /**
     * Test searching.
     */
    public void testSearch()
    {
        StudioProgressMonitor monitor = null;
        ConnectionParameter connectionParameter = null;
        Connection connection = null;
        JNDIConnectionWrapper connectionWrapper = null;

        // simple auth without principal and credential
        monitor = getProgressMonitor();
        connectionParameter = new ConnectionParameter( null, "localhost", ldapService.getIpPort(),
            EncryptionMethod.NONE, AuthenticationMethod.SIMPLE, "uid=admin,ou=system", "secret", null, true, null );
        connection = new Connection( connectionParameter );
        connectionWrapper = connection.getJNDIConnectionWrapper();
        connectionWrapper.connect( monitor );
        connectionWrapper.bind( monitor );
        assertTrue( connectionWrapper.isConnected() );
        assertNull( monitor.getException() );

        SearchControls searchControls = new SearchControls();
        NamingEnumeration<SearchResult> result = connectionWrapper.search( "ou=system", "objectClass=*",
            searchControls, AliasDereferencingMethod.NEVER, ReferralHandlingMethod.IGNORE, null, monitor, null );
        assertNotNull( result );
View Full Code Here

    }


    private StudioProgressMonitor getProgressMonitor()
    {
        StudioProgressMonitor monitor = new StudioProgressMonitor( new NullProgressMonitor() );
        return monitor;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor

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.