directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r584564 - in /directory/studio/trunk: studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/dialogs/ studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/widgets/ studio-ldapbrowser-common/src/...
Date Sun, 14 Oct 2007 16:12:49 GMT
Author: seelmann
Date: Sun Oct 14 09:12:48 2007
New Revision: 584564

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

Modified:
    directory/studio/trunk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/dialogs/MultiValuedDialog.java
    directory/studio/trunk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Attribute.java
    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/internal/model/Value.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateValuesJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IBrowserConnection.java
    directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCellModifier.java
    directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCursor.java
    directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorPasteAction.java
    directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java

Modified: directory/studio/trunk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/dialogs/MultiValuedDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/dialogs/MultiValuedDialog.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/dialogs/MultiValuedDialog.java
(original)
+++ directory/studio/trunk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/dialogs/MultiValuedDialog.java
Sun Oct 14 09:12:48 2007
@@ -28,7 +28,6 @@
 import org.apache.directory.studio.ldapbrowser.core.internal.model.Value;
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
-import org.apache.directory.studio.ldapbrowser.core.model.ModelModificationException;
 import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
@@ -282,27 +281,21 @@
      */
     private void addValue()
     {
-        try
-        {
-            IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
-            IValue value = new Value( attribute, "" ); //$NON-NLS-1$
-            Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$
-            
-            CellEditor cellEditor = valueEditor.getCellEditor();
-            cellEditor.setValue( oldRawValue );
-            cellEditor.activate();
-            Object newRawValue = cellEditor.getValue();
-            
-            if ( newRawValue != null )
-            {
-                String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue
);
-                
-                values.add( newValue );
-                tableViewer.refresh();
-            }
-        }
-        catch ( ModelModificationException e )
+        IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
+        IValue value = new Value( attribute, "" ); //$NON-NLS-1$
+        Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$
+
+        CellEditor cellEditor = valueEditor.getCellEditor();
+        cellEditor.setValue( oldRawValue );
+        cellEditor.activate();
+        Object newRawValue = cellEditor.getValue();
+
+        if ( newRawValue != null )
         {
+            String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue
);
+
+            values.add( newValue );
+            tableViewer.refresh();
         }
     }
 
@@ -316,28 +309,22 @@
         String oldValue = getSelectedValue();
         if ( oldValue != null )
         {
-            try
-            {
-                IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
-                IValue value = new Value( attribute, oldValue ); //$NON-NLS-1$
-                Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$
-                
-                CellEditor cellEditor = valueEditor.getCellEditor();
-                cellEditor.setValue( oldRawValue );
-                cellEditor.activate();
-                Object newRawValue = cellEditor.getValue();
-                
-                if ( newRawValue != null )
-                {
-                    String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue
);
-                    
-                    values.remove( oldValue );
-                    values.add( newValue );
-                    tableViewer.refresh();
-                }
-            }
-            catch ( ModelModificationException e )
+            IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
+            IValue value = new Value( attribute, oldValue ); //$NON-NLS-1$
+            Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$
+
+            CellEditor cellEditor = valueEditor.getCellEditor();
+            cellEditor.setValue( oldRawValue );
+            cellEditor.activate();
+            Object newRawValue = cellEditor.getValue();
+
+            if ( newRawValue != null )
             {
+                String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue
);
+
+                values.remove( oldValue );
+                values.add( newValue );
+                tableViewer.refresh();
             }
         }
     }

Modified: directory/studio/trunk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java
(original)
+++ directory/studio/trunk/studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java
Sun Oct 14 09:12:48 2007
@@ -36,7 +36,6 @@
 import org.apache.directory.studio.ldapbrowser.core.internal.model.Value;
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
-import org.apache.directory.studio.ldapbrowser.core.model.ModelModificationException;
 import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.CellEditor;
@@ -506,29 +505,23 @@
                 {
                     oldValue = ""; //$NON-NLS-1$
                 }
