directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r584396 - in /directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core: internal/model/ jobs/ model/
Date Sat, 13 Oct 2007 13:01:57 GMT
Author: seelmann
Date: Sat Oct 13 06:01:55 2007
New Revision: 584396

URL: http://svn.apache.org/viewvc?rev=584396&view=rev
Log:
DIRSTUDIO-123: Moved create entry code from BrowserConnection to CreateEntryJob.

Modified:
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/BrowserConnection.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/ConnectionModifyHandler.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/DummyConnection.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CopyEntriesJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IBrowserConnection.java

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/BrowserConnection.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/BrowserConnection.java?rev=584396&r1=584395&r2=584396&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/BrowserConnection.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/BrowserConnection.java
Sat Oct 13 06:01:55 2007
@@ -553,12 +553,6 @@
     }
 
 
-    public void create( IEntry entryToCreate, StudioProgressMonitor monitor )
-    {
-        modifyHandler.create( entryToCreate, monitor );
-    }
-
-
     public void rename( IEntry entryToRename, DN newDn, boolean deleteOldRdn, StudioProgressMonitor
monitor )
     {
         modifyHandler.rename( entryToRename, newDn, deleteOldRdn, monitor );

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/ConnectionModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/ConnectionModifyHandler.java?rev=584396&r1=584395&r2=584396&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/ConnectionModifyHandler.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/ConnectionModifyHandler.java
Sat Oct 13 06:01:55 2007
@@ -247,23 +247,6 @@
     }
 
 
-    void create( IEntry entryToCreate, StudioProgressMonitor monitor )
-    {
-        try
-        {
-            LdifChangeAddRecord car = ModelConverter.entryToLdifChangeAddRecord( entryToCreate
);
-            this.applyModificationAndLog( car, monitor );
-
-            // connection.cacheEntry(entryToCreate);
-            // entryToCreate.setDirectoryEntry(true);
-        }
-        catch ( ConnectionException e )
-        {
-            monitor.reportError( e );
-        }
-    }
-
-
     void rename( IEntry entryToRename, DN newDn, boolean deleteOldRdn, StudioProgressMonitor
monitor )
     {
         try

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/DummyConnection.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/DummyConnection.java?rev=584396&r1=584395&r2=584396&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/DummyConnection.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/DummyConnection.java
Sat Oct 13 06:01:55 2007
@@ -54,11 +54,6 @@
     }
 
 
-    public void create( IEntry entryToCreate, StudioProgressMonitor monitor )
-    {
-    }
-
-
     public void create( IValue[] valuesToCreate, StudioProgressMonitor monitor )
     {
     }

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CopyEntriesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CopyEntriesJob.java?rev=584396&r1=584395&r2=584396&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CopyEntriesJob.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CopyEntriesJob.java
Sat Oct 13 06:01:55 2007
@@ -47,16 +47,32 @@
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
 
 
+/**
+ * Job to copy entries asynchronously.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class CopyEntriesJob extends AbstractAsyncBulkJob
 {
 
+    /** The parent entry. */
     private IEntry parent;
 
+    /** The entries to copy. */
     private IEntry[] entriesToCopy;
 
+    /** The copy scope */
     private int scope;
 
 
