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/09/07 19:46:22 UTC

svn commit: r993447 - in /directory/shared/trunk: i18n/src/main/java/org/apache/directory/shared/i18n/ i18n/src/main/resources/org/apache/directory/shared/i18n/ ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/

Author: elecharny
Date: Tue Sep  7 17:46:21 2010
New Revision: 993447

URL: http://svn.apache.org/viewvc?rev=993447&view=rev
Log:
Reviewed the ldap-convertor files

Modified:
    directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
    directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
    directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/AttributeTypeHolder.java
    directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ObjectClassHolder.java
    directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ParserException.java
    directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/Schema.java
    directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElement.java
    directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElementImpl.java
    directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaParser.java
    directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaToLdif.java

Modified: directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java?rev=993447&r1=993446&r2=993447&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java (original)
+++ directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java Tue Sep  7 17:46:21 2010
@@ -626,12 +626,12 @@ public enum I18n
     ERR_05001_UNKNOWN_AUTHENT_LEVEL( "ERR_05001_UNKNOWN_AUTHENT_LEVEL" ),
 
     // ldap-converter
-    ERR_06001( "ERR_06001" ),
-    ERR_06002( "ERR_06002" ),
-    ERR_06003( "ERR_06003" ),
-    ERR_06004( "ERR_06004" ),
-    ERR_06005( "ERR_06005" ),
-    ERR_06006( "ERR_06006" ),
+    ERR_06001_EMPTY_OR_NULL_SCHEMA_OBJECT( "ERR_06001_EMPTY_OR_NULL_SCHEMA_OBJECT" ),
+    ERR_06002_PARSER_FAILURE( "ERR_06002_PARSER_FAILURE" ),
+    ERR_06003_NO_NAME( "ERR_06003_NO_NAME" ),
+    ERR_06004_CANNOT_GENERATE_SOURCES( "ERR_06004_CANNOT_GENERATE_SOURCES" ),
+    ERR_06005_NULL_SCHEMA( "ERR_06005_NULL_SCHEMA" ),
+    ERR_06006_NO_PROPERTY( "ERR_06006_NO_PROPERTY" ),
 
     // ldap-jndi
     // no exceptions to translate

Modified: directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties?rev=993447&r1=993446&r2=993447&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties (original)
+++ directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties Tue Sep  7 17:46:21 2010
@@ -614,12 +614,12 @@ ERR_04486_VALUE_ALREADY_EXISTS=The value
 ERR_05001_UNKNOWN_AUTHENT_LEVEL=Unknown AuthenticationLevel {0}
 
 # ldap-converter
-ERR_06001=The schemaObject is either null or is empty!
-ERR_06002=Parser failure on\:\n\t{0}\nAntlr exception trace\:\n{1}
-ERR_06003={0} the schema configuration element must specify a name.
-ERR_06004=Failed while generating sources for {0}
-ERR_06005=Can't generate a ldif for a null schema
-ERR_06006=the schema property must be set
+ERR_06001_EMPTY_OR_NULL_SCHEMA_OBJECT=The schemaObject is either null or is empty!
+ERR_06002_PARSER_FAILURE=Parser failure on\:\n\t{0}\nAntlr exception trace\:\n{1}
+ERR_06003_NO_NAME={0} the schema configuration element must specify a name.
+ERR_06004_CANNOT_GENERATE_SOURCES=Failed while generating sources for {0}
+ERR_06005_NULL_SCHEMA=Can't generate a ldif for a null schema
+ERR_06006_NO_PROPERTY=the schema property must be set
 
 # ldap-jndi
 # no exception to translate

Modified: directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/AttributeTypeHolder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/AttributeTypeHolder.java?rev=993447&r1=993446&r2=993447&view=diff
==============================================================================
--- directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/AttributeTypeHolder.java (original)
+++ directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/AttributeTypeHolder.java Tue Sep  7 17:46:21 2010
@@ -69,15 +69,10 @@ public class AttributeTypeHolder extends
     private UsageEnum usage = UsageEnum.USER_APPLICATIONS;
 
 
