directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1666520 - /directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
Date Fri, 13 Mar 2015 17:19:05 GMT
Author: elecharny
Date: Fri Mar 13 17:19:04 2015
New Revision: 1666520

URL: http://svn.apache.org/r1666520
Log:
Fix for DIRAPI-226. The value is transformed accordingly to its AT HR flag, if we have one.

Modified:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java?rev=1666520&r1=1666519&r2=1666520&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
Fri Mar 13 17:19:04 2015
@@ -51,6 +51,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.util.Base64;
 import org.apache.directory.api.util.Chars;
@@ -1024,6 +1025,29 @@ public class LdifReader implements Itera
 
         Object attributeValue = parseValue( line, colonIndex );
 
+        if ( schemaManager != null )
+        {
+            AttributeType at = schemaManager.getAttributeType( attributeType );
+
+            if ( at != null )
+            {
+                if ( at.getSyntax().isHumanReadable() )
+                {
+                    if ( attributeValue instanceof byte[] )
+                    {
+                        attributeValue = Strings.utf8ToString( ( byte[] ) attributeValue
);
+                    }
+                }
+                else
+                {
+                    if ( attributeValue instanceof String )
+                    {
+                        attributeValue = Strings.getBytesUtf8( ( String ) attributeValue
);
+                    }
+                }
+            }
+        }
+
         // Update the entry
         entry.addAttribute( attributeType, attributeValue );
     }



Mime
View raw message