+    /**
+     * Creates a new instance of CopyEntriesJob.
+     * 
+     * @param parent the parent entry
+     * @param entriesToCopy the entries to copy
+     * @param scope the copy scope
+     */
     public CopyEntriesJob( final IEntry parent, final IEntry[] entriesToCopy, int scope )
     {
         this.parent = parent;
@@ -67,6 +83,9 @@
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getConnections()
+     */
     protected Connection[] getConnections()
     {
         return new Connection[]
@@ -74,18 +93,23 @@
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getLockedObjects()
+     */
     protected Object[] getLockedObjects()
     {
-        List l = new ArrayList();
+        List<IEntry> l = new ArrayList<IEntry>();
         l.add( parent );
         l.addAll( Arrays.asList( entriesToCopy ) );
         return l.toArray();
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractAsyncBulkJob#executeBulkJob(org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
     protected void executeBulkJob( StudioProgressMonitor monitor )
     {
-
         monitor.beginTask( entriesToCopy.length == 1 ? BrowserCoreMessages.bind(
             BrowserCoreMessages.jobs__copy_entries_task_1, new String[]
                 { entriesToCopy[0].getDn().toString(), parent.getDn().toString() } ) : BrowserCoreMessages.bind(
@@ -116,6 +140,9 @@
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractAsyncBulkJob#runNotification()
+     */
     protected void runNotification()
     {
         parent.setChildrenInitialized( false );
@@ -124,6 +151,9 @@
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getErrorMessage()
+     */
     protected String getErrorMessage()
     {
         return entriesToCopy.length == 1 ? BrowserCoreMessages.jobs__copy_entries_error_1
@@ -131,8 +161,18 @@
     }
 
 
-    private int copyEntryRecursive( IEntry entryToCopy, IEntry parent, int scope, int num,
-        StudioProgressMonitor monitor )
+    /**
+     * Copies the entry recursive.
+     * 
+     * @param entryToCopy the entry to copy
+     * @param parent the parent entry
+     * @param scope the copy scope
+     * @param num the number of copied entries
+     * @param monitor the progress monitor
+     * 
+     * @return the number of copied entries
+     */
+    private int copyEntryRecursive( IEntry entryToCopy, IEntry parent, int scope, int num,
StudioProgressMonitor monitor )
     {
         try
         {
@@ -249,7 +289,7 @@
                     }
                 }
 
-                newEntry.getBrowserConnection().create( newEntry, monitor );
+                CreateEntryJob.createEntry( newEntry.getBrowserConnection(), newEntry, monitor
);
                 newEntry.setHasChildrenHint( false );
 
                 num++;
@@ -302,6 +342,16 @@
     }
 
 
+    /**
+     * Gets the new rdn.
+     * 
+     * @param rdn the rdn
+     * @param newRdnValue the new rdn value
+     * 
+     * @return the new rdn
+     * 
+     * @throws NameException the name exception
+     */
     private RDN getNewRdn( RDN rdn, String newRdnValue ) throws NameException
     {
         String[] names = rdn.getTypes();

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryJob.java?rev=584396&r1=584395&r2=584396&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryJob.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateEntryJob.java
Sat Oct 13 06:01:55 2007
@@ -21,35 +21,60 @@
 package org.apache.directory.studio.ldapbrowser.core.jobs;
 
 
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.ManageReferralControl;
+
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.StudioProgressMonitor;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
 import org.apache.directory.studio.ldapbrowser.core.events.EntryAddedEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
 
 
+/**
+ * Job to create an entry asynchronously.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class CreateEntryJob extends AbstractAsyncBulkJob
 {
 
+    /** The entry to create. */
     private IEntry entryToCreate;
-    
+
+    /** The browser connection. */
     private IBrowserConnection browserConnection;
 
+    /** The created entry. */
     private IEntry createdEntry;
 
 
+    /**
+     * Creates a new instance of CreateEntryJob.
+     * 
+     * @param entryToCreate the entry to create
+     * @param browserConnection the browser connection
+     */
     public CreateEntryJob( IEntry entryToCreate, IBrowserConnection browserConnection )
     {
         this.entryToCreate = entryToCreate;
         this.browserConnection = browserConnection;
         this.createdEntry = null;
-        
+
         setName( BrowserCoreMessages.jobs__create_entry_name_1 );
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getConnections()
+     */
     protected Connection[] getConnections()
     {
         return new Connection[]
@@ -57,6 +82,9 @@
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getLockedObjects()
+     */
     protected Object[] getLockedObjects()
     {
         return new Object[]
@@ -64,15 +92,17 @@
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractAsyncBulkJob#executeBulkJob(org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
     protected void executeBulkJob( StudioProgressMonitor monitor )
     {
-
         monitor.beginTask( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__create_entry_task_1,
new String[]
-                { entryToCreate.getDn().toString() } ), 2 + 1 );
+            { entryToCreate.getDn().toString() } ), 2 + 1 );
         monitor.reportProgress( " " ); //$NON-NLS-1$
         monitor.worked( 1 );
 
-        browserConnection.create( entryToCreate, monitor );
+        createEntry( browserConnection, entryToCreate, monitor );
 
         if ( !monitor.errorsReported() )
         {
@@ -81,23 +111,76 @@
             createdEntry.setHasChildrenHint( false );
         }
 
+        monitor.reportProgress( " " ); //$NON-NLS-1$
         monitor.worked( 1 );
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractAsyncBulkJob#runNotification()
+     */
     protected void runNotification()
     {
         if ( createdEntry != null )
         {
-            EventRegistry.fireEntryUpdated( new EntryAddedEvent( browserConnection,
-                createdEntry ), this );
+            EventRegistry.fireEntryUpdated( new EntryAddedEvent( browserConnection, createdEntry
), this );
         }
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getErrorMessage()
+     */
     protected String getErrorMessage()
     {
         return BrowserCoreMessages.jobs__create_entry_error_1;
+    }
+
+
+    /**
+     * Creates the entry using the underlying JNDI connection wrapper.
+     * 
+     * @param browserConnection the browser connection
+     * @param entryToCreate the entry to create
+     * @param monitor the monitor
+     */
+    static void createEntry( IBrowserConnection browserConnection, IEntry entryToCreate,
StudioProgressMonitor monitor )
+    {
+        // dn
+        String dn = entryToCreate.getDn().toString();
+
+        // attributes
+        Attributes jndiAttributes = new BasicAttributes();
+        IAttribute[] attributes = entryToCreate.getAttributes();
+        for ( int i = 0; i < attributes.length; i++ )
+        {
+            String description = attributes[i].getDescription();
+            IValue[] values = attributes[i].getValues();
+            for ( int ii = 0; ii < values.length; ii++ )
+            {
+                IValue value = values[ii];
+                Object rawValue = value.getRawValue();
+                if ( jndiAttributes.get( description ) != null )
+                {
+                    jndiAttributes.get( description ).add( rawValue );
+                }
+                else
+                {
+                    jndiAttributes.put( description, rawValue );
+                }
+            }
+        }
+
+        // controls
+        Control[] controls = null;
+        if ( entryToCreate.isReferral() )
+        {
+            controls = new Control[]
+                { new ManageReferralControl() };
+        }
+
+        browserConnection.getConnection().getJNDIConnectionWrapper()
+            .createEntry( dn, jndiAttributes, controls, monitor );
     }
 
 }

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IBrowserConnection.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IBrowserConnection.java?rev=584396&r1=584395&r2=584396&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IBrowserConnection.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IBrowserConnection.java
Sat Oct 13 06:01:55 2007
@@ -163,9 +163,6 @@
     public abstract void delete( IAttribute attriubtesToDelete[], StudioProgressMonitor monitor
);
 
 
-    public abstract void create( IEntry entryToCreate, StudioProgressMonitor monitor );
-
-
     public abstract void create( IValue valuesToCreate[], StudioProgressMonitor monitor );
 
 



Mime
View raw message