directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r478527 - in /directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser: controller/ controller/actions/ model/ view/views/ view/views/wrappers/
Date Thu, 23 Nov 2006 10:28:05 GMT
Author: pamarcelot
Date: Thu Nov 23 02:28:04 2006
New Revision: 478527

URL: http://svn.apache.org/viewvc?view=rev&rev=478527
Log:
Updating the Refresh Action. Fixing a Bug that caused a double error message when a node (Entry
or Connection) was refreshed and the server was down. Only a single error message is displayed
now.

Modified:
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/BrowserViewController.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionEditAction.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/ConnectionWizardInformationPage.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/ConnectionWrapper.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/EntryWrapper.java

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java?view=diff&rev=478527&r1=478526&r2=478527
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java
Thu Nov 23 02:28:04 2006
@@ -87,7 +87,7 @@
     public void setView( final AttributesView view )
     {
         this.view = view;
-        
+
         // Handling selection of the Browser View to update this view
         view.getSite().getPage().addSelectionListener( BrowserView.ID, new ISelectionListener()
         {
@@ -100,7 +100,7 @@
                 view.resizeColumsToFit();
             }
         } );
-        
+
         // Handling the double click modification
         view.getViewer().getTable().addSelectionListener( new SelectionAdapter()
         {
@@ -189,7 +189,7 @@
                 }
                 else
                 {
-                    if ( ( ( StructuredSelection ) selection).size() == 1 )
+                    if ( ( ( StructuredSelection ) selection ).size() == 1 )
                     {
                         attributeEditAction.setEnabled( true );
                         if ( attributeDeleteAction.getText().equals( "Delete attributes"
) )
@@ -207,7 +207,7 @@
                             attributeDeleteAction.setToolTipText( "Delete attributes" );
                         }
                     }
-                    
+
                     attributeDeleteAction.setEnabled( true );
                 }
             }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/BrowserViewController.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/BrowserViewController.java?view=diff&rev=478527&r1=478526&r2=478527
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/BrowserViewController.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/BrowserViewController.java
Thu Nov 23 02:28:04 2006
@@ -107,7 +107,7 @@
     public void setView( final BrowserView view )
     {
         this.view = view;
-        
+
         // Adding DoubleClick behavior
         view.getViewer().addDoubleClickListener( new IDoubleClickListener()
         {
@@ -119,7 +119,8 @@
                 // Here's the real object
                 Object objectSelection = selection.getFirstElement();
 
-                view.getViewer().setExpandedState( objectSelection, !view.getViewer().getExpandedState(
objectSelection ) );
+                view.getViewer().setExpandedState( objectSelection,
+                    !view.getViewer().getExpandedState( objectSelection ) );
             }
         } );
     }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionEditAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionEditAction.java?view=diff&rev=478527&r1=478526&r2=478527
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionEditAction.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/ConnectionEditAction.java
Thu Nov 23 02:28:04 2006
@@ -82,7 +82,7 @@
         // Updating the state of the Connection since it has changed (this causes the icon
to change)
         connectionWrapper.setState( ConnectionWrapperState.NONE );
         connectionWrapper.connectionChanged();
-        
+
         selectedConnection.notifyListeners();
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java?view=diff&rev=478527&r1=478526&r2=478527
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java
Thu Nov 23 02:28:04 2006
@@ -27,14 +27,7 @@
 import org.apache.directory.ldapstudio.browser.view.views.BrowserView;
 import org.apache.directory.ldapstudio.browser.view.views.wrappers.ConnectionWrapper;
 import org.apache.directory.ldapstudio.browser.view.views.wrappers.EntryWrapper;
-import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2ResponseParser;
-import org.apache.directory.ldapstudio.dsmlv2.engine.Dsmlv2Engine;
-import org.apache.directory.ldapstudio.dsmlv2.reponse.ErrorResponse;
-import org.apache.directory.ldapstudio.dsmlv2.reponse.SearchResponse;
-import org.apache.directory.shared.ldap.codec.LdapResponse;
-import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
 import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.TreeSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.ui.PlatformUI;
