directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r584620 - in /directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs: CreateValuesJob.java ModifyValueJob.java
Date Sun, 14 Oct 2007 21:45:08 GMT
Author: seelmann
Date: Sun Oct 14 14:45:08 2007
New Revision: 584620

URL: http://svn.apache.org/viewvc?rev=584620&view=rev
Log:
Fixed behaviour for new entry wizard.

Modified:
    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/ModifyValueJob.java

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=584620&r1=584619&r2=584620&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 14:45:08 2007
@@ -184,32 +184,50 @@
      * @param entryToModify the entry to modify
      * @param valuesToCreate the values to create
      * @param monitor the progress monitor
+     * 
+     * @throws ModelModificationException
      */
     static void createValues( IBrowserConnection browserConnection, IEntry entryToModify,
IValue[] valuesToCreate,
-        StudioProgressMonitor monitor )
+        StudioProgressMonitor monitor ) throws ModelModificationException
     {
-        // dn
-        String dn = entryToModify.getDn().toString();
-
-        // modification items
-        ModificationItem[] modificationItems = new ModificationItem[valuesToCreate.length];
-        for ( int i = 0; i < modificationItems.length; i++ )
+        if ( browserConnection.getConnection() != null )
         {
-            BasicAttribute attribute = new BasicAttribute( valuesToCreate[i].getAttribute().getDescription(),
-                valuesToCreate[i].getRawValue() );
-            modificationItems[i] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attribute
);
-        }
+            // 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
+            Control[] controls = null;
+            if ( entryToModify.isReferral() )
+            {
+                controls = new Control[]
+                    { new ManageReferralControl() };
+            }
+
+            browserConnection.getConnection().getJNDIConnectionWrapper().modifyAttributes(
dn, modificationItems,
+                controls, monitor );
+        }
+        else
         {
-            controls = new Control[]
-                { new ManageReferralControl() };
+            for ( IValue value : valuesToCreate )
+            {
+                IAttribute attribute = entryToModify.getAttribute( value.getAttribute().getDescription()
);
+                if ( attribute == null )
+                {
+                    attribute = new Attribute( entryToModify, value.getAttribute().getDescription()
);
+                    entryToModify.addAttribute( attribute );
+                }
+                attribute.addValue( value );
+            }
         }
-
-        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/ModifyValueJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ModifyValueJob.java?rev=584620&r1=584619&r2=584620&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ModifyValueJob.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ModifyValueJob.java
Sun Oct 14 14:45:08 2007
@@ -88,7 +88,6 @@
         monitor.worked( 1 );
 
         IValue newValue = new Value( attribute, newRawValue );
-        //attribute.modifyValue( oldValue, newValue );
 
         modifyValue( attribute.getEntry().getBrowserConnection(), attribute.getEntry(), oldValue,
newValue, monitor );
         if ( !monitor.errorsReported() )
@@ -155,45 +154,54 @@
      * @param oldValue the old value
      * @param newValue the new value
      * @param monitor the progress monitor
+     * 
+     * @throws ModelModificationException
      */
     private void modifyValue( IBrowserConnection browserConnection, IEntry entry, IValue
oldValue, IValue newValue,
-        StudioProgressMonitor monitor )
+        StudioProgressMonitor monitor ) throws ModelModificationException
     {
-        // dn
-        String dn = entry.getDn().toString();
-
-        // modification items
-        // perform a replace if the current attribute is single-valued
-        // perform an add and a remove operation if the current attribute is multi-valued
-        ModificationItem[] modificationItems;
-        if ( oldValue.getAttribute().getValueSize() == 1 )
+        if ( browserConnection.getConnection() != null )
         {
-            modificationItems = new ModificationItem[1];
-            BasicAttribute attribute = new BasicAttribute( newValue.getAttribute().getDescription(),
newValue
-                .getRawValue() );
-            modificationItems[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attribute
);
+            // dn
+            String dn = entry.getDn().toString();
+
+            // modification items
+            // perform a replace if the current attribute is single-valued
+            // perform an add and a remove operation if the current attribute is multi-valued
+            ModificationItem[] modificationItems;
+            if ( oldValue.getAttribute().getValueSize() == 1 )
+            {
+                modificationItems = new ModificationItem[1];
+                BasicAttribute attribute = new BasicAttribute( newValue.getAttribute().getDescription(),
newValue
+                    .getRawValue() );
+                modificationItems[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE,
attribute );
+            }
+            else
+            {
+                modificationItems = new ModificationItem[2];
+                BasicAttribute newAttribute = new BasicAttribute( newValue.getAttribute().getDescription(),
newValue
+                    .getRawValue() );
+                modificationItems[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, newAttribute
);
+                BasicAttribute oldAttribute = new BasicAttribute( oldValue.getAttribute().getDescription(),
oldValue
+                    .getRawValue() );
+                modificationItems[1] = new ModificationItem( DirContext.REMOVE_ATTRIBUTE,
oldAttribute );
+            }
+
+            // controls
+            Control[] controls = null;
+            if ( entry.isReferral() )
+            {
+                controls = new Control[]
+                    { new ManageReferralControl() };
+            }
+
+            browserConnection.getConnection().getJNDIConnectionWrapper().modifyAttributes(
dn, modificationItems,
+                controls, monitor );
         }
         else
         {
-            modificationItems = new ModificationItem[2];
-            BasicAttribute newAttribute = new BasicAttribute( newValue.getAttribute().getDescription(),
newValue
-                .getRawValue() );
-            modificationItems[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, newAttribute
);
-            BasicAttribute oldAttribute = new BasicAttribute( oldValue.getAttribute().getDescription(),
oldValue
-                .getRawValue() );
-            modificationItems[1] = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, oldAttribute
);
+            oldValue.getAttribute().modifyValue( oldValue, newValue );
         }
-
-        // controls
-        Control[] controls = null;
-        if ( entry.isReferral() )
-        {
-            controls = new Control[]
-                { new ManageReferralControl() };
-        }
-
-        browserConnection.getConnection().getJNDIConnectionWrapper().modifyAttributes( dn,
modificationItems, controls,
-            monitor );
     }
 
 }



Mime
View raw message