directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r691070 [1/3] - in /directory/studio/trunk: connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ ldapbrowser-common/resources/icons/ ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/comm...
Date Mon, 01 Sep 2008 21:48:26 GMT
Author: seelmann
Date: Mon Sep  1 14:48:25 2008
New Revision: 691070

URL: http://svn.apache.org/viewvc?rev=691070&view=rev
Log:
Fix for DIRSTUDIO-327: Added support for paged results control

Added:
    directory/studio/trunk/ldapbrowser-common/resources/icons/next.gif   (with props)
    directory/studio/trunk/ldapbrowser-common/resources/icons/previous.gif   (with props)
    directory/studio/trunk/ldapbrowser-common/resources/icons/top.gif   (with props)
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/StudioControl.java
      - copied, changed from r690676, directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/StudioPagedResultsControl.java   (with props)
Removed:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java
Modified:
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/BrowserCommonConstants.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserConfiguration.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSorter.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionIO.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesRunnable.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeChildrenRunnable.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IBrowserConnection.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ISearch.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/SearchParameter.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/BrowserConnection.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/ChildrenInfo.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyConnection.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/JNDIUtils.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.java

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java (original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java Mon Sep  1 14:48:25 2008
@@ -47,10 +47,9 @@
 import javax.net.ssl.SSLSession;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.directory.shared.ldap.util.LdapURL;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.EmptyEnumeration;
+import org.apache.directory.shared.ldap.util.LdapURL;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
 import org.apache.directory.studio.connection.core.ConnectionParameter;
@@ -275,11 +274,13 @@
      * 
      * @return the naming enumeration or null if an exception occurs.
      */
-    public NamingEnumeration<SearchResult> search( final String searchBase, final String filter,
+    public StudioNamingEnumeration search( final String searchBase, final String filter,
         final SearchControls searchControls, final AliasDereferencingMethod aliasesDereferencingMethod,
         final ReferralHandlingMethod referralsHandlingMethod, final Control[] controls,
         final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
+        final long requestNum = SEARCH_RESQUEST_NUM++;
+        
         // start
         InnerRunnable runnable = new InnerRunnable()
         {
@@ -287,7 +288,6 @@
             {
                 // add ManageDsaIT control
                 Control[] localControls = addManageDsaItControls( controls, referralsHandlingMethod );
-                long requestNum = SEARCH_RESQUEST_NUM++;
 
                 try
                 {
@@ -309,7 +309,7 @@
                     //   user provided ATAV.
                     NamingEnumeration<SearchResult> ne = searchCtx.search( new LdapName( searchBase ), filter,
                         searchControls );
-                    namingEnumeration = new StudioNamingEnumeration( connection, ne, searchBase, filter,
+                    namingEnumeration = new StudioNamingEnumeration( connection, searchCtx, ne, searchBase, filter,
                         searchControls, aliasesDereferencingMethod, referralsHandlingMethod, controls, requestNum,
                         monitor, referralsInfo );
                 }
@@ -418,7 +418,9 @@
         }
         else
         {
-            return new EmptyEnumeration<SearchResult>();
+            return new StudioNamingEnumeration( connection, null, null, searchBase, filter,
+                searchControls, aliasesDereferencingMethod, referralsHandlingMethod, controls, requestNum,
+                monitor, referralsInfo );
         }
     }
 
@@ -1136,7 +1138,7 @@
          * 
          * @return the result
          */
-        public NamingEnumeration<SearchResult> getResult()
+        public StudioNamingEnumeration getResult()
         {
             return namingEnumeration;
         }

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java (original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioNamingEnumeration.java Mon Sep  1 14:48:25 2008
@@ -27,6 +27,7 @@
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.Control;
+import javax.naming.ldap.LdapContext;
 
 import org.apache.directory.shared.ldap.util.LdapURL;
 import org.apache.directory.studio.connection.core.Connection;
@@ -47,6 +48,7 @@
 public class StudioNamingEnumeration implements NamingEnumeration<SearchResult>
 {
     private final Connection connection;
+    private final LdapContext ctx;
     private NamingEnumeration<SearchResult> delegate;
 
     private long requestNum;
@@ -66,6 +68,7 @@
      * Creates a new instance of ReferralNamingEnumeration.
      * 
      * @param connection the connection
+     * @param LdapContext ctx the JNDI context
      * @param delegate the delegate
      * @param searchBase the search base
      * @param filter the filter
@@ -76,12 +79,13 @@
      * @param monitor the progress monitor
      * @param referralsInfo the referrals info
      */
-    public StudioNamingEnumeration( Connection connection, NamingEnumeration<SearchResult> delegate, String searchBase,
+    public StudioNamingEnumeration( Connection connection, LdapContext ctx, NamingEnumeration<SearchResult> delegate, String searchBase,
         String filter, SearchControls searchControls, AliasDereferencingMethod aliasesDereferencingMethod,
         ReferralHandlingMethod referralsHandlingMethod, Control[] controls, long requestNum,
         StudioProgressMonitor monitor, ReferralsInfo referralsInfo )
     {
         this.connection = connection;
+        this.ctx = ctx;
         this.delegate = delegate;
         this.requestNum = requestNum;
         this.resultEntryCounter = 0;
@@ -238,7 +242,7 @@
     /**
      * @see javax.naming.NamingEnumeration#next()
      */
-    public SearchResult next() throws NamingException
+    public StudioSearchResult next() throws NamingException
     {
         StudioSearchResult studioSearchResult = null;
         NamingException namingException = null;
@@ -267,7 +271,7 @@
     /**
      * @see java.util.Enumeration#nextElement()
      */
-    public SearchResult nextElement()
+    public StudioSearchResult nextElement()
     {
         SearchResult searchResult = delegate.nextElement();
         resultEntryCounter++;
@@ -298,4 +302,18 @@
         }
     }
 
+    
+    
+    /**
+     * Gets the response controls.
+     * 
+     * @return the response controls, may be null
+     * 
+     * @throws NamingException the naming exception
+     */
+    public Control[] getResponseControls() throws NamingException
+    {
+        return ctx != null ? ctx.getResponseControls() : null;
+    }
+
 }

Added: directory/studio/trunk/ldapbrowser-common/resources/icons/next.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/resources/icons/next.gif?rev=691070&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/ldapbrowser-common/resources/icons/next.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/studio/trunk/ldapbrowser-common/resources/icons/previous.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/resources/icons/previous.gif?rev=691070&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/ldapbrowser-common/resources/icons/previous.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/studio/trunk/ldapbrowser-common/resources/icons/top.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/resources/icons/top.gif?rev=691070&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/ldapbrowser-common/resources/icons/top.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/BrowserCommonConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/BrowserCommonConstants.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/BrowserCommonConstants.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/BrowserCommonConstants.java Mon Sep  1 14:48:25 2008
@@ -163,6 +163,9 @@
     public static final String IMG_OCD_STRUCTURAL = "resources/icons/ocd_structural.gif";
     public static final String IMG_MRD = "resources/icons/mrd.png";
     public static final String IMG_ENTRY_WIZARD = "resources/icons/entry_wizard.gif";
+    public static final String IMG_TOP = "resources/icons/top.gif";
+    public static final String IMG_NEXT = "resources/icons/next.gif";
+    public static final String IMG_PREVIOUS = "resources/icons/previous.gif";
 
     public static final String CMD_ADD_ATTRIBUTE = BrowserCommonActivator.getDefault().getPluginProperties().getString(
         "Cmd_AddAttribute_id" );

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java Mon Sep  1 14:48:25 2008
@@ -46,6 +46,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.StudioControl;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -165,7 +166,7 @@
                 message.append( BrowserCoreConstants.LINE_SEPARATOR );
 
                 if ( entries[0].getBrowserConnection().getRootDSE().isControlSupported(
-                    org.apache.directory.studio.ldapbrowser.core.model.Control.TREEDELETE_CONTROL.getOid() ) )
+                    StudioControl.TREEDELETE_CONTROL.getOid() ) )
                 {
                     askForTreeDeleteControl = true;
                 }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java Mon Sep  1 14:48:25 2008
@@ -139,6 +139,10 @@
         }
         if ( searches.length > 0 )
         {
+            for ( ISearch search : searches )
+            {
+                search.setSearchResults( null );
+            }
             new StudioBrowserJob( new SearchRunnable( searches ) ).execute();
         }
 
@@ -149,6 +153,7 @@
         }
         if ( searchInput != null )
         {
+            searchInput.setSearchResults( null );
             new StudioBrowserJob( new SearchRunnable( new ISearch[]
                 { searchInput } ) ).execute();
         }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserConfiguration.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserConfiguration.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserConfiguration.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserConfiguration.java Mon Sep  1 14:48:25 2008
@@ -145,7 +145,7 @@
     {
         if ( contentProvider == null )
         {
-            contentProvider = new BrowserContentProvider( getPreferences(), getSorter() );
+            contentProvider = new BrowserContentProvider( viewer, getPreferences(), getSorter() );
         }
 
         return contentProvider;

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java Mon Sep  1 14:48:25 2008
@@ -29,6 +29,7 @@
 import java.util.Map;
 
 import org.apache.directory.studio.connection.core.jobs.OpenConnectionsRunnable;
+import org.apache.directory.studio.connection.core.jobs.StudioRunnableWithProgress;
 import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeChildrenRunnable;
 import org.apache.directory.studio.ldapbrowser.core.jobs.SearchRunnable;
 import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob;
@@ -39,7 +40,11 @@
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.DirectoryMetadataEntry;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 
 
@@ -53,7 +58,10 @@
 public class BrowserContentProvider implements ITreeContentProvider
 {
 
-    /** The prefernces */
+    /** The viewer. */
+    private TreeViewer viewer;
+
+    /** The preferences */
     protected BrowserPreferences preferences;
 
     /** The sorter */
@@ -68,20 +76,38 @@
     /** This map contains the top-level categories for each connection */
     private Map<IBrowserConnection, BrowserCategory[]> connectionToCategoriesMap;
 
+    /** The page listener. */
+    private ISelectionChangedListener pageListener = new ISelectionChangedListener()
+    {
+        public void selectionChanged( SelectionChangedEvent event )
+        {
+            IStructuredSelection selection = ( IStructuredSelection ) event.getSelection();
+            if ( selection.size() == 1 && selection.getFirstElement() instanceof StudioRunnableWithProgress )
+            {
+                StudioRunnableWithProgress runnable = ( StudioRunnableWithProgress ) selection.getFirstElement();
+                new StudioBrowserJob( runnable ).execute();
+            }
+        }
+    };
+
 
     /**
      * Creates a new instance of BrowserContentProvider.
      *
+     * @param viewer the viewer
      * @param preferences the preferences
      * @param sorter the sorter
      */
-    public BrowserContentProvider( BrowserPreferences preferences, BrowserSorter sorter )
+    public BrowserContentProvider( TreeViewer viewer, BrowserPreferences preferences, BrowserSorter sorter )
     {
+        this.viewer = viewer;
         this.preferences = preferences;
         this.sorter = sorter;
         this.entryToEntryPagesMap = new HashMap<IEntry, BrowserEntryPage[]>();
         this.searchToSearchResultPagesMap = new HashMap<ISearch, BrowserSearchResultPage[]>();
         this.connectionToCategoriesMap = new HashMap<IBrowserConnection, BrowserCategory[]>();
+
+        viewer.addSelectionChangedListener( pageListener );
     }
 
 
@@ -113,6 +139,7 @@
             connectionToCategoriesMap.clear();
             connectionToCategoriesMap = null;
         }
+        viewer.removeSelectionChangedListener( pageListener );
     }
 
 
@@ -315,15 +342,32 @@
                     entryToEntryPagesMap.remove( parentEntry );
                 }
 
-                IEntry[] entries = parentEntry.getChildren();
-                if ( entries == null )
+                Object[] results = parentEntry.getChildren();
+
+                List<Object> objects = new ArrayList<Object>();
+
+                if ( parentEntry.getTopPageChildrenRunnable() != null )
+                {
+                    objects.add( parentEntry.getTopPageChildrenRunnable() );
+                }
+
+                objects.addAll( Arrays.asList( results ) );
+
+                if ( parentEntry.getNextPageChildrenRunnable() != null )
+                {
+                    objects.add( parentEntry.getNextPageChildrenRunnable() );
+                }
+
+                results = objects.toArray();
+
+                if ( results == null )
                 {
                     return new String[]
                         { "Fetching Entries..." };
                 }
                 else
                 {
-                    return entries;
+                    return results;
                 }
             }
             else
@@ -382,7 +426,23 @@
             }
             else if ( search.getSearchResults().length <= preferences.getFoldingSize() || !preferences.isUseFolding() )
             {
-                ISearchResult[] results = search.getSearchResults();
+                Object[] results = search.getSearchResults();
+                List<Object> objects = new ArrayList<Object>();
+
+                if ( search.getTopSearchRunnable() != null )
+                {
+                    objects.add( search.getTopSearchRunnable() );
+                }
+
+                objects.addAll( Arrays.asList( results ) );
+
+                if ( search.getNextSearchRunnable() != null )
+                {
+                    objects.add( search.getNextSearchRunnable() );
+                }
+
+                results = objects.toArray();
+
                 return results;
             }
             else
