directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r993315 [2/2] - in /directory/shared/trunk: i18n/src/main/java/org/apache/directory/shared/i18n/ i18n/src/main/resources/org/apache/directory/shared/i18n/ ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/ ldap-ldif/src/test/jav...
Date Tue, 07 Sep 2010 10:41:57 GMT
Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java?rev=993315&r1=993314&r2=993315&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java Tue Sep  7 10:41:57 2010
@@ -43,6 +43,7 @@ import java.util.NoSuchElementException;
 
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
@@ -169,51 +170,11 @@ public class LdifReader implements Itera
     /** A logger */
     private static final Logger LOG = LoggerFactory.getLogger( LdifReader.class );
 
-    /** 
-     * A private class to track the current position in a line 
-     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
-     */
-    public class Position
-    {
-        /** The current position */
-        private int pos;
-
-
-        /**
-         * Creates a new instance of Position.
-         */
-        public Position()
-        {
-            pos = 0;
-        }
-
-
-        /**
-         * Increment the current position by one
-         *
-         */
-        public void inc()
-        {
-            pos++;
-        }
-
-
-        /**
-         * Increment the current position by the given value
-         *
-         * @param val The value to add to the current position
-         */
-        public void inc( int val )
-        {
-            pos += val;
-        }
-    }
-
     /** A list of read lines */
     protected List<String> lines;
 
     /** The current position */
-    protected Position position;
+    protected static int position;
 
     /** The ldif file version default value */
     protected static final int DEFAULT_VERSION = 1;
@@ -221,11 +182,13 @@ public class LdifReader implements Itera
     /** The ldif version */
     protected int version;
 
-    /** Type of element read */
+    /** Type of element read : ENTRY */
     protected static final int LDIF_ENTRY = 0;
 
+    /** Type of element read : CHANGE */
     protected static final int CHANGE = 1;
 
+    /** Type of element read : UNKNOWN */
     protected static final int UNKNOWN = 2;
 
     /** Size limit for file contained values */
@@ -234,11 +197,13 @@ public class LdifReader implements Itera
     /** The default size limit : 1Mo */
     protected static final long SIZE_LIMIT_DEFAULT = 1024000;
 
-    /** State values for the modify operation */
+    /** State values for the modify operation : MOD_SPEC */
     protected static final int MOD_SPEC = 0;
 
+    /** State values for the modify operation : ATTRVAL_SPEC */
     protected static final int ATTRVAL_SPEC = 1;
 
+    /** State values for the modify operation : ATTRVAL_SPEC_OR_SEP */
     protected static final int ATTRVAL_SPEC_OR_SEP = 2;
 
     /** Iterator prefetched entry */
@@ -266,16 +231,16 @@ public class LdifReader implements Itera
     public LdifReader()
     {
         lines = new ArrayList<String>();
-        position = new Position();
+        position = 0;
         version = DEFAULT_VERSION;
     }
 
 
-    private void init( BufferedReader reader ) throws LdapLdifException, LdapException
+    private void init( BufferedReader reader ) throws LdapException
     {
         this.reader = reader;
         lines = new ArrayList<String>();
-        position = new Position();
+        position = 0;
         version = DEFAULT_VERSION;
         containsChanges = false;
         containsEntries = false;
@@ -290,8 +255,7 @@ public class LdifReader implements Itera
      * A constructor which takes a file name
      * 
      * @param ldifFileName A file name containing ldif formated input
-     * @throws LdapLdifException
-     *             If the file cannot be processed or if the format is incorrect
+     * @throws LdapLdifException If the file cannot be processed or if the format is incorrect
      */
     public LdifReader( String ldifFileName ) throws LdapLdifException
     {
@@ -299,14 +263,14 @@ public class LdifReader implements Itera
 
         if ( !file.exists() )
         {
-            String msg = I18n.err( I18n.ERR_12010, file.getAbsoluteFile() );
+            String msg = I18n.err( I18n.ERR_12010_CANNOT_FIND_FILE, file.getAbsoluteFile() );
             LOG.error( msg );
             throw new LdapLdifException( msg );
         }
 
         if ( !file.canRead() )
         {
-            String msg = I18n.err( I18n.ERR_12011, file.getName() );
+            String msg = I18n.err( I18n.ERR_12011_CANNOT_READ_FILE, file.getName() );
             LOG.error( msg );
             throw new LdapLdifException( msg );
         }
@@ -317,7 +281,7 @@ public class LdifReader implements Itera
         }
         catch ( FileNotFoundException fnfe )
         {
-            String msg = I18n.err( I18n.ERR_12010, file.getAbsoluteFile() );
+            String msg = I18n.err( I18n.ERR_12010_CANNOT_FIND_FILE, file.getAbsoluteFile() );
             LOG.error( msg );
             throw new LdapLdifException( msg );
         }
@@ -335,13 +299,10 @@ public class LdifReader implements Itera
     /**
      * A constructor which takes a Reader
      * 
-     * @param in
-     *            A Reader containing ldif formated input
-     * @throws LdapLdifException
-     *             If the file cannot be processed or if the format is incorrect
-     * @throws LdapException 
+     * @param in A Reader containing ldif formated input
+     * @throws LdapException If the file cannot be processed or if the format is incorrect
      */
-    public LdifReader( Reader in ) throws LdapLdifException, LdapException
+    public LdifReader( Reader in ) throws LdapException
     {
         init( new BufferedReader( in ) );
     }
@@ -350,13 +311,10 @@ public class LdifReader implements Itera
     /**
      * A constructor which takes an InputStream
      * 
-     * @param in
-     *            An InputStream containing ldif formated input
-     * @throws LdapLdifException
-     *             If the file cannot be processed or if the format is incorrect
-     * @throws LdapException 
+     * @param in An InputStream containing ldif formated input
+     * @throws LdapException If the file cannot be processed or if the format is incorrect
      */
-    public LdifReader( InputStream in ) throws LdapLdifException, LdapException
+    public LdifReader( InputStream in ) throws LdapException
     {
         init( new BufferedReader( new InputStreamReader( in ) ) );
     }
@@ -365,23 +323,21 @@ public class LdifReader implements Itera
     /**
      * A constructor which takes a File
      * 
-     * @param file
-     *            A File containing ldif formated input
-     * @throws LdapLdifException
-     *             If the file cannot be processed or if the format is incorrect
+     * @param file A File containing ldif formated input
+     * @throws LdapLdifException If the file cannot be processed or if the format is incorrect
      */
     public LdifReader( File file ) throws LdapLdifException
     {
         if ( !file.exists() )
         {
-            String msg = I18n.err( I18n.ERR_12010, file.getAbsoluteFile() );
+            String msg = I18n.err( I18n.ERR_12010_CANNOT_FIND_FILE, file.getAbsoluteFile() );
             LOG.error( msg );
             throw new LdapLdifException( msg );
         }
 
         if ( !file.canRead() )
         {
-            String msg = I18n.err( I18n.ERR_12011, file.getName() );
+            String msg = I18n.err( I18n.ERR_12011_CANNOT_READ_FILE, file.getName() );
             LOG.error( msg );
             throw new LdapLdifException( msg );
         }
@@ -392,7 +348,7 @@ public class LdifReader implements Itera
         }
         catch ( FileNotFoundException fnfe )
         {
-            String msg = I18n.err( I18n.ERR_12010, file.getAbsoluteFile() );
+            String msg = I18n.err( I18n.ERR_12010_CANNOT_FIND_FILE, file.getAbsoluteFile() );
             LOG.error( msg );
             throw new LdapLdifException( msg );
         }
@@ -428,8 +384,7 @@ public class LdifReader implements Itera
     /**
      * Set the maximum file size that can be accepted for an attribute value
      * 
-     * @param sizeLimit
-     *            The size in bytes
+     * @param sizeLimit The size in bytes
      */
     public void setSizeLimit( long sizeLimit )
     {
@@ -437,13 +392,12 @@ public class LdifReader implements Itera
     }
 
 
-    // <fill> ::= ' ' <fill> | ���������
-    private static void parseFill( char[] document, Position position )
+    // <fill> ::= ' ' <fill> | e
+    private static void parseFill( char[] document )
     {
-
-        while ( StringTools.isCharASCII( document, position.pos, ' ' ) )
+        while ( StringTools.isCharASCII( document, position, ' ' ) )
         {
-            position.inc();
+            position++;
         }
     }
 
@@ -457,18 +411,17 @@ public class LdifReader implements Itera
      * Check that the number is in the interval
      * 
      * @param document The document containing the number to parse
-     * @param position The current position in the document
      * @return a String representing the parsed number
      */
-    private static String parseNumber( char[] document, Position position )
+    private static String parseNumber( char[] document )
     {
-        int initPos = position.pos;
+        int initPos = position;
 
         while ( true )
         {
-            if ( StringTools.isDigit( document, position.pos ) )
+            if ( StringTools.isDigit( document, position ) )
             {
-                position.inc();
+                position++;
             }
             else
             {
@@ -476,13 +429,13 @@ public class LdifReader implements Itera
             }
         }
 
-        if ( position.pos == initPos )
+        if ( position == initPos )
         {
             return null;
         }
         else
         {
-            return new String( document, initPos, position.pos - initPos );
+            return new String( document, initPos, position - initPos );
         }
     }
 
@@ -490,8 +443,7 @@ public class LdifReader implements Itera
     /**
      * Parse the changeType
      * 
-     * @param line
-     *            The line which contains the changeType
+     * @param line The line which contains the changeType
      * @return The operation.
      */
     private ChangeType parseChangeType( String line )
@@ -528,11 +480,9 @@ public class LdifReader implements Itera
     /**
      * Parse the DN of an entry
      * 
-     * @param line
-     *            The line to parse
+     * @param line The line to parse
      * @return A DN
-     * @throws LdapLdifException
-     *             If the DN is invalid
+     * @throws LdapLdifException If the DN is invalid
      */
     private String parseDn( String line ) throws LdapLdifException
     {
@@ -548,8 +498,8 @@ public class LdifReader implements Itera
             if ( length == 3 )
             {
                 // The DN is empty : error
-                LOG.error( I18n.err( I18n.ERR_12012 ) );
-                throw new LdapLdifException( I18n.err( I18n.ERR_12013 ) );
+                LOG.error( I18n.err( I18n.ERR_12012_EMPTY_DN_NOT_ALLOWED ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12013_NO_DN ) );
             }
             else if ( line.charAt( 3 ) == ':' )
             {
@@ -565,15 +515,15 @@ public class LdifReader implements Itera
                     catch ( UnsupportedEncodingException uee )
                     {
                         // The DN is not base 64 encoded
-                        LOG.error( I18n.err( I18n.ERR_12014 ) );
-                        throw new LdapLdifException( I18n.err( I18n.ERR_12015 ) );
+                        LOG.error( I18n.err( I18n.ERR_12014_BASE64_DN_EXPECTED ) );
+                        throw new LdapLdifException( I18n.err( I18n.ERR_12015_INVALID_BASE64_DN ) );
                     }
                 }
                 else
                 {
                     // The DN is empty : error
-                    LOG.error( I18n.err( I18n.ERR_12012 ) );
-                    throw new LdapLdifException( I18n.err( I18n.ERR_12013 ) );
+                    LOG.error( I18n.err( I18n.ERR_12012_EMPTY_DN_NOT_ALLOWED ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12013_NO_DN ) );
                 }
             }
             else
@@ -583,8 +533,8 @@ public class LdifReader implements Itera
         }
         else
         {
-            LOG.error( I18n.err( I18n.ERR_12016 ) );
-            throw new LdapLdifException( I18n.err( I18n.ERR_12013 ) );
+            LOG.error( I18n.err( I18n.ERR_12016_DN_EXPECTED ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12013_NO_DN ) );
         }
 
         // Check that the DN is valid. If not, an exception will be thrown
