directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r950079 - in /directory: apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java
Date Tue, 01 Jun 2010 14:06:31 GMT
Author: kayyagari
Date: Tue Jun  1 14:06:31 2010
New Revision: 950079

URL: http://svn.apache.org/viewvc?rev=950079&view=rev
Log:
o overloaded convertEntryToLdif() method to include version info in the generated LDIF
o updated the LdifPartition to call this new method while writing back LDIF to disk

Modified:
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=950079&r1=950078&r2=950079&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
Tue Jun  1 14:06:31 2010
@@ -321,7 +321,7 @@ public class LdifPartition extends BTree
 
         // And write it back on disk
         FileWriter fw = new FileWriter( getFile( dn, DELETE ) );
-        fw.write( LdifUtils.convertEntryToLdif( modifiedEntry ) );
+        fw.write( LdifUtils.convertEntryToLdif( modifiedEntry, true ) );
         fw.close();
     }
 

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java?rev=950079&r1=950078&r2=950079&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java
(original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java
Tue Jun  1 14:06:31 2010
@@ -56,6 +56,8 @@ public class LdifUtils
     /** The default length for a line in a ldif file */
     private static final int DEFAULT_LINE_LENGTH = 80;
     
+    private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
+    
     static
     {
         // Initialization of the array that will be used to match the first char.
@@ -200,6 +202,26 @@ public class LdifUtils
         return convertEntryToLdif( entry, DEFAULT_LINE_LENGTH );
     }
     
+
+    /**
+     * Convert an Entry to LDIF including a version number at the top
+     * @param entry the Entry to convert
+     * @param includeVersionInfo flag to tell whether to include version number or not
+     * @return the corresponding LDIF code as a String
+     * @throws LdapException If a naming exception is encountered.
+     */    
+    public static String convertEntryToLdif( Entry entry, boolean includeVersionInfo ) throws
LdapException
+    {
+        String ldif = convertEntryToLdif( entry, DEFAULT_LINE_LENGTH );
+        
+        if( includeVersionInfo )
+        {
+            ldif = "version: 1" + LINE_SEPARATOR + ldif;
+        }
+        
+        return ldif;
+    }
+
     
     /**
      * Convert all the Entry's attributes to LDIF. The DN is not written



Mime
View raw message