You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/12/28 22:28:02 UTC
svn commit: r123561 - in incubator/directory/eve/trunk/plugin/src: antlr java/org/apache/eve/tools/schema test/org/apache/eve/tools/schema
Author: akarasulu
Date: Tue Dec 28 13:28:01 2004
New Revision: 123561
URL: http://svn.apache.org/viewcvs?view=rev&rev=123561
Log:
Changes ...
o found bug where schema DESC feilds with quotes were causing the parser to
bomb: we fixed this using some weird code because we could not get replaceAll
on string working for some reason
o add test case to test changes
o cleaned up the velocity template a bit
Modified:
incubator/directory/eve/trunk/plugin/src/antlr/openldap.g
incubator/directory/eve/trunk/plugin/src/java/org/apache/eve/tools/schema/AttributeTypes.template
incubator/directory/eve/trunk/plugin/src/test/org/apache/eve/tools/schema/OpenLdapSchemaParserTest.java
Modified: incubator/directory/eve/trunk/plugin/src/antlr/openldap.g
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/plugin/src/antlr/openldap.g?view=diff&rev=123561&p1=incubator/directory/eve/trunk/plugin/src/antlr/openldap.g&r1=123560&p2=incubator/directory/eve/trunk/plugin/src/antlr/openldap.g&r2=123561
==============================================================================
--- incubator/directory/eve/trunk/plugin/src/antlr/openldap.g (original)
+++ incubator/directory/eve/trunk/plugin/src/antlr/openldap.g Tue Dec 28 13:28:01 2004
@@ -290,7 +290,30 @@
}
: d:DESC
{
- objectClass.setDescription( d.getText().split( "'" )[1] );
+ String desc = d.getText().split( "'" )[1];
+ String[] quoted = desc.split( "\"" );
+
+ if ( quoted.length == 1 )
+ {
+ objectClass.setDescription( desc );
+ }
+ else
+ {
+ StringBuffer buf = new StringBuffer();
+ for ( int ii = 0; ii < quoted.length; ii++ )
+ {
+ if ( ii < quoted.length - 1 )
+ {
+ buf.append( quoted[ii] ).append( "\\" ).append( "\"" );
+ }
+ else
+ {
+ buf.append( quoted[ii] );
+ }
+ }
+
+ objectClass.setDescription( buf.toString() );
+ }
}
;
@@ -366,7 +389,30 @@
}
: d:DESC
{
- type.setDescription( d.getText().split( "'" )[1] );
+ String desc = d.getText().split( "'" )[1];
+ String[] quoted = desc.split( "\"" );
+
+ if ( quoted.length == 1 )
+ {
+ type.setDescription( desc );
+ }
+ else
+ {
+ StringBuffer buf = new StringBuffer();
+ for ( int ii = 0; ii < quoted.length; ii++ )
+ {
+ if ( ii < quoted.length - 1 )
+ {
+ buf.append( quoted[ii] ).append( "\\" ).append( "\"" );
+ }
+ else
+ {
+ buf.append( quoted[ii] );
+ }
+ }
+
+ type.setDescription( buf.toString() );
+ }
}
;
Modified: incubator/directory/eve/trunk/plugin/src/java/org/apache/eve/tools/schema/AttributeTypes.template
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/plugin/src/java/org/apache/eve/tools/schema/AttributeTypes.template?view=diff&rev=123561&p1=incubator/directory/eve/trunk/plugin/src/java/org/apache/eve/tools/schema/AttributeTypes.template&r1=123560&p2=incubator/directory/eve/trunk/plugin/src/java/org/apache/eve/tools/schema/AttributeTypes.template&r2=123561
==============================================================================
--- incubator/directory/eve/trunk/plugin/src/java/org/apache/eve/tools/schema/AttributeTypes.template (original)
+++ incubator/directory/eve/trunk/plugin/src/java/org/apache/eve/tools/schema/AttributeTypes.template Tue Dec 28 13:28:01 2004
@@ -65,7 +65,8 @@
// --------------------------------------------------------------------
attributeType = newAttributeType( "$attrType.getOid()", registries );
-#if ( $attrType.getDescription() ) attributeType.setDescription( "$attrType.getDescription()" );#end
+#if ( $attrType.getDescription() ) attributeType.setDescription( "$attrType.getDescription()" );
+#end
attributeType.setCanUserModify( ! $attrType.isNoUserModification() );
attributeType.setSingleValue( $attrType.isSingleValue() );
attributeType.setCollective( $attrType.isCollective() );
@@ -73,7 +74,8 @@
attributeType.setLength( $attrType.getLength() );
attributeType.setUsage( UsageEnum.getUsage( "$attrType.getUsage().getName()" ) );
#if ( $attrType.getSuperior() ) attributeType.setSuperiorId( "$attrType.getSuperior()" ); #end
-#if ( $attrType.getEquality() ) attributeType.setEqualityId( "$attrType.getEquality()" );#end
+#if ( $attrType.getEquality() ) attributeType.setEqualityId( "$attrType.getEquality()" );
+#end
#if ( $attrType.getSubstr() ) attributeType.setSubstrId( "$attrType.getSubstr()" );#end
#if ( $attrType.getOrdering() ) attributeType.setOrderingId( "$attrType.getOrdering()" );#end
#if ( $attrType.getSyntax() ) attributeType.setSyntaxId( "$attrType.getSyntax()" );#end
Modified: incubator/directory/eve/trunk/plugin/src/test/org/apache/eve/tools/schema/OpenLdapSchemaParserTest.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/plugin/src/test/org/apache/eve/tools/schema/OpenLdapSchemaParserTest.java?view=diff&rev=123561&p1=incubator/directory/eve/trunk/plugin/src/test/org/apache/eve/tools/schema/OpenLdapSchemaParserTest.java&r1=123560&p2=incubator/directory/eve/trunk/plugin/src/test/org/apache/eve/tools/schema/OpenLdapSchemaParserTest.java&r2=123561
==============================================================================
--- incubator/directory/eve/trunk/plugin/src/test/org/apache/eve/tools/schema/OpenLdapSchemaParserTest.java (original)
+++ incubator/directory/eve/trunk/plugin/src/test/org/apache/eve/tools/schema/OpenLdapSchemaParserTest.java Tue Dec 28 13:28:01 2004
@@ -89,6 +89,26 @@
}
+ public void testAttributeTypeParseWithDescQuotes() throws Exception
+ {
+ String attributeTypeData = "# adding a comment \n" +
+ "attributetype ( 2.5.4.2 NAME 'knowledgeInformation'\n" +
+ " DESC 'RFC2256: \"knowledge\" information'\n" +
+ " EQUALITY caseIgnoreMatch\n" +
+ " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
+ parser.parse( attributeTypeData );
+ Map attributeTypes = parser.getAttributeTypes();
+ AttributeTypeLiteral type = ( AttributeTypeLiteral ) attributeTypes.get( "2.5.4.2" );
+
+ assertNotNull( type );
+ assertEquals( "2.5.4.2", type.getOid() );
+ assertEquals( "knowledgeInformation", type.getNames()[0] );
+ assertEquals( "RFC2256: \\\"knowledge\\\" information", type.getDescription() );
+ assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", type.getSyntax() );
+ assertEquals( 32768, type.getLength() );
+ }
+
+
public void testComplexAttributeTypeParse() throws Exception
{
String attributeTypeData = "# adding a comment \n" +