You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/03/16 16:47:00 UTC

svn commit: r923819 [1/2] - in /directory/shared/trunk/ldap-ldif/src: main/java/org/apache/directory/shared/ldap/ldif/ test/java/org/apache/directory/shared/ldap/ldif/

Author: elecharny
Date: Tue Mar 16 15:47:00 2010
New Revision: 923819

URL: http://svn.apache.org/viewvc?rev=923819&view=rev
Log:
o Fixed the project, using the new Exceptions
o Removed references to JNDI
o Duplicated some methods to work with Entry or Attributes

Added:
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdapLdifException.java
Modified:
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
    directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifUtils.java
    directory/shared/trunk/ldap-ldif/src/test/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReaderTest.java
    directory/shared/trunk/ldap-ldif/src/test/java/org/apache/directory/shared/ldap/ldif/LdifRevertorTest.java
    directory/shared/trunk/ldap-ldif/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java

Added: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdapLdifException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdapLdifException.java?rev=923819&view=auto
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdapLdifException.java (added)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdapLdifException.java Tue Mar 16 15:47:00 2010
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.ldif;
+
+
+/**
+ * An exception throws when we get an error while parsing a LDIF file.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 923395 $
+ */
+public class LdapLdifException extends Exception
+{
+    /** The serial version UUID */
+    private static final long serialVersionUID = 1L;
+    
+    /**
+     * Creates a new instance of LdapLdifException.
+     *
+     * @param message The exception message
+     */
+    public LdapLdifException( String message )
+    {
+        super( message );
+    }
+}

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java?rev=923819&r1=923818&r2=923819&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java Tue Mar 16 15:47:00 2010
@@ -24,12 +24,14 @@ import java.io.IOException;
 import java.io.StringReader;
 import java.util.ArrayList;
 
-import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttributes;
 
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -165,7 +167,7 @@ public class LdifAttributesReader extend
      * @param lowerLine The same line, lowercased
      * @throws NamingException If anything goes wrong
      */
-    private void parseAttribute( Attributes attributes, String line, String lowerLine ) throws NamingException
+    private void parseAttribute( Attributes attributes, String line, String lowerLine ) throws LdapLdifException
     {
         int colonIndex = line.indexOf( ':' );
 
@@ -175,7 +177,7 @@ public class LdifAttributesReader extend
         if ( attributeType.equals( "dn" ) )
         {
             LOG.error( I18n.err( I18n.ERR_12002 ) );
-            throw new NamingException( I18n.err( I18n.ERR_12003 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12003 ) );
         }
 
         Object attributeValue = parseValue( line, colonIndex );
@@ -193,6 +195,122 @@ public class LdifAttributesReader extend
         }
     }
 
