directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r808008 - in /directory/shared/branches/shared-schema/ldap/src: main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
Date Wed, 26 Aug 2009 13:41:12 GMT
Author: elecharny
Date: Wed Aug 26 13:41:12 2009
New Revision: 808008

URL: http://svn.apache.org/viewvc?rev=808008&view=rev
Log:
Fixed the OpenLdap parser to produce AttributeType instead of AttributeTypeLiteral

Modified:
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java
    directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java?rev=808008&r1=808007&r2=808008&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java
Wed Aug 26 13:41:12 2009
@@ -31,6 +31,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.syntaxChecker.OpenLdapObjectIdentifierMacro;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 
@@ -50,8 +52,8 @@
     /** The list of parsed schema descriptions */
     private List<Object> schemaDescriptions;
 
-    /** The list of attribute type literals, initialized by splitParsedSchemaDescriptions()
*/
-    private List<AttributeTypeLiteral> attributeTypeLiterals;
+    /** The list of attribute type, initialized by splitParsedSchemaDescriptions() */
+    private List<AttributeType> attributeTypes;
 
     /** The list of object class literals, initialized by splitParsedSchemaDescriptions()*/
     private List<ObjectClassLiteral> objectClassLiterals;
@@ -88,9 +90,9 @@
      * 
      * @return the attribute types
      */
-    public List<AttributeTypeLiteral> getAttributeTypes()
+    public List<AttributeType> getAttributeTypes()
     {
-        return attributeTypeLiterals;
+        return attributeTypes;
     }
 
 
@@ -125,7 +127,7 @@
     private void afterParse() throws ParseException
     {
         objectClassLiterals = new ArrayList<ObjectClassLiteral>();
-        attributeTypeLiterals = new ArrayList<AttributeTypeLiteral>();
+        attributeTypes = new ArrayList<AttributeType>();
         objectIdentifierMacros = new HashMap<String, OpenLdapObjectIdentifierMacro>();
 
         // split parsed schema descriptions
@@ -136,24 +138,11 @@
                 OpenLdapObjectIdentifierMacro oid = ( OpenLdapObjectIdentifierMacro ) obj;
                 objectIdentifierMacros.put( oid.getName(), oid );
             }
-            else if ( obj instanceof AttributeTypeDescription )
+            else if ( obj instanceof AttributeType )
             {
-                AttributeTypeDescription atd = ( AttributeTypeDescription ) obj;
-                AttributeTypeLiteral literal = new AttributeTypeLiteral( atd.getNumericOid()
);
-                literal.setNames( atd.getNames().toArray( new String[atd.getNames().size()]
) );
-                literal.setDescription( atd.getDescription() );
-                literal.setSuperior( atd.getSuperType() );
-                literal.setEquality( atd.getEqualityMatchingRule() );
-                literal.setOrdering( atd.getOrderingMatchingRule() );
-                literal.setSubstr( atd.getSubstringsMatchingRule() );
-                literal.setSyntax( atd.getSyntax() );
-                literal.setLength( atd.getSyntaxLength() );
-                literal.setObsolete( atd.isObsolete() );
-                literal.setCollective( atd.isCollective() );
-                literal.setSingleValue( atd.isSingleValued() );
-                literal.setNoUserModification( !atd.isUserModifiable() );
-                literal.setUsage( atd.getUsage() );
-                attributeTypeLiterals.add( literal );
+                AttributeType attributeType = ( AttributeType ) obj;
+
+                attributeTypes.add( attributeType );
             }
             else if ( obj instanceof ObjectClassDescription )
             {
@@ -184,13 +173,7 @@
             {
                 ocl.setOid( getResolveOid( ocl.getOid() ) );
             }
-            for ( AttributeTypeLiteral atl : attributeTypeLiterals )
-            {
-                atl.setOid( getResolveOid( atl.getOid() ) );
-                atl.setSyntax( getResolveOid( atl.getSyntax() ) );
-            }
         }
-
     }
 
 
@@ -258,7 +241,7 @@
      * @throws IOException If the schemaObject can't be transformed to a byteArrayInputStream
      * @throws ParseException If the schemaObject can't be parsed
      */
