From commits-return-5594-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Fri Aug 12 04:30:28 2005 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 65335 invoked from network); 12 Aug 2005 04:30:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Aug 2005 04:30:28 -0000 Received: (qmail 63771 invoked by uid 500); 12 Aug 2005 04:30:27 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 63729 invoked by uid 500); 12 Aug 2005 04:30:27 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 63709 invoked by uid 99); 12 Aug 2005 04:30:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Aug 2005 21:30:27 -0700 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 11 Aug 2005 21:30:49 -0700 Received: (qmail 65303 invoked by uid 65534); 12 Aug 2005 04:30:26 -0000 Message-ID: <20050812043026.65302.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r232201 - in /directory/shared/ldap/trunk/common/src: java/org/apache/ldap/common/ldif/LdifParserImpl.java test/org/apache/ldap/common/ldif/LdifParserImplTest.java Date: Fri, 12 Aug 2005 04:30:25 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.3 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: akarasulu Date: Thu Aug 11 21:30:20 2005 New Revision: 232201 URL: http://svn.apache.org/viewcvs?rev=232201&view=rev Log: Added code to handle comments. For the issue DIRLDAP-24: http://issues.apache.org/jira/browse/DIRLDAP-24 Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/LdifParserImplTest.java Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java?rev=232201&r1=232200&r2=232201&view=diff ============================================================================== --- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java (original) +++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/ldif/LdifParserImpl.java Thu Aug 11 21:30:20 2005 @@ -84,6 +84,24 @@ { while ( ( line = in.readLine() ) != null ) { + // check and see if we have a comment on this line and if so + // we need to forgo the entire line or chop off the comment + int asteriskIndex = line.indexOf( '#' ); + if ( asteriskIndex != -1 ) + { + if ( asteriskIndex < 3 ) + { + continue; + } + + line = line.substring( 0, asteriskIndex ).trim(); + + if ( line.equals( "" ) ) + { + continue; + } + } + // Try to advance to ':' if one exists. if ( ( index = line.indexOf( ':' ) ) == -1 ) { @@ -92,7 +110,7 @@ + "attribute value pair.\n{" + ldif + "}", ResultCodeEnum.OTHER ); } - + // Capture data while at first colon. attrName = line.substring( 0, index ).trim(); Modified: directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/LdifParserImplTest.java URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/LdifParserImplTest.java?rev=232201&r1=232200&r2=232201&view=diff ============================================================================== --- directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/LdifParserImplTest.java (original) +++ directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/ldif/LdifParserImplTest.java Thu Aug 11 21:30:20 2005 @@ -39,6 +39,32 @@ Attribute attr = attrs.get( "objectClass" ); assertTrue( attr.contains( "apApplication" ) ); assertTrue( attr.contains( "top" ) ); + } + + public void testLdifParserComments() throws NamingException + { + String ldif = "#comment\n" + + "dn: cn=app1,ou=applications,ou=conf,dc=apache,dc=org\n" + + "cn: app1#another comment\n" + + "objectClass: top\n" + + "objectClass: apApplication\n" + + "displayName: app1\n" + + "serviceType: http\n" + + "dependencies:\n" + + "httpHeaders:\n" + + "startupOptions:\n" + + "envVars:"; + LdifParser parser = new LdifParserImpl(); + Attributes attrs = new LockableAttributesImpl(); + parser.parse( attrs, ldif ); + + assertNotNull( attrs ); + + Attribute attr = attrs.get( "objectClass" ); + assertTrue( attr.contains( "apApplication" ) ); + assertTrue( attr.contains( "top" ) ); + + assertEquals( "app1", attrs.get( "cn" ).get() ); } }