+    
+
+
+    /**
+     * Parse an AttributeType/AttributeValue
+     * 
+     * @param attributes The entry where to store the value
+     * @param line The line to parse
+     * @param lowerLine The same line, lowercased
+     * @throws NamingException If anything goes wrong
+     */
+    private void parseEntryAttribute( Entry entry, String line, String lowerLine ) throws LdapLdifException
+    {
+        int colonIndex = line.indexOf( ':' );
+
+        String attributeType = lowerLine.substring( 0, colonIndex );
+
+        // 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 ) );
+        }
+
+        Object attributeValue = parseValue( line, colonIndex );
+
+        // Update the entry
+        EntryAttribute attribute = entry.get( attributeType );
+        
+        if ( attribute == null )
+        {
+            if ( attributeValue instanceof String )
+            {
+                entry.put( attributeType, (String)attributeValue );
+            }
+            else
+            {
+                entry.put( attributeType, (byte[])attributeValue );
+            }
+        }
+        else
+        {
+            if ( attributeValue instanceof String )
+            {
+                attribute.add( (String)attributeValue );
+            }
+            else
+            {
+                attribute.add( (byte[])attributeValue );
+            }
+        }
+    }
+
+    
+    /**
+     * Parse a ldif file. The following rules are processed :
+     * 
+     * &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;changerecord&gt; ::= "changetype:" &lt;fill&gt; &lt;change-op&gt;
+     * 
+     * @return The read entry
+     * @throws LdapLdifException If the entry can't be read or is invalid
+     */
+    private Entry parseEntry() throws LdapLdifException
+    {
+        if ( ( lines == null ) || ( lines.size() == 0 ) )
+        {
+            LOG.debug( "The entry is empty : end of ldif file" );
+            return null;
+        }
+
+        Entry entry = new DefaultClientEntry();
+
+        // Now, let's iterate through the other lines
+        for ( String line:lines )
+        {
+            // Each line could start either with an OID, an attribute type, with
+            // "control:" or with "changetype:"
+            String lowerLine = line.toLowerCase();
+
+            // We have three cases :
+            // 1) The first line after the DN is a "control:" -> this is an error
+            // 2) The first line after the DN is a "changeType:" -> this is an error
+            // 3) The first line after the DN is anything else
+            if ( lowerLine.startsWith( "control:" ) )
+            {
+                LOG.error( I18n.err( I18n.ERR_12004 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
+            }
+            else if ( lowerLine.startsWith( "changetype:" ) )
+            {
+                LOG.error( I18n.err( I18n.ERR_12004 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
+            }
+            else if ( line.indexOf( ':' ) > 0 )
+            {
+                parseEntryAttribute( entry, line, lowerLine );
+            }
+            else
+            {
+                // Invalid attribute Value
+                LOG.error( I18n.err( I18n.ERR_12006 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12007 ) );
+            }
+        }
+
+        LOG.debug( "Read an attributes : {}", entry );
+        
+        return entry;
+    }
+
+
     /**
      * Parse a ldif file. The following rules are processed :
      * 
@@ -206,7 +324,7 @@ public class LdifAttributesReader extend
      * @return The read entry
      * @throws NamingException If the entry can't be read or is invalid
      */
-    private Attributes parseAttributes() throws NamingException
+    private Attributes parseAttributes() throws LdapLdifException
     {
         if ( ( lines == null ) || ( lines.size() == 0 ) )
         {
@@ -230,12 +348,12 @@ public class LdifAttributesReader extend
             if ( lowerLine.startsWith( "control:" ) )
             {
                 LOG.error( I18n.err( I18n.ERR_12004 ) );
-                throw new NamingException( I18n.err( I18n.ERR_12005 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
             }
             else if ( lowerLine.startsWith( "changetype:" ) )
             {
                 LOG.error( I18n.err( I18n.ERR_12004 ) );
-                throw new NamingException( I18n.err( I18n.ERR_12005 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
             }
             else if ( line.indexOf( ':' ) > 0 )
             {
@@ -245,7 +363,7 @@ public class LdifAttributesReader extend
             {
                 // Invalid attribute Value
                 LOG.error( I18n.err( I18n.ERR_12006 ) );
-                throw new NamingException( I18n.err( I18n.ERR_12007 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12007 ) );
             }
         }
 
@@ -256,14 +374,13 @@ public class LdifAttributesReader extend
 
 
     /**
-     * A method which parses a ldif string and returns a list of entries.
+     * A method which parses a ldif string and returns a list of Attributes.
      * 
      * @param ldif The ldif string
-     * @return A list of entries, or an empty List
-     * @throws NamingException
-     *             If something went wrong
+     * @return A list of Attributes, or an empty List
+     * @throws LdapLdifException If something went wrong
      */
-    public Attributes parseAttributes( String ldif ) throws NamingException
+    public Attributes parseAttributes( String ldif ) throws LdapLdifException
     {
         lines = new ArrayList<String>();
         position = new Position();
@@ -291,10 +408,64 @@ public class LdifAttributesReader extend
 
             return attributes;
         }
-        catch (NamingException ne)
+        catch (LdapLdifException ne)
+        {
+            LOG.error( I18n.err( I18n.ERR_12008, ne.getLocalizedMessage() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12009 ) );
+        }
+        finally
+        {
+            try
+            {
+                reader.close();
+            }
+            catch ( IOException ioe )
+            {
+                // Do nothing
+            }
+        }
+    }
+    
+    
+    /**
+     * A method which parses a ldif string and returns a list of Entry.
+     * 
+     * @param ldif The ldif string
+     * @return A list of Entry, or an empty List
+     * @throws LdapLdifException If something went wrong
+     */
+    public Entry parseEntry( String ldif ) throws LdapLdifException
+    {
+        lines = new ArrayList<String>();
+        position = new Position();
+
+        LOG.debug( "Starts parsing ldif buffer" );
+
+        if ( StringTools.isEmpty( ldif ) )
+        {
+            return new DefaultClientEntry();
+        }
+
+        StringReader strIn = new StringReader( ldif );
+        reader = new BufferedReader( strIn );
+
+        try
+        {
+            readLines();
+            
+            Entry entry = parseEntry();
+
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( "Parsed {} entries.", ( entry == null ? 0 : 1 ) );
+            }
+
+            return entry;
+        }
+        catch (LdapLdifException ne)
         {
             LOG.error( I18n.err( I18n.ERR_12008, ne.getLocalizedMessage() ) );
-            throw new NamingException( I18n.err( I18n.ERR_12009 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12009 ) );
         }
         finally
         {

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java?rev=923819&r1=923818&r2=923819&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java Tue Mar 16 15:47:00 2010
@@ -29,9 +29,6 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
-import javax.naming.InvalidNameException;
-import javax.naming.NamingException;
-
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
@@ -42,6 +39,8 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
@@ -122,7 +121,7 @@ public class LdifEntry implements Clonea
      * 
      * @param dn The Distinguished Name
      */
-    public void setDn( String dn ) throws InvalidNameException
+    public void setDn( String dn ) throws LdapInvalidDnException
     {
         entry.setDn( new DN( dn ) );
     }
@@ -246,7 +245,7 @@ public class LdifEntry implements Clonea
      * @param attr
      *            The attribute to be added
      */
-    public void addAttribute( EntryAttribute attr ) throws NamingException
+    public void addAttribute( EntryAttribute attr ) throws LdapException
     {
         entry.put( attr );
     }
@@ -261,7 +260,7 @@ public class LdifEntry implements Clonea
      *            The attribute value
      * 
      */
-    public void addAttribute( String id, Object value ) throws NamingException
+    public void addAttribute( String id, Object value ) throws LdapException
     {
         if ( value instanceof String )
         {
@@ -302,7 +301,7 @@ public class LdifEntry implements Clonea
      *            The attribute value
      * 
      */
-    public void putAttribute( String id, Object value ) throws NamingException
+    public void putAttribute( String id, Object value ) throws LdapException
     {
         if ( value instanceof String )
         {
@@ -657,7 +656,7 @@ public class LdifEntry implements Clonea
         {
             return LdifUtils.convertToLdif( this );
         }
-        catch ( NamingException ne )
+        catch ( LdapException ne )
         {
             return null;
         }
@@ -878,7 +877,7 @@ public class LdifEntry implements Clonea
                         return false;
                     }
                 }
-                catch ( InvalidNameException ine )
+                catch ( LdapInvalidDnException ine )
                 {
                     return false;
                 }
@@ -894,7 +893,7 @@ public class LdifEntry implements Clonea
                         return false;
                     }
                 }
-                catch ( InvalidNameException ine )
+                catch ( LdapInvalidDnException ine )
                 {
                     return false;
                 }

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=923819&r1=923818&r2=923819&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 Mar 16 15:47:00 2010
@@ -41,17 +41,13 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.NoSuchElementException;
 
-import javax.naming.InvalidNameException;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
-
-import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.DnParser;
@@ -277,7 +273,7 @@ public class LdifReader implements Itera
     }
 
 
-    private void init( BufferedReader reader ) throws NamingException
+    private void init( BufferedReader reader ) throws LdapLdifException, LdapException
     {
         this.reader = reader;
         lines = new ArrayList<String>();
@@ -296,23 +292,23 @@ public class LdifReader implements Itera
      * A constructor which takes a file name
      * 
      * @param ldifFileName A file name containing ldif formated input
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If the file cannot be processed or if the format is incorrect
      */
-    public LdifReader( String ldifFileName ) throws NamingException
+    public LdifReader( String ldifFileName ) throws LdapLdifException
     {
         File file = new File( ldifFileName );
 
         if ( !file.exists() )
         {
             LOG.error( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
-            throw new NamingException( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
         }
 
         if ( !file.canRead() )
         {
             LOG.error( I18n.err( I18n.ERR_12011, file.getName() ) );
-            throw new NamingException( I18n.err( I18n.ERR_12011, file.getName() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12011, file.getName() ) );
         }
 
         try
@@ -322,7 +318,15 @@ public class LdifReader implements Itera
         catch ( FileNotFoundException fnfe )
         {
             LOG.error( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
-            throw new NamingException( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            throw new LdapLdifException( lide.getMessage() );
+        }
+        catch ( LdapException le )
+        {
+            throw new LdapLdifException( le.getMessage() );
         }
     }
 
@@ -332,10 +336,11 @@ public class LdifReader implements Itera
      * 
      * @param in
      *            A Reader containing ldif formated input
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If the file cannot be processed or if the format is incorrect
+     * @throws LdapException 
      */
-    public LdifReader( Reader in ) throws NamingException
+    public LdifReader( Reader in ) throws LdapLdifException, LdapException
     {
         init( new BufferedReader( in ) );
     }
@@ -346,10 +351,11 @@ public class LdifReader implements Itera
      * 
      * @param in
      *            An InputStream containing ldif formated input
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If the file cannot be processed or if the format is incorrect
+     * @throws LdapException 
      */
-    public LdifReader( InputStream in ) throws NamingException
+    public LdifReader( InputStream in ) throws LdapLdifException, LdapException
     {
         init( new BufferedReader( new InputStreamReader( in ) ) );
     }
@@ -360,21 +366,21 @@ public class LdifReader implements Itera
      * 
      * @param in
      *            A File containing ldif formated input
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If the file cannot be processed or if the format is incorrect
      */
-    public LdifReader( File file ) throws NamingException
+    public LdifReader( File file ) throws LdapLdifException
     {
         if ( !file.exists() )
         {
             LOG.error( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
-            throw new NamingException( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
         }
 
         if ( !file.canRead() )
         {
             LOG.error( I18n.err( I18n.ERR_12011, file.getName() ) );
-            throw new NamingException( I18n.err( I18n.ERR_12011, file.getName() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12011, file.getName() ) );
         }
 
         try
@@ -384,7 +390,15 @@ public class LdifReader implements Itera
         catch ( FileNotFoundException fnfe )
         {
             LOG.error( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
-            throw new NamingException( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12010, file.getAbsoluteFile() ) );
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            throw new LdapLdifException( lide.getMessage() );
+        }
+        catch ( LdapException le )
+        {
+            throw new LdapLdifException( le.getMessage() );
         }
     }
 
@@ -513,10 +527,10 @@ public class LdifReader implements Itera
      * @param line
      *            The line to parse
      * @return A DN
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If the DN is invalid
      */
-    private String parseDn( String line ) throws NamingException
+    private String parseDn( String line ) throws LdapLdifException
     {
         String dn = null;
 
@@ -531,7 +545,7 @@ public class LdifReader implements Itera
             {
                 // The DN is empty : error
                 LOG.error( I18n.err( I18n.ERR_12012 ) );
-                throw new NamingException( I18n.err( I18n.ERR_12013 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12013 ) );
             }
             else if ( line.charAt( 3 ) == ':' )
             {
@@ -548,14 +562,14 @@ public class LdifReader implements Itera
                     {
                         // The DN is not base 64 encoded
                         LOG.error( I18n.err( I18n.ERR_12014 ) );
-                        throw new NamingException( I18n.err( I18n.ERR_12015 ) );
+                        throw new LdapLdifException( I18n.err( I18n.ERR_12015 ) );
                     }
                 }
                 else
                 {
                     // The DN is empty : error
                     LOG.error( I18n.err( I18n.ERR_12012 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12013 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12013 ) );
                 }
             }
             else
@@ -566,7 +580,7 @@ public class LdifReader implements Itera
         else
         {
             LOG.error( I18n.err( I18n.ERR_12016 ) );
-            throw new NamingException( I18n.err( I18n.ERR_12013 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12013 ) );
         }
 
         // Check that the DN is valid. If not, an exception will be thrown
@@ -574,10 +588,10 @@ public class LdifReader implements Itera
         {
             DnParser.parseInternal( dn, new ArrayList<RDN>() );
         }
-        catch ( InvalidNameException ine )
+        catch ( LdapInvalidDnException ine )
         {
             LOG.error( I18n.err( I18n.ERR_12017, dn ) );
-            throw ine;
+            throw new LdapLdifException( ine.getMessage() );
         }
 
         return dn;
@@ -620,15 +634,13 @@ 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
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If something went wrong
      */
-    protected Object parseValue( String line, int pos ) throws NamingException
+    protected Object parseValue( String line, int pos ) throws LdapLdifException
     {
         if ( line.length() > pos + 1 )
         {
@@ -657,7 +669,7 @@ public class LdifReader implements Itera
                         if ( !file.exists() )
                         {
                             LOG.error( I18n.err( I18n.ERR_12018, fileName ) );
-                            throw new NamingException( I18n.err( I18n.ERR_12019 ) );
+                            throw new LdapLdifException( I18n.err( I18n.ERR_12019 ) );
                         }
                         else
                         {
@@ -666,7 +678,7 @@ public class LdifReader implements Itera
                             if ( length > sizeLimit )
                             {
                                 LOG.error( I18n.err( I18n.ERR_12020, fileName ) );
-                                throw new NamingException( I18n.err( I18n.ERR_12021 ) );
+                                throw new LdapLdifException( I18n.err( I18n.ERR_12021 ) );
                             }
                             else
                             {
@@ -686,12 +698,12 @@ public class LdifReader implements Itera
                                     // existence has already been
                                     // checked
                                     LOG.error( I18n.err( I18n.ERR_12018, fileName ) );
-                                    throw new NamingException( I18n.err( I18n.ERR_12019 ) );
+                                    throw new LdapLdifException( I18n.err( I18n.ERR_12019 ) );
                                 }
                                 catch ( IOException ioe )
                                 {
                                     LOG.error( I18n.err( I18n.ERR_12022, fileName ) );
-                                    throw new NamingException( I18n.err( I18n.ERR_12023 ) );
+                                    throw new LdapLdifException( I18n.err( I18n.ERR_12023 ) );
                                 }
                                 finally
                                 {
@@ -711,13 +723,13 @@ public class LdifReader implements Itera
                     else
                     {
                         LOG.error( I18n.err( I18n.ERR_12025 ) );
-                        throw new NamingException( I18n.err( I18n.ERR_12026 ) );
+                        throw new LdapLdifException( I18n.err( I18n.ERR_12026 ) );
                     }
                 }
                 catch ( MalformedURLException mue )
                 {
                     LOG.error( I18n.err( I18n.ERR_12027, urlName ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12028 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12028 ) );
                 }
             }
             else
@@ -745,10 +757,10 @@ public class LdifReader implements Itera
      * 
      * @param line The line containing the control
      * @return A control
-     * @exception NamingException If the control has no OID or if the OID is incorrect,
+     * @exception LdapLdifException If the control has no OID or if the OID is incorrect,
      * of if the criticality is not set when it's mandatory.
      */
-    private Control parseControl( String line ) throws NamingException
+    private Control parseControl( String line ) throws LdapLdifException
     {
         String lowerLine = line.toLowerCase().trim();
         char[] controlValue = line.trim().toCharArray();
@@ -760,7 +772,7 @@ public class LdifReader implements Itera
         {
             // No OID : error !
             LOG.error( I18n.err( I18n.ERR_12029 ) );
-            throw new NamingException( I18n.err( I18n.ERR_12030 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12030 ) );
         }
 
         int initPos = pos;
@@ -774,22 +786,16 @@ public class LdifReader implements Itera
         {
             // Not a valid OID !
             LOG.error( I18n.err( I18n.ERR_12029 ) );
-            throw new NamingException( I18n.err( I18n.ERR_12030 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12030 ) );
         }
 
         // Create and check the OID
         String oidString = lowerLine.substring( 0, pos );
 
-        OID oid = null;
-
-        try
-        {
-            oid = new OID( oidString );
-        }
-        catch ( DecoderException de )
+        if ( !OID.isOID( oidString ) )
         {
             LOG.error( I18n.err( I18n.ERR_12031, oidString ) );
-            throw new NamingException( I18n.err( I18n.ERR_12032 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12032 ) );
         }
 
         LdifControl control = new LdifControl( oidString );
@@ -828,7 +834,7 @@ public class LdifReader implements Itera
             // If we have a criticality, it should be either "true" or "false",
             // nothing else
             LOG.error( I18n.err( I18n.ERR_12033 ) );
-            throw new NamingException( I18n.err( I18n.ERR_12034 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12034 ) );
         }
 
         if ( criticalPos > 0 )
@@ -869,7 +875,7 @@ public class LdifReader implements Itera
      * @param line The line to parse
      * @return the parsed Attribute
      */
-    public static Attribute parseAttributeValue( String line )
+    public static EntryAttribute parseAttributeValue( String line )
     {
         int colonIndex = line.indexOf( ':' );
 
@@ -879,7 +885,14 @@ public class LdifReader implements Itera
             Object attributeValue = parseSimpleValue( line, colonIndex );
 
             // Create an attribute
-            return new BasicAttribute( attributeType, attributeValue );
+            if ( attributeValue instanceof String )
+            {
+                return new DefaultClientAttribute( attributeType, (String)attributeValue );
+            }
+            else
+            {
+                return new DefaultClientAttribute( attributeType, (byte[])attributeValue );
+            }
         }
         else
         {
@@ -894,9 +907,9 @@ public class LdifReader implements Itera
      * @param entry The entry where to store the value
      * @param line The line to parse
      * @param lowerLine The same line, lowercased
-     * @throws NamingException If anything goes wrong
+     * @throws LdapLdifException If anything goes wrong
      */
-    public void parseAttributeValue( LdifEntry entry, String line, String lowerLine ) throws NamingException
+    public void parseAttributeValue( LdifEntry entry, String line, String lowerLine ) throws LdapLdifException, LdapException
     {
         int colonIndex = line.indexOf( ':' );
 
@@ -906,7 +919,7 @@ public class LdifReader implements Itera
         if ( attributeType.equals( "dn" ) )
         {
             LOG.error( I18n.err( I18n.ERR_12002 ) );
-            throw new NamingException( I18n.err( I18n.ERR_12003 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12003 ) );
         }
 
         Object attributeValue = parseValue( line, colonIndex );
@@ -923,10 +936,10 @@ public class LdifReader implements Itera
      *            The entry to update
      * @param iter
      *            The lines iterator
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If anything goes wrong
      */
-    private void parseModRdn( LdifEntry entry, Iterator<String> iter ) throws NamingException
+    private void parseModRdn( LdifEntry entry, Iterator<String> iter ) throws LdapLdifException
     {
         // We must have two lines : one starting with "newrdn:" or "newrdn::",
         // and the second starting with "deleteoldrdn:"
@@ -945,14 +958,14 @@ public class LdifReader implements Itera
             else
             {
                 LOG.error( I18n.err( I18n.ERR_12035 ) );
-                throw new NamingException( I18n.err( I18n.ERR_12036 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12036 ) );
             }
 
         }
         else
         {
             LOG.error( I18n.err( I18n.ERR_12035 ) );
-            throw new NamingException( I18n.err( I18n.ERR_12037 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12037 ) );
         }
 
         if ( iter.hasNext() )
@@ -969,13 +982,13 @@ public class LdifReader implements Itera
             else
             {
                 LOG.error( I18n.err( I18n.ERR_12038 ) );
-                throw new NamingException( I18n.err( I18n.ERR_12039 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12039 ) );
             }
         }
         else
         {
             LOG.error( I18n.err( I18n.ERR_12038 ) );
-            throw new NamingException( I18n.err( I18n.ERR_12039 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12039 ) );
         }
 
         return;
@@ -995,9 +1008,9 @@ public class LdifReader implements Itera
      * 
      * @param entry The entry to feed
      * @param iter The lines
-     * @exception NamingException If the modify operation is invalid
+     * @exception LdapLdifException If the modify operation is invalid
      */
-    private void parseModify( LdifEntry entry, Iterator<String> iter ) throws NamingException
+    private void parseModify( LdifEntry entry, Iterator<String> iter ) throws LdapLdifException
     {
         int state = MOD_SPEC;
         String modified = null;
@@ -1017,7 +1030,7 @@ public class LdifReader implements Itera
                 if ( state != ATTRVAL_SPEC_OR_SEP )
                 {
                     LOG.error( I18n.err( I18n.ERR_12040 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12041 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12041 ) );
                 }
                 else
                 {
@@ -1042,7 +1055,7 @@ public class LdifReader implements Itera
                 if ( ( state != MOD_SPEC ) && ( state != ATTRVAL_SPEC ) )
                 {
                     LOG.error( I18n.err( I18n.ERR_12042 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12043 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12043 ) );
                 }
 
                 modified = StringTools.trim( line.substring( "add:".length() ) );
@@ -1056,7 +1069,7 @@ public class LdifReader implements Itera
                 if ( ( state != MOD_SPEC ) && ( state != ATTRVAL_SPEC ) )
                 {
                     LOG.error( I18n.err( I18n.ERR_12042 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12043 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12043 ) );
                 }
 
                 modified = StringTools.trim( line.substring( "delete:".length() ) );
@@ -1070,7 +1083,7 @@ public class LdifReader implements Itera
                 if ( ( state != MOD_SPEC ) && ( state != ATTRVAL_SPEC ) )
                 {
                     LOG.error( I18n.err( I18n.ERR_12042 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12043 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12043 ) );
                 }
 
                 modified = StringTools.trim( line.substring( "replace:".length() ) );
@@ -1084,7 +1097,7 @@ public class LdifReader implements Itera
                 if ( ( state != ATTRVAL_SPEC ) && ( state != ATTRVAL_SPEC_OR_SEP ) )
                 {
                     LOG.error( I18n.err( I18n.ERR_12040 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12043 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12043 ) );
                 }
 
                 // A standard AttributeType/AttributeValue pair
@@ -1095,14 +1108,14 @@ public class LdifReader implements Itera
                 if ( !attributeType.equalsIgnoreCase( modified ) )
                 {
                     LOG.error( I18n.err( I18n.ERR_12044 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12045 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12045 ) );
                 }
 
                 // We should *not* have a DN twice
                 if ( attributeType.equalsIgnoreCase( "dn" ) )
                 {
                     LOG.error( I18n.err( I18n.ERR_12002 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12003 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12003 ) );
                 }
 
                 Object attributeValue = parseValue( line, colonIndex );
@@ -1148,9 +1161,9 @@ public class LdifReader implements Itera
      * @param entry The entry to feed
      * @param iter The lines iterator
      * @param operation The change operation (add, modify, delete, moddn or modrdn)
-     * @exception NamingException If the change operation is invalid
+     * @exception LdapLdifException If the change operation is invalid
      */
-    private void parseChange( LdifEntry entry, Iterator<String> iter, ChangeType operation ) throws NamingException
+    private void parseChange( LdifEntry entry, Iterator<String> iter, ChangeType operation ) throws LdapLdifException, LdapException
     {
         // The changetype and operation has already been parsed.
         entry.setChangeType( operation );
@@ -1200,7 +1213,7 @@ public class LdifReader implements Itera
                         if ( operation == ChangeType.ModDn )
                         {
                             LOG.error( I18n.err( I18n.ERR_12046 ) );
-                            throw new NamingException( I18n.err( I18n.ERR_12047 ) );
+                            throw new LdapLdifException( I18n.err( I18n.ERR_12047 ) );
                         }
                     }
                 }
@@ -1209,7 +1222,7 @@ public class LdifReader implements Itera
                     if ( operation == ChangeType.ModDn )
                     {
                         LOG.error( I18n.err( I18n.ERR_12046 ) );
-                        throw new NamingException( I18n.err( I18n.ERR_12047 ) );
+                        throw new LdapLdifException( I18n.err( I18n.ERR_12047 ) );
                     }
                 }
 
@@ -1218,7 +1231,7 @@ public class LdifReader implements Itera
             default:
                 // This is an error
                 LOG.error( I18n.err( I18n.ERR_12048 ) );
-                throw new NamingException( I18n.err( I18n.ERR_12049 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12049 ) );
         }
     }
 
@@ -1234,9 +1247,10 @@ public class LdifReader implements Itera
      * &lt;changerecord&gt; ::= "changetype:" &lt;fill&gt; &lt;change-op&gt;
      * 
      * @return the parsed ldifEntry
-     * @exception NamingException If the ldif file does not contain a valid entry 
+     * @exception LdapLdifException If the ldif file does not contain a valid entry 
+     * @throws LdapException 
      */
-    private LdifEntry parseEntry() throws NamingException
+    private LdifEntry parseEntry() throws LdapLdifException, LdapException
     {
         if ( ( lines == null ) || ( lines.size() == 0 ) )
         {
@@ -1292,7 +1306,7 @@ public class LdifReader implements Itera
                 if ( containsEntries )
                 {
                     LOG.error( I18n.err( I18n.ERR_12004 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12005 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
                 }
 
                 containsChanges = true;
@@ -1300,7 +1314,7 @@ public class LdifReader implements Itera
                 if ( controlSeen )
                 {
                     LOG.error( I18n.err( I18n.ERR_12050 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12051 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12051 ) );
                 }
 
                 // Parse the control
@@ -1312,7 +1326,7 @@ public class LdifReader implements Itera
                 if ( containsEntries )
                 {
                     LOG.error( I18n.err( I18n.ERR_12004 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12005 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
                 }
 
                 containsChanges = true;
@@ -1320,7 +1334,7 @@ public class LdifReader implements Itera
                 if ( changeTypeSeen )
                 {
                     LOG.error( I18n.err( I18n.ERR_12052 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12053 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12053 ) );
                 }
 
                 // A change request
@@ -1338,7 +1352,7 @@ public class LdifReader implements Itera
                 if ( containsChanges )
                 {
                     LOG.error( I18n.err( I18n.ERR_12004 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12005 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12005 ) );
                 }
 
                 containsEntries = true;
@@ -1346,7 +1360,7 @@ public class LdifReader implements Itera
                 if ( controlSeen || changeTypeSeen )
                 {
                     LOG.error( I18n.err( I18n.ERR_12054 ) );
-                    throw new NamingException( I18n.err( I18n.ERR_12055 ) );
+                    throw new LdapLdifException( I18n.err( I18n.ERR_12055 ) );
                 }
 
                 parseAttributeValue( entry, line, lowerLine );
@@ -1356,7 +1370,7 @@ public class LdifReader implements Itera
             {
                 // Invalid attribute Value
                 LOG.error( I18n.err( I18n.ERR_12056 ) );
-                throw new NamingException( I18n.err( I18n.ERR_12057 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12057 ) );
             }
         }
 
@@ -1372,7 +1386,7 @@ public class LdifReader implements Itera
         else
         {
             LOG.error( I18n.err( I18n.ERR_12058 ) );
-            throw new NamingException( I18n.err( I18n.ERR_12059 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12059 ) );
         }
 
         return entry;
@@ -1383,12 +1397,12 @@ public class LdifReader implements Itera
      * Parse the version from the ldif input.
      * 
      * @return A number representing the version (default to 1)
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If the version is incorrect
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If the input is incorrect
      */
-    private int parseVersion() throws NamingException
+    private int parseVersion() throws LdapLdifException
     {
         int ver = DEFAULT_VERSION;
 
@@ -1420,7 +1434,7 @@ public class LdifReader implements Itera
             if ( position.pos != document.length )
             {
                 LOG.error( I18n.err( I18n.ERR_12060 ) );
-                throw new NamingException( I18n.err( I18n.ERR_12061 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12061 ) );
             }
 
             try
@@ -1430,7 +1444,7 @@ public class LdifReader implements Itera
             catch ( NumberFormatException nfe )
             {
                 LOG.error( I18n.err( I18n.ERR_12060 ) );
-                throw new NamingException( I18n.err( I18n.ERR_12061 ) );
+                throw new LdapLdifException( I18n.err( I18n.ERR_12061 ) );
             }
 
             LOG.debug( "Ldif version : {}", versionNumber );
@@ -1459,9 +1473,9 @@ public class LdifReader implements Itera
      * 
      * The lines represent *one* entry.
      * 
-     * @throws NamingException If something went wrong
+     * @throws LdapLdifException If something went wrong
      */
-    protected void readLines() throws NamingException
+    protected void readLines() throws LdapLdifException
     {
         String line = null;
         boolean insideComment = true;
@@ -1505,7 +1519,7 @@ public class LdifReader implements Itera
                         else if ( sb.length() == 0 )
                         {
                             LOG.error( I18n.err( I18n.ERR_12062 ) );
-                            throw new NamingException( I18n.err( I18n.ERR_12061 ) );
+                            throw new LdapLdifException( I18n.err( I18n.ERR_12061 ) );
                         }
                         else
                         {
@@ -1533,7 +1547,7 @@ public class LdifReader implements Itera
         }
         catch ( IOException ioe )
         {
-            throw new NamingException( I18n.err( I18n.ERR_12063 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12063 ) );
         }
 
         // Stores the current line if necessary.
@@ -1552,10 +1566,10 @@ public class LdifReader implements Itera
      * @param fileName
      *            The ldif file
      * @return A list of entries
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If the parsing fails
      */
-    public List<LdifEntry> parseLdifFile( String fileName ) throws NamingException
+    public List<LdifEntry> parseLdifFile( String fileName ) throws LdapLdifException
     {
         return parseLdifFile( fileName, Charset.forName( StringTools.getDefaultCharsetName() ).toString() );
     }
@@ -1569,15 +1583,15 @@ public class LdifReader implements Itera
      * @param encoding
      *            The charset encoding to use
      * @return A list of entries
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If the parsing fails
      */
-    public List<LdifEntry> parseLdifFile( String fileName, String encoding ) throws NamingException
+    public List<LdifEntry> parseLdifFile( String fileName, String encoding ) throws LdapLdifException
     {
         if ( StringTools.isEmpty( fileName ) )
         {
             LOG.error( I18n.err( I18n.ERR_12064 ) );
-            throw new NamingException( I18n.err( I18n.ERR_12065 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12065 ) );
         }
 
         File file = new File( fileName );
@@ -1585,7 +1599,7 @@ public class LdifReader implements Itera
         if ( !file.exists() )
         {
             LOG.error( I18n.err( I18n.ERR_12066, fileName ) );
-            throw new NamingException( I18n.err( I18n.ERR_12067, fileName ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12067, fileName ) );
         }
 
         BufferedReader reader = null;
@@ -1602,7 +1616,11 @@ public class LdifReader implements Itera
         catch ( FileNotFoundException fnfe )
         {
             LOG.error( I18n.err( I18n.ERR_12068, fileName ) );
-            throw new NamingException( I18n.err( I18n.ERR_12067, fileName ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12067, fileName ) );
+        }
+        catch ( LdapException le )
+        {
+            throw new LdapLdifException( le.getMessage() );
         }
         finally
         {
@@ -1628,10 +1646,10 @@ public class LdifReader implements Itera
      * @param ldif
      *            The ldif string
      * @return A list of entries, or an empty List
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If something went wrong
      */
-    public List<LdifEntry> parseLdif( String ldif ) throws NamingException
+    public List<LdifEntry> parseLdif( String ldif ) throws LdapLdifException
     {
         LOG.debug( "Starts parsing ldif buffer" );
 
@@ -1655,10 +1673,14 @@ public class LdifReader implements Itera
 
             return entries;
         }
-        catch ( NamingException ne )
+        catch ( LdapLdifException ne )
         {
             LOG.error( I18n.err( I18n.ERR_12069, ne.getLocalizedMessage() ) );
-            throw new NamingException( I18n.err( I18n.ERR_12070 ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12070 ) );
+        }
+        catch ( LdapException le )
+        {
+            throw new LdapLdifException( le.getMessage() );
         }
         finally
         {
@@ -1702,17 +1724,21 @@ public class LdifReader implements Itera
             {
                 prefetched = parseEntry();
             }
-            catch ( NamingException ne )
+            catch ( LdapLdifException ne )
             {
                 error = ne;
                 throw new NoSuchElementException( ne.getMessage() );
             }
+            catch ( LdapException le )
+            {
+                throw new NoSuchElementException( le.getMessage() );
+            }
 
             LOG.debug( "next(): -- returning ldif {}\n", entry );
 
             return entry;
         }
-        catch ( NamingException ne )
+        catch ( LdapLdifException ne )
         {
             LOG.error( I18n.err( I18n.ERR_12071 ) );
             error = ne;
@@ -1831,10 +1857,11 @@ public class LdifReader implements Itera
      * @param inf
      *            The buffer being processed
      * @return A list of entries
-     * @throws NamingException
+     * @throws LdapLdifException
      *             If something went wrong
+     * @throws LdapException 
      */
-    public List<LdifEntry> parseLdif( BufferedReader reader ) throws NamingException
+    public List<LdifEntry> parseLdif( BufferedReader reader ) throws LdapLdifException, LdapException
     {
         // Create a list that will contain the read entries
         List<LdifEntry> entries = new ArrayList<LdifEntry>();
@@ -1858,7 +1885,7 @@ public class LdifReader implements Itera
         }
         catch ( NoSuchElementException nsee )
         {
-            throw new NamingException( I18n.err( I18n.ERR_12072, error.getLocalizedMessage() ) );
+            throw new LdapLdifException( I18n.err( I18n.ERR_12072, error.getLocalizedMessage() ) );
         }
 
         return entries;

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=923819&r1=923818&r2=923819&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 Mar 16 15:47:00 2010
@@ -25,9 +25,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import javax.naming.InvalidNameException;
-import javax.naming.NamingException;
-
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -35,6 +32,8 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.entry.client.ClientModification;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.name.AVA;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
@@ -77,7 +76,7 @@ public class LdifRevertor
      * @param deletedEntry The entry which has been deleted
      * @return A reverse LDIF
      */
-    public static LdifEntry reverseDel( DN dn, Entry deletedEntry ) throws NamingException
+    public static LdifEntry reverseDel( DN dn, Entry deletedEntry ) throws LdapException
     {
         LdifEntry entry = new LdifEntry();
 
@@ -112,7 +111,7 @@ public class LdifRevertor
     * @throws NamingException If something went wrong
     */
     public static LdifEntry reverseModify( DN dn, List<Modification> forwardModifications, Entry modifiedEntry )
-        throws NamingException
+        throws LdapException
     {
         // First, protect the original entry by cloning it : we will modify it
         Entry clonedEntry = ( Entry ) modifiedEntry.clone();
@@ -248,7 +247,7 @@ public class LdifRevertor
      * @return a reverse LDIF
      * @throws NamingException if something went wrong
      */
-    public static LdifEntry reverseMove( DN newSuperiorDn, DN modifiedDn ) throws NamingException
+    public static LdifEntry reverseMove( DN newSuperiorDn, DN modifiedDn ) throws LdapException
     {
         LdifEntry entry = new LdifEntry();
         DN currentParent = null;
@@ -290,7 +289,7 @@ public class LdifRevertor
      * A small helper class to compute the simple revert.
      */
     private static LdifEntry revertEntry( List<LdifEntry> entries, Entry entry, DN newDn, 
-        DN newSuperior, RDN oldRdn, RDN newRdn ) throws InvalidNameException
+        DN newSuperior, RDN oldRdn, RDN newRdn ) throws LdapInvalidDnException
     {
         LdifEntry reverted = new LdifEntry();
         
@@ -366,7 +365,7 @@ public class LdifRevertor
      * A helper method which generates a reverted entry
      */
     private static LdifEntry generateReverted( DN newSuperior, RDN newRdn, DN newDn, 
-        RDN oldRdn, boolean deleteOldRdn ) throws InvalidNameException
+        RDN oldRdn, boolean deleteOldRdn ) throws LdapInvalidDnException
     {
         LdifEntry reverted = new LdifEntry();
         reverted.setChangeType( ChangeType.ModRdn );
@@ -409,7 +408,7 @@ public class LdifRevertor
      * @return A list of LDIF reverted entries 
      * @throws NamingException If the name reverting failed
      */
-    public static List<LdifEntry> reverseRename( Entry entry, RDN newRdn, boolean deleteOldRdn ) throws NamingException
+    public static List<LdifEntry> reverseRename( Entry entry, RDN newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException
     {
         return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn );
     }
@@ -427,7 +426,7 @@ public class LdifRevertor
      * @return A list of LDIF reverted entries 
      * @throws NamingException If the name reverting failed
      */
-    public static List<LdifEntry> reverseMoveAndRename( Entry entry, DN newSuperior, RDN newRdn, boolean deleteOldRdn ) throws NamingException
+    public static List<LdifEntry> reverseMoveAndRename( Entry entry, DN newSuperior, RDN newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException
     {
         DN parentDn = entry.getDn();
         DN newDn = null;
@@ -466,7 +465,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 NamingException( I18n.err( I18n.ERR_12080 ) ); 
+                throw new LdapInvalidDnException( I18n.err( I18n.ERR_12080 ) ); 
             }
 
             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=923819&r1=923818&r2=923819&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 Mar 16 15:47:00 2010
@@ -21,9 +21,7 @@ package org.apache.directory.shared.ldap
 
 import java.io.UnsupportedEncodingException;
 
-import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
-import javax.naming.directory.InvalidAttributeValueException;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.entry.Entry;
@@ -31,6 +29,9 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.Base64;
@@ -144,9 +145,9 @@ public class LdifUtils
      * Convert an Attributes as LDIF
      * @param attrs the Attributes to convert
      * @return the corresponding LDIF code as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertToLdif( Attributes attrs ) throws NamingException
+    public static String convertToLdif( Attributes attrs ) throws LdapException
     {
         return convertAttributesToLdif( AttributeUtils.toClientEntry( attrs, null ), DEFAULT_LINE_LENGTH );
     }
@@ -156,9 +157,9 @@ public class LdifUtils
      * Convert an Attributes as LDIF
      * @param attrs the Attributes to convert
      * @return the corresponding LDIF code as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertToLdif( Attributes attrs, int length ) throws NamingException
+    public static String convertToLdif( Attributes attrs, int length ) throws LdapException
     {
         return convertAttributesToLdif( AttributeUtils.toClientEntry( attrs, null ), length );
     }
@@ -168,9 +169,9 @@ public class LdifUtils
      * Convert an Attributes as LDIF. The DN is written.
      * @param attrs the Attributes to convert
      * @return the corresponding LDIF code as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertToLdif( Attributes attrs, DN dn, int length ) throws NamingException
+    public static String convertToLdif( Attributes attrs, DN dn, int length ) throws LdapException
     {
         return convertEntryToLdif( AttributeUtils.toClientEntry( attrs, dn ), length );
     }
@@ -180,9 +181,9 @@ public class LdifUtils
      * Convert an Attributes as LDIF. The DN is written.
      * @param attrs the Attributes to convert
      * @return the corresponding LDIF code as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertToLdif( Attributes attrs, DN dn ) throws NamingException
+    public static String convertToLdif( Attributes attrs, DN dn ) throws LdapException
     {
         return convertEntryToLdif( AttributeUtils.toClientEntry( attrs, dn ), DEFAULT_LINE_LENGTH );
     }
@@ -192,9 +193,9 @@ public class LdifUtils
      * Convert an Entry to LDIF
      * @param entry the Entry to convert
      * @return the corresponding LDIF code as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertEntryToLdif( Entry entry ) throws NamingException
+    public static String convertEntryToLdif( Entry entry ) throws LdapException
     {
         return convertEntryToLdif( entry, DEFAULT_LINE_LENGTH );
     }
@@ -204,9 +205,9 @@ 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 NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertAttributesToLdif( Entry entry ) throws NamingException
+    public static String convertAttributesToLdif( Entry entry ) throws LdapException
     {
         return convertAttributesToLdif( entry, DEFAULT_LINE_LENGTH );
     }
@@ -217,13 +218,13 @@ public class LdifUtils
      * 
      * @param ldif The LDIF string containing an attribute value
      * @return An Attributes instance
-     * @exception NamingException If the LDIF String cannot be converted to an Attributes
+     * @exception LdapException If the LDIF String cannot be converted to an Attributes
      */
-    public static Attributes convertAttributesFromLdif( String ldif ) throws NamingException
+    public static Attributes convertAttributesFromLdif( String ldif ) throws LdapLdifException
     {
         LdifAttributesReader reader = new  LdifAttributesReader();
         
-        return reader.parseAttributes( ldif );
+        return AttributeUtils.toAttributes( reader.parseEntry( ldif ) );
     }
     
     
@@ -232,9 +233,9 @@ public class LdifUtils
      * @param entry the Entry to convert
      * @param length the expected line length
      * @return the corresponding LDIF code as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertEntryToLdif( Entry entry, int length ) throws NamingException
+    public static String convertEntryToLdif( Entry entry, int length ) throws LdapException
     {
         StringBuilder sb = new StringBuilder();
         
@@ -268,9 +269,9 @@ public class LdifUtils
      * @param entry the Entry to convert
      * @param length the expected line length
      * @return the corresponding LDIF code as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertAttributesToLdif( Entry entry, int length ) throws NamingException
+    public static String convertAttributesToLdif( Entry entry, int length ) throws LdapException
     {
         StringBuilder sb = new StringBuilder();
         
@@ -288,9 +289,9 @@ public class LdifUtils
      * Convert an LdifEntry to LDIF
      * @param entry the LdifEntry to convert
      * @return the corresponding LDIF as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertToLdif( LdifEntry entry ) throws NamingException
+    public static String convertToLdif( LdifEntry entry ) throws LdapException
     {
         return convertToLdif( entry, DEFAULT_LINE_LENGTH );
     }
@@ -301,9 +302,9 @@ public class LdifUtils
      * @param entry the LdifEntry to convert
      * @param length The maximum line's length 
      * @return the corresponding LDIF as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertToLdif( LdifEntry entry, int length ) throws NamingException
+    public static String convertToLdif( LdifEntry entry, int length ) throws LdapException
     {
         StringBuilder sb = new StringBuilder();
         
@@ -333,7 +334,7 @@ public class LdifUtils
             case Delete :
                 if ( entry.getEntry() != null )
                 {
-                    throw new NamingException( I18n.err( I18n.ERR_12081 ) );
+                    throw new LdapException( I18n.err( I18n.ERR_12081 ) );
                 }
                 
                 break;
@@ -341,7 +342,7 @@ public class LdifUtils
             case Add :
                 if ( ( entry.getEntry() == null ) )
                 {
-                    throw new NamingException( I18n.err( I18n.ERR_12082 ) );
+                    throw new LdapException( I18n.err( I18n.ERR_12082 ) );
                 }
 
                 // Now, iterate through all the attributes
@@ -356,7 +357,7 @@ public class LdifUtils
             case ModRdn :
                 if ( entry.getEntry() != null )
                 {
-                    throw new NamingException( I18n.err( I18n.ERR_12083 ) );
+                    throw new LdapException( I18n.err( I18n.ERR_12083 ) );
                 }
                 
                 
@@ -454,9 +455,9 @@ public class LdifUtils
      * Converts an EntryAttribute to LDIF
      * @param attr the >EntryAttribute to convert
      * @return the corresponding LDIF code as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertToLdif( EntryAttribute attr ) throws NamingException
+    public static String convertToLdif( EntryAttribute attr ) throws LdapException
     {
         return convertToLdif( attr, DEFAULT_LINE_LENGTH );
     }
@@ -467,9 +468,9 @@ public class LdifUtils
      * @param attr the EntryAttribute to convert
      * @param length the expected line length
      * @return the corresponding LDIF code as a String
-     * @throws NamingException If a naming exception is encountered.
+     * @throws LdapException If a naming exception is encountered.
      */
-    public static String convertToLdif( EntryAttribute attr, int length ) throws NamingException
+    public static String convertToLdif( EntryAttribute attr, int length ) throws LdapException
     {
         StringBuilder sb = new StringBuilder();
         
@@ -593,9 +594,10 @@ public class LdifUtils
      * @param avas The AttributeType and Values, using a ldif format, or a couple of 
      * Attribute ID/Value
      * @return An Attributes instance
-     * @throws NamingException If the data are invalid
+     * @throws LdapException If the data are invalid
+     * @throws LdapLdifException 
      */
-    public static Attributes createAttributes( Object... avas ) throws NamingException
+    public static Attributes createAttributes( Object... avas ) throws LdapException, LdapLdifException
     {
         StringBuilder sb = new StringBuilder();
         int pos = 0;
@@ -607,7 +609,7 @@ public class LdifUtils
             {
                 if ( !(ava instanceof String) )
                 {
-                    throw new InvalidAttributeValueException( 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;
@@ -636,7 +638,7 @@ public class LdifUtils
                 }
                 else
                 {
-                    throw new InvalidAttributeValueException( I18n.err( I18n.ERR_12086, (pos+1) ) );
+                    throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12086, (pos+1) ) );
                 }
                 
                 valueExpected = false;
@@ -645,11 +647,11 @@ public class LdifUtils
         
         if ( valueExpected )
         {
-            throw new InvalidAttributeValueException( I18n.err( I18n.ERR_12087 ) );
+            throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_12087 ) );
         }
         
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( sb.toString() );
+        Attributes attributes = AttributeUtils.toAttributes( reader.parseEntry( sb.toString() ) );
 
         return attributes;
     }

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=923819&r1=923818&r2=923819&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 Mar 16 15:47:00 2010
@@ -32,6 +32,9 @@ import javax.naming.NamingException;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Before;
 import org.junit.Test;
@@ -86,39 +89,39 @@ public class LdifAttributesReaderTest
         HJENSEN_JPEG_FILE = createFile( "hjensen", data );
     }
 
-    @Test public void testLdifNull() throws NamingException
+    @Test public void testLdifNull() throws LdapLdifException
     {
         String ldif = null;
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
-        assertEquals( 0, attributes.size() );
+        assertEquals( 0, entry.size() );
     }
     
 
-    @Test public void testLdifEmpty() throws NamingException
+    @Test public void testLdifEmpty() throws LdapLdifException
     {
         String ldif = "";
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
-        assertEquals( 0, attributes.size() );
+        assertEquals( 0, entry.size() );
     }
 
     
-    @Test public void testLdifEmptyLines() throws NamingException
+    @Test public void testLdifEmptyLines() throws LdapLdifException
     {
         String ldif = "\n\n\r\r\n";
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
-        assertNull( attributes );
+        Entry entry = reader.parseEntry( ldif );
+        assertNull( entry );
     }
 
     
-    @Test public void testLdifComments() throws NamingException
+    @Test public void testLdifComments() throws LdapLdifException
     {
         String ldif = 
             "#Comment 1\r" + 
@@ -128,13 +131,13 @@ public class LdifAttributesReaderTest
             "\n";
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
-        assertNull( attributes );
+        assertNull( entry );
     }
 
     
-    @Test public void testLdifVersionStart() throws NamingException
+    @Test public void testLdifVersionStart() throws LdapLdifException
     {
         String ldif = 
             "cn: app1\n" + 
@@ -146,12 +149,12 @@ public class LdifAttributesReaderTest
 
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
         assertEquals( 1, reader.getVersion() );
-        assertNotNull( attributes );
+        assertNotNull( entry );
 
-        Attribute attr = attributes.get( "displayname" );
+        EntryAttribute attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
     }
 
@@ -161,7 +164,7 @@ public class LdifAttributesReaderTest
      * 
      * @throws NamingException
      */
-    @Test public void testLdifParserEndSpaces() throws NamingException
+    @Test public void testLdifParserEndSpaces() throws LdapLdifException
     {
         String ldif = 
             "cn: app1\n" + 
@@ -173,16 +176,16 @@ public class LdifAttributesReaderTest
 
         LdifAttributesReader reader = new LdifAttributesReader();
 
-        Attributes attributes = reader.parseAttributes( ldif );
-        assertNotNull( attributes );
+        Entry entry = reader.parseEntry( ldif );
+        assertNotNull( entry );
 
-        Attribute attr = attributes.get( "displayname" );
+        EntryAttribute attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
 
     }
 
 
-    @Test public void testLdifParser() throws NamingException
+    @Test public void testLdifParser() throws LdapLdifException, LdapInvalidAttributeValueException
     {
         String ldif = 
             "cn: app1\n" + 
@@ -193,29 +196,29 @@ public class LdifAttributesReaderTest
             "envVars:";
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
-        assertNotNull( attributes );
+        assertNotNull( entry );
 
-        Attribute attr = attributes.get( "cn" );
+        EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "app1" ) );
 
-        attr = attributes.get( "objectclass" );
+        attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "apApplication" ) );
 
-        attr = attributes.get( "displayname" );
+        attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
 
-        attr = attributes.get( "dependencies" );
-        assertNull( attr.get() );
+        attr = entry.get( "dependencies" );
+        assertNull( attr.get().get() );
 
-        attr = attributes.get( "envvars" );
-        assertNull( attr.get() );
+        attr = entry.get( "envvars" );
+        assertNull( attr.get().get() );
     }
 
     
-    @Test public void testLdifParserMuiltiLineComments() throws NamingException
+    @Test public void testLdifParserMuiltiLineComments() throws LdapLdifException
     {
         String ldif = 
             "#comment\n" + 
@@ -231,29 +234,29 @@ public class LdifAttributesReaderTest
             "envVars:";
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
-        assertNotNull( attributes );
+        assertNotNull( entry );
 
-        Attribute attr = attributes.get( "cn" );
+        EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "app1#another comment" ) );
 
-        attr = attributes.get( "objectclass" );
+        attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "apApplication" ) );
 
-        attr = attributes.get( "displayname" );
+        attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
 
-        attr = attributes.get( "dependencies" );
-        assertNull( attr.get() );
+        attr = entry.get( "dependencies" );
+        assertNull( attr.get().get() );
 
-        attr = attributes.get( "envvars" );
-        assertNull( attr.get() );
+        attr = entry.get( "envvars" );
+        assertNull( attr.get().get() );
     }
 
     
-    @Test public void testLdifParserMultiLineEntries() throws NamingException
+    @Test public void testLdifParserMultiLineEntries() throws LdapLdifException
     {
         String ldif = 
             "#comment\n" + 
@@ -269,29 +272,29 @@ public class LdifAttributesReaderTest
             "envVars:";
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
-        assertNotNull( attributes );
+        assertNotNull( entry );
 
-        Attribute attr = attributes.get( "cn" );
+        EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "app1#another comment" ) );
 
-        attr = attributes.get( "objectclass" );
+        attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "apApplication" ) );
 
-        attr = attributes.get( "displayname" );
+        attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
 
-        attr = attributes.get( "dependencies" );
-        assertNull( attr.get() );
+        attr = entry.get( "dependencies" );
+        assertNull( attr.get().get() );
 
-        attr = attributes.get( "envvars" );
-        assertNull( attr.get() );
+        attr = entry.get( "envvars" );
+        assertNull( attr.get().get() );
     }
 
     
-    @Test public void testLdifParserBase64() throws NamingException, UnsupportedEncodingException
+    @Test public void testLdifParserBase64() throws LdapLdifException, UnsupportedEncodingException
     {
         String ldif = 
             "#comment\n" + 
@@ -306,29 +309,29 @@ public class LdifAttributesReaderTest
             "envVars:";
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
-        assertNotNull( attributes );
+        assertNotNull( entry );
 
-        Attribute attr = attributes.get( "cn" );
+        EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "Emmanuel L\u00e9charny".getBytes( "UTF-8" ) ) );
 
-        attr = attributes.get( "objectclass" );
+        attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "apApplication" ) );
 
-        attr = attributes.get( "displayname" );
+        attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
 
-        attr = attributes.get( "dependencies" );
-        assertNull( attr.get() );
+        attr = entry.get( "dependencies" );
+        assertNull( attr.get().get() );
 
-        attr = attributes.get( "envvars" );
-        assertNull( attr.get() );
+        attr = entry.get( "envvars" );
+        assertNull( attr.get().get() );
     }
 
     
-    @Test public void testLdifParserBase64MultiLine() throws NamingException, UnsupportedEncodingException
+    @Test public void testLdifParserBase64MultiLine() throws LdapLdifException, UnsupportedEncodingException
     {
         String ldif = 
             "#comment\n" + 
@@ -344,29 +347,29 @@ public class LdifAttributesReaderTest
             "envVars:";
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
-        assertNotNull( attributes );
+        assertNotNull( entry );
 
-        Attribute attr = attributes.get( "cn" );
+        EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "Emmanuel L\u00e9charny  ".getBytes( "UTF-8" ) ) );
 
-        attr = attributes.get( "objectclass" );
+        attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "apApplication" ) );
 
-        attr = attributes.get( "displayname" );
+        attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
 
-        attr = attributes.get( "dependencies" );
-        assertNull( attr.get() );
+        attr = entry.get( "dependencies" );
+        assertNull( attr.get().get() );
 
-        attr = attributes.get( "envvars" );
-        assertNull( attr.get() );
+        attr = entry.get( "envvars" );
+        assertNull( attr.get().get() );
     }
 
     
-    @Test public void testLdifParserRFC2849Sample1() throws NamingException
+    @Test public void testLdifParserRFC2849Sample1() throws LdapLdifException
     {
         String ldif = 
             "objectclass: top\n" + 
@@ -381,34 +384,34 @@ public class LdifAttributesReaderTest
             "description: A big sailing fan.\n"; 
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
-        Attribute attr = attributes.get( "objectclass" );
+        EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "person" ) );
         assertTrue( attr.contains( "organizationalPerson" ) );
 
-        attr = attributes.get( "cn" );
+        attr = entry.get( "cn" );
         assertTrue( attr.contains( "Barbara Jensen" ) );
         assertTrue( attr.contains( "Barbara J Jensen" ) );
         assertTrue( attr.contains( "Babs Jensen" ) );
 
-        attr = attributes.get( "sn" );
+        attr = entry.get( "sn" );
         assertTrue( attr.contains( "Jensen" ) );
 
-        attr = attributes.get( "uid" );
+        attr = entry.get( "uid" );
         assertTrue( attr.contains( "bjensen" ) );
 
-        attr = attributes.get( "telephonenumber" );
+        attr = entry.get( "telephonenumber" );
         assertTrue( attr.contains( "+1 408 555 1212" ) );
 
-        attr = attributes.get( "description" );
+        attr = entry.get( "description" );
         assertTrue( attr.contains( "A big sailing fan." ) );
 
     }
 
     
-    @Test public void testLdifParserRFC2849Sample2() throws NamingException
+    @Test public void testLdifParserRFC2849Sample2() throws LdapLdifException
     {
         String ldif = 
             "objectclass: top\n" + 
@@ -425,38 +428,38 @@ public class LdifAttributesReaderTest
             "title:Product Manager, Rod and Reel Division";
 
         LdifAttributesReader reader = new LdifAttributesReader();
-        Attributes attributes = reader.parseAttributes( ldif );
+        Entry entry = reader.parseEntry( ldif );
 
-        Attribute attr = attributes.get( "objectclass" );
+        EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "person" ) );
         assertTrue( attr.contains( "organizationalPerson" ) );
 
-        attr = attributes.get( "cn" );
+        attr = entry.get( "cn" );
         assertTrue( attr.contains( "Barbara Jensen" ) );
         assertTrue( attr.contains( "Barbara J Jensen" ) );
         assertTrue( attr.contains( "Babs Jensen" ) );
 
-        attr = attributes.get( "sn" );
+        attr = entry.get( "sn" );
         assertTrue( attr.contains( "Jensen" ) );
 
-        attr = attributes.get( "uid" );
+        attr = entry.get( "uid" );
         assertTrue( attr.contains( "bjensen" ) );
 
-        attr = attributes.get( "telephonenumber" );
+        attr = entry.get( "telephonenumber" );
         assertTrue( attr.contains( "+1 408 555 1212" ) );
 
-        attr = attributes.get( "description" );
+        attr = entry.get( "description" );
         assertTrue( attr
                 .contains( "Babs is a big sailing fan, and travels extensively in search of perfect sailing conditions." ) );
 
-        attr = attributes.get( "title" );
+        attr = entry.get( "title" );
         assertTrue( attr.contains( "Product Manager, Rod and Reel Division" ) );
 
     }
 
     
-    @Test public void testLdifParserRFC2849Sample3() throws NamingException, Exception
+    @Test public void testLdifParserRFC2849Sample3() throws LdapLdifException, Exception
     {
         String ldif = 
             "objectclass: top\n" + 
@@ -500,7 +503,7 @@ public class LdifAttributesReaderTest
     }
 
     
-    @Test public void testLdifParserRFC2849Sample3VariousSpacing() throws NamingException, Exception
+    @Test public void testLdifParserRFC2849Sample3VariousSpacing() throws LdapLdifException, Exception
     {
         String ldif = 
             "objectclass:top\n" + 
@@ -661,10 +664,10 @@ public class LdifAttributesReaderTest
 
         try
         {
-            reader.parseAttributes( ldif );
+            reader.parseEntry( ldif );
             fail();
         }
-        catch (NamingException ne)
+        catch ( LdapLdifException ne )
         {
         	assertTrue(I18n.err(I18n.ERR_12009), ne.getMessage().startsWith(I18n.ERR_12009));
         }