@@ -548,5 +608,4 @@
 
         return pages;
     }
-
 }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserLabelProvider.java Mon Sep  1 14:48:25 2008
@@ -25,6 +25,8 @@
 
 import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
 import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.studio.connection.core.Utils;
+import org.apache.directory.studio.connection.core.jobs.StudioRunnableWithProgress;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
@@ -36,7 +38,6 @@
 import org.apache.directory.studio.ldapbrowser.core.model.impl.BaseDNEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.DirectoryMetadataEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.ReferralBaseEntry;
-import org.apache.directory.studio.connection.core.Utils;
 import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.viewers.IColorProvider;
 import org.eclipse.jface.viewers.IFontProvider;
@@ -85,7 +86,7 @@
             IEntry entry = ( IEntry ) obj;
 
             StringBuffer append = new StringBuffer();
-           
+
             if ( entry.isChildrenInitialized() && ( entry.getChildrenCount() > 0 ) || entry.getChildrenFilter() != null )
             {
                 append.append( " (" ).append( entry.getChildrenCount() );
@@ -219,6 +220,38 @@
             }
 
         }
+        else if ( obj instanceof StudioRunnableWithProgress )
+        {
+            StudioRunnableWithProgress runnable = ( StudioRunnableWithProgress ) obj;
+            for ( Object lockedObject : runnable.getLockedObjects() )
+            {
+                if ( lockedObject instanceof ISearch )
+                {
+                    ISearch search = ( ISearch ) lockedObject;
+                    if ( obj == search.getTopSearchRunnable() )
+                    {
+                        return "--- Top Page ---";
+                    }
+                    else if ( obj == search.getNextSearchRunnable() )
+                    {
+                        return "--- Next Page ---";
+                    }
+                }
+                else if ( lockedObject instanceof IEntry )
+                {
+                    IEntry entry = ( IEntry ) lockedObject;
+                    if ( obj == entry.getTopPageChildrenRunnable() )
+                    {
+                        return "--- Top Page ---";
+                    }
+                    else if ( obj == entry.getNextPageChildrenRunnable() )
+                    {
+                        return "--- Next Page ---";
+                    }
+                }
+            }
+            return obj.toString();
+        }
         else if ( obj instanceof BrowserCategory )
         {
             BrowserCategory category = ( BrowserCategory ) obj;
@@ -275,6 +308,38 @@
             IEntry entry = sr.getEntry();
             return getImageByRdn( entry );
         }