@@ -64,81 +57,29 @@
 
         Object selection = ( ( TreeSelection ) viewer.getSelection() ).getFirstElement();
 
+        boolean isExpanded = viewer.getExpandedState( selection );
+
         // Clearing the children of the selected node
         if ( selection instanceof ConnectionWrapper )
         {
             ConnectionWrapper connectionWrapper = ( ConnectionWrapper ) selection;
             connectionWrapper.clearChildren();
+            isExpanded = true;
         }
         else if ( selection instanceof EntryWrapper )
         {
             EntryWrapper entryWrapper = ( EntryWrapper ) selection;
-            updateEntry( entryWrapper );
             entryWrapper.clearChildren();
+            entryWrapper.refreshAttributes();
         }
 
         // Refreshing the Browser View
         viewer.refresh( selection );
-        viewer.setExpandedState( selection, true );
+        viewer.setExpandedState( selection, isExpanded );
 
         // Refreshing the Attributes View
         AttributesView attributesView = ( AttributesView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
             .getActivePage().findView( AttributesView.ID );
         attributesView.refresh();
-    }
-
-
-    public void updateEntry( EntryWrapper entryWrapper )
-    {
-        try
-        {
-            // Initialization of the DSML Engine and the DSML Response Parser
-            Dsmlv2Engine engine = entryWrapper.getDsmlv2Engine();
-            Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();
-
-            String request = "<batchRequest>" + "	<searchRequest dn=\""
-                + entryWrapper.getEntry().getObjectName().getNormName() + "\""
-                + "			scope=\"baseObject\" derefAliases=\"neverDerefAliases\">"
-                + "		<filter><present name=\"objectclass\"></present></filter>"
+ "       <attributes>"
-                + "			<attribute name=\"*\"/>" + "			<attribute name=\"namingContexts\"/>"
-                + "			<attribute name=\"subSchemaSubEntry\"/>" + "			<attribute
name=\"altServer\"/>"
-                + "			<attribute name=\"supportedExtension\"/>" + "			<attribute
name=\"supportedControl\"/>"
-                + "			<attribute name=\"supportedSaslMechanism\"/>" + "			<attribute
name=\"supportedLdapVersion\"/>"
-                + "       </attributes>" + "	</searchRequest>" + "</batchRequest>";
-
-            // Executing the request and sending the result to the Response Parser
-            parser.setInput( engine.processDSML( request ) );
-            parser.parse();
-
-            LdapResponse ldapResponse = parser.getBatchResponse().getCurrentResponse();
-
-            if ( ldapResponse instanceof ErrorResponse )
-            {
-                ErrorResponse errorResponse = ( ( ErrorResponse ) ldapResponse );
-
-                // Displaying an error
-                MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
"Error !",
-                    "An error has ocurred.\n" + errorResponse.getMessage() );
-                return;
-            }
-            else if ( ldapResponse instanceof SearchResponse )
-            {
-
-                // Getting the Search Result Entry List containing our objects for the response
-                SearchResponse searchResponse = ( ( SearchResponse ) ldapResponse );
-
-                SearchResultEntry sre = searchResponse.getSearchResultEntryList().get( 0
);
-
-                entryWrapper.getEntry().setPartialAttributeList( sre.getPartialAttributeList()
);
-                return;
-            }
-        }
-        catch ( Exception e )
-        {
-            // Displaying an error
-            MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
"Error !",
-                "An error has ocurred.\n" + e.getMessage() );
-            return;
-        }
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java?view=diff&rev=478527&r1=478526&r2=478527
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java
Thu Nov 23 02:28:04 2006
@@ -258,7 +258,8 @@
         sb
             .append( "<userDN>" + ( ( "".equals( userDN.getNormName() ) ) ? "null"
: userDN.getNormName() )
                 + "</userDN>" );