@@ -594,7 +544,7 @@ public class LdifReader implements Itera
         }
         catch ( LdapInvalidDnException ine )
         {
-            LOG.error( I18n.err( I18n.ERR_12017, dn ) );
+            LOG.error( I18n.err( I18n.ERR_12017_INVALID_DN, dn ) );
             throw new LdapLdifException( ine.getMessage() );
         }
 
@@ -605,10 +555,8 @@ public class LdifReader implements Itera
     /**
      * Parse the value part.
      * 
-     * @param line
-     *            The line which contains the value
-     * @param pos
-     *            The starting position in the line
+     * @param line The line which contains the value
+     * @param pos The starting position in the line
      * @return A String or a byte[], depending of the kind of value we get
      */
     protected static Object parseSimpleValue( String line, int pos )
@@ -641,8 +589,7 @@ public class LdifReader implements Itera
      * @param line The line which contains the value
      * @param pos The starting position in the line
      * @return A String or a byte[], depending of the kind of value we get
-     * @throws LdapLdifException
-     *             If something went wrong
+     * @throws LdapLdifException If something went wrong
      */
     protected Object parseValue( String line, int pos ) throws LdapLdifException
     {
@@ -749,15 +696,21 @@ public class LdifReader implements Itera
 
 
     /**
-     * Parse a control. The grammar is : &lt;control&gt; ::= "control:" &lt;fill&gt;
-     * &lt;ldap-oid&gt; &lt;critical-e&gt; &lt;value-spec-e&gt; &lt;sep&gt; &lt;critical-e&gt; ::= &lt;spaces&gt;
-     * &lt;boolean&gt; | e &lt;boolean&gt; ::= "true" | "false" &lt;value-spec-e&gt; ::=
-     * &lt;value-spec&gt; | e &lt;value-spec&gt; ::= ":" &lt;fill&gt; &lt;SAFE-STRING-e&gt; | "::"
-     * &lt;fill&gt; &lt;BASE64-STRING&gt; | ":<" &lt;fill&gt; &lt;url&gt;
-     * 
-     * It can be read as : "control:" &lt;fill&gt; &lt;ldap-oid&gt; [ " "+ ( "true" |
+     * Parse a control. The grammar is : 
+     * <pre>
+     * &lt;control&gt; ::= "control:" &lt;fill&gt; &lt;ldap-oid&gt; &lt;critical-e&gt; &lt;value-spec-e&gt; &lt;sep&gt; 
+     * &lt;critical-e&gt; ::= &lt;spaces&gt; &lt;boolean&gt; | e 
+     * &lt;boolean&gt; ::= "true" | "false" 
+     * &lt;value-spec-e&gt; ::= &lt;value-spec&gt; | e 
+     * &lt;value-spec&gt; ::= ":" &lt;fill&gt; &lt;SAFE-STRING-e&gt; | "::" &lt;fill&gt; &lt;BASE64-STRING&gt; | ":<" &lt;fill&gt; &lt;url&gt;
+     * </pre>
+     * 
+     * It can be read as :
+     * <pre> 
+     * "control:" &lt;fill&gt; &lt;ldap-oid&gt; [ " "+ ( "true" |
      * "false") ] [ ":" &lt;fill&gt; &lt;SAFE-STRING-e&gt; | "::" &lt;fill&gt; &lt;BASE64-STRING&gt; | ":<"
      * &lt;fill&gt; &lt;url&gt; ]
+     * </pre>
      * 
      * @param line The line containing the control
      * @return A control
@@ -854,7 +807,7 @@ public class LdifReader implements Itera
             else if ( StringTools.isCharASCII( controlValue, criticalPos + 1, '<' ) )
             {
                 // File contained value
-                // TODO : Add the missing code
+                throw new NotImplementedException( "See DIRSERVER-1547" );
             }
             else
             {
@@ -892,11 +845,11 @@ public class LdifReader implements Itera
             // Create an attribute
             if ( attributeValue instanceof String )
             {
-                return new DefaultEntryAttribute( attributeType, (String)attributeValue );
+                return new DefaultEntryAttribute( attributeType, ( String ) attributeValue );
             }
             else
             {
-                return new DefaultEntryAttribute( attributeType, (byte[])attributeValue );
+                return new DefaultEntryAttribute( attributeType, ( byte[] ) attributeValue );
             }
         }
         else
@@ -914,7 +867,8 @@ public class LdifReader implements Itera
      * @param lowerLine The same line, lowercased
      * @throws LdapLdifException If anything goes wrong
      */
-    public void parseAttributeValue( LdifEntry entry, String line, String lowerLine ) throws LdapLdifException, LdapException
+    public void parseAttributeValue( LdifEntry entry, String line, String lowerLine ) throws LdapLdifException,
+        LdapException
     {
         int colonIndex = line.indexOf( ':' );
 
@@ -923,8 +877,8 @@ public class LdifReader implements Itera
         // We should *not* have a DN twice
         if ( attributeType.equals( "dn" ) )
         {
-            LOG.error( I18n.err( I18n.ERR_12002 ) );
-            throw new LdapLdifException( I18n.err( I18n.ERR_12003 ) );
+            LOG.error( I18n.err( I18n.ERR_12002_ENTRY_WITH_TWO_DNS ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12003_LDIF_ENTRY_WITH_TWO_DNS ) );
         }
 
         Object attributeValue = parseValue( line, colonIndex );
@@ -937,12 +891,9 @@ public class LdifReader implements Itera
     /**
      * Parse a ModRDN operation
      * 
-     * @param entry
-     *            The entry to update
-     * @param iter
-     *            The lines iterator
-     * @throws LdapLdifException
-     *             If anything goes wrong
+     * @param entry The entry to update
+     * @param iter The lines iterator
+     * @throws LdapLdifException If anything goes wrong
      */
     private void parseModRdn( LdifEntry entry, Iterator<String> iter ) throws LdapLdifException
     {
@@ -957,8 +908,15 @@ public class LdifReader implements Itera
             {
                 int colonIndex = line.indexOf( ':' );
                 Object attributeValue = parseValue( line, colonIndex );
-                entry.setNewRdn( attributeValue instanceof String ? ( String ) attributeValue : StringTools
-                    .utf8ToString( ( byte[] ) attributeValue ) );
+
+                if ( attributeValue instanceof String )
+                {
+                    entry.setNewRdn( ( String ) attributeValue );
+                }
+                else
+                {
+                    entry.setNewRdn( StringTools.utf8ToString( ( byte[] ) attributeValue ) );
+                }
             }
             else
             {
@@ -1001,13 +959,16 @@ public class LdifReader implements Itera
     /**
      * Parse a modify change type.
      * 
-     * The grammar is : &lt;changerecord&gt; ::= "changetype:" FILL "modify" SEP
-     * &lt;mod-spec&gt; &lt;mod-specs-e&gt; &lt;mod-spec&gt; ::= "add:" &lt;mod-val&gt; | "delete:"
-     * &lt;mod-val-del&gt; | "replace:" &lt;mod-val&gt; &lt;mod-specs-e&gt; ::= &lt;mod-spec&gt;
-     * &lt;mod-specs-e&gt; | e &lt;mod-val&gt; ::= FILL ATTRIBUTE-DESCRIPTION SEP
-     * ATTRVAL-SPEC &lt;attrval-specs-e&gt; "-" SEP &lt;mod-val-del&gt; ::= FILL
-     * ATTRIBUTE-DESCRIPTION SEP &lt;attrval-specs-e&gt; "-" SEP &lt;attrval-specs-e&gt; ::=
-     * ATTRVAL-SPEC &lt;attrval-specs&gt; | e *
+     * The grammar is :
+     * <pre> 
+     * &lt;changerecord&gt; ::= "changetype:" FILL "modify" SEP &lt;mod-spec&gt; &lt;mod-specs-e&gt; 
+     * &lt;mod-spec&gt; ::= "add:" &lt;mod-val&gt; | "delete:" &lt;mod-val-del&gt; | "replace:" &lt;mod-val&gt; 
+     * &lt;mod-specs-e&gt; ::= &lt;mod-spec&gt;
+     * &lt;mod-specs-e&gt; | e 
+     * &lt;mod-val&gt; ::= FILL ATTRIBUTE-DESCRIPTION SEP ATTRVAL-SPEC &lt;attrval-specs-e&gt; "-" SEP 
+     * &lt;mod-val-del&gt; ::= FILL ATTRIBUTE-DESCRIPTION SEP &lt;attrval-specs-e&gt; "-" SEP 
+     * &lt;attrval-specs-e&gt; ::= ATTRVAL-SPEC &lt;attrval-specs&gt; | e
+     * </pre>
      * 
      * @param entry The entry to feed
      * @param iter The lines
@@ -1117,8 +1078,8 @@ public class LdifReader implements Itera
                 // We should *not* have a DN twice
                 if ( attributeType.equalsIgnoreCase( "dn" ) )
                 {
-                    LOG.error( I18n.err( I18n.ERR_12002 ) );
-                    throw new LdapLdifException( I18n.err( I18n.ERR_12003 ) );
+                    LOG.error( I18n.err( I18n.ERR_12002_ENTRY_WITH_TWO_DNS ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12003_LDIF_ENTRY_WITH_TWO_DNS ) );
                 }
 
                 Object attributeValue = parseValue( line, colonIndex );
@@ -1142,31 +1103,38 @@ public class LdifReader implements Itera
 
     /**
      * Parse a change operation. We have to handle different cases depending on
-     * the operation. 1) Delete : there should *not* be any line after the
-     * "changetype: delete" 2) Add : we must have a list of AttributeType :
-     * AttributeValue elements 3) ModDN : we must have two following lines: a
-     * "newrdn:" and a "deleteoldrdn:" 4) ModRDN : the very same, but a
-     * "newsuperior:" line is expected 5) Modify :
-     * 
-     * The grammar is : &lt;changerecord&gt; ::= "changetype:" FILL "add" SEP
-     * &lt;attrval-spec&gt; &lt;attrval-specs-e&gt; | "changetype:" FILL "delete" |
-     * "changetype:" FILL "modrdn" SEP &lt;newrdn&gt; SEP &lt;deleteoldrdn&gt; SEP | // To
-     * be checked "changetype:" FILL "moddn" SEP &lt;newrdn&gt; SEP &lt;deleteoldrdn&gt; SEP
-     * &lt;newsuperior&gt; SEP | "changetype:" FILL "modify" SEP &lt;mod-spec&gt;
-     * &lt;mod-specs-e&gt; &lt;newrdn&gt; ::= "newrdn:" FILL RDN | "newrdn::" FILL
-     * BASE64-RDN &lt;deleteoldrdn&gt; ::= "deleteoldrdn:" FILL "0" | "deleteoldrdn:"
-     * FILL "1" &lt;newsuperior&gt; ::= "newsuperior:" FILL DN | "newsuperior::" FILL
-     * BASE64-DN &lt;mod-specs-e&gt; ::= &lt;mod-spec&gt; &lt;mod-specs-e&gt; | e &lt;mod-spec&gt; ::=
-     * "add:" &lt;mod-val&gt; | "delete:" &lt;mod-val&gt; | "replace:" &lt;mod-val&gt; &lt;mod-val&gt;
-     * ::= FILL ATTRIBUTE-DESCRIPTION SEP ATTRVAL-SPEC &lt;attrval-specs-e&gt; "-" SEP
+     * the operation.
+     * <ul> 
+     * <li>1) Delete : there should *not* be any line after the "changetype: delete" </li> 
+     * <li>2) Add : we must have a list of AttributeType : AttributeValue elements </li>
+     * <li>3) ModDN : we must have two following lines: a "newrdn:" and a "deleteoldrdn:" </li>
+     * <li>4) ModRDN : the very same, but a "newsuperior:" line is expected </li>
+     * <li>5) Modify</li>
+     * </ul>
+     * 
+     * The grammar is : 
+     * <pre>
+     * &lt;changerecord&gt; ::= "changetype:" FILL "add" SEP &lt;attrval-spec&gt; &lt;attrval-specs-e&gt; | 
+     *     "changetype:" FILL "delete" |
+     *     "changetype:" FILL "modrdn" SEP &lt;newrdn&gt; SEP &lt;deleteoldrdn&gt; SEP | 
+     *     // To be checked 
+     *     "changetype:" FILL "moddn" SEP &lt;newrdn&gt; SEP &lt;deleteoldrdn&gt; SEP &lt;newsuperior&gt; SEP | 
+     *     "changetype:" FILL "modify" SEP &lt;mod-spec&gt; &lt;mod-specs-e&gt; 
+     * &lt;newrdn&gt; ::= "newrdn:" FILL RDN | "newrdn::" FILL BASE64-RDN 
+     * &lt;deleteoldrdn&gt; ::= "deleteoldrdn:" FILL "0" | "deleteoldrdn:" FILL "1" 
+     * &lt;newsuperior&gt; ::= "newsuperior:" FILL DN | "newsuperior::" FILL BASE64-DN 
+     * &lt;mod-specs-e&gt; ::= &lt;mod-spec&gt; &lt;mod-specs-e&gt; | e 
+     * &lt;mod-spec&gt; ::= "add:" &lt;mod-val&gt; | "delete:" &lt;mod-val&gt; | "replace:" &lt;mod-val&gt; 
+     * &lt;mod-val&gt; ::= FILL ATTRIBUTE-DESCRIPTION SEP ATTRVAL-SPEC &lt;attrval-specs-e&gt; "-" SEP
      * &lt;attrval-specs-e&gt; ::= ATTRVAL-SPEC &lt;attrval-specs&gt; | e
+     * </pre>
      * 
      * @param entry The entry to feed
      * @param iter The lines iterator
      * @param operation The change operation (add, modify, delete, moddn or modrdn)
-     * @exception LdapLdifException If the change operation is invalid
+     * @exception LdapException If the change operation is invalid
      */
-    private void parseChange( LdifEntry entry, Iterator<String> iter, ChangeType operation ) throws LdapLdifException, LdapException
+    private void parseChange( LdifEntry entry, Iterator<String> iter, ChangeType operation ) throws LdapException
     {
         // The changetype and operation has already been parsed.
         entry.setChangeType( operation );
@@ -1208,8 +1176,15 @@ public class LdifReader implements Itera
                     {
                         int colonIndex = line.indexOf( ':' );
                         Object attributeValue = parseValue( line, colonIndex );
-                        entry.setNewSuperior( attributeValue instanceof String ? ( String ) attributeValue
-                            : StringTools.utf8ToString( ( byte[] ) attributeValue ) );
+
+                        if ( attributeValue instanceof String )
+                        {
+                            entry.setNewSuperior( ( String ) attributeValue );
+                        }
+                        else
+                        {
+                            entry.setNewSuperior( StringTools.utf8ToString( ( byte[] ) attributeValue ) );
+                        }
                     }
                     else
                     {
@@ -1241,19 +1216,19 @@ public class LdifReader implements Itera
 
     /**
      * Parse a ldif file. The following rules are processed :
-     * 
+     * <pre>
      * &lt;ldif-file&gt; ::= &lt;ldif-attrval-record&gt; &lt;ldif-attrval-records&gt; |
-     * &lt;ldif-change-record&gt; &lt;ldif-change-records&gt; &lt;ldif-attrval-record&gt; ::=
-     * &lt;dn-spec&gt; &lt;sep&gt; &lt;attrval-spec&gt; &lt;attrval-specs&gt; &lt;ldif-change-record&gt; ::=
-     * &lt;dn-spec&gt; &lt;sep&gt; &lt;controls-e&gt; &lt;changerecord&gt; &lt;dn-spec&gt; ::= "dn:" &lt;fill&gt;
-     * &lt;distinguishedName&gt; | "dn::" &lt;fill&gt; &lt;base64-distinguishedName&gt;
+     *     &lt;ldif-change-record&gt; &lt;ldif-change-records&gt; 
+     * &lt;ldif-attrval-record&gt; ::= &lt;dn-spec&gt; &lt;sep&gt; &lt;attrval-spec&gt; &lt;attrval-specs&gt; 
+     * &lt;ldif-change-record&gt; ::= &lt;dn-spec&gt; &lt;sep&gt; &lt;controls-e&gt; &lt;changerecord&gt; 
+     * &lt;dn-spec&gt; ::= "dn:" &lt;fill&gt; &lt;distinguishedName&gt; | "dn::" &lt;fill&gt; &lt;base64-distinguishedName&gt;
      * &lt;changerecord&gt; ::= "changetype:" &lt;fill&gt; &lt;change-op&gt;
+     * </pre>
      * 
      * @return the parsed ldifEntry
-     * @exception LdapLdifException If the ldif file does not contain a valid entry 
-     * @throws LdapException 
+     * @exception LdapException If the ldif file does not contain a valid entry 
      */
-    private LdifEntry parseEntry() throws LdapLdifException, LdapException
+    private LdifEntry parseEntry() throws LdapException
     {
         if ( ( lines == null ) || ( lines.size() == 0 ) )
         {
@@ -1308,8 +1283,8 @@ public class LdifReader implements Itera
             {
                 if ( containsEntries )
                 {
-                    LOG.error( I18n.err( I18n.ERR_12004 ) );
-                    throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
+                    LOG.error( I18n.err( I18n.ERR_12004_CHANGE_NOT_ALLOWED ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12005_NO_CHANGE ) );
                 }
 
                 containsChanges = true;
@@ -1328,8 +1303,8 @@ public class LdifReader implements Itera
             {
                 if ( containsEntries )
                 {
-                    LOG.error( I18n.err( I18n.ERR_12004 ) );
-                    throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
+                    LOG.error( I18n.err( I18n.ERR_12004_CHANGE_NOT_ALLOWED ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12005_NO_CHANGE ) );
                 }
 
                 containsChanges = true;
@@ -1354,8 +1329,8 @@ public class LdifReader implements Itera
             {
                 if ( containsChanges )
                 {
-                    LOG.error( I18n.err( I18n.ERR_12004 ) );
-                    throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
+                    LOG.error( I18n.err( I18n.ERR_12004_CHANGE_NOT_ALLOWED ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12005_NO_CHANGE ) );
                 }
 
                 containsEntries = true;
@@ -1400,10 +1375,7 @@ public class LdifReader implements Itera
      * Parse the version from the ldif input.
      * 
      * @return A number representing the version (default to 1)
-     * @throws LdapLdifException
-     *             If the version is incorrect
-     * @throws LdapLdifException
-     *             If the input is incorrect
+     * @throws LdapLdifException If the version is incorrect or if the input is incorrect
      */
     private int parseVersion() throws LdapLdifException
     {
@@ -1427,14 +1399,14 @@ public class LdifReader implements Itera
 
         if ( line.startsWith( "version:" ) )
         {
-            position.inc( "version:".length() );
-            parseFill( document, position );
+            position += "version:".length();
+            parseFill( document );
 
             // Version number. Must be '1' in this version
-            versionNumber = parseNumber( document, position );
+            versionNumber = parseNumber( document );
 
             // We should not have any other chars after the number
-            if ( position.pos != document.length )
+            if ( position != document.length )
             {
                 LOG.error( I18n.err( I18n.ERR_12060 ) );
                 throw new LdapLdifException( I18n.err( I18n.ERR_12061 ) );
@@ -1564,11 +1536,9 @@ public class LdifReader implements Itera
     /**
      * Parse a ldif file (using the default encoding).
      * 
-     * @param fileName
-     *            The ldif file
+     * @param fileName The ldif file
      * @return A list of entries
-     * @throws LdapLdifException
-     *             If the parsing fails
+     * @throws LdapLdifException If the parsing fails
      */
     public List<LdifEntry> parseLdifFile( String fileName ) throws LdapLdifException
     {
@@ -1579,13 +1549,10 @@ public class LdifReader implements Itera
     /**
      * Parse a ldif file, decoding it using the given charset encoding
      * 
-     * @param fileName
-     *            The ldif file
-     * @param encoding
-     *            The charset encoding to use
+     * @param fileName The ldif file
+     * @param encoding The charset encoding to use
      * @return A list of entries
-     * @throws LdapLdifException
-     *             If the parsing fails
+     * @throws LdapLdifException If the parsing fails
      */
     // This will suppress PMD.EmptyCatchBlock warnings in this method
     @SuppressWarnings("PMD.EmptyCatchBlock")
@@ -1611,8 +1578,7 @@ public class LdifReader implements Itera
         try
         {
             reader = new BufferedReader(
-                new InputStreamReader( 
-                    new FileInputStream( file ), Charset.forName( encoding ) ) );
+                new InputStreamReader( new FileInputStream( file ), Charset.forName( encoding ) ) );
 
             return parseLdif( reader );
         }
@@ -1647,11 +1613,9 @@ public class LdifReader implements Itera
     /**
      * A method which parses a ldif string and returns a list of entries.
      * 
-     * @param ldif
-     *            The ldif string
+     * @param ldif The ldif string
      * @return A list of entries, or an empty List
-     * @throws LdapLdifException
-     *             If something went wrong
+     * @throws LdapLdifException If something went wrong
      */
     // This will suppress PMD.EmptyCatchBlock warnings in this method
     @SuppressWarnings("PMD.EmptyCatchBlock")
@@ -1664,8 +1628,7 @@ public class LdifReader implements Itera
             return new ArrayList<LdifEntry>();
         }
 
-        BufferedReader reader = new BufferedReader( 
-            new StringReader( ldif ) );
+        BufferedReader reader = new BufferedReader( new StringReader( ldif ) );
 
         try
         {
@@ -1710,12 +1673,10 @@ public class LdifReader implements Itera
     // ------------------------------------------------------------------------
     // Iterator Methods
     // ------------------------------------------------------------------------
-
     /**
      * Gets the next LDIF on the channel.
      * 
      * @return the next LDIF as a String.
-     * @exception NoSuchElementException If we can't read the next entry
      */
     private LdifEntry nextInternal()
     {
@@ -1757,7 +1718,6 @@ public class LdifReader implements Itera
      * Gets the next LDIF on the channel.
      * 
      * @return the next LDIF as a String.
-     * @exception NoSuchElementException If we can't read the next entry
      */
     public LdifEntry next()
     {
@@ -1783,7 +1743,14 @@ public class LdifReader implements Itera
      */
     public boolean hasNext()
     {
-        LOG.debug( "hasNext(): -- returning {}", ( prefetched != null ) ? Boolean.TRUE : Boolean.FALSE );
+        if ( prefetched != null )
+        {
+            LOG.debug( "hasNext(): -- returning true" );
+        }
+        else
+        {
+            LOG.debug( "hasNext(): -- returning false" );
+        }
 
         return hasNextInternal();
     }
@@ -1860,14 +1827,11 @@ public class LdifReader implements Itera
      * The main entry point of the LdifParser. It reads a buffer and returns a
      * List of entries.
      * 
-     * @param reader
-     *            The buffer being processed
+     * @param reader The buffer being processed
      * @return A list of entries
-     * @throws LdapLdifException
-     *             If something went wrong
-     * @throws LdapException 
+     * @throws LdapException If something went wrong
      */
-    public List<LdifEntry> parseLdif( BufferedReader reader ) throws LdapLdifException, LdapException
+    public List<LdifEntry> parseLdif( BufferedReader reader ) throws LdapException
     {
         // Create a list that will contain the read entries
         List<LdifEntry> entries = new ArrayList<LdifEntry>();
@@ -1899,8 +1863,7 @@ public class LdifReader implements Itera
 
 
     /**
-     * @return True if the ldif file contains entries, fals if it contains
-     *         changes
+     * @return True if the ldif file contains entries, fals if it contains changes
      */
     public boolean containsEntries()
     {
@@ -1915,12 +1878,10 @@ public class LdifReader implements Itera
     {
         if ( reader != null )
         {
-            position = new Position();
+            position = 0;
             reader.close();
             containsEntries = false;
             containsChanges = false;
         }
     }
 }
-
-

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java?rev=993315&r1=993314&r2=993315&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java Tue Sep  7 10:41:57 2010
@@ -45,12 +45,15 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdifRevertor
+public final class LdifRevertor
 {
-    /** Two constants for the deleteOldRdn flag */
+    /** Flag used when we want to delete the old RDN */
     public static final boolean DELETE_OLD_RDN = true;
+
+    /** Flag used when we want to keep the old RDN */
     public static final boolean KEEP_OLD_RDN = false;
-    
+
+
     /**
      * Compute a reverse LDIF of an AddRequest. It's simply a delete request
      * of the added entry
@@ -74,6 +77,7 @@ public class LdifRevertor
      * @param dn The deleted entry DN
      * @param deletedEntry The entry which has been deleted
      * @return A reverse LDIF
+     * @throws LdapException If something went wrong
      */
     public static LdifEntry reverseDel( DN dn, Entry deletedEntry ) throws LdapException
     {
@@ -92,23 +96,25 @@ public class LdifRevertor
 
 
     /**
-    *
-    * Compute the reversed LDIF for a modify request. We will deal with the
-    * three kind of modifications :
-    * - add
-    * - remove
-    * - replace
-    *
-    * As the modifications should be issued in a reversed order ( ie, for
-    * the initials modifications {A, B, C}, the reversed modifications will
-    * be ordered like {C, B, A}), we will change the modifications order.
-    *
-    * @param dn the dn of the modified entry
-    * @param forwardModifications the modification items for the forward change
-    * @param modifiedEntry The modified entry. Necessary for the destructive modifications
-    * @return A reversed LDIF
-    * @throws NamingException If something went wrong
-    */
+     *
+     * Compute the reversed LDIF for a modify request. We will deal with the
+     * three kind of modifications :
+     * <ul>
+     * <li>add</li>
+     * <li>remove</li>
+     * <li>replace</li>
+     * </ul>
+     * 
+     * As the modifications should be issued in a reversed order ( ie, for
+     * the initials modifications {A, B, C}, the reversed modifications will
+     * be ordered like {C, B, A}), we will change the modifications order.
+     *
+     * @param dn the dn of the modified entry
+     * @param forwardModifications the modification items for the forward change
+     * @param modifiedEntry The modified entry. Necessary for the destructive modifications
+     * @return A reversed LDIF
+     * @throws LdapException If something went wrong
+     */
     public static LdifEntry reverseModify( DN dn, List<Modification> forwardModifications, Entry modifiedEntry )
         throws LdapException
     {
@@ -192,7 +198,8 @@ public class LdifRevertor
 
                     if ( mod.get() == null )
                     {
-                        reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, previous );
+                        reverseModification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
+                            previous );
                         reverseModifications.add( 0, reverseModification );
                         continue;
                     }
@@ -244,7 +251,7 @@ public class LdifRevertor
      * @param newSuperiorDn the new parent dn to be (must not be null)
      * @param modifiedDn the dn of the entry being moved (must not be null)
      * @return a reverse LDIF
-     * @throws NamingException if something went wrong
+     * @throws LdapException if something went wrong
      */
     public static LdifEntry reverseMove( DN newSuperiorDn, DN modifiedDn ) throws LdapException
     {
@@ -283,29 +290,29 @@ public class LdifRevertor
         return entry;
     }
 
-    
+
     /**
      * A small helper class to compute the simple revert.
      */
-    private static LdifEntry revertEntry( Entry entry, DN newDn, 
-        DN newSuperior, RDN oldRdn, RDN newRdn ) throws LdapInvalidDnException
+    private static LdifEntry revertEntry( Entry entry, DN newDn, DN newSuperior, RDN oldRdn, RDN newRdn )
+        throws LdapInvalidDnException
     {
         LdifEntry reverted = new LdifEntry();
-        
+
         // We have a composite old RDN, something like A=a+B=b
         // It does not matter if the RDNs overlap
         reverted.setChangeType( ChangeType.ModRdn );
-        
+
         if ( newSuperior != null )
         {
-            DN restoredDn = newSuperior.add( newRdn ); 
+            DN restoredDn = newSuperior.add( newRdn );
             reverted.setDn( restoredDn );
         }
         else
         {
             reverted.setDn( newDn );
         }
-        
+
         reverted.setNewRdn( oldRdn.getName() );
 
         // Is the newRdn's value present in the entry ?
@@ -314,7 +321,7 @@ public class LdifRevertor
         boolean keepOldRdn = entry.contains( newRdn.getNormType(), newRdn.getNormValue() );
 
         reverted.setDeleteOldRdn( !keepOldRdn );
-        
+
         if ( newSuperior != null )
         {
             DN oldSuperior = entry.getDn();
@@ -325,8 +332,8 @@ public class LdifRevertor
 
         return reverted;
     }
-    
-    
+
+
     /**
      * A helper method to generate the modified attribute after a rename.
      */
@@ -334,53 +341,52 @@ public class LdifRevertor
     {
         LdifEntry restored = new LdifEntry();
         restored.setChangeType( ChangeType.Modify );
-        
+
         // We have to use the parent DN, the entry has already
         // been renamed
         restored.setDn( parentDn );
 
-        for ( AVA ava:newRdn )
+        for ( AVA ava : newRdn )
         {
             // No need to add something which has already been added
             // in the previous modification
-            if ( !entry.contains( ava.getNormType(), ava.getNormValue().getString() ) &&
-                 !(ava.getNormType().equals( oldRdn.getNormType() ) &&
-                   ava.getNormValue().getString().equals( oldRdn.getNormValue().getString() ) ) )
+            if ( !entry.contains( ava.getNormType(), ava.getNormValue().getString() )
+                && !( ava.getNormType().equals( oldRdn.getNormType() ) && ava.getNormValue().getString().equals(
+                    oldRdn.getNormValue().getString() ) ) )
             {
                 // Create the modification, which is an Remove
-                Modification modification = new DefaultModification( 
-                    ModificationOperation.REMOVE_ATTRIBUTE, 
+                Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
                     new DefaultEntryAttribute( ava.getUpType(), ava.getUpValue().getString() ) );
-                
+
                 restored.addModificationItem( modification );
             }
         }
-        
+
         return restored;
     }
-    
-    
+
+
     /**
      * A helper method which generates a reverted entry
      */
-    private static LdifEntry generateReverted( DN newSuperior, RDN newRdn, DN newDn, 
-        RDN oldRdn, boolean deleteOldRdn ) throws LdapInvalidDnException
+    private static LdifEntry generateReverted( DN newSuperior, RDN newRdn, DN newDn, RDN oldRdn, boolean deleteOldRdn )
+        throws LdapInvalidDnException
     {
         LdifEntry reverted = new LdifEntry();
         reverted.setChangeType( ChangeType.ModRdn );
 
         if ( newSuperior != null )
         {
-            DN restoredDn = newSuperior.add( newRdn ); 
+            DN restoredDn = newSuperior.add( newRdn );
             reverted.setDn( restoredDn );
         }
         else
         {
             reverted.setDn( newDn );
         }
-        
+
         reverted.setNewRdn( oldRdn.getName() );
-        
+
         if ( newSuperior != null )
         {
             DN oldSuperior = newDn;
@@ -388,14 +394,14 @@ public class LdifRevertor
             oldSuperior = oldSuperior.remove( oldSuperior.size() - 1 );
             reverted.setNewSuperior( oldSuperior.getName() );
         }
-        
+
         // Delete the newRDN values
         reverted.setDeleteOldRdn( deleteOldRdn );
-        
+
         return reverted;
     }
-    
-    
+
+
     /**
      * Revert a DN to it's previous version by removing the first RDN and adding the given RDN.
      * It's a rename operation. The biggest issue is that we have many corner cases, depending 
@@ -405,14 +411,15 @@ public class LdifRevertor
      * @param newRdn The new RDN
      * @param deleteOldRdn A flag which tells to delete the old RDN AVAs
      * @return A list of LDIF reverted entries 
-     * @throws NamingException If the name reverting failed
+     * @throws LdapInvalidDnException If the name reverting failed
      */
-    public static List<LdifEntry> reverseRename( Entry entry, RDN newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException
+    public static List<LdifEntry> reverseRename( Entry entry, RDN newRdn, boolean deleteOldRdn )
+        throws LdapInvalidDnException
     {
         return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn );
     }
-    
-    
+
+
     /**
      * Revert a DN to it's previous version by removing the first RDN and adding the given RDN.
      * It's a rename operation. The biggest issue is that we have many corner cases, depending 
@@ -423,9 +430,10 @@ public class LdifRevertor
      * @param newRdn The new RDN
      * @param deleteOldRdn A flag which tells to delete the old RDN AVAs
      * @return A list of LDIF reverted entries 
-     * @throws NamingException If the name reverting failed
+     * @throws LdapInvalidDnException If the name reverting failed
      */
-    public static List<LdifEntry> reverseMoveAndRename( Entry entry, DN newSuperior, RDN newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException
+    public static List<LdifEntry> reverseMoveAndRename( Entry entry, DN newSuperior, RDN newRdn, boolean deleteOldRdn )
+        throws LdapInvalidDnException
     {
         DN parentDn = entry.getDn();
         DN newDn = null;
@@ -464,7 +472,7 @@ public class LdifRevertor
                 // We have a simple old RDN, something like A=a
                 // If the values overlap, we can't rename the entry, just get out
                 // with an error
-                throw new LdapInvalidDnException( I18n.err( I18n.ERR_12080 ) ); 
+                throw new LdapInvalidDnException( I18n.err( I18n.ERR_12080 ) );
             }
 
             reverted = revertEntry( entry, newDn, newSuperior, oldRdn, newRdn );
@@ -479,10 +487,10 @@ public class LdifRevertor
                 // The old RDN is simple
                 boolean overlapping = false;
                 boolean existInEntry = false;
-                
+
                 // Does it overlap ?
                 // Is the new RDN AVAs contained into the entry?
-                for ( AVA atav:newRdn )
+                for ( AVA atav : newRdn )
                 {
                     if ( atav.equals( oldRdn.getAtav() ) )
                     {
@@ -497,7 +505,7 @@ public class LdifRevertor
                         }
                     }
                 }
-                
+
                 if ( overlapping )
                 {
                     // The new RDN includes the old one
@@ -507,12 +515,12 @@ public class LdifRevertor
                         // We have to restore them, but we also have to remove
                         // the new values
                         reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn, KEEP_OLD_RDN );
-                        
+
                         entries.add( reverted );
-                        
+
                         // Now, restore the initial values
                         LdifEntry restored = generateModify( parentDn, entry, oldRdn, newRdn );
-                        
+
                         entries.add( restored );
                     }
                     else
@@ -520,7 +528,7 @@ public class LdifRevertor
                         // This is the simplest case, we don't have to restore
                         // some existing values (case 8.1 and 9.1)
                         reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn, DELETE_OLD_RDN );
-                        
+
                         entries.add( reverted );
                     }
                 }
@@ -532,11 +540,11 @@ public class LdifRevertor
                         // We have to restore them, but we also have to remove
                         // the new values
                         reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn, KEEP_OLD_RDN );
-                        
+
                         entries.add( reverted );
-                        
+
                         LdifEntry restored = generateModify( parentDn, entry, oldRdn, newRdn );
-                        
+
                         entries.add( restored );
                     }
                     else
@@ -554,18 +562,18 @@ public class LdifRevertor
                 // Does the RDN overlap ?
                 boolean overlapping = false;
                 boolean existInEntry = false;
-                
+
                 Set<AVA> oldAtavs = new HashSet<AVA>();
 
                 // We first build a set with all the oldRDN ATAVs 
-                for ( AVA atav:oldRdn )
+                for ( AVA atav : oldRdn )
                 {
                     oldAtavs.add( atav );
                 }
-                
+
                 // Now we loop on the newRDN ATAVs to evaluate if the Rdns are overlaping
                 // and if the newRdn ATAVs are present in the entry
-                for ( AVA atav:newRdn )
+                for ( AVA atav : newRdn )
                 {
                     if ( oldAtavs.contains( atav ) )
                     {
@@ -576,8 +584,8 @@ public class LdifRevertor
                         existInEntry = true;
                     }
                 }
-                
-                if ( overlapping ) 
+
+                if ( overlapping )
                 {
                     // They overlap
                     if ( existInEntry )
@@ -585,7 +593,7 @@ public class LdifRevertor
                         // In this case, we have to reestablish the removed ATAVs
                         // (Cases 12.2 and 13.2)
                         reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn, KEEP_OLD_RDN );
-    
+
                         entries.add( reverted );
                     }
                     else
@@ -594,7 +602,7 @@ public class LdifRevertor
                         // overlapping values will be re-created.
                         // (Cases 12.1 and 13.1)
                         reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn, DELETE_OLD_RDN );
-    
+
                         entries.add( reverted );
                     }
                 }
@@ -606,11 +614,11 @@ public class LdifRevertor
                         // In this case, we have to reestablish the removed ATAVs
                         // (Cases 10.2 and 11.2)
                         reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn, KEEP_OLD_RDN );
-    
+
                         entries.add( reverted );
-                        
+
                         LdifEntry restored = generateModify( parentDn, entry, oldRdn, newRdn );
-                        
+
                         entries.add( restored );
                     }
                     else
@@ -618,7 +626,7 @@ public class LdifRevertor
                         // We are safe ! We can delete all the new Rdn ATAVs
                         // (Cases 10.1 and 11.1)
                         reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn, DELETE_OLD_RDN );
-    
+
                         entries.add( reverted );
                     }
                 }

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=993315&r1=993314&r2=993315&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 Sep  7 10:41:57 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.ldif;
 
+
 import java.io.UnsupportedEncodingException;
 
 import javax.naming.directory.Attributes;
@@ -40,13 +41,12 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.util.StringTools;
 
 
-
 /**
  * Some LDIF useful methods
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdifUtils
+public final class LdifUtils
 {
     /** The array that will be used to match the first char.*/
     private static boolean[] LDIF_SAFE_STARTING_CHAR_ALPHABET = new boolean[128];
@@ -57,12 +57,13 @@ public class LdifUtils
     /** The default length for a line in a ldif file */
     private static final int DEFAULT_LINE_LENGTH = 80;
 
+    /** The file separator */
     private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
 
     static
     {
         // Initialization of the array that will be used to match the first char.
-        for (int i = 0; i < 128; i++)
+        for ( int i = 0; i < 128; i++ )
         {
             LDIF_SAFE_STARTING_CHAR_ALPHABET[i] = true;
         }
@@ -75,7 +76,7 @@ public class LdifUtils
         LDIF_SAFE_STARTING_CHAR_ALPHABET[60] = false; // 60 (>)
 
         // Initialization of the array that will be used to match the other chars.
-        for (int i = 0; i < 128; i++)
+        for ( int i = 0; i < 128; i++ )
         {
             LDIF_SAFE_OTHER_CHARS_ALPHABET[i] = true;
         }
@@ -93,19 +94,23 @@ public class LdifUtils
      * The data does not need to be encoded if all the following are true:
      *
      * The data cannot start with the following char values:
-     *         00 (NUL)
-     *         10 (LF)
-     *         13 (CR)
-     *         32 (SPACE)
-     *         58 (:)
-     *         60 (<)
-     *         Any character with value greater than 127
+     * <ul>
+     * <li>00 (NUL)</li>
+     * <li>10 (LF)</li>
+     * <li>13 (CR)</li>
+     * <li>32 (SPACE)</li>
+     * <li>58 (:)</li>
+     * <li>60 (<)</li>
+     * <li>Any character with value greater than 127</li>
+     * </ul>
      *
      * The data cannot contain any of the following char values:
-     *         00 (NUL)
-     *         10 (LF)
-     *         13 (CR)
-     *         Any character with value greater than 127
+     * <ul>
+     * <li>00 (NUL)</li>
+     * <li>10 (LF)</li>
+     * <li>13 (CR)</li>
+     * <li>Any character with value greater than 127</li>
+     * </ul>
      *
      * The data cannot end with a space.
      *
@@ -121,7 +126,7 @@ public class LdifUtils
         }
 
         // Checking the first char
-        char currentChar = str.charAt(0);
+        char currentChar = str.charAt( 0 );
 
         if ( ( currentChar > 127 ) || !LDIF_SAFE_STARTING_CHAR_ALPHABET[currentChar] )
         {
@@ -129,9 +134,9 @@ public class LdifUtils
         }
 
         // Checking the other chars
-        for (int i = 1; i < str.length(); i++)
+        for ( int i = 1; i < str.length(); i++ )
         {
-            currentChar = str.charAt(i);
+            currentChar = str.charAt( i );
 
             if ( ( currentChar > 127 ) || !LDIF_SAFE_OTHER_CHARS_ALPHABET[currentChar] )
             {
@@ -146,6 +151,7 @@ public class LdifUtils
 
     /**
      * Convert an Attributes as LDIF
+     * 
      * @param attrs the Attributes to convert
      * @return the corresponding LDIF code as a String
      * @throws LdapException If a naming exception is encountered.
@@ -158,7 +164,9 @@ public class LdifUtils
 
     /**
      * Convert an Attributes as LDIF
+     * 
      * @param attrs the Attributes to convert
+     * @param length The ldif line length
      * @return the corresponding LDIF code as a String
      * @throws LdapException If a naming exception is encountered.
      */
@@ -170,7 +178,10 @@ public class LdifUtils
 
     /**
      * Convert an Attributes as LDIF. The DN is written.
+     * 
      * @param attrs the Attributes to convert
+     * @param dn The DN for this entry
+     * @param length The ldif line length
      * @return the corresponding LDIF code as a String
      * @throws LdapException If a naming exception is encountered.
      */
@@ -182,7 +193,9 @@ public class LdifUtils
 
     /**
      * Convert an Attributes as LDIF. The DN is written.
+     * 
      * @param attrs the Attributes to convert
+     * @param dn The DN for this entry
      * @return the corresponding LDIF code as a String
      * @throws LdapException If a naming exception is encountered.
      */
@@ -194,6 +207,7 @@ public class LdifUtils
 
     /**
      * Convert an Entry to LDIF
+     * 
      * @param entry the Entry to convert
      * @return the corresponding LDIF code as a String
      * @throws LdapException If a naming exception is encountered.
@@ -206,6 +220,7 @@ public class LdifUtils
 
     /**
      * 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
@@ -215,7 +230,7 @@ public class LdifUtils
     {
         String ldif = convertEntryToLdif( entry, DEFAULT_LINE_LENGTH );
 
-        if( includeVersionInfo )
+        if ( includeVersionInfo )
         {
             ldif = "version: 1" + LINE_SEPARATOR + ldif;
         }
@@ -226,6 +241,7 @@ public class LdifUtils
 
     /**
      * Convert all the Entry's attributes to LDIF. The DN is not written
+     * 
      * @param entry the Entry to convert
      * @return the corresponding LDIF code as a String
      * @throws LdapException If a naming exception is encountered.
@@ -245,7 +261,7 @@ public class LdifUtils
      */
     public static Attributes convertAttributesFromLdif( String ldif ) throws LdapLdifException
     {
-        LdifAttributesReader reader = new  LdifAttributesReader();
+        LdifAttributesReader reader = new LdifAttributesReader();
 
         return AttributeUtils.toAttributes( reader.parseEntry( ldif ) );
     }
@@ -253,6 +269,7 @@ public class LdifUtils
 
     /**
      * Convert an Entry as LDIF
+     * 
      * @param entry the Entry to convert
      * @param length the expected line length
      * @return the corresponding LDIF code as a String
@@ -278,7 +295,7 @@ public class LdifUtils
         }
 
         // Then all the attributes
-        for ( EntryAttribute attribute:entry )
+        for ( EntryAttribute attribute : entry )
         {
             sb.append( convertToLdif( attribute, length ) );
         }
@@ -289,6 +306,7 @@ public class LdifUtils
 
     /**
      * Convert the Entry's attributes to LDIF. The DN is not written.
+     * 
      * @param entry the Entry to convert
      * @param length the expected line length
      * @return the corresponding LDIF code as a String
@@ -299,7 +317,7 @@ public class LdifUtils
         StringBuilder sb = new StringBuilder();
 
         // Then all the attributes
-        for ( EntryAttribute attribute:entry )
+        for ( EntryAttribute attribute : entry )
         {
             sb.append( convertToLdif( attribute, length ) );
         }
@@ -310,6 +328,7 @@ public class LdifUtils
 
     /**
      * Convert an LdifEntry to LDIF
+     * 
      * @param entry the LdifEntry to convert
      * @return the corresponding LDIF as a String
      * @throws LdapException If a naming exception is encountered.
@@ -322,6 +341,7 @@ public class LdifUtils
 
     /**
      * Convert an LdifEntry to LDIF
+     * 
      * @param entry the LdifEntry to convert
      * @param length The maximum line's length
      * @return the corresponding LDIF as a String
@@ -374,7 +394,7 @@ public class LdifUtils
 
         switch ( entry.getChangeType() )
         {
-            case None :
+            case None:
                 if ( entry.hasControls() )
                 {
                     sb.append( stripLineToNChars( "changetype: " + ChangeType.Add, length ) );
@@ -382,21 +402,21 @@ public class LdifUtils
 
                 // Fallthrough
 
-            case Add :
+            case Add:
                 if ( ( entry.getEntry() == null ) )
                 {
                     throw new LdapException( I18n.err( I18n.ERR_12082 ) );
                 }
 
                 // Now, iterate through all the attributes
-                for ( EntryAttribute attribute:entry.getEntry() )
+                for ( EntryAttribute attribute : entry.getEntry() )
                 {
                     sb.append( convertToLdif( attribute, length ) );
                 }
 
                 break;
 
-            case Delete :
+            case Delete:
                 if ( entry.getEntry() != null )
                 {
                     throw new LdapException( I18n.err( I18n.ERR_12081 ) );
@@ -404,14 +424,13 @@ public class LdifUtils
 
                 break;
 
-            case ModDn :
-            case ModRdn :
+            case ModDn:
+            case ModRdn:
                 if ( entry.getEntry() != null )
                 {
                     throw new LdapException( I18n.err( I18n.ERR_12083 ) );
                 }
 
-
                 // Stores the new RDN
                 EntryAttribute newRdn = new DefaultEntryAttribute( "newrdn", entry.getNewRdn() );
                 sb.append( convertToLdif( newRdn, length ) );
@@ -431,7 +450,7 @@ public class LdifUtils
                 sb.append( '\n' );
 
                 // Stores the optional newSuperior
-                if ( ! StringTools.isEmpty( entry.getNewSuperior() ) )
+                if ( !StringTools.isEmpty( entry.getNewSuperior() ) )
                 {
                     EntryAttribute newSuperior = new DefaultEntryAttribute( "newsuperior", entry.getNewSuperior() );
                     sb.append( convertToLdif( newSuperior, length ) );
@@ -439,24 +458,24 @@ public class LdifUtils
 
                 break;
 
-            case Modify :
-                for ( Modification modification:entry.getModificationItems() )
+            case Modify:
+                for ( Modification modification : entry.getModificationItems() )
                 {
                     switch ( modification.getOperation() )
                     {
-                        case ADD_ATTRIBUTE :
+                        case ADD_ATTRIBUTE:
                             sb.append( "add: " );
                             break;
 
-                        case REMOVE_ATTRIBUTE :
+                        case REMOVE_ATTRIBUTE:
                             sb.append( "delete: " );
                             break;
 
-                        case REPLACE_ATTRIBUTE :
+                        case REPLACE_ATTRIBUTE:
                             sb.append( "replace: " );
                             break;
 
-                        default :
+                        default:
                             break; // Do nothing
 
                     }
@@ -469,7 +488,7 @@ public class LdifUtils
                 }
                 break;
 
-            default :
+            default:
                 break; // Do nothing
 
         }
@@ -479,14 +498,16 @@ public class LdifUtils
         return sb.toString();
     }
 
+
     /**
      * Base64 encode a String
+     * 
      * @param str The string to encode
      * @return the base 64 encoded string
      */
     private static String encodeBase64( String str )
     {
-        char[] encoded =null;
+        char[] encoded = null;
 
         try
         {
@@ -504,6 +525,7 @@ public class LdifUtils
 
     /**
      * Converts an EntryAttribute to LDIF
+     * 
      * @param attr the >EntryAttribute to convert
      * @return the corresponding LDIF code as a String
      * @throws LdapException If a naming exception is encountered.
@@ -516,6 +538,7 @@ public class LdifUtils
 
     /**
      * Converts an EntryAttribute as LDIF
+     * 
      * @param attr the EntryAttribute to convert
      * @param length the expected line length
      * @return the corresponding LDIF code as a String
@@ -525,7 +548,7 @@ public class LdifUtils
     {
         StringBuilder sb = new StringBuilder();
 
-        for ( Value<?> value:attr )
+        for ( Value<?> value : attr )
         {
             StringBuilder lineBuffer = new StringBuilder();
 
@@ -556,7 +579,7 @@ public class LdifUtils
                 {
                     lineBuffer.append( ":" );
 
-                    if ( str != null)
+                    if ( str != null )
                     {
                         lineBuffer.append( " " ).append( str );
                     }
@@ -573,11 +596,12 @@ public class LdifUtils
 
     /**
      * Strips the String every n specified characters
+     * 
      * @param str the string to strip
      * @param nbChars the number of characters
      * @return the stripped String
      */
-    public static String stripLineToNChars( String str, int nbChars)
+    public static String stripLineToNChars( String str, int nbChars )
     {
         int strLength = str.length();
 
@@ -597,12 +621,11 @@ public class LdifUtils
 
         int remaining = ( strLength - nbChars ) % charsPerLine;
 
-        int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) +
-                        ( remaining == 0 ? 0 : 1 );
+        int nbLines = 1 + ( ( strLength - nbChars ) / charsPerLine ) + ( remaining == 0 ? 0 : 1 );
 
         int nbCharsTotal = strLength + nbLines + nbLines - 2;
 
-        char[] buffer = new char[ nbCharsTotal ];
+        char[] buffer = new char[nbCharsTotal];
         char[] orig = str.toCharArray();
 
         int posSrc = 0;
@@ -612,7 +635,7 @@ public class LdifUtils
         posSrc += nbChars;
         posDst += nbChars;
 
-        for ( int i = 0; i < nbLines - 2; i ++ )
+        for ( int i = 0; i < nbLines - 2; i++ )
         {
             buffer[posDst++] = '\n';
             buffer[posDst++] = ' ';
@@ -646,24 +669,24 @@ public class LdifUtils
      * Attribute ID/Value
      * @return An Attributes instance
      * @throws LdapException If the data are invalid
-     * @throws LdapLdifException
      */
-    public static Attributes createAttributes( Object... avas ) throws LdapException, LdapLdifException
+    public static Attributes createAttributes( Object... avas ) throws LdapException
     {
         StringBuilder sb = new StringBuilder();
         int pos = 0;
         boolean valueExpected = false;
 
-        for ( Object ava : avas)
+        for ( Object ava : avas )
         {
             if ( !valueExpected )
             {
-                if ( !(ava instanceof String) )
+                if ( !( ava instanceof String ) )
                 {
-                    throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12085, (pos+1) ) );
+                    throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
+                        I18n.ERR_12085, ( pos + 1 ) ) );
                 }
 
-                String attribute = (String)ava;
+                String attribute = ( String ) ava;
                 sb.append( attribute );
 
                 if ( attribute.indexOf( ':' ) != -1 )
@@ -679,17 +702,18 @@ public class LdifUtils
             {
                 if ( ava instanceof String )
                 {
-                    sb.append( ": " ).append( (String)ava ).append( '\n' );
+                    sb.append( ": " ).append( ( String ) ava ).append( '\n' );
                 }
                 else if ( ava instanceof byte[] )
                 {
                     sb.append( ":: " );
-                    sb.append( new String( Base64.encode( (byte[] )ava ) ) );
+                    sb.append( new String( Base64.encode( ( byte[] ) ava ) ) );
                     sb.append( '\n' );
                 }
                 else
                 {
-                    throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12086, (pos+1) ) );
+                    throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
+                        I18n.ERR_12086, ( pos + 1 ) ) );
                 }
 
                 valueExpected = false;
@@ -698,7 +722,8 @@ public class LdifUtils
 
         if ( valueExpected )
         {
-            throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12087 ) );
+            throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n
+                .err( I18n.ERR_12087 ) );
         }
 
         LdifAttributesReader reader = new LdifAttributesReader();
@@ -726,9 +751,8 @@ public class LdifUtils
      * Attribute ID/Value
      * @return An Entry instance
      * @throws LdapException If the data are invalid
-     * @throws LdapLdifException
      */
-    public static Entry createEntry( DN dn, Object... avas ) throws LdapException, LdapLdifException
+    public static Entry createEntry( DN dn, Object... avas ) throws LdapException
     {
         return createEntry( null, dn, avas );
     }
@@ -752,9 +776,8 @@ public class LdifUtils
      * Attribute ID/Value
      * @return An Entry instance
      * @throws LdapException If the data are invalid
-     * @throws LdapLdifException
      */
-    public static Entry createEntry( String dn, Object... avas ) throws LdapException, LdapLdifException
+    public static Entry createEntry( String dn, Object... avas ) throws LdapException
     {
         return createEntry( null, new DN( dn ), avas );
     }
@@ -773,14 +796,14 @@ public class LdifUtils
      *     "jpegPhoto", new byte[]{0x01, 0x02} );
      * </pre>
      *
+     * @param schemaManager The SchemaManager instance
      * @param dn The entry's DN
      * @param avas The AttributeType and Values, using a ldif format, or a couple of
      * Attribute ID/Value
      * @return An Entry instance
      * @throws LdapException If the data are invalid
-     * @throws LdapLdifException
      */
-    public static Entry createEntry( SchemaManager schemaManager, String dn, Object... avas ) throws LdapException, LdapLdifException
+    public static Entry createEntry( SchemaManager schemaManager, String dn, Object... avas ) throws LdapException
     {
         return createEntry( schemaManager, new DN( dn ), avas );
     }
@@ -799,29 +822,30 @@ public class LdifUtils
      *     "jpegPhoto", new byte[]{0x01, 0x02} );
      * </pre>
      *