-                
-                try
-                {
-                    IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
-                    IValue value = new Value( attribute, oldValue ); //$NON-NLS-1$
-                    Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$
-
-                    CellEditor cellEditor = valueEditor.getCellEditor();
-                    cellEditor.setValue( oldRawValue );
-                    cellEditor.activate();
-                    Object newRawValue = cellEditor.getValue();
 
-                    if ( newRawValue != null )
-                    {
-                        String newValue = ( String ) valueEditor.getStringOrBinaryValue(
newRawValue );
+                IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
+                IValue value = new Value( attribute, oldValue ); //$NON-NLS-1$
+                Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$
+
+                CellEditor cellEditor = valueEditor.getCellEditor();
+                cellEditor.setValue( oldRawValue );
+                cellEditor.activate();
+                Object newRawValue = cellEditor.getValue();
 
-                        values.clear();
-                        values.add( newValue );
-                        tableViewer.refresh();
-                    }
-                }
-                catch ( ModelModificationException e )
+                if ( newRawValue != null )
                 {
+                    String newValue = ( String ) valueEditor.getStringOrBinaryValue( newRawValue
);
+
+                    values.clear();
+                    values.add( newValue );
+                    tableViewer.refresh();
                 }
             }
         }

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
Sun Oct 14 09:12:48 2007
@@ -206,14 +206,15 @@
 
         if ( entry != null )
         {
-            String[] attributeNames = new String[values.length];
-            Object[] rawValues = new Object[values.length];
-            for ( int v = 0; v < values.length; v++ )
-            {
-                attributeNames[v] = values[v].getAttribute().getDescription();
-                rawValues[v] = values[v].getRawValue();
-            }
-            new CreateValuesJob( entry, attributeNames, rawValues ).execute();
+//            String[] attributeNames = new String[values.length];
+//            Object[] rawValues = new Object[values.length];
+//            for ( int v = 0; v < values.length; v++ )
+//            {
+//                attributeNames[v] = values[v].getAttribute().getDescription();
+//                rawValues[v] = values[v].getRawValue();
+//            }
+//            new CreateValuesJob( entry, attributeNames, rawValues ).execute();
+            new CreateValuesJob( entry, values ).execute();
         }
     }
 

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Attribute.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Attribute.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Attribute.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Attribute.java
Sun Oct 14 09:12:48 2007
@@ -75,19 +75,11 @@
      *                The entry of this attribute, mustn't be null
      * @param description
      *                The attribute descrption, mustn't be null.
-     * @throws ModelModificationException
-     *                 if the attribute name is null or empty.
      */
-    public Attribute( IEntry entry, String description ) throws ModelModificationException
+    public Attribute( IEntry entry, String description )
     {
-        if ( entry == null )
-        {
-            throw new ModelModificationException( BrowserCoreMessages.model__empty_entry
);
-        }
-        if ( description == null )
-        {
-            throw new ModelModificationException( BrowserCoreMessages.model__empty_attribute
);
-        }
+        assert entry != null;
+        assert description != null;
 
         this.entry = entry;
         this.attributeDescription = new AttributeDescription( description );
@@ -203,16 +195,9 @@
      */
     public void addEmptyValue()
     {
-        try
-        {
-            IValue emptyValue = new Value( this );
-            valueList.add( emptyValue );
-            this.attributeModified( new EmptyValueAddedEvent( getEntry().getBrowserConnection(),
getEntry(), this, emptyValue ) );
-        }
-        catch ( ModelModificationException mme )
-        {
-            // Shouldn't occur
-        }
+        IValue emptyValue = new Value( this );
+        valueList.add( emptyValue );
+        this.attributeModified( new EmptyValueAddedEvent( getEntry().getBrowserConnection(),
getEntry(), this, emptyValue ) );
     }
 
 

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=584564&r1=584563&r2=584564&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
Sun Oct 14 09:12:48 2007
@@ -541,12 +541,6 @@
     }
 
 