-        sb.append( "<appendBaseDNtoUserDNWithBaseDN>" + appendBaseDNtoUserDNWithBaseDN
+ "</appendBaseDNtoUserDNWithBaseDN>" );
+        sb.append( "<appendBaseDNtoUserDNWithBaseDN>" + appendBaseDNtoUserDNWithBaseDN
+            + "</appendBaseDNtoUserDNWithBaseDN>" );
         sb.append( "<password>" + ( ( "".equals( password ) ) ? "null" : password )
+ "</password>" );
         sb.append( "</connection>" );
 

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java?view=diff&rev=478527&r1=478526&r2=478527
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java
Thu Nov 23 02:28:04 2006
@@ -172,8 +172,8 @@
             USERDN_END, null ) );
 
         // State: [USERDN_END] - Tag: <appendBaseDNtoUserDNWithBaseDN>
-        super.transitions[USERDN_END].put( new Tag( "appendBaseDNtoUserDNWithBaseDN", Tag.START
), new GrammarTransition(
-            USERDN_END, APPENDBASEDNTOUSERDN_START, appendBaseDNtoUserDNWithBaseDN ) );
+        super.transitions[USERDN_END].put( new Tag( "appendBaseDNtoUserDNWithBaseDN", Tag.START
),
+            new GrammarTransition( USERDN_END, APPENDBASEDNTOUSERDN_START, appendBaseDNtoUserDNWithBaseDN
) );
 
         // State: [PREFIXUSERDNWITHBASEDN_START] - Tag: </appendBaseDNtoUserDNWithBaseDN>
         super.transitions[APPENDBASEDNTOUSERDN_START].put( new Tag( "appendBaseDNtoUserDNWithBaseDN",
Tag.END ),
@@ -462,7 +462,8 @@
     /**
      * GrammarAction that adds a appendBaseDNtoUserDNWithBaseDN to a Connection
      */
-    private final GrammarAction appendBaseDNtoUserDNWithBaseDN = new GrammarAction( "Add
appendBaseDNtoUserDNWithBaseDN" )
+    private final GrammarAction appendBaseDNtoUserDNWithBaseDN = new GrammarAction(
+        "Add appendBaseDNtoUserDNWithBaseDN" )
     {
         public void action( ConnectionParserContainer container ) throws XmlPullParserException
         {

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/ConnectionWizardInformationPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/ConnectionWizardInformationPage.java?view=diff&rev=478527&r1=478526&r2=478527
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/ConnectionWizardInformationPage.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/ConnectionWizardInformationPage.java
Thu Nov 23 02:28:04 2006
@@ -403,7 +403,7 @@
 
         // User DN
         userDNText.setText( ( connection.getUserDN() == null ) ? "" : connection.getUserDN().getNormName()
);
-        
+
         // Append Base DN to User DN
         appendBaseDNtoUserDNWithBaseDNButton.setSelection( connection.isAppendBaseDNtoUserDNWithBaseDN()
);
 

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/ConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/ConnectionWrapper.java?view=diff&rev=478527&r1=478526&r2=478527
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/ConnectionWrapper.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/ConnectionWrapper.java
Thu Nov 23 02:28:04 2006
@@ -53,17 +53,20 @@
      *
      * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
      */
-    public enum ConnectionWrapperState{ NONE, RUNNING, ERROR }
-    
+    public enum ConnectionWrapperState
+    {
+        NONE, RUNNING, ERROR
+    }
+
     /** The parent element */
     private Object parent;
-    
+
     /** The children list */
     private List<EntryWrapper> children;
-    
+
     /** The wrapped conneection */
     private Connection connection;
-    
+
     /** The state of the ConnectionWrapper*/
     private ConnectionWrapperState state;
 
@@ -99,22 +102,19 @@
     {
         if ( state == ConnectionWrapperState.NONE )
         {
-            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION
).createImage();
+            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION
)
+                .createImage();
         }
         else if ( state == ConnectionWrapperState.RUNNING )
         {
-            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION_RUNNING
).createImage();
+            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION_RUNNING
)
+                .createImage();
         }
         else if ( state == ConnectionWrapperState.ERROR )
         {
-            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION_ERROR
).createImage();
+            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION_ERROR
)
+                .createImage();
         }