+        else if ( obj instanceof StudioRunnableWithProgress )
+        {
+            StudioRunnableWithProgress runnable = ( StudioRunnableWithProgress ) obj;
+            for ( Object lockedObject : runnable.getLockedObjects() )
+            {
+                if ( lockedObject instanceof ISearch )
+                {
+                    ISearch search = ( ISearch ) lockedObject;
+                    if ( obj == search.getTopSearchRunnable() )
+                    {
+                        return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_TOP );
+                    }
+                    else if ( obj == search.getNextSearchRunnable() )
+                    {
+                        return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_NEXT );
+                    }
+                }
+                else if ( lockedObject instanceof IEntry )
+                {
+                    IEntry entry = ( IEntry ) lockedObject;
+                    if ( obj == entry.getTopPageChildrenRunnable() )
+                    {
+                        return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_TOP );
+                    }
+                    else if ( obj == entry.getNextPageChildrenRunnable() )
+                    {
+                        return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_NEXT );
+                    }
+                }
+            }
+            return null;
+        }
         else if ( obj instanceof BrowserCategory )
         {
             BrowserCategory category = ( BrowserCategory ) obj;
@@ -318,11 +383,13 @@
         }
         else if ( entry instanceof DirectoryMetadataEntry && ( ( DirectoryMetadataEntry ) entry ).isSchemaEntry() )
         {
-            return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
+            return BrowserCommonActivator.getDefault()
+                .getImage( BrowserCommonConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
         }
         else if ( entry.getDn().equals( entry.getBrowserConnection().getSchema().getDn() ) )
         {
-            return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
+            return BrowserCommonActivator.getDefault()
+                .getImage( BrowserCommonConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
         }
         else if ( entry.isAlias() )
         {
@@ -334,7 +401,8 @@
         }
         else if ( entry.isSubentry() )
         {
-            return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
+            return BrowserCommonActivator.getDefault()
+                .getImage( BrowserCommonConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
         }
         else
         {

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSorter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSorter.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSorter.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSorter.java Mon Sep  1 14:48:25 2008
@@ -24,8 +24,10 @@
 import java.math.BigInteger;
 
 import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.studio.connection.core.jobs.StudioRunnableWithProgress;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.DirectoryMetadataEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.RootDSE;
@@ -142,6 +144,71 @@
      */
     public int compare( Viewer viewer, Object o1, Object o2 )
     {
+        if ( o1 instanceof StudioRunnableWithProgress )
+        {
+            StudioRunnableWithProgress runnable = ( StudioRunnableWithProgress ) o1;
+            for ( Object lockedObject : runnable.getLockedObjects() )
+            {
+                if ( lockedObject instanceof ISearch )
+                {
+                    ISearch search = ( ISearch ) lockedObject;
+                    if ( o1 == search.getTopSearchRunnable() )
+                    {
+                        return lessThan();
+                    }
+                    else if ( o1 == search.getNextSearchRunnable() )
+                    {
+                        return greaterThan();
+                    }
+                }
+                else if ( lockedObject instanceof IEntry )
+                {
+                    IEntry entry = ( IEntry ) lockedObject;
+                    if ( o1 == entry.getTopPageChildrenRunnable() )
+                    {
+                        return lessThan();
+                    }
+                    else if ( o1 == entry.getNextPageChildrenRunnable() )
+                    {
+                        return greaterThan();
+                    }
+                }
+            }
+            return lessThan();
+        }
+        if ( o2 instanceof StudioRunnableWithProgress )
+        {
+            StudioRunnableWithProgress runnable = ( StudioRunnableWithProgress ) o2;
+            for ( Object lockedObject : runnable.getLockedObjects() )
+            {
+                if ( lockedObject instanceof ISearch )
+                {
+                    ISearch search = ( ISearch ) lockedObject;
+                    if ( o2 == search.getTopSearchRunnable() )
+                    {
+                        return greaterThan();
+                    }
+                    else if ( o2 == search.getNextSearchRunnable() )
+                    {
+                        return lessThan();
+                    }
+                }
+                else if ( lockedObject instanceof IEntry )
+                {
+                    IEntry entry = ( IEntry ) lockedObject;
+                    if ( o2 == entry.getTopPageChildrenRunnable() )
+                    {
+                        return greaterThan();
+                    }
+                    else if ( o2 == entry.getNextPageChildrenRunnable() )
+                    {
+                        return lessThan();
+                    }
+                }
+            }
+            return greaterThan();
+        }
+
         if ( o1 == null && o2 == null )
         {
             return equal();

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java Mon Sep  1 14:48:25 2008
@@ -45,12 +45,16 @@
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
 
 
 /**
@@ -85,6 +89,12 @@
 
     private static final String X_FETCH_SUBENTRIES = "X-FETCH-SUBENTRIES";
 
+    private static final String X_PAGED_SEARCH = "X-PAGED-SEARCH";
+
+    private static final String X_PAGED_SEARCH_SIZE = "X-PAGED-SEARCH-SIZE";
+
+    private static final String X_PAGED_SEARCH_SCROLL_MODE = "X-PAGED-SEARCH-SCROLL-MODE";
+
     /** The checkbox to fetch the base DN's from namingContexts whenever opening the connection */
     private Button autoFetchBaseDnsButton;
 
@@ -106,6 +116,18 @@
     /** The fetch subentries button. */
     private Button fetchSubentriesButton;
 
+    /** The paged search button. */
+    protected Button pagedSearchButton;
+
+    /** The paged search size label. */
+    protected Label pagedSearchSizeLabel;
+
+    /** The paged search size text. */
+    protected Text pagedSearchSizeText;
+
+    /** The paged search scroll mode button. */
+    protected Button pagedSearchScrollModeButton;
+
 
     /**
      * Creates a new instance of BrowserParameterPage.
@@ -195,7 +217,51 @@
 
 
     /**
-     * Gets a temporary connection with all conection parameter 
+     * Returns true if paged search should be used
+     * while browsing.
+     * 
+     * @return true, if paged search should be used
+     */
+    private boolean isPagedSearch()
+    {
+        return pagedSearchButton.getSelection();
+    }
+
+
+    /**
+     * Gets the paged search size.
+     * 
+     * @return the paged search size
+     */
+    private int getPagedSearchSize()
+    {
+        int pageSize;
+        try
+        {
+            pageSize = new Integer( pagedSearchSizeText.getText() ).intValue();
+        }
+        catch ( NumberFormatException e )
+        {
+            pageSize = 100;
+        }
+        return pageSize;
+    }
+
+
+    /**
+     * Returns true if scroll mode should be used
+     * for paged search.
+     * 
+     * @return true, if scroll mode should be used
+     */
+    private boolean isPagedSearchScrollMode()
+    {
+        return pagedSearchScrollModeButton.getSelection();
+    }
+
+
+    /**
+     * Gets a temporary connection with all connection parameter 
      * entered in this page. 
      *
      * @return a test connection
@@ -215,7 +281,7 @@
     {
         addBaseDNInput( parent );
         addLimitInput( parent );
-        addOptionsInput( parent );
+        addControlInput( parent );
     }
 
 
@@ -248,20 +314,39 @@
 
 
     /**
-     * Adds the options input.
+     * Adds the control input.
      * 
      * @param parent the parent
      */
-    private void addOptionsInput( Composite parent )
+    private void addControlInput( Composite parent )
     {
         Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
 
-        Group group = BaseWidgetUtils.createGroup( composite, "Options", 1 );
+        Group group = BaseWidgetUtils.createGroup( composite, "Controls", 1 );
         Composite groupComposite = BaseWidgetUtils.createColumnContainer( group, 1, 1 );
 
+        // fetch subentries control
         fetchSubentriesButton = BaseWidgetUtils.createCheckbox( groupComposite,
             "Fetch subentries while browsing (requires additional search request)", 1 );
+        fetchSubentriesButton
+            .setToolTipText( "If enabled both, normal entries and subentries according to RFC 3672, are retrieved. "
+                + "This causes additional search requests while browsing the DIT." );
         fetchSubentriesButton.setSelection( false );
+
+        // paged search control
+        Composite sprcComposite = BaseWidgetUtils.createColumnContainer( groupComposite, 4, 1 );
+        pagedSearchButton = BaseWidgetUtils.createCheckbox( sprcComposite, "Paged Search", 1 );
+        pagedSearchButton.setToolTipText( "If enabled simple paged results control is used." );
+
+        pagedSearchSizeLabel = BaseWidgetUtils.createLabel( sprcComposite, " Page Size:", 1 );
+        pagedSearchSizeText = BaseWidgetUtils.createText( sprcComposite, "100", 5, 1 );
+        pagedSearchScrollModeButton = BaseWidgetUtils.createCheckbox( sprcComposite, "Scroll Mode", 1 );
+        pagedSearchScrollModeButton
+            .setToolTipText( "If enabled only one page is fetched from the server at once while browsing, "
+                + "you could 'scroll' through the pages by using the 'next page' and 'top page' items. "
+                + "If disabled _all_ entries are fetched from the server, the paged result control "
+                + "is only used in background to avoid server-side limits." );
+        pagedSearchScrollModeButton.setSelection( true );
     }
 
 
@@ -292,6 +377,9 @@
     {
         // set enabled/disabled state of fields and buttons
         baseDNCombo.setEnabled( !isAutoFetchBaseDns() );
+        pagedSearchSizeLabel.setEnabled( isPagedSearch() );
+        pagedSearchSizeText.setEnabled( isPagedSearch() );
+        pagedSearchScrollModeButton.setEnabled( isPagedSearch() );
 
         // validate input fields
         message = null;
@@ -340,6 +428,15 @@
         boolean fetchSubentries = parameter
             .getExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_FETCH_SUBENTRIES );
         fetchSubentriesButton.setSelection( fetchSubentries );
+
+        boolean pagedSearch = parameter.getExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH );
+        pagedSearchButton.setSelection( pagedSearch );
+        String pagedSearchSize = parameter
+            .getExtendedProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SIZE );
+        pagedSearchSizeText.setText( pagedSearchSize != null ? pagedSearchSize : "100" );
+        boolean pagedSearchScrollMode = parameter
+            .getExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SCROLL_MODE );
+        pagedSearchScrollModeButton.setSelection( pagedSearch ? pagedSearchScrollMode : true );
     }
 
 
@@ -405,6 +502,31 @@
                 connectionPageModified();
             }
         } );