-    public void create( IValue[] valuesToCreate, StudioProgressMonitor monitor )
-    {
-        modifyHandler.create( valuesToCreate, monitor );
-    }
-
-
     public void modify( IValue oldValue, IValue newValue, StudioProgressMonitor monitor )
     {
         modifyHandler.modify( oldValue, newValue, 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=584564&r1=584563&r2=584564&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
Sun Oct 14 09:12:48 2007
@@ -80,43 +80,6 @@
     }
 
 
-    void create( IValue[] valuesToCreate, StudioProgressMonitor monitor )
-    {
-        for ( int i = 0; !monitor.isCanceled() && i < valuesToCreate.length; i++
)
-        {
-
-            LdifChangeModifyRecord cmr = new LdifChangeModifyRecord( LdifDnLine.create( valuesToCreate[i]
-                .getAttribute().getEntry().getDn().toString() ) );
-            ModelConverter.addControls( cmr, valuesToCreate[i].getAttribute().getEntry()
);
-            cmr.setChangeType( LdifChangeTypeLine.createModify() );
-
-            LdifModSpec modSpec = LdifModSpec.createAdd( valuesToCreate[i].getAttribute().getDescription()
);
-            if ( valuesToCreate[i].isString() )
-            {
-                modSpec.addAttrVal( LdifAttrValLine.create( valuesToCreate[i].getAttribute().getDescription(),
-                    valuesToCreate[i].getStringValue() ) );
-            }
-            else
-            {
-                modSpec.addAttrVal( LdifAttrValLine.create( valuesToCreate[i].getAttribute().getDescription(),
-                    valuesToCreate[i].getBinaryValue() ) );
-            }
-            modSpec.finish( LdifModSpecSepLine.create() );
-            cmr.addModSpec( modSpec );
-            cmr.finish( LdifSepLine.create() );
-
-            try
-            {
-                this.applyModificationAndLog( cmr, monitor );
-            }
-            catch ( ConnectionException e )
-            {
-                monitor.reportError( e );
-            }
-        }
-    }
-
-
     void modify( IValue oldValue, IValue newValue, 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=584564&r1=584563&r2=584564&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
Sun Oct 14 09:12:48 2007
@@ -54,11 +54,6 @@
     }
 
 
-    public void create( IValue[] valuesToCreate, StudioProgressMonitor monitor )
-    {
-    }
-
-
     public void delete( IEntry entryToDelete, StudioProgressMonitor monitor )
     {
     }

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Value.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Value.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Value.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/internal/model/Value.java
Sun Oct 14 09:12:48 2007
@@ -22,13 +22,11 @@
 
 
 import org.apache.directory.studio.connection.core.Connection;
-import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
 import org.apache.directory.studio.ldapbrowser.core.internal.search.LdapSearchPageScoreComputer;
 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;
-import org.apache.directory.studio.ldapbrowser.core.model.ModelModificationException;
 import org.apache.directory.studio.ldapbrowser.core.model.RDNPart;
 import org.apache.directory.studio.ldapbrowser.core.utils.LdifUtils;
 import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
@@ -59,16 +57,11 @@
      *
      * @param attribute the attribute this value belongs to 
      * @param rawValue the raw value, either a String or a byte[]
-     * @throws ModelModificationException if one of the parameter is null
      */
-    public Value( IAttribute attribute, Object rawValue ) throws ModelModificationException
+    public Value( IAttribute attribute, Object rawValue )
     {
         this.init( attribute, rawValue );
-
-        if ( rawValue == null )
-        {
-            throw new ModelModificationException( BrowserCoreMessages.model__empty_value
);
-        }
+        assert rawValue != null;
     }
 
 
@@ -76,9 +69,8 @@
      * Creates a new instance of Value with an empty value.
      *
      * @param attribute the attribute this value belongs to
-     * @throws ModelModificationException if one of the parameter is null
      */
-    public Value( IAttribute attribute ) throws ModelModificationException
+    public Value( IAttribute attribute )
     {
         this.init( attribute, null );
     }
@@ -89,14 +81,10 @@
      *
      * @param attribute the attribute this value belongs to 
      * @param rawValue the raw value, either a String or a byte[] or null 
-     * @throws ModelModificationException
      */
-    private void init( IAttribute attribute, Object rawValue ) throws ModelModificationException
+    private void init( IAttribute attribute, Object rawValue )
     {
-        if ( attribute == null )
-        {
-            throw new ModelModificationException( BrowserCoreMessages.model__empty_attribute
);
-        }
+        assert attribute != null;
 
         this.attribute = attribute;
 

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateValuesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateValuesJob.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateValuesJob.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateValuesJob.java
Sun Oct 14 09:12:48 2007
@@ -24,117 +24,192 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.ManageReferralControl;
+
 import org.apache.directory.studio.connection.core.StudioProgressMonitor;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
 import org.apache.directory.studio.ldapbrowser.core.events.ValueAddedEvent;
 import org.apache.directory.studio.ldapbrowser.core.internal.model.Attribute;
 import org.apache.directory.studio.ldapbrowser.core.internal.model.Value;
 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;
 import org.apache.directory.studio.ldapbrowser.core.model.ModelModificationException;
 
 
+/**
+ * Job to create values asynchronously.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class CreateValuesJob extends AbstractModificationJob
 {
 
+    /** The entry to modify. */
     private IEntry entry;
 
-    private String[] attributeDescriptions;
-
-    private Object[] rawValues;
+    /** The values to create. */
+    private IValue[] valuesToCreate;
 
-    private ValueAddedEvent event;
+    /** The created values. */
+    private IValue[] createdValues;
 
 
-    public CreateValuesJob( IEntry entry, String[] attributeDescriptions, Object[] rawValues
)
+    /**
+     * Creates a new instance of CreateValuesJob.
+     * 
+     * @param entry the entry to modify
+     * @param valuesToCreate the values to create
+     */
+    public CreateValuesJob( IEntry entry, IValue[] valuesToCreate )
     {
         this.entry = entry;
-        this.attributeDescriptions = attributeDescriptions;
-        this.rawValues = rawValues;
+        this.valuesToCreate = valuesToCreate;
 
-        setName( rawValues.length == 1 ? BrowserCoreMessages.jobs__create_values_name_1
+        setName( valuesToCreate.length == 1 ? BrowserCoreMessages.jobs__create_values_name_1
             : BrowserCoreMessages.jobs__create_values_name_n );
     }
 
 
+    /**
+     * Creates a new instance of CreateValuesJob.
+     *
+     * @param attribute the attribute to modify
+     * @param newValue the new value
+     */
     public CreateValuesJob( IAttribute attribute, Object newValue )
     {
-        this( attribute.getEntry(), new String[]
-            { attribute.getDescription() }, new Object[]
-            { newValue } );
+        this( attribute.getEntry(), new IValue[]
+            { new Value( attribute, newValue ) } );
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractModificationJob#executeAsyncModificationJob(org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
     protected void executeAsyncModificationJob( StudioProgressMonitor monitor ) throws ModelModificationException
     {
-
-        monitor.beginTask( rawValues.length == 1 ? BrowserCoreMessages.jobs__create_values_task_1
+        monitor.beginTask( valuesToCreate.length == 1 ? BrowserCoreMessages.jobs__create_values_task_1
             : BrowserCoreMessages.jobs__create_values_task_n, 2 );
         monitor.reportProgress( " " ); //$NON-NLS-1$
         monitor.worked( 1 );
 
-        IValue[] newValues = new IValue[rawValues.length];
+        IValue[] newValues = new IValue[valuesToCreate.length];
         for ( int i = 0; i < newValues.length; i++ )
         {
-            IAttribute attribute = entry.getAttribute( attributeDescriptions[i] );
+            IAttribute attribute = entry.getAttribute( valuesToCreate[i].getAttribute().getDescription()
);
             if ( attribute == null )
             {
-                // String[] possibleAttributeNames =
-                // entry.getSubschema().getAllAttributeNames();
-                // if(!Arrays.asList(possibleAttributeNames).contains(attributeNames[i]))
-                // {
-                // throw new ModelModificationException("Attribute
-                // "+attributeNames[i]+" is not in subschema");
-                // }
-                attribute = new Attribute( entry, attributeDescriptions[i] );
-                entry.addAttribute( attribute );
+                attribute = new Attribute( entry, valuesToCreate[i].getAttribute().getDescription()
);
             }
 
-            newValues[i] = new Value( attribute, rawValues[i] );
-            attribute.addValue( newValues[i] );
-
-            if ( this.event == null )
-            {
-                event = new ValueAddedEvent( entry.getBrowserConnection(), entry, attribute,
newValues[i] );
-            }
+            newValues[i] = new Value( attribute, valuesToCreate[i].getRawValue() );
         }
 
-        entry.getBrowserConnection().create( newValues, monitor );
+        createValues( entry.getBrowserConnection(), entry, newValues, monitor );
+        if ( !monitor.errorsReported() )
+        {
+            createdValues = newValues;
+        }
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractModificationJob#getModifiedEntry()
+     */
     protected IEntry getModifiedEntry()
     {
         return entry;
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractModificationJob#getAffectedAttributeNames()
+     */
     protected String[] getAffectedAttributeNames()
     {
-        Set affectedAttributeNameSet = new HashSet();
-        for ( int i = 0; i < attributeDescriptions.length; i++ )
+        Set<String> affectedAttributeNameSet = new HashSet<String>();
+        for ( IValue value : valuesToCreate )
         {
-            affectedAttributeNameSet.add( attributeDescriptions[i] );
+            affectedAttributeNameSet.add( value.getAttribute().getDescription() );
         }
-        return ( String[] ) affectedAttributeNameSet.toArray( new String[affectedAttributeNameSet.size()]
);
+        return affectedAttributeNameSet.toArray( new String[affectedAttributeNameSet.size()]
);
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractAsyncBulkJob#runNotification()
+     */
     protected void runNotification()
     {
-        if ( this.event != null )
+        EntryModificationEvent event;
+
+        if ( createdValues != null && createdValues.length > 0 )
+        {
+            event = new ValueAddedEvent( entry.getBrowserConnection(), entry, createdValues[0].getAttribute(),
+                createdValues[0] );
+        }
+        else
         {
-            EventRegistry.fireEntryUpdated( this.event, this );
+            event = new AttributesInitializedEvent( entry );
         }
+
+        EventRegistry.fireEntryUpdated( event, this );
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getErrorMessage()
+     */
     protected String getErrorMessage()
     {
-        return attributeDescriptions.length == 1 ? BrowserCoreMessages.jobs__create_values_error_1
+        return valuesToCreate.length == 1 ? BrowserCoreMessages.jobs__create_values_error_1
             : BrowserCoreMessages.jobs__create_values_error_n;
+    }
+
+
+    /**
+     * Creates the values using the underlying JNDI connection wrapper.
+     * 
+     * @param browserConnection the browser connection
+     * @param entryToModify the entry to modify
+     * @param valuesToCreate the values to create
+     * @param monitor the progress monitor
+     */
+    static void createValues( IBrowserConnection browserConnection, IEntry entryToModify,
IValue[] valuesToCreate,
+        StudioProgressMonitor monitor )
+    {
+        // dn
+        String dn = entryToModify.getDn().toString();
+
+        // modification items
+        ModificationItem[] modificationItems = new ModificationItem[valuesToCreate.length];
+        for ( int i = 0; i < modificationItems.length; i++ )
+        {
+            BasicAttribute attribute = new BasicAttribute( valuesToCreate[i].getAttribute().getDescription(),
+                valuesToCreate[i].getRawValue() );
+            modificationItems[i] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attribute
);
+        }
+
+        // controls
+        Control[] controls = null;
+        if ( entryToModify.isReferral() )
+        {
+            controls = new Control[]
+                { new ManageReferralControl() };
+        }
+
+        browserConnection.getConnection().getJNDIConnectionWrapper().modifyAttributes( dn,
modificationItems, controls,
+            monitor );
     }
 
 }

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java
Sun Oct 14 09:12:48 2007
@@ -26,6 +26,8 @@
 
 import org.apache.directory.studio.connection.core.StudioProgressMonitor;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
 import org.apache.directory.studio.ldapbrowser.core.events.ValueRenamedEvent;
 import org.apache.directory.studio.ldapbrowser.core.internal.model.Attribute;
@@ -36,40 +38,59 @@
 import org.apache.directory.studio.ldapbrowser.core.model.ModelModificationException;
 
 
+/**
+ * Job to rename the attribute description of values asynchronously.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class RenameValuesJob extends AbstractModificationJob
 {
 
+    /** The entry to modify. */
     private IEntry entry;
 
+    /** The old values. */
     private IValue[] oldValues;
 
-    private String newAttributeName;
+    /** The new attribute description. */
+    private String newAttributeDescription;
 
-    private ValueRenamedEvent event;
+    /** The created values. */
+    private IValue[] createdValues;
 
 
-    public RenameValuesJob( IEntry entry, IValue[] oldValues, String newAttributeName )
+    /**
+     * Creates a new instance of RenameValuesJob.
+     * 
+     * @param entry the entry to modify
+     * @param oldValues the old values
+     * @param newAttributeDescription the new attribute description
+     */
+    public RenameValuesJob( IEntry entry, IValue[] oldValues, String newAttributeDescription
)
     {
         this.entry = entry;
         this.oldValues = oldValues;
-        this.newAttributeName = newAttributeName;
+        this.newAttributeDescription = newAttributeDescription;
 
         setName( oldValues.length == 1 ? BrowserCoreMessages.jobs__rename_value_name_1
             : BrowserCoreMessages.jobs__rename_value_name_n );
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractModificationJob#executeAsyncModificationJob(org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
     protected void executeAsyncModificationJob( StudioProgressMonitor monitor ) throws ModelModificationException
     {
-
         monitor.beginTask( oldValues.length == 1 ? BrowserCoreMessages.jobs__rename_value_task_1
             : BrowserCoreMessages.jobs__rename_value_task_n, 2 );
         monitor.reportProgress( " " ); //$NON-NLS-1$
         monitor.worked( 1 );
 
-        for ( int i = 0; i < oldValues.length; i++ )
+        for ( IValue oldValue : oldValues )
         {
-            if ( oldValues[i].getAttribute().getEntry() != this.entry )
+            if ( oldValue.getAttribute().getEntry() != entry )
             {
                 return;
             }
@@ -78,63 +99,74 @@
         IValue[] newValues = new IValue[oldValues.length];
         for ( int i = 0; i < oldValues.length; i++ )
         {
-
-            IAttribute newAttribute = entry.getAttribute( newAttributeName );
-            if ( newAttribute == null )
+            IAttribute attribute = entry.getAttribute( newAttributeDescription );
+            if ( attribute == null )
             {
-                newAttribute = new Attribute( entry, newAttributeName );
-                entry.addAttribute( newAttribute );
+                attribute = new Attribute( entry, newAttributeDescription );
             }
 
-            newValues[i] = new Value( newAttribute, oldValues[i].getRawValue() );
-            newAttribute.addValue( newValues[i] );
-
-            oldValues[i].getAttribute().deleteValue( oldValues[i] );
-
-            if ( this.event == null )
-            {
-                this.event = new ValueRenamedEvent( entry.getBrowserConnection(), entry,
oldValues[0], newValues[0] );
-            }
+            newValues[i] = new Value( attribute, oldValues[i].getRawValue() );
         }
 
+        CreateValuesJob.createValues( entry.getBrowserConnection(), entry, newValues, monitor
);
         if ( !monitor.errorsReported() )
         {
-            entry.getBrowserConnection().create( newValues, monitor );
+            entry.getBrowserConnection().delete( oldValues, monitor );
         }
         if ( !monitor.errorsReported() )
         {
-            entry.getBrowserConnection().delete( oldValues, monitor );
+            createdValues = newValues;
         }
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractModificationJob#getModifiedEntry()
+     */
     protected IEntry getModifiedEntry()
     {
-        return this.entry;
+        return entry;
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractModificationJob#getAffectedAttributeNames()
+     */
     protected String[] getAffectedAttributeNames()
     {
-        Set affectedAttributeNameSet = new HashSet();
-        affectedAttributeNameSet.add( newAttributeName );
-        for ( int i = 0; i < oldValues.length; i++ )
+        Set<String> affectedAttributeNameSet = new HashSet<String>();
+        affectedAttributeNameSet.add( newAttributeDescription );
+        for ( IValue oldValue : oldValues )
         {
-            affectedAttributeNameSet.add( oldValues[i].getAttribute().getDescription() );
+            affectedAttributeNameSet.add( oldValue.getAttribute().getDescription() );
         }
-        return ( String[] ) affectedAttributeNameSet.toArray( new String[affectedAttributeNameSet.size()]
);
+        return affectedAttributeNameSet.toArray( new String[affectedAttributeNameSet.size()]
);
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractAsyncBulkJob#runNotification()
+     */
     protected void runNotification()
     {
-        if ( this.event != null )
+        EntryModificationEvent event;
+
+        if ( createdValues != null && createdValues.length > 0 )
         {
-            EventRegistry.fireEntryUpdated( this.event, this );
+            event = new ValueRenamedEvent( entry.getBrowserConnection(), entry, oldValues[0],
createdValues[0] );
         }
+        else
+        {
+            event = new AttributesInitializedEvent( entry );
+        }
+
+        EventRegistry.fireEntryUpdated( event, this );
     }
 
 
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob#getErrorMessage()
+     */
     protected String getErrorMessage()
     {
         return oldValues.length == 1 ? BrowserCoreMessages.jobs__rename_value_error_1

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=584564&r1=584563&r2=584564&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
Sun Oct 14 09:12:48 2007
@@ -163,9 +163,6 @@
     public abstract void delete( IAttribute attriubtesToDelete[], StudioProgressMonitor monitor
);
 
 
-    public abstract void create( IValue valuesToCreate[], StudioProgressMonitor monitor );
-
-
     public abstract void modify( IValue oldValue, IValue newVaue, StudioProgressMonitor monitor
);
 
 

Modified: directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCellModifier.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCellModifier.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCellModifier.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCellModifier.java
Sun Oct 14 09:12:48 2007
@@ -76,16 +76,8 @@
             // attribute dummy
             if ( ah == null )
             {
-                try
-                {
-                    ah = new AttributeHierarchy( result.getEntry(), property, new IAttribute[]
-                        { new Attribute( result.getEntry(), property ) } );
-                }
-                catch ( ModelModificationException e )
-                {
-                    e.printStackTrace();
-                    return false;
-                }
+                ah = new AttributeHierarchy( result.getEntry(), property, new IAttribute[]
+                    { new Attribute( result.getEntry(), property ) } );
             }
 
             // check schema modifyable
@@ -145,16 +137,8 @@
 
             if ( ah == null )
             {
-                try
-                {
-                    ah = new AttributeHierarchy( result.getEntry(), property, new IAttribute[]
-                        { new Attribute( result.getEntry(), property ) } );
-                }
-                catch ( ModelModificationException e )
-                {
-                    e.printStackTrace();
-                    return null;
-                }
+                ah = new AttributeHierarchy( result.getEntry(), property, new IAttribute[]
+                    { new Attribute( result.getEntry(), property ) } );
             }
 
             return this.valueEditorManager.getCurrentValueEditor( ah ).getRawValue( ah );

Modified: directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCursor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCursor.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCursor.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCursor.java
Sun Oct 14 09:12:48 2007
@@ -33,9 +33,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
-import org.apache.directory.studio.ldapbrowser.core.model.ModelModificationException;
 import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
-
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.ISelectionProvider;
@@ -164,15 +162,8 @@
 
                 if ( ah == null )
                 {
-                    try
-                    {
-                        ah = new AttributeHierarchy( sr.getEntry(), property, new IAttribute[]
-                            { new Attribute( sr.getEntry(), property ) } );
-                    }
-                    catch ( ModelModificationException e )
-                    {
-                        e.printStackTrace();
-                    }
+                    ah = new AttributeHierarchy( sr.getEntry(), property, new IAttribute[]
+                        { new Attribute( sr.getEntry(), property ) } );
                 }
 
                 return ah;

Modified: directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorPasteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorPasteAction.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorPasteAction.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorPasteAction.java
Sun Oct 14 09:12:48 2007
@@ -69,19 +69,20 @@
         IValue[] values = getValuesToPaste();
         if ( values != null )
         {
-
-            String attributeDescription = getSelectedAttributeHierarchies()[0].getAttribute().getDescription();
-
-            String[] attributeDescriptions = new String[values.length];
-            Object[] rawValues = new Object[values.length];
-            for ( int v = 0; v < values.length; v++ )
-            {
-                attributeDescriptions[v] = attributeDescription;
-                rawValues[v] = values[v].getRawValue();
-            }
+//            String attributeDescription = getSelectedAttributeHierarchies()[0].getAttribute().getDescription();
+//
+//            String[] attributeDescriptions = new String[values.length];
+//            Object[] rawValues = new Object[values.length];
+//            for ( int v = 0; v < values.length; v++ )
+//            {
+//                attributeDescriptions[v] = attributeDescription;
+//                rawValues[v] = values[v].getRawValue();
+//            }
+//            IEntry entry = getSelectedAttributeHierarchies()[0].getAttribute().getEntry();
+//
+//            new CreateValuesJob( entry, attributeDescriptions, rawValues ).execute();
             IEntry entry = getSelectedAttributeHierarchies()[0].getAttribute().getEntry();
-
-            new CreateValuesJob( entry, attributeDescriptions, rawValues ).execute();
+            new CreateValuesJob( entry, values ).execute();
         }
     }
 

Modified: directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java?rev=584564&r1=584563&r2=584564&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java
(original)
+++ directory/studio/trunk/studio-ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java
Sun Oct 14 09:12:48 2007
@@ -27,7 +27,6 @@
 import org.apache.directory.studio.ldapbrowser.core.internal.model.Value;
 import org.apache.directory.studio.ldapbrowser.core.model.DN;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
-import org.apache.directory.studio.ldapbrowser.core.model.ModelModificationException;
 import org.apache.directory.studio.ldapbrowser.core.model.NameException;
 import org.apache.directory.studio.ldapbrowser.core.model.ldif.LdifPart;
 import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContainer;
@@ -161,10 +160,6 @@
             {
                 e.printStackTrace();
             }
-            catch ( ModelModificationException e )
-            {
-                e.printStackTrace();
-            }
         }
 
         return rawValue;
@@ -184,8 +179,8 @@
         }
         return dn;
     }
-    
-    
+
+
     protected Object getValue()
     {
         LdifPart[] parts = getSelectedLdifParts();



Mime
View raw message