-         
-//        if ( hasError() )
-//        {
-//            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION_ERROR
)
-//                .createImage();
-//        }
 
         return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.CONNECTION
).createImage();
     }
@@ -178,16 +178,16 @@
                     if ( connection.isAppendBaseDNtoUserDNWithBaseDN() )
                     {
                         engine = new Dsmlv2Engine( connection.getHost(), connection.getPort(),
new LdapDN( connection
-                            .getUserDN().getNormName() + "," + connection.getBaseDN().getNormName()
).getNormName(),
-                            connection.getPassword() );
+                            .getUserDN().getNormName()
+                            + "," + connection.getBaseDN().getNormName() ).getNormName(),
connection.getPassword() );
                     }
                     else
                     {
-                        engine = new Dsmlv2Engine( connection.getHost(), connection.getPort(),
connection
-                            .getUserDN().getNormName(), connection.getPassword() );
+                        engine = new Dsmlv2Engine( connection.getHost(), connection.getPort(),
connection.getUserDN()
+                            .getNormName(), connection.getPassword() );
                     }
                 }
-                
+
                 Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();
 
                 String request = "<batchRequest>" + "	<searchRequest dn=\"" + connection.getBaseDN().getNormName()
@@ -222,7 +222,7 @@
                         baseDNWrapper.setIsBaseDN( true );
 
                         children.add( baseDNWrapper );
-                        
+
                         setState( ConnectionWrapperState.RUNNING );
                         browserView.getViewer().update( this, null );
                     }
@@ -231,7 +231,7 @@
                         setState( ConnectionWrapperState.ERROR );
                         clearChildren();
                         browserView.getViewer().update( this, null );
-                        
+
                         // Displaying an error
                         MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                             "Error !", "An error has ocurred.\n" + ldapResult.getErrorMessage()
);
@@ -241,7 +241,7 @@
                 else if ( ldapResponse instanceof ErrorResponse )
                 {
                     setState( ConnectionWrapperState.ERROR );
-                    clearChildren();
+                    children = new ArrayList<EntryWrapper>( 0 );
                     browserView.getViewer().update( this, null );
 
                     ErrorResponse errorResponse = ( ErrorResponse ) ldapResponse;
@@ -272,7 +272,8 @@
     {
         children = null;
     }
-    
+
+
     /**
      * Erases the Children List and the Dsmlv2 Engine
      */
@@ -282,7 +283,7 @@
         engine = null;
     }
 