+
+        pagedSearchButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                connectionPageModified();
+            }
+        } );
+        pagedSearchSizeText.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) )
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+        pagedSearchSizeText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                connectionPageModified();
+            }
+        } );
     }
 
 
@@ -424,6 +546,11 @@
             getAliasesDereferencingMethod().getOrdinal() );
         parameter.setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_FETCH_SUBENTRIES,
             isFetchSubentries() );
+        parameter.setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH, isPagedSearch() );
+        parameter.setExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SIZE,
+            getPagedSearchSize() );
+        parameter.setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SCROLL_MODE,
+            isPagedSearchScrollMode() );
     }
 
 
@@ -480,10 +607,18 @@
             .getByOrdinal( aliasesDereferencingMethodOrdinal );
         boolean fetchSubentries = connectionParameter
             .getExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_FETCH_SUBENTRIES );
+        boolean pagedSearch = connectionParameter
+            .getExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH );
+        int pagedSearchSize = connectionParameter
+            .getExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SIZE );
+        boolean pagedSearchScrollMode = connectionParameter
+            .getExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SCROLL_MODE );
 
         return fetchBaseDns != isAutoFetchBaseDns() || !StringUtils.equals( baseDn, getBaseDN() )
             || referralsHandlingMethod != getReferralsHandlingMethod()
-            || aliasesDereferencingMethod != getAliasesDereferencingMethod() || fetchSubentries != isFetchSubentries();
+            || aliasesDereferencingMethod != getAliasesDereferencingMethod() || fetchSubentries != isFetchSubentries()
+            || pagedSearch != isPagedSearch() || pagedSearchSize != getPagedSearchSize()
+            || pagedSearchScrollMode != isPagedSearchScrollMode();
     }
 
 
@@ -553,12 +688,30 @@
                 break;
         }
 
+        // fetch subentries
         boolean fetchSubentries = parameter
             .getExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_FETCH_SUBENTRIES );
         if ( fetchSubentries )
         {
             ldapUrl.getExtensions().add( new Extension( false, X_FETCH_SUBENTRIES, null ) );
         }
+
+        // paged search
+        boolean pagedSearch = parameter
+            .getExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH );
+        if ( pagedSearch )
+        {
+            ldapUrl.getExtensions().add( new Extension( false, X_PAGED_SEARCH, null ) );
+            ldapUrl.getExtensions().add(
+                new Extension( false, X_PAGED_SEARCH_SIZE, parameter
+                    .getExtendedProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SIZE ) ) );
+            boolean pagedSearchScrollMode = parameter
+                .getExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SCROLL_MODE );
+            if ( pagedSearchScrollMode )
+            {
+                ldapUrl.getExtensions().add( new Extension( false, X_PAGED_SEARCH_SCROLL_MODE, null ) );
+            }
+        }
     }
 
 
@@ -649,5 +802,26 @@
         Extension fetchSubentries = ldapUrl.getExtension( X_FETCH_SUBENTRIES );
         parameter.setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_FETCH_SUBENTRIES,
             fetchSubentries != null );
+
+        // paged search
+        Extension pagedSearch = ldapUrl.getExtension( X_PAGED_SEARCH );
+        String pagedSearchSize = ldapUrl.getExtensionValue( X_PAGED_SEARCH_SIZE );
+        Extension pagedSearchScrollMode = ldapUrl.getExtension( X_PAGED_SEARCH_SCROLL_MODE );
+        if ( pagedSearch != null )
+        {
+            parameter.setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH,
+                pagedSearch != null );
+            try
+            {
+                parameter.setExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SIZE,
+                    new Integer( pagedSearchSize ).intValue() );
+            }
+            catch ( NumberFormatException e )
+            {
+                parameter.setExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SIZE, 100 );
+            }
+            parameter.setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SCROLL_MODE,
+                pagedSearchScrollMode != null );
+        }
     }
 }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java Mon Sep  1 14:48:25 2008
