directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r749785 - in /directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser: model/container/LdifChangeModifyRecord.java parser/LdifParser.java parser/LdifScanner.java
Date Tue, 03 Mar 2009 22:03:54 GMT
Author: seelmann
Date: Tue Mar  3 22:03:54 2009
New Revision: 749785

URL: http://svn.apache.org/viewvc?rev=749785&view=rev
Log:
Fix for DIRSTUDIO-468 and DIRSTUDIO-439:
o keywords are case-insensitive
o order of newrdn, deleteoldrdn and newsuperior in moddn record doesn't matter
o empty modify record is allowed

Modified:
    directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java
    directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifParser.java
    directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifScanner.java

Modified: directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java?rev=749785&r1=749784&r2=749785&view=diff
==============================================================================
--- directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java
(original)
+++ directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java
Tue Mar  3 22:03:54 2009
@@ -84,7 +84,7 @@
             return false;
         }
 
-        return this.getModSpecs().length > 0;
+        return true;
     }
 
 }

Modified: directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifParser.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifParser.java?rev=749785&r1=749784&r2=749785&view=diff
==============================================================================
--- directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifParser.java
(original)
+++ directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifParser.java
Tue Mar  3 22:03:54 2009
@@ -475,117 +475,117 @@
 
     private void parseChangeModDnRecord( LdifChangeModDnRecord record )
     {
-        // do {
-        if ( checkAndParseEndOfRecord( record ) )
-        {
-            return;
-        }
+        boolean newrdnRead = false;
+        boolean deleteoldrdnRead = false;
+        boolean newsuperiorRead = false;
 
-        // comments
-        checkAndParseComment( record );
-
-        // read newrdn line
-        LdifToken newrdnSpecToken = this.scanner.matchNewrdnSpec();
-        if ( newrdnSpecToken != null )
+        do
         {
-            LdifToken newrdnValueTypeToken = this.scanner.matchValueType();
-            LdifToken newrdnValueToken = this.scanner.matchValue();
-            LdifToken newrdnSepToken = null;
-            if ( newrdnValueTypeToken != null || newrdnValueToken != null )
+            if ( checkAndParseEndOfRecord( record ) )
             {
-                newrdnSepToken = this.scanner.matchSep();
+                return;
             }
 
-            LdifNewrdnLine newrdnLine = new LdifNewrdnLine( newrdnSpecToken.getOffset(),
-                getValueOrNull( newrdnSpecToken ), getValueOrNull( newrdnValueTypeToken ),
-                getValueOrNull( newrdnValueToken ), getValueOrNull( newrdnSepToken ) );
-            record.setNewrdn( newrdnLine );
+            // comments
+            checkAndParseComment( record );
 
-            if ( newrdnSepToken == null )
+            LdifToken newrdnSpecToken = null;
+            LdifToken deleteoldrdnSpecToken = null;
+            LdifToken newsuperiorSpecToken = null;
+            if ( !newrdnRead )
             {
-                this.cleanupLine( record );
+                newrdnSpecToken = this.scanner.matchNewrdnSpec();
             }
-        }
-
-        if ( newrdnSpecToken == null )
-        {
-            if ( !checkAndParseComment( record ) && !checkAndParseOther( record )
)
+            if ( !deleteoldrdnRead && newrdnSpecToken == null )
             {
-                return;
+                deleteoldrdnSpecToken = this.scanner.matchDeleteoldrdnSpec();
             }
-        }
-
-        // comments
-        checkAndParseComment( record );
-
-        // read deleteoldrdnline
-        LdifToken deleteoldrdnSpecToken = this.scanner.matchDeleteoldrdnSpec();
-        if ( deleteoldrdnSpecToken != null )
-        {
-            LdifToken deleteoldrdnValueTypeToken = this.scanner.matchValueType();
-            LdifToken deleteoldrdnValueToken = this.scanner.matchValue();
-            LdifToken deleteoldrdnSepToken = null;
-            if ( deleteoldrdnValueTypeToken != null || deleteoldrdnValueToken != null )
+            if ( !newsuperiorRead && newrdnSpecToken == null && newsuperiorSpecToken
== null )
             {
-                deleteoldrdnSepToken = this.scanner.matchSep();
+                newsuperiorSpecToken = this.scanner.matchNewsuperiorSpec();
             }
 
-            LdifDeloldrdnLine deloldrdnLine = new LdifDeloldrdnLine( deleteoldrdnSpecToken.getOffset(),
-                getValueOrNull( deleteoldrdnSpecToken ), getValueOrNull( deleteoldrdnValueTypeToken
),
-                getValueOrNull( deleteoldrdnValueToken ), getValueOrNull( deleteoldrdnSepToken
) );
-            record.setDeloldrdn( deloldrdnLine );
-
-            if ( deleteoldrdnSepToken == null )
+            if ( newrdnSpecToken != null )
             {
-                this.cleanupLine( record );
-            }
-        }
+                // read newrdn line
+                newrdnRead = true;
+                LdifToken newrdnValueTypeToken = this.scanner.matchValueType();
+                LdifToken newrdnValueToken = this.scanner.matchValue();
+                LdifToken newrdnSepToken = null;
+                if ( newrdnValueTypeToken != null || newrdnValueToken != null )
+                {
+                    newrdnSepToken = this.scanner.matchSep();
+                }
 
-        if ( deleteoldrdnSpecToken == null )
-        {
-            if ( !checkAndParseComment( record ) && !checkAndParseOther( record )
)
-            {
-                return;
+                LdifNewrdnLine newrdnLine = new LdifNewrdnLine( newrdnSpecToken.getOffset(),
+                    getValueOrNull( newrdnSpecToken ), getValueOrNull( newrdnValueTypeToken
),
+                    getValueOrNull( newrdnValueToken ), getValueOrNull( newrdnSepToken )
);
+                record.setNewrdn( newrdnLine );
+
+                if ( newrdnSepToken == null )
+                {
+                    this.cleanupLine( record );
+                }
             }
-        }
+            else if ( deleteoldrdnSpecToken != null )
+            {
+                // read deleteoldrdnline
+                deleteoldrdnRead = true;
+                LdifToken deleteoldrdnValueTypeToken = this.scanner.matchValueType();
+                LdifToken deleteoldrdnValueToken = this.scanner.matchValue();
+                LdifToken deleteoldrdnSepToken = null;
+                if ( deleteoldrdnValueTypeToken != null || deleteoldrdnValueToken != null
)
+                {
+                    deleteoldrdnSepToken = this.scanner.matchSep();
+                }
 
-        // comments
-        checkAndParseComment( record );
+                LdifDeloldrdnLine deloldrdnLine = new LdifDeloldrdnLine( deleteoldrdnSpecToken.getOffset(),
+                    getValueOrNull( deleteoldrdnSpecToken ), getValueOrNull( deleteoldrdnValueTypeToken
),
+                    getValueOrNull( deleteoldrdnValueToken ), getValueOrNull( deleteoldrdnSepToken
) );
+                record.setDeloldrdn( deloldrdnLine );
 
-        // read newsuperior line
-        LdifToken newsuperiorSpecToken = this.scanner.matchNewsuperiorSpec();
-        if ( newsuperiorSpecToken != null )
-        {
-            LdifToken newsuperiorValueTypeToken = this.scanner.matchValueType();
-            LdifToken newsuperiorValueToken = this.scanner.matchValue();
-            LdifToken newsuperiorSepToken = null;
-            if ( newsuperiorValueTypeToken != null || newsuperiorValueToken != null )
-            {
-                newsuperiorSepToken = this.scanner.matchSep();
+                if ( deleteoldrdnSepToken == null )
+                {
+                    this.cleanupLine( record );
+                }
             }
+            else if ( newsuperiorSpecToken != null )
+            {
+                // read newsuperior line
+                newsuperiorRead = true;
+                LdifToken newsuperiorValueTypeToken = this.scanner.matchValueType();
+                LdifToken newsuperiorValueToken = this.scanner.matchValue();
+                LdifToken newsuperiorSepToken = null;
+                if ( newsuperiorValueTypeToken != null || newsuperiorValueToken != null )
+                {
+                    newsuperiorSepToken = this.scanner.matchSep();
+                }
 
-            LdifNewsuperiorLine newsuperiorLine = new LdifNewsuperiorLine( newsuperiorSpecToken.getOffset(),
-                getValueOrNull( newsuperiorSpecToken ), getValueOrNull( newsuperiorValueTypeToken
),
-                getValueOrNull( newsuperiorValueToken ), getValueOrNull( newsuperiorSepToken
) );
-            record.setNewsuperior( newsuperiorLine );
+                LdifNewsuperiorLine newsuperiorLine = new LdifNewsuperiorLine( newsuperiorSpecToken.getOffset(),
+                    getValueOrNull( newsuperiorSpecToken ), getValueOrNull( newsuperiorValueTypeToken
),
+                    getValueOrNull( newsuperiorValueToken ), getValueOrNull( newsuperiorSepToken
) );
+                record.setNewsuperior( newsuperiorLine );
 
-            if ( newsuperiorSepToken == null )
+                if ( newsuperiorSepToken == null )
+                {
+                    this.cleanupLine( record );
+                }
+            }
+            else
             {
-                this.cleanupLine( record );
+                if ( !checkAndParseComment( record ) && !checkAndParseOther( record
) )
+                {
+                    return;
+                }
             }
-        }
-
-        // comments
-        checkAndParseComment( record );
 
-        // eor
-        checkAndParseEndOfRecord( record );
+            // comments
+            checkAndParseComment( record );
 
-        // comments
-        // checkAndParseComment(record);
-
-        // }
-        // while(true);
+            // eor
+            checkAndParseEndOfRecord( record );
+        }
+        while ( true );
     }
 
 

Modified: directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifScanner.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifScanner.java?rev=749785&r1=749784&r2=749785&view=diff
==============================================================================
--- directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifScanner.java
(original)
+++ directory/studio/trunk/ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifScanner.java
Tue Mar  3 22:03:54 2009
@@ -473,7 +473,8 @@
             {
 
                 char c = read( sb );
-                if ( c != word.charAt( i ) )
+                //if ( c != word.charAt( i ) )
+                if ( Character.toUpperCase( c ) != Character.toUpperCase( word.charAt( i
) ) )
                 {
                     matches = false;
                     unread( sb );
@@ -947,6 +948,11 @@
     }
 
 
+    /**
+     * Matches "add", "replace", or "delete"
+     *
+     * @return the LIDF token if matched, null if not matched
+     */
     public LdifToken matchModTypeSpec()
     {
         this.flushBuffer();



Mime
View raw message