-    public AbstractSchemaDescription parse( String schemaObject ) throws ParseException
+    public SchemaObject parse( String schemaObject ) throws ParseException
     {
         if ( schemaObject == null || schemaObject.trim().equals( "" ) )
         {
@@ -274,7 +257,7 @@
             {
                 if ( obj instanceof AbstractSchemaDescription )
                 {
-                    return ( AbstractSchemaDescription ) obj;
+                    return ( SchemaObject ) obj;
                 }
             }
         }

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java?rev=808008&r1=808007&r2=808008&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
Wed Aug 26 13:41:12 2009
@@ -26,8 +26,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
-import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeLiteral;
 import org.apache.directory.shared.ldap.schema.parsers.ObjectClassLiteral;
 import org.apache.directory.shared.ldap.schema.parsers.OpenLdapSchemaParser;
 import org.apache.directory.shared.ldap.schema.syntaxChecker.OpenLdapObjectIdentifierMacro;
@@ -74,25 +74,25 @@
             + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.25 )";
 
         parser.parse( attributeTypeData );
-        List<AttributeTypeLiteral> attributeTypeList = parser.getAttributeTypes();
-        Map<String, AttributeTypeLiteral> attributeTypes = mapAttributeTypes( attributeTypeList
);
-        AttributeTypeLiteral type = attributeTypes.get( "2.5.4.14" );
+        List<AttributeType> attributeTypes = parser.getAttributeTypes();
+        Map<String, AttributeType> mapAttributeTypes = mapAttributeTypes( attributeTypes
);
+        AttributeType attributeType = mapAttributeTypes.get( "2.5.4.14" );
 
-        assertNotNull( type );
-        assertEquals( "2.5.4.14", type.getOid() );
-        assertEquals( "searchGuide", type.getNames()[0] );
-        assertEquals( "RFC2256: search guide, obsoleted by enhancedSearchGuide", type.getDescription()
);
-        assertEquals( "1.3.6.1.4.1.1466.115.121.1.25", type.getSyntax() );
+        assertNotNull( attributeType );
+        assertEquals( "2.5.4.14", attributeType.getOid() );
+        assertEquals( "searchGuide", attributeType.getName() );
+        assertEquals( "RFC2256: search guide, obsoleted by enhancedSearchGuide", attributeType.getDescription()
);
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.25", attributeType.getSyntaxOid() );
     }
 
 
-    private Map<String, AttributeTypeLiteral> mapAttributeTypes( List<AttributeTypeLiteral>
attributeTypeList )
+    private Map<String, AttributeType> mapAttributeTypes( List<AttributeType>
attributeTypes )
     {
-        Map<String, AttributeTypeLiteral> m = new HashMap<String, AttributeTypeLiteral>();
+        Map<String, AttributeType> m = new HashMap<String, AttributeType>();
 
-        for ( AttributeTypeLiteral type : attributeTypeList )
+        for ( AttributeType attributeType : attributeTypes )
         {
-            m.put( type.getOid(), type );
+            m.put( attributeType.getOid(), attributeType );
         }
 
         return m;
@@ -106,15 +106,15 @@
             + "        DESC 'RFC2256: knowledge information'\n" + "        EQUALITY caseIgnoreMatch\n"
             + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
         parser.parse( attributeTypeData );
-        List<AttributeTypeLiteral> attributeTypeList = parser.getAttributeTypes();
-        Map<String, AttributeTypeLiteral> attributeTypes = mapAttributeTypes( attributeTypeList
);
-        AttributeTypeLiteral type = attributeTypes.get( "2.5.4.2" );
+        List<AttributeType> attributeTypeList = parser.getAttributeTypes();
+        Map<String, AttributeType> attributeTypes = mapAttributeTypes( attributeTypeList
);
+        AttributeType type = attributeTypes.get( "2.5.4.2" );
 
         assertNotNull( type );
         assertEquals( "2.5.4.2", type.getOid() );
-        assertEquals( "knowledgeInformation", type.getNames()[0] );
+        assertEquals( "knowledgeInformation", type.getName() );
         assertEquals( "RFC2256: knowledge information", type.getDescription() );
-        assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", type.getSyntax() );
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", type.getSyntaxOid() );
         assertEquals( 32768, type.getLength() );
     }
 
@@ -126,15 +126,15 @@
             + "        DESC 'RFC2256: \"knowledge\" information'\n" + "        EQUALITY caseIgnoreMatch\n"
             + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
         parser.parse( attributeTypeData );
-        List<AttributeTypeLiteral> attributeTypeList = parser.getAttributeTypes();
-        Map<String, AttributeTypeLiteral> attributeTypes = mapAttributeTypes( attributeTypeList
);
-        AttributeTypeLiteral type = attributeTypes.get( "2.5.4.2" );
+        List<AttributeType> attributeTypeList = parser.getAttributeTypes();
+        Map<String, AttributeType> attributeTypes = mapAttributeTypes( attributeTypeList
);
+        AttributeType type = attributeTypes.get( "2.5.4.2" );
 
         assertNotNull( type );
         assertEquals( "2.5.4.2", type.getOid() );