-    
+
     /**
      * Sets the current state of the ConnectionWrapper
      * @param state the state to set
@@ -291,7 +292,8 @@
     {
         this.state = state;
     }
-    
+
+
     /**
      * Gets the current state of the ConnectionWrapper
      * @return the state of the ConnectionWrapper
@@ -300,7 +302,8 @@
     {
         return this.state;
     }
-    
+
+
     /**
      * Gets the Dsmlv2Engine
      * @return the Dsmlv2Engine

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/EntryWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/EntryWrapper.java?view=diff&rev=478527&r1=478526&r2=478527
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/EntryWrapper.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/EntryWrapper.java
Thu Nov 23 02:28:04 2006
@@ -29,16 +29,16 @@
 import org.apache.directory.ldapstudio.browser.model.Connection;
 import org.apache.directory.ldapstudio.browser.view.ImageKeys;
 import org.apache.directory.ldapstudio.browser.view.views.BrowserView;
+import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2ResponseParser;
+import org.apache.directory.ldapstudio.dsmlv2.engine.Dsmlv2Engine;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.ErrorResponse;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.SearchResponse;
 import org.apache.directory.shared.ldap.codec.LdapResponse;
 import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2ResponseParser;
-import org.apache.directory.ldapstudio.dsmlv2.engine.Dsmlv2Engine;
-import org.apache.directory.ldapstudio.dsmlv2.reponse.ErrorResponse;
-import org.apache.directory.ldapstudio.dsmlv2.reponse.SearchResponse;
 
 
 /**
@@ -318,7 +318,7 @@
         hasChildren = true;
     }
 
-    
+
     /**
      * Gets the Dsmlv2Engine
      * @return the Dsmlv2Engine
@@ -326,7 +326,7 @@
     public Dsmlv2Engine getDsmlv2Engine()
     {
         Object parent = getParent();
-        
+
         if ( parent instanceof EntryWrapper )
         {
             return ( ( EntryWrapper ) parent ).getDsmlv2Engine();
@@ -335,7 +335,78 @@
         {
             return ( ( ConnectionWrapper ) parent ).getDsmlv2Engine();
         }
-        
+
         return null;
+    }
+
+
+    /**
+     * Refreshes the Entry
+     * Executes a request on the server to re-fecth the attributes of the entry
+     * and its children
+     */
+    public void refreshAttributes()
+    {
+        try
+        {
+            // Initialization of the DSML Engine and the DSML Response Parser
+            Dsmlv2Engine engine = getDsmlv2Engine();
+            Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();
+
+            String request = "<batchRequest>" + "   <searchRequest dn=\"" + getEntry().getObjectName().getNormName()
+                + "\"" + "         scope=\"baseObject\" derefAliases=\"neverDerefAliases\">"
+                + "     <filter><present name=\"objectclass\"></present></filter>"
+ "       <attributes>"
+                + "         <attribute name=\"*\"/>" + "            <attribute name=\"namingContexts\"/>"
+                + "         <attribute name=\"subSchemaSubEntry\"/>" + "          
 <attribute name=\"altServer\"/>"
+                + "         <attribute name=\"supportedExtension\"/>"
+                + "           <attribute name=\"supportedControl\"/>"
+                + "         <attribute name=\"supportedSaslMechanism\"/>"
+                + "           <attribute name=\"supportedLdapVersion\"/>" + "     
 </attributes>"
+                + "    </searchRequest>" + "</batchRequest>";
+
+            // Executing the request and sending the result to the Response Parser
+            parser.setInput( engine.processDSML( request ) );
+            parser.parse();
+
+            LdapResponse ldapResponse = parser.getBatchResponse().getCurrentResponse();
+
+            if ( ldapResponse instanceof ErrorResponse )
+            {
+                ErrorResponse errorResponse = ( ( ErrorResponse ) ldapResponse );
+
+                // Displaying an error
+                MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
"Error !",
+                    "An error has ocurred.\n" + errorResponse.getMessage() );
+
+                // Creating an empty children list (this prevents the refresh to getting
a new error)
+                children = new ArrayList<EntryWrapper>( 0 );
+
+                return;
+            }
+            else if ( ldapResponse instanceof SearchResponse )
+            {
+
+                // Getting the Search Result Entry List containing our objects for the response
+                SearchResponse searchResponse = ( ( SearchResponse ) ldapResponse );
+
+                SearchResultEntry sre = searchResponse.getSearchResultEntryList().get( 0
);
+
+                getEntry().setPartialAttributeList( sre.getPartialAttributeList() );
+                return;
+            }
+        }
+        catch ( Exception e )
+        {
+            // Displaying an error
+            MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
"Error !",
+                "An error has ocurred.\n" + e.getMessage() );
+
+            // Creating an empty children list (this prevents the refresh to getting a new
error)
+            children = new ArrayList<EntryWrapper>( 0 );
+
+            return;
+        }
+
+        clearChildren();
     }
 }



Mime
View raw message