directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1393189 - /directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java
Date Tue, 02 Oct 2012 21:19:47 GMT
Author: elecharny
Date: Tue Oct  2 21:19:47 2012
New Revision: 1393189

URL: http://svn.apache.org/viewvc?rev=1393189&view=rev
Log:
Fix DIRSERVER-1732 : When an attribute contains binary values (because it has been Base64
encoded for instance), and if the attribute is HR, then we transform the value to a String

Modified:
    directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java

Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java?rev=1393189&r1=1393188&r2=1393189&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java
(original)
+++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java
Tue Oct  2 21:19:47 2012
@@ -31,6 +31,7 @@ import org.apache.directory.shared.i18n.
 import org.apache.directory.shared.ldap.model.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.Attribute;
+import org.apache.directory.shared.ldap.model.entry.BinaryValue;
 import org.apache.directory.shared.ldap.model.entry.DefaultAttribute;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.Value;
@@ -1072,7 +1073,17 @@ public class SchemaEntityFactory impleme
 
         if ( mDescription != null )
         {
-            schemaObject.setDescription( mDescription.getString() );
+            Value<?> value = mDescription.get();
+
+            if ( value instanceof BinaryValue )
+            {
+                // We have to transform the value to a String
+                schemaObject.setDescription( Strings.utf8ToString( mDescription.getBytes()
) );
+            }
+            else
+            {
+                schemaObject.setDescription( mDescription.getString() );
+            }
         }
 
         // The names field
@@ -1122,47 +1133,47 @@ public class SchemaEntityFactory impleme
         // The extensions fields
         // X-SCHEMA
         Attribute xSchema = entry.get( MetaSchemaConstants.X_SCHEMA_AT );
-        
+
         if ( xSchema != null )
         {
             String schemaName = xSchema.getString();
-            
+
             if ( !schema.getSchemaName().equalsIgnoreCase( schemaName ) )
             {
-               LOG.warn( "Schema (" + schema.getSchemaName() + ") and X-SCHEMA ("
-                   + schemaName + ") are different : " + entry );
+                LOG.warn( "Schema (" + schema.getSchemaName() + ") and X-SCHEMA ("
+                    + schemaName + ") are different : " + entry );
             }
-            
+
             schemaObject.addExtension( MetaSchemaConstants.X_SCHEMA_AT, schemaName );
         }
-        
+
         // X-NOT-HUMAN-READABLE
         Attribute xNotHumanReadable = entry.get( MetaSchemaConstants.X_NOT_HUMAN_READABLE_AT
);
-        
+
         if ( xNotHumanReadable != null )
         {
             String value = xNotHumanReadable.getString();
-            
+
             schemaObject.addExtension( MetaSchemaConstants.X_NOT_HUMAN_READABLE_AT, value
);
         }
-        
+
         // X-READ-ONLY
         Attribute xReadOnly = entry.get( MetaSchemaConstants.X_READ_ONLY_AT );
-        
+
         if ( xReadOnly != null )
         {
             String value = xReadOnly.getString();
-            
+
             schemaObject.addExtension( MetaSchemaConstants.X_READ_ONLY_AT, value );
         }
-        
+
         // X-ENABLED
         Attribute xEnabled = entry.get( MetaSchemaConstants.X_ENABLED_AT );
-        
+
         if ( xEnabled != null )
         {
             String value = xEnabled.getString();
-            
+
             schemaObject.addExtension( MetaSchemaConstants.X_ENABLED_AT, value );
         }
     }



Mime
View raw message