@@ -212,7 +212,7 @@
                         entry = browserConnection.getEntryFromCache( initialDN );
                         if ( entry == null )
                         {
-                            ReadEntryRunnable runnable = new ReadEntryRunnable( browserConnection, suffix );
+                            ReadEntryRunnable runnable = new ReadEntryRunnable( browserConnection, initialDN );
                             RunnableContextRunner.execute( runnable, null, true );
                             entry = runnable.getReadEntry();
                         }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java Mon Sep  1 14:48:25 2008
@@ -24,7 +24,9 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.syntax.AttributeTypeDescription;
@@ -35,18 +37,21 @@
 import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
 import org.apache.directory.studio.ldapbrowser.core.jobs.SearchRunnable;
 import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob;
-import org.apache.directory.studio.ldapbrowser.core.model.Control;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.StudioControl;
+import org.apache.directory.studio.ldapbrowser.core.model.StudioPagedResultsControl;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
@@ -193,6 +198,18 @@
     /** The subentries control button. */
     protected Button subentriesControlButton;
 
+    /** The paged search control button. */
+    protected Button pagedSearchControlButton;
+
+    /** The paged search control size label. */
+    protected Label pagedSearchControlSizeLabel;
+
+    /** The paged search control size text. */
+    protected Text pagedSearchControlSizeText;
+
+    /** The paged search control scroll button. */
+    protected Button pagedSearchControlScrollButton;
+
 
     /**
      * Creates a new instance of SearchPageWrapper.
@@ -509,16 +526,59 @@
             return;
         }
 
-        controlLabel = BaseWidgetUtils.createLabel( composite, "Controls:", 1 );
+        Composite controlComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 3 );
+        Group controlGroup = BaseWidgetUtils.createGroup( controlComposite, "Controls", 1 );
 
-        subentriesControlButton = BaseWidgetUtils.createCheckbox( composite, Control.SUBENTRIES_CONTROL.getName(), 2 );
-        subentriesControlButton.addSelectionListener( new SelectionListener()
+        // subentries control
+        subentriesControlButton = BaseWidgetUtils.createCheckbox( controlGroup, "Subentries", 1 );
+        subentriesControlButton
+            .setToolTipText( "If enabled only subentries according to RFC 3672 are retrieved, no normal entries." );
+        subentriesControlButton.addSelectionListener( new SelectionAdapter()
         {
-            public void widgetDefaultSelected( SelectionEvent e )
+            public void widgetSelected( SelectionEvent e )
             {
+                validate();
             }
+        } );
 
-
+        // simple paged results control
+        Composite sprcComposite = BaseWidgetUtils.createColumnContainer( controlGroup, 4, 1 );
+        pagedSearchControlButton = BaseWidgetUtils.createCheckbox( sprcComposite, "Paged Search", 1 );
+        pagedSearchControlButton.setToolTipText( "If enabled simple paged results control is used." );
+        pagedSearchControlButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                validate();
+            }
+        } );
+        pagedSearchControlSizeLabel = BaseWidgetUtils.createLabel( sprcComposite, " Page Size:", 1 );
+        pagedSearchControlSizeText = BaseWidgetUtils.createText( sprcComposite, "100", 5, 1 );
+        pagedSearchControlSizeText.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) )
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+        pagedSearchControlSizeText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+        pagedSearchControlScrollButton = BaseWidgetUtils.createCheckbox( sprcComposite, "Scroll Mode", 1 );
+        pagedSearchControlScrollButton.setToolTipText( "If enabled only one page is fetched from the server at once, "
+            + "you could 'scroll' through the pages by using the 'next page' and 'top page' items. "
+            + "If disabled _all_ entries are fetched from the server, the paged result control "
+            + "is only used in background to avoid server-side limits." );
+        pagedSearchControlScrollButton.setSelection( true );
+        pagedSearchControlScrollButton.addSelectionListener( new SelectionAdapter()
+        {
             public void widgetSelected( SelectionEvent e )
             {
                 validate();
@@ -532,7 +592,6 @@
      */
     protected void validate()
     {
-
         if ( browserConnectionWidget.getBrowserConnection() != null )
         {
             if ( searchBaseWidget.getDn() == null
@@ -544,6 +603,10 @@
 
         filterWidget.setBrowserConnection( browserConnectionWidget.getBrowserConnection() );
 
+        pagedSearchControlSizeLabel.setEnabled( pagedSearchControlButton.getSelection() );
+        pagedSearchControlSizeText.setEnabled( pagedSearchControlButton.getSelection() );
+        pagedSearchControlScrollButton.setEnabled( pagedSearchControlButton.getSelection() );
+
         super.notifyListeners();
     }
 
@@ -617,16 +680,22 @@
             }
             if ( subentriesControlButton != null )
             {
-                Control[] searchControls = search.getControls();
-                if ( searchControls != null && searchControls.length > 0 )
+                List<StudioControl> searchControls = search.getControls();
+                if ( searchControls != null && searchControls.size() > 0 )
                 {
-                    for ( int i = 0; i < searchControls.length; i++ )
+                    for ( StudioControl c : searchControls )
                     {
-                        Control c = searchControls[i];
-                        if ( Control.SUBENTRIES_CONTROL.equals( c ) )
+                        if ( StudioControl.SUBENTRIES_CONTROL.equals( c ) )
                         {
                             subentriesControlButton.setSelection( true );
                         }
+                        else if ( c.getOid().equalsIgnoreCase( StudioPagedResultsControl.OID ) )
+                        {
+                            pagedSearchControlButton.setSelection( true );
+                            pagedSearchControlSizeText.setText( "" + ( ( StudioPagedResultsControl ) c ).getSize() );
+                            pagedSearchControlScrollButton.setSelection( ( ( StudioPagedResultsControl ) c )
+                                .isScrollMode() );
+                        }
                     }
                 }
             }
@@ -702,7 +771,8 @@
                     if ( returnOperationalAttributesButton.getSelection() )
                     {
                         Collection<AttributeTypeDescription> opAtds = SchemaUtils
-                            .getOperationalAttributeDescriptions( browserConnectionWidget.getBrowserConnection().getSchema() );
+                            .getOperationalAttributeDescriptions( browserConnectionWidget.getBrowserConnection()
+                                .getSchema() );
                         Collection<String> opAtdNames = SchemaUtils.getNames( opAtds );
                         raList.addAll( opAtdNames );
                         raList.add( ISearch.ALL_OPERATIONAL_ATTRIBUTES );
@@ -753,7 +823,8 @@
         }
         if ( referralsHandlingWidget != null )
         {
-            Connection.ReferralHandlingMethod referralsHandlingMethod = referralsHandlingWidget.getReferralsHandlingMethod();
+            Connection.ReferralHandlingMethod referralsHandlingMethod = referralsHandlingWidget
+                .getReferralsHandlingMethod();
             if ( referralsHandlingMethod != search.getReferralsHandlingMethod() )
             {
                 search.getSearchParameter().setReferralsHandlingMethod( referralsHandlingMethod );
@@ -762,35 +833,38 @@
         }
         if ( subentriesControlButton != null )
         {
-            Control selectedSubControl = subentriesControlButton.getSelection() ? Control.SUBENTRIES_CONTROL : null;
-            Control searchSubentriesControl = null;
-            Control[] searchControls = search.getControls();
-            if ( searchControls != null && searchControls.length > 0 )
+            Set<StudioControl> oldControls = new HashSet<StudioControl>();
+            oldControls.addAll( search.getSearchParameter().getControls() );
+
+            search.getSearchParameter().getControls().clear();
+
+            if ( subentriesControlButton.getSelection() )
             {
-                for ( int i = 0; i < searchControls.length; i++ )
-                {
-                    Control c = searchControls[i];
-                    if ( Control.SUBENTRIES_CONTROL.equals( c ) )
-                    {
-                        searchSubentriesControl = Control.SUBENTRIES_CONTROL;
-                        break;
-                    }
-                }
+                search.getSearchParameter().getControls().add( StudioControl.SUBENTRIES_CONTROL );
             }
-            if ( selectedSubControl != searchSubentriesControl )
+            if ( pagedSearchControlButton.getSelection() )
             {
-                if ( selectedSubControl == null )
+                int pageSize;
+                try
                 {
-                    search.getSearchParameter().setControls( null );
+                    pageSize = new Integer( pagedSearchControlSizeText.getText() ).intValue();
                 }
-                else
+                catch ( NumberFormatException e )
                 {
-                    search.getSearchParameter().setControls( new Control[]
-                        { selectedSubControl } );
+                    pageSize = 100;
                 }
-                searchModified = true;
+                boolean isScrollMode = pagedSearchControlScrollButton.getSelection();
+                StudioPagedResultsControl control = new StudioPagedResultsControl( pageSize, null, false, isScrollMode );
+                search.getSearchParameter().getControls().add( control );
             }
 
+            Set<StudioControl> newControls = new HashSet<StudioControl>();
+            newControls.addAll( search.getSearchParameter().getControls() );
+
+            if ( !oldControls.equals( newControls ) )
+            {
+                searchModified = true;
+            }
         }
 
         return searchModified;
@@ -808,6 +882,7 @@
     {
         if ( search.getBrowserConnection() != null )
         {
+            search.setSearchResults( null );
             new StudioBrowserJob( new SearchRunnable( new ISearch[]
                 { search } ) ).execute();
             return true;
@@ -842,12 +917,16 @@
         {
             return false;
         }
+        if ( pagedSearchControlButton != null && pagedSearchControlButton.isEnabled()
+            && "".equals( pagedSearchControlButton.getText() ) )
+        {
+            return false;
+        }
 
         return true;
     }
 
 
-    
     /**
      * Gets the error message or null if the search page is valid.
      * 
@@ -871,11 +950,11 @@
         {
             return "Please enter a valid filter.";
         }
-        
+
         return null;
     }
-    
-    
+
+
     /**
      * Sets the enabled state of the widget.
      * 

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionIO.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionIO.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionIO.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionIO.java Mon Sep  1 14:48:25 2008
@@ -20,8 +20,12 @@
 package org.apache.directory.studio.ldapbrowser.core;
 
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -31,6 +35,7 @@
 import javax.naming.InvalidNameException;
 
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.Base64;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.io.ConnectionIOException;
 import org.apache.directory.studio.ldapbrowser.core.model.BookmarkParameter;
@@ -38,6 +43,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
+import org.apache.directory.studio.ldapbrowser.core.model.StudioControl;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.Bookmark;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.Search;
@@ -61,10 +67,10 @@
 {
     // XML tags
     private static final String BROWSER_CONNECTIONS_TAG = "browserConnections";
-    
+
     private static final String BROWSER_CONNECTION_TAG = "browserConnection";
     private static final String ID_TAG = "id";
-    
+
     private static final String SEARCHES_TAG = "searches";
     private static final String SEARCH_PARAMETER_TAG = "searchParameter";
     private static final String NAME_TAG = "name";
@@ -78,12 +84,13 @@
     private static final String COUNT_LIMIT_TAG = "countLimit";
     private static final String ALIASES_DEREFERENCING_METHOD_TAG = "aliasesDereferencingMethod";
     private static final String REFERRALS_HANDLING_METHOD_TAG = "referralsHandlingMethod";
-    //TODO: Controls
-    
+    private static final String CONTROLS_TAG = "controls";
+    private static final String CONTROL_TAG = "control";
+
     private static final String BOOKMARKS_TAG = "bookmarks";
     private static final String BOOKMARK_PARAMETER_TAG = "bookmarkParameter";
     private static final String DN_TAG = "dn";
-    
+
 
     /**
      * Loads the browser connections using the input stream.
@@ -95,7 +102,8 @@
      * @throws ConnectionIOException 
      *      if an error occurs when converting the document
      */
-    public static void load( InputStream stream, Map<String, IBrowserConnection> browserConnectionMap ) throws ConnectionIOException
+    public static void load( InputStream stream, Map<String, IBrowserConnection> browserConnectionMap )
+        throws ConnectionIOException
     {
         SAXReader saxReader = new SAXReader();
         Document document = null;
@@ -133,7 +141,8 @@
      * @throws ConnectionIOException
      *      if an error occurs when converting values
      */
-    private static void readBrowserConnection( Element element, Map<String, IBrowserConnection> browserConnectionMap ) throws ConnectionIOException
+    private static void readBrowserConnection( Element element, Map<String, IBrowserConnection> browserConnectionMap )
+        throws ConnectionIOException
     {
         // ID
         Attribute idAttribute = element.attribute( ID_TAG );
@@ -141,8 +150,8 @@
         {
             String id = idAttribute.getValue();
             IBrowserConnection browserConnection = browserConnectionMap.get( id );
-            
-            if( browserConnection != null )
+
+            if ( browserConnection != null )
             {
                 Element searchesElement = element.element( SEARCHES_TAG );
                 if ( searchesElement != null )
@@ -155,7 +164,7 @@
                         browserConnection.getSearchManager().addSearch( search );
                     }
                 }
-                
+
                 Element bookmarksElement = element.element( BOOKMARKS_TAG );
                 if ( bookmarksElement != null )
                 {
@@ -170,19 +179,20 @@
             }
         }
     }
-    
-    
-    private static SearchParameter readSearch( Element searchParameterElement, IBrowserConnection browserConnection ) throws ConnectionIOException
+
+
+    private static SearchParameter readSearch( Element searchParameterElement, IBrowserConnection browserConnection )
+        throws ConnectionIOException
     {
         SearchParameter searchParameter = new SearchParameter();
-        
+
         // Name
         Attribute nameAttribute = searchParameterElement.attribute( NAME_TAG );
         if ( nameAttribute != null )
         {
             searchParameter.setName( nameAttribute.getValue() );
         }
-        
+
         // Search base
         Attribute searchBaseAttribute = searchParameterElement.attribute( SEARCH_BASE_TAG );
         if ( searchBaseAttribute != null )
@@ -193,18 +203,18 @@
             }
             catch ( InvalidNameException e )
             {
-                throw new ConnectionIOException( "Unable to parse 'Search Base' of search '" + searchParameter.getName()
-                    + "' :" + searchBaseAttribute.getValue() );
+                throw new ConnectionIOException( "Unable to parse 'Search Base' of search '"
+                    + searchParameter.getName() + "' :" + searchBaseAttribute.getValue() );
             }
         }
-        
+
         // Filter
         Attribute filterAttribute = searchParameterElement.attribute( FILTER_TAG );
         if ( filterAttribute != null )
         {
             searchParameter.setFilter( filterAttribute.getValue() );
         }
-        
+
         // Returning Attributes
         Element returningAttributesElement = searchParameterElement.element( RETURNING_ATTRIBUTES_TAG );
         if ( returningAttributesElement != null )
@@ -213,7 +223,7 @@
             for ( Iterator<?> i = returningAttributesElement.elementIterator( RETURNING_ATTRIBUTE_TAG ); i.hasNext(); )
             {
                 Element returningAttributeElement = ( Element ) i.next();
-                
+
                 Attribute valueAttribute = returningAttributeElement.attribute( VALUE_TAG );
                 if ( valueAttribute != null )
                 {
@@ -223,7 +233,7 @@
             searchParameter.setReturningAttributes( returningAttributes
                 .toArray( new String[returningAttributes.size()] ) );
         }
-        
+
         // Scope
         Attribute scopeAttribute = searchParameterElement.attribute( SCOPE_TAG );
         if ( scopeAttribute != null )
@@ -234,12 +244,11 @@
             }
             catch ( IllegalArgumentException e )
             {
-                throw new ConnectionIOException( "Unable to parse 'Scope' of search '"
-                    + searchParameter.getName() + "' as int value. Scope value :"
-                    + scopeAttribute.getValue() );
+                throw new ConnectionIOException( "Unable to parse 'Scope' of search '" + searchParameter.getName()
+                    + "' as int value. Scope value :" + scopeAttribute.getValue() );
             }
         }
-        
+
         // Time limit
         Attribute timeLimitAttribute = searchParameterElement.attribute( TIME_LIMIT_TAG );
         if ( timeLimitAttribute != null )
@@ -254,7 +263,7 @@
                     + "' as int value. Time limit value :" + timeLimitAttribute.getValue() );
             }
         }