-        assertEquals( "knowledgeInformation", type.getNames()[0] );
+        assertEquals( "knowledgeInformation", type.getName() );
         assertEquals( "RFC2256: \"knowledge\" information", type.getDescription() );
-        assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", type.getSyntax() );
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", type.getSyntaxOid() );
         assertEquals( 32768, type.getLength() );
     }
 
@@ -147,15 +147,15 @@
             + "        DESC 'RFC2256: knowledge information'\n" + "        EQUALITY caseIgnoreMatch\n"
             + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
         parser.parse( attributeTypeData );
-        List<AttributeTypeLiteral> attributeTypeList = parser.getAttributeTypes();
-        Map<String, AttributeTypeLiteral> attributeTypes = mapAttributeTypes( attributeTypeList
);
-        AttributeTypeLiteral type = attributeTypes.get( "2.5.4.2" );
+        List<AttributeType> attributeTypeList = parser.getAttributeTypes();
+        Map<String, AttributeType> attributeTypes = mapAttributeTypes( attributeTypeList
);
+        AttributeType type = attributeTypes.get( "2.5.4.2" );
 
         assertNotNull( type );
         assertEquals( "2.5.4.2", type.getOid() );
-        assertEquals( "knowledgeInformation", type.getNames()[0] );
+        assertEquals( "knowledgeInformation", type.getName() );
         assertEquals( "RFC2256: knowledge information", type.getDescription() );
-        assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", type.getSyntax() );
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", type.getSyntaxOid() );
         assertEquals( 32768, type.getLength() );
     }
 
@@ -250,7 +250,7 @@
         InputStream input = getClass().getResourceAsStream( "core.schema" );
         parser.parse( input );
 
-        List<AttributeTypeLiteral> attributeTypes = parser.getAttributeTypes();
+        List<AttributeType> attributeTypes = parser.getAttributeTypes();
         List<ObjectClassLiteral> objectClassTypes = parser.getObjectClassTypes();
         Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
 
@@ -266,7 +266,7 @@
         InputStream input = getClass().getResourceAsStream( "inetorgperson.schema" );
         parser.parse( input );
 
-        List<AttributeTypeLiteral> attributeTypes = parser.getAttributeTypes();
+        List<AttributeType> attributeTypes = parser.getAttributeTypes();
         List<ObjectClassLiteral> objectClassTypes = parser.getObjectClassTypes();
         Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
 
@@ -282,14 +282,14 @@
         InputStream input = getClass().getResourceAsStream( "collective.schema" );
         parser.parse( input );
 
-        List<AttributeTypeLiteral> attributeTypes = parser.getAttributeTypes();
+        List<AttributeType> attributeTypes = parser.getAttributeTypes();
         List<ObjectClassLiteral> objectClassTypes = parser.getObjectClassTypes();
         Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
 
         assertEquals( 13, attributeTypes.size() );
         assertEquals( 0, objectClassTypes.size() );
         assertEquals( 0, objectIdentifierMacros.size() );
-        for ( AttributeTypeLiteral attributeTypeLiteral : attributeTypes )
+        for ( AttributeType attributeTypeLiteral : attributeTypes )
         {
             assertTrue( attributeTypeLiteral.isCollective() );
         }
@@ -302,7 +302,7 @@
         InputStream input = getClass().getResourceAsStream( "dyngroup.schema" );
         parser.parse( input );
 
-        List<AttributeTypeLiteral> attributeTypes = parser.getAttributeTypes();
+        List<AttributeType> attributeTypes = parser.getAttributeTypes();
         List<ObjectClassLiteral> objectClassTypes = parser.getObjectClassTypes();
         Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
 
@@ -335,16 +335,18 @@
                 fail( "object class 'groupOfURLs' or 'dgIdentityAux' expected" );
             }
         }
-        for ( AttributeTypeLiteral attributeTypeLiteral : attributeTypes )
+        
+        for ( AttributeType attributeType : attributeTypes )
         {
-            List<String> asList = Arrays.asList( attributeTypeLiteral.getNames() );
+            List<String> asList = attributeType.getNames();
+            
             if ( asList.contains( "memberURL" ) )
             {
-                assertEquals( "2.16.840.1.113730.3.1.198", attributeTypeLiteral.getOid()
);
+                assertEquals( "2.16.840.1.113730.3.1.198", attributeType.getOid() );
             }
             else if ( asList.contains( "dgIdentity" ) )
             {
-                assertEquals( "1.3.6.1.4.1.4203.666.11.8.1.1", attributeTypeLiteral.getOid()
);
+                assertEquals( "1.3.6.1.4.1.4203.666.11.8.1.1", attributeType.getOid() );
             }
             else
             {



Mime
View raw message