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 2014/09/03 23:59:04 UTC
svn commit: r1622368 -
/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
Author: elecharny
Date: Wed Sep 3 21:59:04 2014
New Revision: 1622368
URL: http://svn.apache.org/r1622368
Log:
Add a constructor that takes a SchemaManager as a parameter
Modified:
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java?rev=1622368&r1=1622367&r2=1622368&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java Wed Sep 3 21:59:04 2014
@@ -408,6 +408,52 @@ public class LdifReader implements Itera
/**
+ * A constructor which takes a File and a SchemaManager
+ *
+ * @param file A File containing ldif formated input
+ * @param schemaManager The SchemaManager instance to use
+ * @throws LdapLdifException If the file cannot be processed or if the format is incorrect
+ */
+ public LdifReader( File file, SchemaManager schemaManager ) throws LdapLdifException
+ {
+ if ( !file.exists() )
+ {
+ 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_CANNOT_READ_FILE, file.getName() );
+ LOG.error( msg );
+ throw new LdapLdifException( msg );
+ }
+
+ this.schemaManager = schemaManager;
+
+ try
+ {
+ initReader( new BufferedReader( new FileReader( file ) ) );
+ }
+ catch ( FileNotFoundException fnfe )
+ {
+ String msg = I18n.err( I18n.ERR_12010_CANNOT_FIND_FILE, file.getAbsoluteFile() );
+ LOG.error( msg );
+ throw new LdapLdifException( msg, fnfe );
+ }
+ catch ( LdapInvalidDnException lide )
+ {
+ throw new LdapLdifException( lide.getMessage(), lide );
+ }
+ catch ( LdapException le )
+ {
+ throw new LdapLdifException( le.getMessage(), le );
+ }
+ }
+
+
+ /**
* @return The ldif file version
*/
public int getVersion()