-        
+
         // Count limit
         Attribute countLimitAttribute = searchParameterElement.attribute( COUNT_LIMIT_TAG );
         if ( countLimitAttribute != null )
@@ -265,13 +274,15 @@
             }
             catch ( NumberFormatException e )
             {
-                throw new ConnectionIOException( "Unable to parse 'Count limit' of search '" + searchParameter.getName()
-                    + "' as int value. Count limit value :" + countLimitAttribute.getValue() );
+                throw new ConnectionIOException( "Unable to parse 'Count limit' of search '"
+                    + searchParameter.getName() + "' as int value. Count limit value :"
+                    + countLimitAttribute.getValue() );
             }
         }
-        
+
         // Alias dereferencing method
-        Attribute aliasesDereferencingMethodAttribute = searchParameterElement.attribute( ALIASES_DEREFERENCING_METHOD_TAG );
+        Attribute aliasesDereferencingMethodAttribute = searchParameterElement
+            .attribute( ALIASES_DEREFERENCING_METHOD_TAG );
         if ( aliasesDereferencingMethodAttribute != null )
         {
             try
@@ -286,7 +297,7 @@
                     + aliasesDereferencingMethodAttribute.getValue() );
             }
         }
-        
+
         // Referrals handling method
         Attribute referralsHandlingMethodAttribute = searchParameterElement.attribute( REFERRALS_HANDLING_METHOD_TAG );
         if ( referralsHandlingMethodAttribute != null )
