directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r432491 - /directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
Date Fri, 18 Aug 2006 05:27:03 GMT
Author: akarasulu
Date: Thu Aug 17 22:27:02 2006
New Revision: 432491

URL: http://svn.apache.org/viewvc?rev=432491&view=rev
Log:
Applying PAMs patches for DIRSERVER-612

Modified:
    directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java

Modified: directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java?rev=432491&r1=432490&r2=432491&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
(original)
+++ directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
Thu Aug 17 22:27:02 2006
@@ -44,10 +44,12 @@
 import org.apache.directory.server.core.schema.AttributeTypeRegistry;
 import org.apache.directory.server.core.schema.bootstrap.BootstrapRegistries;
 import org.apache.directory.server.core.schema.bootstrap.BootstrapSchemaLoader;
+import org.apache.directory.shared.ldap.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.message.LockableAttributeImpl;
 import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.shared.ldap.util.Base64;
 
 
 /**
@@ -155,7 +157,31 @@
                     entry.put( myattr );
                     for ( int ii = 0; ii < attr.size(); ii++ )
                     {
-                        myattr.add( attr.get( ii ) );
+                    	Object value = attr.get(ii);
+                        
+                        // Checking if the value is binary
+                        if ( value instanceof byte[] )
+                        {
+                        	// It is binary, so we have to encode it using Base64 before adding
it
+                        	char[] encoded = Base64.encode( ( byte[] ) value );
+                        	
+                        	myattr.add( new String( encoded ) );                        	
+                        }
+                        else if ( value instanceof String )
+                        {
+                        	// It's a String but, we have to check if encoding isn't required
+                        	String str = (String) value;
+                        	if ( !LdifUtils.isLDIFSafe( str ) )
+                        	{
+                        		char[] encoded = Base64.encode( ( ( String ) value ).getBytes()
);
+                        		
+                        		myattr.add( new String( encoded ) );
+                        	}
+                        	else
+                        	{
+                        		myattr.add( value );
+                        	}
+                        }
                     }
                 }
             }



Mime
View raw message