+     * @param schemaManager The SchemaManager instance
      * @param dn The entry's DN
      * @param avas The AttributeType and Values, using a ldif format, or a couple of
      * Attribute ID/Value
      * @return An Entry instance
      * @throws LdapException If the data are invalid
-     * @throws LdapLdifException
      */
-    public static Entry createEntry( SchemaManager schemaManager, DN dn, Object... avas ) throws LdapException, LdapLdifException
+    public static Entry createEntry( SchemaManager schemaManager, DN dn, Object... avas ) throws LdapException
     {
         StringBuilder sb = new StringBuilder();
         int pos = 0;
         boolean valueExpected = false;
 
-        for ( Object ava : avas)
+        for ( Object ava : avas )
         {
             if ( !valueExpected )
             {
-                if ( !(ava instanceof String) )
+                if ( !( ava instanceof String ) )
                 {
-                    throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12085, (pos+1) ) );
+                    throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
+                        I18n.ERR_12085, ( pos + 1 ) ) );
                 }
 
-                String attribute = (String)ava;
+                String attribute = ( String ) ava;
                 sb.append( attribute );
 
                 if ( attribute.indexOf( ':' ) != -1 )
@@ -837,17 +861,18 @@ public class LdifUtils
             {
                 if ( ava instanceof String )
                 {
-                    sb.append( ": " ).append( (String)ava ).append( '\n' );
+                    sb.append( ": " ).append( ( String ) ava ).append( '\n' );
                 }
                 else if ( ava instanceof byte[] )
                 {
                     sb.append( ":: " );
-                    sb.append( new String( Base64.encode( (byte[] )ava ) ) );
+                    sb.append( new String( Base64.encode( ( byte[] ) ava ) ) );
                     sb.append( '\n' );
                 }
                 else
                 {
-                    throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12086, (pos+1) ) );
+                    throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
+                        I18n.ERR_12086, ( pos + 1 ) ) );
                 }
 
                 valueExpected = false;
@@ -856,7 +881,8 @@ public class LdifUtils
 
         if ( valueExpected )
         {
-            throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12087 ) );
+            throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n
+                .err( I18n.ERR_12087 ) );
         }
 
         LdifAttributesReader reader = new LdifAttributesReader();

Modified: directory/shared/trunk/ldap-ldif/src/test/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReaderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/test/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReaderTest.java?rev=993315&r1=993314&r2=993315&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/test/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReaderTest.java (original)
+++ directory/shared/trunk/ldap-ldif/src/test/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReaderTest.java Tue Sep  7 10:41:57 2010
@@ -587,7 +587,8 @@ public class LdifAttributesReaderTest
         }
         catch ( LdapLdifException ne )
         {
-            assertTrue( I18n.err( I18n.ERR_12009 ), ne.getMessage().startsWith( I18n.ERR_12009.getErrorCode() ) );
+            assertTrue( I18n.err( I18n.ERR_12009_ERROR_PARSING_LDIF_BUFFER ), ne.getMessage().startsWith(
+                I18n.ERR_12009_ERROR_PARSING_LDIF_BUFFER.getErrorCode() ) );
         }
     }
 



Mime
View raw message