@@ -303,25 +314,54 @@
                     + referralsHandlingMethodAttribute.getValue() );
             }
         }
-    
-        // TODO: Controls
-    
+
+        // Controls
+        Element controlsElement = searchParameterElement.element( CONTROLS_TAG );
+        if ( controlsElement != null )
+        {
+            for ( Iterator<?> i = controlsElement.elementIterator( CONTROL_TAG ); i.hasNext(); )
+            {
+                Element controlElement = ( Element ) i.next();
+
+                Attribute valueAttribute = controlElement.attribute( VALUE_TAG );
+                if ( valueAttribute != null )
+                {
+                    byte[] bytes = Base64.decode( valueAttribute.getValue().toCharArray() );
+                    ByteArrayInputStream bais = null;
+                    ObjectInputStream ois = null;
+                    try
+                    {
+                        bais = new ByteArrayInputStream( bytes );
+                        ois = new ObjectInputStream( bais );
+                        StudioControl control = ( StudioControl ) ois.readObject();
+                        searchParameter.getControls().add( control );
+                        ois.close();
+                    }
+                    catch ( Exception e )
+                    {
+                        throw new ConnectionIOException( "Unable to parse 'Control' of search '"
+                            + searchParameter.getName() + "'. Control value :" + valueAttribute.getValue() );
+                    }
+                }
+            }
+        }
+
         return searchParameter;
     }
 
 
-    private static BookmarkParameter readBookmark( Element bookmarkParameterElement, IBrowserConnection browserConnection )
-        throws ConnectionIOException
+    private static BookmarkParameter readBookmark( Element bookmarkParameterElement,
+        IBrowserConnection browserConnection ) throws ConnectionIOException
     {
         BookmarkParameter bookmarkParameter = new BookmarkParameter();
-    
+
         // Name
         Attribute nameAttribute = bookmarkParameterElement.attribute( NAME_TAG );
         if ( nameAttribute != null )
         {
             bookmarkParameter.setName( nameAttribute.getValue() );
         }
-    
+
         // DN
         Attribute dnAttribute = bookmarkParameterElement.attribute( DN_TAG );
         if ( dnAttribute != null )
@@ -336,7 +376,7 @@
                     + "' :" + dnAttribute.getValue() );
             }
         }
-    
+
         return bookmarkParameter;
     }
 
@@ -351,7 +391,8 @@
      * @throws IOException
      *      if an I/O error occurs
      */
-    public static void save( OutputStream stream, Map<String, IBrowserConnection> browserConnectionMap ) throws IOException
+    public static void save( OutputStream stream, Map<String, IBrowserConnection> browserConnectionMap )
+        throws IOException
     {
         // Creating the Document
         Document document = DocumentHelper.createDocument();
@@ -383,8 +424,10 @@
      *      the parent Element
      * @param browserConnection
      *      the browser connection
+     * @throws IOException 
      */
     private static void writeBrowserConnection( Element parent, IBrowserConnection browserConnection )
+        throws IOException
     {
         Element browserConnectionElement = parent.addElement( BROWSER_CONNECTION_TAG );
 
@@ -399,7 +442,7 @@
             Element searchParameterElement = searchesElement.addElement( SEARCH_PARAMETER_TAG );
             writeSearch( searchParameterElement, search.getSearchParameter() );
         }
-        
+
         // Bookmarks
         Element bookmarksElement = browserConnectionElement.addElement( BOOKMARKS_TAG );
         IBookmark[] bookmarks = browserConnection.getBookmarkManager().getBookmarks();
@@ -408,70 +451,61 @@
             Element bookmarkParameterElement = bookmarksElement.addElement( BOOKMARK_PARAMETER_TAG );
             writeBookmark( bookmarkParameterElement, bookmark.getBookmarkParameter() );
         }
-        
-        
-//        // Name
-//        connectionElement.addAttribute( NAME_TAG, connection.getName() );
-//
-//        // Host
-//        connectionElement.addAttribute( HOST_TAG, connection.getHost() );
-//
-//        // Port
-//        connectionElement.addAttribute( PORT_TAG, "" + connection.getPort() );
-//
-//        // Encryption Method
-//        connectionElement.addAttribute( ENCRYPTION_METHOD_TAG, connection.getEncryptionMethod().toString() );
-//
-//        // Auth Method
-//        connectionElement.addAttribute( AUTH_METHOD_TAG, connection.getAuthMethod().toString() );
-//
-//        // Bind Principal
-//        connectionElement.addAttribute( BIND_PRINCIPAL_TAG, connection.getBindPrincipal() );
-//
-//        // Bind Password
-//        connectionElement.addAttribute( BIND_PASSWORD_TAG, connection.getBindPassword() );
-
     }
 
 
     private static void writeSearch( Element searchParameterElement, SearchParameter searchParameter )