-    // ------------------------------------------------------------------------
-    // C O N S T R U C T O R S
-    // ------------------------------------------------------------------------
-
     /**
      * Create an instance of an attributeType
      * 
-     * @param oid
-     *            The attributeType's OID
+     * @param oid The attributeType's OID
      */
     public AttributeTypeHolder( String oid )
     {
@@ -85,10 +80,6 @@ public class AttributeTypeHolder extends
     }
 
 
-    // ------------------------------------------------------------------------
-    // Accessors and mutators
-    // ------------------------------------------------------------------------
-
     /**
      * Tells if the attribute is single-valued
      * 
@@ -103,8 +94,7 @@ public class AttributeTypeHolder extends
     /**
      * Set the attributeType singleValue flag
      * 
-     * @param singleValue
-     *            The value for this flag
+     * @param singleValue The value for this flag
      */
     public void setSingleValue( boolean singleValue )
     {
@@ -126,8 +116,7 @@ public class AttributeTypeHolder extends
     /**
      * Set the attributeType collective flag
      * 
-     * @param collective
-     *            The value for this flag
+     * @param collective The value for this flag
      */
     public void setCollective( boolean collective )
     {
@@ -136,7 +125,7 @@ public class AttributeTypeHolder extends
 
 
     /**
-     * Tellse if the attributeType is mutable or not
+     * Tells if the attributeType is mutable or not
      * 
      * @return True if the attributeType is immutable, false otherwise
      */
@@ -149,8 +138,7 @@ public class AttributeTypeHolder extends
     /**
      * Set the attributeType noUserModification flag
      * 
-     * @param noUserModification
-     *            The value for this flag
+     * @param noUserModification The value for this flag
      */
     public void setNoUserModification( boolean noUserModification )
     {
@@ -172,8 +160,7 @@ public class AttributeTypeHolder extends
     /**
      * Set the attributeType's superior
      * 
-     * @param superior
-     *            The attributeType's superior
+     * @param superior The attributeType's superior
      */
     public void setSuperior( String superior )
     {
@@ -195,8 +182,7 @@ public class AttributeTypeHolder extends
     /**
      * Set the equality Matching Rule
      * 
-     * @param equality
-     *            The equality Matching Rule
+     * @param equality The equality Matching Rule
      */
     public void setEquality( String equality )
     {
@@ -218,8 +204,7 @@ public class AttributeTypeHolder extends
     /**
      * Set the ordering Matching Rule
      * 
-     * @param ordering
-     *            The ordering Matching Rule
+     * @param ordering The ordering Matching Rule
      */
     public void setOrdering( String ordering )
     {
@@ -241,8 +226,7 @@ public class AttributeTypeHolder extends
     /**
      * Set the substring Matching Rule
      * 
-     * @param substr
-     *            The substring Matching Rule
+     * @param substr The substring Matching Rule
      */
     public void setSubstr( String substr )
     {
@@ -264,8 +248,7 @@ public class AttributeTypeHolder extends
     /**
      * Set the attributeType's syntax
      * 
-     * @param syntax
-     *            The attributeType's syntax
+     * @param syntax The attributeType's syntax
      */
     public void setSyntax( String syntax )
     {
@@ -287,8 +270,7 @@ public class AttributeTypeHolder extends
     /**
      * Set the attributeType's usage
      * 
-     * @param usage
-     *            The attributeType's usage
+     * @param usage The attributeType's usage
      */
     public void setUsage( UsageEnum usage )
     {
@@ -310,8 +292,7 @@ public class AttributeTypeHolder extends
     /**
      * Set the attributeType's syntax length
      * 
-     * @param oidLen
-     *            The attributeType's syntax length
+     * @param oidLen The attributeType's syntax length
      */
     public void setOidLen( int oidLen )
     {
@@ -322,9 +303,9 @@ public class AttributeTypeHolder extends
     /**
      * Convert this attributeType to a Ldif string
      * 
-     * @param schemaName
-     *            The name of the schema file containing this attributeType
+     * @param schemaName The name of the schema file containing this attributeType
      * @return A ldif formatted string
+     * @throws LdapException If something went wrong
      */
     public String toLdif( String schemaName ) throws LdapException
     {
@@ -359,7 +340,7 @@ public class AttributeTypeHolder extends
         // The value syntax
         if ( syntax != null )
         {
-            sb.append( "m-syntax: " ).append( syntax ).append(  '\n'  );
+            sb.append( "m-syntax: " ).append( syntax ).append( '\n' );
 
             if ( oidLen != -1 )
             {
@@ -403,7 +384,7 @@ public class AttributeTypeHolder extends
 
 
     /**
-     * Return a String representing this AttributeType.
+     * @return a String representing this AttributeType.
      */
     public String toString()
     {
@@ -411,14 +392,18 @@ public class AttributeTypeHolder extends
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.shared.converter.schema.SchemaElementImpl#dnToLdif(java.lang.String)
+    /**
+     * Transform a schema name to a DN pointing to the correct position in the DIT
+     * 
+     * @param schemaName The schema name
+     * @return the DN associated with this schema in the DIT
      */
     public String dnToLdif( String schemaName ) throws LdapException
     {
         StringBuilder sb = new StringBuilder();
 
-        String dn = "m-oid=" + oid + ", " + SchemaConstants.ATTRIBUTES_TYPE_PATH + ", cn=" + RDN.escapeValue( schemaName ) + ", ou=schema";
+        String dn = "m-oid=" + oid + ", " + SchemaConstants.ATTRIBUTES_TYPE_PATH + ", cn="
+            + RDN.escapeValue( schemaName ) + ", ou=schema";
 
         // First dump the DN only
         Entry entry = new DefaultEntry( new DN( dn ) );

Modified: directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ObjectClassHolder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ObjectClassHolder.java?rev=993447&r1=993446&r2=993447&view=diff
==============================================================================
--- directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ObjectClassHolder.java (original)
+++ directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ObjectClassHolder.java Tue Sep  7 17:46:21 2010
@@ -56,6 +56,8 @@ public class ObjectClassHolder extends S
 
     /**
      * Create an instance of ObjectClass element
+     * 
+     * @param OID the OjectClass OID
      */
     public ObjectClassHolder( String oid )
     {
@@ -145,6 +147,7 @@ public class ObjectClassHolder extends S
      * 
      * @param schemaName The name of the schema file containing this objectClass
      * @return A ldif formatted string
+     * @throws LdapException If something went wrong
      */
     public String toLdif( String schemaName ) throws LdapException
     {
@@ -196,7 +199,7 @@ public class ObjectClassHolder extends S
 
 
     /**
-     * Return a String representing this ObjectClass.
+     * @return a String representing this ObjectClass.
      */
     public String toString()
     {
@@ -204,14 +207,18 @@ public class ObjectClassHolder extends S
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.shared.converter.schema.SchemaElementImpl#dnToLdif(java.lang.String)
+    /**
+     * Transform a schema name to a DN pointing to the correct position in the DIT
+     * 
+     * @param schemaName The schema name
+     * @return the DN associated with this schema in the DIT
      */
     public String dnToLdif( String schemaName ) throws LdapException
     {
         StringBuilder sb = new StringBuilder();
 
-        String dn = "m-oid=" + oid + ", " + SchemaConstants.OBJECT_CLASSES_PATH + ", cn=" + RDN.escapeValue( schemaName ) + ", ou=schema";
+        String dn = "m-oid=" + oid + ", " + SchemaConstants.OBJECT_CLASSES_PATH + ", cn="
+            + RDN.escapeValue( schemaName ) + ", ou=schema";
 
         // First dump the DN only
         Entry entry = new DefaultEntry( new DN( dn ) );

Modified: directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ParserException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ParserException.java?rev=993447&r1=993446&r2=993447&view=diff
==============================================================================
--- directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ParserException.java (original)
+++ directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/ParserException.java Tue Sep  7 17:46:21 2010
@@ -19,14 +19,17 @@
  */
 package org.apache.directory.shared.converter.schema;
 
+
 /**
  * An exception thrown if we have an error while parsing a schema file.
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class ParserException extends Exception
 {
+    /** The serial Version UID */
     private static final long serialVersionUID = 1L;
-    
+
+
     /**
      * A strandard constuctor
      */
@@ -35,6 +38,7 @@ public class ParserException extends Exc
         super();
     }
 
+
     /**
      * A constructor with a message
      * @param msg The message containg the error's cause

Modified: directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/Schema.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/Schema.java?rev=993447&r1=993446&r2=993447&view=diff
==============================================================================
--- directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/Schema.java (original)
+++ directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/Schema.java Tue Sep  7 17:46:21 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.converter.schema;
 
+
 import java.io.InputStream;
 import java.io.Writer;
 
@@ -34,26 +35,28 @@ public class Schema
 {
     /** The schema name */
     private String name;
-    
+
     /** The inputStream mapped on the file to read */
-    private InputStream in; 
-    
+    private InputStream in;
+
     /** The writer where we dump the ldif lines */
     private Writer out;
 
+
     /**
      * Set the schema name to parse. This name is the prefix of the
-     * schema file, which postifx is '.schema'.
+     * schema file, which postfix is '.schema'.
      * 
      * For instance, 'test.schema' being the file to parse, its name 
      * will be 'test'
-     * @param name
+     * @param name The schema name
      */
     public void setName( String name )
     {
         this.name = name;
     }
 
+
     /**
      * @return The schema name.
      */
@@ -61,7 +64,8 @@ public class Schema
     {
         return name;
     }
-    
+
+
     /**
      * Set the inputStream mapped on the schema file
      * @param in The InputStream mapped on the schema file
@@ -70,7 +74,8 @@ public class Schema
     {
         this.in = in;
     }
-    
+
+
     /**
      * @return The InputStream mapped on the schema file
      */
@@ -79,6 +84,7 @@ public class Schema
         return in;
     }
 
+
     /**
      * @return The writer in which the ldif lines will be dumped
      */
@@ -87,6 +93,7 @@ public class Schema
         return out;
     }
 
+
     /**
      * Set a writer to dump the ldif files
      * @param out The writer 

Modified: directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElement.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElement.java?rev=993447&r1=993446&r2=993447&view=diff
==============================================================================
--- directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElement.java (original)
+++ directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElement.java Tue Sep  7 17:46:21 2010
@@ -19,10 +19,12 @@
  */
 package org.apache.directory.shared.converter.schema;
 
+
 import java.util.List;
 
 import org.apache.directory.shared.ldap.exception.LdapException;
 
+
 /**
  * An interface defining the methods to be implemented by the SchemaElement 
  * classes
@@ -37,7 +39,8 @@ public interface SchemaElement
      * @return true if the schema element is obsolete, folse otherwise
      */
     boolean isObsolete();
-    
+
+
     /**
      * Set the obsolete flag
      * 
@@ -45,44 +48,52 @@ public interface SchemaElement
      */
     void setObsolete( boolean isObsolete );
 
+
     /**
      * Returns the schema element's OID
      */
     String getOid();
-    
+
+
     /**
      * @return Return the schema element description
      */
     String getDescription();
-    
+
+
     /**
      * Set the schema element's description
      * @param description The schema element's description
      */
     void setDescription( String description );
-    
+
+
     /**
      * @return The list of names for the schemaElement
      */
     List<String> getNames();
-    
+
+
     /**
      * Set a list of names for a schemaElement
      * @param names The list of names of this schemaElement
      */
     void setNames( List<String> names );
-    
+
+
     /**
      * @return The list of extensions for the schemaElement
      */
     List<String> getExtensions();
-    
+
+
     /**
      * Set a list of extensions for a schemaElement
      * @param extensions The list of extensions of this schemaElement
      */
     void setExtensions( List<String> extensions );
 
+
     /**
      * Generate a String representation of this schemaElement, formated
      * as a ldif string 

Modified: directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElementImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElementImpl.java?rev=993447&r1=993446&r2=993447&view=diff
==============================================================================
--- directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElementImpl.java (original)
+++ directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElementImpl.java Tue Sep  7 17:46:21 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.converter.schema;
 
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -30,6 +31,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
 
+
 /**
  * An abstract SchemaElement implementation. It contains shared
  * elements from AttributeType and ObjectClass, like obsolete, oid, 
@@ -41,59 +43,65 @@ public abstract class SchemaElementImpl 
 {
     /** The schema element oid */
     protected String oid;
-    
+
     /** The schema element description */
     protected String description;
-    
+
     /** The list of names for this schemaElements */
     protected List<String> names = new ArrayList<String>();
 
     /** The obsolete flag */
     protected boolean obsolete = false;
-    
+
     /** The optional list of extensions */
     protected List<String> extensions = new ArrayList<String>();
-    
+
+
     /**
-     * @see SchemaElement#isObsolete()
+     * {@inheritDoc}
      */
     public boolean isObsolete()
     {
         return obsolete;
     }
 
+
     /**
-     * @see SchemaElement#setObsolete(boolean)
+     * {@inheritDoc}
      */
     public void setObsolete( boolean obsolete )
     {
         this.obsolete = obsolete;
     }
 
+
     /**
-     * @see SchemaElement#getOid()
+     * {@inheritDoc}
      */
     public String getOid()
     {
         return oid;
     }
-    
+
+
     /**
-     * @see SchemaElement#getDescription()
+     * {@inheritDoc}
      */
     public String getDescription()
     {
         return description;
     }
-    
+
+
     /**
-     * @see SchemaElement#setDescription(String)
+     * {@inheritDoc}
      */
     public void setDescription( String description )
     {
         this.description = description;
     }
-    
+
+
     /**
      * @see SchemaElement#getNames()
      */
@@ -101,31 +109,35 @@ public abstract class SchemaElementImpl 
     {
         return names;
     }
-    
+
+
     /**
-     * @see SchemaElement#setNames(List)
+     * {@inheritDoc}
      */
     public void setNames( List<String> names )
     {
         this.names = names;
     }
 
+
     /**
-     * @see SchemaElement#getExtensions()
+     * {@inheritDoc}
      */
     public List<String> getExtensions()
     {
         return extensions;
     }
 
+
     /**
-     * @see SchemaElement#setExtensions(List)
+     * {@inheritDoc}
      */
     public void setExtensions( List<String> extensions )
     {
         this.extensions = extensions;
     }
-    
+
+
     /**
      * @return The OID as a Ldif line 
      */
@@ -133,9 +145,11 @@ public abstract class SchemaElementImpl 
     {
         return "m-oid: " + oid + '\n';
     }
-    
+
+
     /**
      * @return the Names as Ldif lines
+     * @throws LdapException If the conversion goes wrong
      */
     private String nameToLdif() throws LdapException
     {
@@ -147,20 +161,22 @@ public abstract class SchemaElementImpl 
         {
             Entry entry = new DefaultEntry();
             EntryAttribute attribute = new DefaultEntryAttribute( "m-name" );
-            
-            for ( String name:names )
+
+            for ( String name : names )
             {
                 attribute.add( name );
             }
-            
+
             entry.put( attribute );
-            
+
             return LdifUtils.convertAttributesToLdif( entry );
         }
     }
-    
+
+
     /**
      * @return The description as a ldif line
+     * @throws LdapException If the conversion goes wrong
      */
     private String descToLdif() throws LdapException
     {
@@ -174,45 +190,60 @@ public abstract class SchemaElementImpl 
             EntryAttribute attribute = new DefaultEntryAttribute( "m-description", description );
 
             entry.put( attribute );
-            
+
             return LdifUtils.convertAttributesToLdif( entry );
         }
     }
-    
+
+
     /**
-     * @return The dn as a ldif line
+     * Transform a Schema Element to a LDIF String
+     * 
+     * @param schemaName The schema element to transform
+     * @return The Schema Element as a ldif String
+     * @throws LdapException If the conversion goes wrong
      */
     public abstract String dnToLdif( String schemaName ) throws LdapException;
-    
+
+
     /**
      * Return the extensions formated as Ldif lines
-     * @param ID The attributeId : can be m-objectClassExtension or
-     * m-attributeTypeExtension
      * 
+     * @param id The attributeId : can be m-objectClassExtension or
+     * m-attributeTypeExtension
      * @return The extensions formated as ldif lines
      * @throws LdapException If the conversion goes wrong
      */
-    protected String extensionsToLdif( String ID ) throws LdapException
+    protected String extensionsToLdif( String id ) throws LdapException
     {
         StringBuilder sb = new StringBuilder();
-        
+
         Entry entry = new DefaultEntry();
-        EntryAttribute attribute = new DefaultEntryAttribute( ID ); 
+        EntryAttribute attribute = new DefaultEntryAttribute( id );
 
-        for ( String extension:extensions )
+        for ( String extension : extensions )
         {
             attribute.add( extension );
         }
 
         sb.append( LdifUtils.convertAttributesToLdif( entry ) );
-        
+
         return sb.toString();
     }
 
+
+    /**
+     * Transform a Schema to a LDIF formated String
+     *
+     * @param schemaName The schema to transform
+     * @param type The ObjectClass type
+     * @return A LDIF String representing the schema
+     * @throws LdapException If the transformation can't be done
+     */
     protected String schemaToLdif( String schemaName, String type ) throws LdapException
     {
         StringBuilder sb = new StringBuilder();
-        
+
         // The DN
         sb.append( dnToLdif( schemaName ) );
 
@@ -226,16 +257,16 @@ public abstract class SchemaElementImpl 
 
         // The name
         sb.append( nameToLdif() );
-        
+
         // The desc
         sb.append( descToLdif() );
-        
+
         // The obsolete flag, only if "true"
         if ( obsolete )
         {
             sb.append( "m-obsolete: TRUE\n" );
         }
-        
+
         return sb.toString();
     }
 }

Modified: directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaParser.java?rev=993447&r1=993446&r2=993447&view=diff
==============================================================================
--- directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaParser.java (original)
+++ directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaParser.java Tue Sep  7 17:46:21 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.converter.schema;
 
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -26,7 +27,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
-import java.io.Writer;
 import java.text.ParseException;
 import java.util.List;
 
@@ -46,19 +46,20 @@ public class SchemaParser
 {
     /** The antlr generated parser */
     private antlrSchemaParser parser = null;
-    
+
     /** A pipe into the parser */
     private PipedOutputStream parserIn = null;
 
     /** A temporary buffer storing the read schema bytes */
-    byte[] buf = new byte[128];
+    private byte[] buf = new byte[128];
 
     /** The inputStream mapped over the schema file to parse */
     private InputStream schemaIn;
-    
+
     /** The thread used to read the schema */
     private Thread producerThread;
 
+
     /**
      * Creates a reusable instance of an SchemaParser.
      *
@@ -69,12 +70,13 @@ public class SchemaParser
         init();
     }
 
+
     /**
      * Initializes a parser and its plumbing.
      *
      * @throws IOException if a pipe cannot be formed.
      */
-    public void init() throws IOException
+    public synchronized void init() throws IOException
     {
         parserIn = new PipedOutputStream();
         PipedInputStream in = new PipedInputStream();
@@ -83,6 +85,7 @@ public class SchemaParser
         parser = new antlrSchemaParser( lexer );
     }
 
+
     /**
      * Clear the parser.
      */
@@ -91,16 +94,20 @@ public class SchemaParser
         parser.clear();
     }
 
+
     /**
      * Thread safe method parses an OpenLDAP schemaObject element/object.
      *
      * @param schemaObject the String image of a complete schema object
+     * @return The list of parsed schema elements
+     * @throws IOException If the schema file can't be processed
+     * @throws ParseException If we weren't able to parse the schema
      */
     public synchronized List<SchemaElement> parse( String schemaObject ) throws IOException, ParseException
     {
         if ( ( schemaObject == null ) || ( schemaObject.trim().equals( "" ) ) )
         {
-            throw new ParseException( I18n.err( I18n.ERR_06001 ), 0 );
+            throw new ParseException( I18n.err( I18n.ERR_06001_EMPTY_OR_NULL_SCHEMA_OBJECT ), 0 );
         }
 
         schemaIn = new ByteArrayInputStream( schemaObject.getBytes() );
@@ -114,42 +121,47 @@ public class SchemaParser
         return invokeParser( schemaObject );
     }
 
+
     /**
      * Invoke the parser
      * @param schemaName The schema to be parsed
      * @return A list of schema elements 
      * 
-     * @throws IOException If the inputStream can't be read
-     * @throws ParseException If the parser encounter an error
+     * @throws IOException If the schema file can't be processed
+     * @throws ParseException If we weren't able to parse the schema
      */
     private List<SchemaElement> invokeParser( String schemaName ) throws IOException, ParseException
     {
         try
         {
             parser.parseSchema();
-            
+
             return parser.getSchemaElements();
         }
         catch ( RecognitionException re )
         {
-            String msg = I18n.err( I18n.ERR_06002, schemaName, ExceptionUtils.getFullStackTrace( re ) );
+            String msg = I18n.err( I18n.ERR_06002_PARSER_FAILURE, schemaName, ExceptionUtils.getFullStackTrace( re ) );
             init();
             throw new ParseException( msg, re.getColumn() );
         }
         catch ( TokenStreamException tse )
         {
-            String msg = I18n.err( I18n.ERR_06002, schemaName, ExceptionUtils.getFullStackTrace( tse ) );
+            String msg = I18n.err( I18n.ERR_06002_PARSER_FAILURE, schemaName, ExceptionUtils.getFullStackTrace( tse ) );
             init();
             throw new ParseException( msg, 0 );
         }
     }
 
+
     /**
      * Thread safe method parses a stream of OpenLDAP schemaObject elements/objects.
      *
      * @param schemaIn a stream of schema objects
+     * @return A list of schema elements
+     * @throws IOException If the schema file can't be processed
+     * @throws ParseException If we weren't able to parse the schema
      */
-    public synchronized List<SchemaElement> parse( InputStream schemaIn, Writer out ) throws IOException, ParseException
+    public synchronized List<SchemaElement> parse( InputStream schemaIn ) throws IOException, ParseException
     {
         this.schemaIn = schemaIn;
 
@@ -168,6 +180,8 @@ public class SchemaParser
      * Thread safe method parses a file of OpenLDAP schemaObject elements/objects.
      *
      * @param schemaFile a file of schema objects
+     * @throws IOException If the schema file can't be processed
+     * @throws ParseException If we weren't able to parse the schema
      */
     public synchronized void parse( File schemaFile ) throws IOException, ParseException
     {
@@ -184,9 +198,9 @@ public class SchemaParser
 
     /**
      * The thread which read the schema files and fill the
-     * temporaru buffer used by the lexical analyzer.
+     * temporary buffer used by the lexical analyzer.
      */
-    class DataProducer implements Runnable
+    private class DataProducer implements Runnable
     {
         public void run()
         {

Modified: directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaToLdif.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaToLdif.java?rev=993447&r1=993446&r2=993447&view=diff
==============================================================================
--- directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaToLdif.java (original)
+++ directory/shared/trunk/ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaToLdif.java Tue Sep  7 17:46:21 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.converter.schema;
 
+
 import java.io.InputStream;
 import java.io.Writer;
 import java.util.List;
@@ -27,6 +28,7 @@ import org.apache.directory.shared.i18n.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
 /**
  * A class used to translate a OpenLdap schema file to a Ldif file compatible
  * with the Apache DS meta schema format
@@ -35,30 +37,25 @@ import org.slf4j.LoggerFactory;
  */
 public class SchemaToLdif
 {
-    private static final String HEADER = 
-        "#\n" +
-        "#  Licensed to the Apache Software Foundation (ASF) under one\n" +
-        "#  or more contributor license agreements.  See the NOTICE file\n" +
-        "#  distributed with this work for additional information\n" +
-        "#  regarding copyright ownership.  The ASF licenses this file\n" +
-        "#  to you under the Apache License, Version 2.0 (the\n" +
-        "#  \"License\"); you may not use this file except in compliance\n" +
-        "#  with the License.  You may obtain a copy of the License at\n" +
-        "#  \n" +
-        "#    http://www.apache.org/licenses/LICENSE-2.0\n" +
-        "#  \n" +
-        "#  Unless required by applicable law or agreed to in writing,\n" +
-        "#  software distributed under the License is distributed on an\n" +
-        "#  \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n" +
-        "#  KIND, either express or implied.  See the License for the\n" +
-        "#  specific language governing permissions and limitations\n" +
-        "#  under the License. \n" +
-        "#\n" +
-        "version: 1\n" +
-        "\n";  
+    /** The ASF Header */
+    private static final String HEADER = "#\n" + "#  Licensed to the Apache Software Foundation (ASF) under one\n"
+        + "#  or more contributor license agreements.  See the NOTICE file\n"
+        + "#  distributed with this work for additional information\n"
+        + "#  regarding copyright ownership.  The ASF licenses this file\n"
+        + "#  to you under the Apache License, Version 2.0 (the\n"
+        + "#  \"License\"); you may not use this file except in compliance\n"
+        + "#  with the License.  You may obtain a copy of the License at\n" + "#  \n"
+        + "#    http://www.apache.org/licenses/LICENSE-2.0\n" + "#  \n"
+        + "#  Unless required by applicable law or agreed to in writing,\n"
+        + "#  software distributed under the License is distributed on an\n"
+        + "#  \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n"
+        + "#  KIND, either express or implied.  See the License for the\n"
+        + "#  specific language governing permissions and limitations\n" + "#  under the License. \n" + "#\n"
+        + "version: 1\n" + "\n";
 
     /** The logger */
-    private static Logger log = LoggerFactory.getLogger( SchemaToLdif.class );
+    private static Logger LOG = LoggerFactory.getLogger( SchemaToLdif.class );
+
 
     /**
      * This method takes a list of schema and transform them to Ldif files 
@@ -71,40 +68,41 @@ public class SchemaToLdif
         // Bypass if no schemas have yet been defined 
         if ( ( schemas == null ) || ( schemas.size() == 0 ) )
         {
-            log.warn( "No schemas defined!" );
+            LOG.warn( "No schemas defined!" );
             return;
         }
 
         // Make sure schema configurations have a name field and set defaults
         // for any other missing properties of the bean: pkg and owner.
         int i = 1;
-        
-        for ( Schema schema:schemas )
+
+        for ( Schema schema : schemas )
         {
             if ( schema.getName() == null )
             {
-                String msg = I18n.err( I18n.ERR_06003, i );
-                log.error( msg );
+                String msg = I18n.err( I18n.ERR_06003_NO_NAME, i );
+                LOG.error( msg );
                 throw new ParserException( msg );
             }
 
         }
 
         // Generate for each schema 
-        for ( Schema schema:schemas )
+        for ( Schema schema : schemas )
         {
             try
             {
-                log.info( "Generating {} schema.", schema.getName() );
+                LOG.info( "Generating {} schema.", schema.getName() );
                 generate( schema );
             }
             catch ( Exception e )
             {
-                throw new ParserException( I18n.err( I18n.ERR_06004, schema.getName() ) );
+                throw new ParserException( I18n.err( I18n.ERR_06004_CANNOT_GENERATE_SOURCES, schema.getName() ) );
             }
         }
     }
-    
+
+
     /**
      * Generate the ldif from a schema. The schema contains the inputStream
      * and Writer.
@@ -116,31 +114,31 @@ public class SchemaToLdif
     {
         if ( schema == null )
         {
-            log.error( I18n.err( I18n.ERR_06005 ) );
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_06006 ) );
+            LOG.error( I18n.err( I18n.ERR_06005_NULL_SCHEMA ) );
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_06006_NO_PROPERTY ) );
         }
 
         InputStream in = schema.getInput();
         Writer out = schema.getOutput();
-        
+
         // First parse the schema
         SchemaParser parser = new SchemaParser();
-        List<SchemaElement> elements = parser.parse( in, out );
-        
+        List<SchemaElement> elements = parser.parse( in );
+
         // Start with the header (apache licence)
         out.write( HEADER );
-        
+
         // Iterate through each schema elemnts
-        for ( SchemaElement element:elements )
+        for ( SchemaElement element : elements )
         {
             out.write( element.toLdif( schema.getName() ) );
-            
+
             out.write( '\n' );
         }
-        
+
         // Done. Flush the result and close the reader and writer
         out.flush();
-        
+
         out.close();
         in.close();
     }