You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2010/10/15 17:32:26 UTC

svn commit: r1022966 - /directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/DirectoryApiConnectionWrapper.java

Author: pamarcelot
Date: Fri Oct 15 15:32:25 2010
New Revision: 1022966

URL: http://svn.apache.org/viewvc?rev=1022966&view=rev
Log:
Added implementation of the 'rename', 'add' and 'delete' operations.

Modified:
    directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/DirectoryApiConnectionWrapper.java

Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/DirectoryApiConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/DirectoryApiConnectionWrapper.java?rev=1022966&r1=1022965&r2=1022966&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/DirectoryApiConnectionWrapper.java (original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/DirectoryApiConnectionWrapper.java Fri Oct 15 15:32:25 2010
@@ -23,6 +23,7 @@ package org.apache.directory.studio.conn
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.directory.Attributes;
@@ -33,13 +34,23 @@ import javax.naming.ldap.Control;
 
 import org.apache.directory.ldap.client.api.LdapConnectionConfig;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
 import org.apache.directory.shared.ldap.cursor.Cursor;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AbandonListener;
+import org.apache.directory.shared.ldap.message.AddRequest;
+import org.apache.directory.shared.ldap.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.message.ArrayNamingEnumeration;
+import org.apache.directory.shared.ldap.message.DeleteRequest;
+import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
+import org.apache.directory.shared.ldap.message.MessageException;
+import org.apache.directory.shared.ldap.message.ModifyDnRequest;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
 import org.apache.directory.shared.ldap.message.Response;
+import org.apache.directory.shared.ldap.message.ResultResponse;
 import org.apache.directory.shared.ldap.message.SearchRequest;
 import org.apache.directory.shared.ldap.message.SearchRequestImpl;
 import org.apache.directory.shared.ldap.message.SearchResultEntry;
@@ -311,7 +322,7 @@ public class DirectoryApiConnectionWrapp
         }
         else
         {
-            return null;
+            return new org.apache.directory.shared.ldap.message.control.Control[0];
         }
     }
 
@@ -357,6 +368,25 @@ public class DirectoryApiConnectionWrapp
     public void renameEntry( final String oldDn, final String newDn, final boolean deleteOldRdn,
         final Control[] controls, final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
+        try
+        {
+            DN newName = new DN( newDn );
+
+            // Preparing the rename request
+            ModifyDnRequest request = new ModifyDnRequestImpl();
+            request.setName( new DN( oldDn ) );
+            request.setDeleteOldRdn( deleteOldRdn );
+            request.setNewRdn( newName.getRdn() );
+            request.setNewSuperior( newName.getParent() );
+            request.addAllControls( convertControls( controls ) );
+
+            // Performing the rename operation
+            getLdapConnection().modifyDn( request );
+        }
+        catch ( Exception e )
+        {
+            monitor.reportError( e );
+        }
     }
 
 
@@ -366,6 +396,21 @@ public class DirectoryApiConnectionWrapp
     public void createEntry( final String dn, final Attributes attributes, final Control[] controls,
         final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
+        try
+        {
+            // Preparing the add request
+            AddRequest request = new AddRequestImpl();
+            request.setEntryDn( new DN( dn ) );
+            request.setEntry( AttributeUtils.toClientEntry( attributes, new DN( dn ) ) );
+            request.addAllControls( convertControls( controls ) );
+
+            // Performing the add operation
+            getLdapConnection().add( request );
+        }
+        catch ( Exception e )
+        {
+            monitor.reportError( e );
+        }
     }
 
 
@@ -375,5 +420,19 @@ public class DirectoryApiConnectionWrapp
     public void deleteEntry( final String dn, final Control[] controls, final StudioProgressMonitor monitor,
         final ReferralsInfo referralsInfo )
     {
+        try
+        {
+            // Preparing the delete request
+            DeleteRequest request = new DeleteRequestImpl();
+            request.setName( new DN( dn ) );
+            request.addAllControls( convertControls( controls ) );
+
+            // Performing the delete operation
+            getLdapConnection().delete( request );
+        }
+        catch ( Exception e )
+        {
+            monitor.reportError( e );
+        }
     }
 }