directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1100176 - /directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java
Date Fri, 06 May 2011 11:43:54 GMT
Author: pamarcelot
Date: Fri May  6 11:43:54 2011
New Revision: 1100176

URL: http://svn.apache.org/viewvc?rev=1100176&view=rev
Log:
Fixed a bug which could lead to empty attributes (without any values) or attributes with a
'null' value being created.
Fixed typos in javadoc.

Modified:
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java

Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java?rev=1100176&r1=1100175&r2=1100176&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java
(original)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java
Fri May  6 11:43:54 2011
@@ -351,7 +351,7 @@ public class ConfigWriter
                     ConfigurationElement configurationElement = field.getAnnotation( ConfigurationElement.class
);
                     if ( configurationElement != null )
                     {
-                        // Checking if we're have a value  for the attribute type
+                        // Checking if we have a value for the attribute type
                         String attributeType = configurationElement.attributeType();
                         if ( ( attributeType != null ) && ( !"".equals( attributeType
) ) )
                         {
@@ -409,7 +409,7 @@ public class ConfigWriter
                                 {
                                     if ( configurationElement.defaultValue().equalsIgnoreCase(
fieldValue.toString() ) )
                                     {
-                                        // Skipping the additin of the value
+                                        // Skipping the addition of the value
                                         continue;
                                     }
                                 }
@@ -562,16 +562,6 @@ public class ConfigWriter
         // We don't store a 'null' value
         if ( o != null )
         {
-            // Getting the attribute from the entry
-            Attribute attribute = entry.get( attributeType );
-
-            // If no attribute has been found, we need to create it and add it to the entry
-            if ( attribute == null )
-            {
-                attribute = new DefaultAttribute( attributeType );
-                entry.addAttribute( attribute );
-            }
-
             // Is the value multiple?
             if ( isMultiple( o.getClass() ) )
             {
@@ -581,14 +571,14 @@ public class ConfigWriter
                 {
                     for ( Object value : values )
                     {
-                        addAttributeTypeValue( attribute, value );
+                        addAttributeTypeValue( attributeType, value, entry );
                     }
                 }
             }
             else
             {
                 // Adding the single value
-                addAttributeTypeValue( attribute, o );
+                addAttributeTypeValue( attributeType, o, entry);
             }
         }
     }
@@ -598,16 +588,28 @@ public class ConfigWriter
      * Adds a value, either byte[] or another type (converted into a String 
      * via the Object.toString() method), to the attribute.
      *
-     * @param attribute
-     *      the attribute
+     * @param attributeType
+     *      the attribute type
      * @param value
      *      the value
+     * @param entry
+     *      the entry
      */
-    private void addAttributeTypeValue( Attribute attribute, Object value ) throws LdapException
+    private void addAttributeTypeValue( String attributeType, Object value, LdifEntry entry
) throws LdapException
     {
         // We don't store a 'null' value
         if ( value != null )
         {
+            // Getting the attribute from the entry
+            Attribute attribute = entry.get( attributeType );
+
+            // If no attribute has been found, we need to create it and add it to the entry
+            if ( attribute == null )
+            {
+                attribute = new DefaultAttribute( attributeType );
+                entry.addAttribute( attribute );
+            }
+            
             // Storing the value to the attribute
             if ( value instanceof byte[] )
             {



Mime
View raw message