+        throws IOException
     {
         // Name
         searchParameterElement.addAttribute( NAME_TAG, searchParameter.getName() );
-        
+
         // Search base
         String searchBase = searchParameter.getSearchBase() != null ? searchParameter.getSearchBase().getUpName() : "";
         searchParameterElement.addAttribute( SEARCH_BASE_TAG, searchBase );
-        
+
         // Filter
         searchParameterElement.addAttribute( FILTER_TAG, searchParameter.getFilter() );
-        
+
         // Returning Attributes
         Element returningAttributesElement = searchParameterElement.addElement( RETURNING_ATTRIBUTES_TAG );
         for ( String ra : searchParameter.getReturningAttributes() )
         {
             Element raElement = returningAttributesElement.addElement( RETURNING_ATTRIBUTE_TAG );
             raElement.addAttribute( VALUE_TAG, ra );
-        } 
-        
+        }
+
         // Scope
         searchParameterElement.addAttribute( SCOPE_TAG, searchParameter.getScope().toString() );
-        
+
         // Time limit
         searchParameterElement.addAttribute( TIME_LIMIT_TAG, "" + searchParameter.getTimeLimit() );
-        
+
         // Count limit
         searchParameterElement.addAttribute( COUNT_LIMIT_TAG, "" + searchParameter.getCountLimit() );
-        
+
         // Alias dereferencing method
         searchParameterElement.addAttribute( ALIASES_DEREFERENCING_METHOD_TAG, searchParameter
             .getAliasesDereferencingMethod().toString() );
-        
+
         // Referrals handling method
         searchParameterElement.addAttribute( REFERRALS_HANDLING_METHOD_TAG, searchParameter
             .getReferralsHandlingMethod().toString() );
-        
-        // TODO: Controls
+
+        // Controls
+        Element controlsElement = searchParameterElement.addElement( CONTROLS_TAG );
+        for ( StudioControl studioControl : searchParameter.getControls() )
+        {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream( baos );
+            oos.writeObject( studioControl );
+            oos.close();
+            byte[] bytes = baos.toByteArray();
+            String controlsValue = new String( Base64.encode( bytes ) );
+
+            Element controlElement = controlsElement.addElement( CONTROL_TAG );
+            controlElement.addAttribute( VALUE_TAG, controlsValue );
+        }
     }
 
 
@@ -479,7 +513,7 @@
     {
         // Name
         bookmarkParameterElement.addAttribute( NAME_TAG, bookmarkParameter.getName() );
-        
+
         // DN
         String dn = bookmarkParameter.getDn() != null ? bookmarkParameter.getDn().getUpName() : "";
         bookmarkParameterElement.addAttribute( DN_TAG, dn );

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteEntriesJob.java Mon Sep  1 14:48:25 2008
@@ -50,6 +50,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.core.model.StudioControl;
 import org.apache.directory.studio.ldapbrowser.core.utils.JNDIUtils;
 
 
@@ -239,7 +240,7 @@
             // do not follow referrals or dereference aliases when deleting entries
             AliasDereferencingMethod aliasDereferencingMethod = AliasDereferencingMethod.NEVER;
             ReferralHandlingMethod referralsHandlingMethod = browserConnection.getRootDSE().isControlSupported(
-                org.apache.directory.studio.ldapbrowser.core.model.Control.MANAGEDSAIT_CONTROL.getOid() ) ? ReferralHandlingMethod.MANAGE
+                StudioControl.MANAGEDSAIT_CONTROL.getOid() ) ? ReferralHandlingMethod.MANAGE
                 : ReferralHandlingMethod.IGNORE;
 
             // perform one-level search and delete recursively
@@ -350,20 +351,17 @@
         // controls
         List<Control> controlList = new ArrayList<Control>();
         if ( useTreeDeleteControl
-            && browserConnection.getRootDSE().isControlSupported(
-                org.apache.directory.studio.ldapbrowser.core.model.Control.TREEDELETE_CONTROL.getOid() ) )
+            && browserConnection.getRootDSE().isControlSupported( StudioControl.TREEDELETE_CONTROL.getOid() ) )
         {
-            Control treeDeleteControl = new BasicControl(
-                org.apache.directory.studio.ldapbrowser.core.model.Control.TREEDELETE_CONTROL.getOid(),
-                org.apache.directory.studio.ldapbrowser.core.model.Control.TREEDELETE_CONTROL.isCritical(),
-                org.apache.directory.studio.ldapbrowser.core.model.Control.TREEDELETE_CONTROL.getControlValue() );
+            Control treeDeleteControl = new BasicControl( StudioControl.TREEDELETE_CONTROL.getOid(),
+                StudioControl.TREEDELETE_CONTROL.isCritical(), StudioControl.TREEDELETE_CONTROL.getControlValue() );
             controlList.add( treeDeleteControl );
         }
         Control[] controls = controlList.toArray( new Control[controlList.size()] );
 
         // do not follow referrals
         ReferralHandlingMethod referralsHandlingMethod = browserConnection.getRootDSE().isControlSupported(
-            org.apache.directory.studio.ldapbrowser.core.model.Control.MANAGEDSAIT_CONTROL.getOid() ) ? ReferralHandlingMethod.MANAGE
+            StudioControl.MANAGEDSAIT_CONTROL.getOid() ) ? ReferralHandlingMethod.MANAGE
             : ReferralHandlingMethod.IGNORE;
 
         // delete entry

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java?rev=691070&r1=691069&r2=691070&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlJob.java Mon Sep  1 14:48:25 2008
@@ -60,7 +60,7 @@
 import org.apache.directory.studio.dsmlv2.engine.Dsmlv2Engine;
 import org.apache.directory.studio.dsmlv2.request.SearchRequestDsml;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
-import org.apache.directory.studio.ldapbrowser.core.model.Control;
+import org.apache.directory.studio.ldapbrowser.core.model.StudioControl;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
@@ -434,15 +434,15 @@
      * @return
      *      a List of Shared LDAP Control Objects corresponding to the given Controls
      */
-    private List<org.apache.directory.shared.ldap.codec.Control> convertToSharedLdapControls( Control[] controls )
+    private List<org.apache.directory.shared.ldap.codec.Control> convertToSharedLdapControls( List<StudioControl> controls )
     {
         List<org.apache.directory.shared.ldap.codec.Control> returnList = new ArrayList<org.apache.directory.shared.ldap.codec.Control>();
 
         if ( controls != null )
         {
-            for ( int i = 0; i < controls.length; i++ )
+            for ( StudioControl control : controls )
             {
-                returnList.add( convertToSharedLDAP( controls[i] ) );
+                returnList.add( convertToSharedLDAP( control ) );
             }
         }
 
@@ -458,7 +458,7 @@
      * @return
      *      the corresponding Control in the Shared LDAP Model
      */
-    private static org.apache.directory.shared.ldap.codec.Control convertToSharedLDAP( Control control )
+    private static org.apache.directory.shared.ldap.codec.Control convertToSharedLDAP( StudioControl control )
     {
         org.apache.directory.shared.ldap.codec.Control sharedLdapControl = new org.apache.directory.shared.ldap.codec.Control();
 



Mime
View raw message