directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject [directory-server] branch master updated: Fix for DIRSERVER-2303
Date Fri, 20 Mar 2020 02:59:25 GMT
This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git


The following commit(s) were added to refs/heads/master by this push:
     new af1a7b2  Fix for DIRSERVER-2303
af1a7b2 is described below

commit af1a7b2b178a00524031a5d94aa1c92d42bf6af0
Author: emmanuel lecharny <emmanuel.lecharny@busit.com>
AuthorDate: Fri Mar 20 03:59:20 2020 +0100

    Fix for DIRSERVER-2303
---
 .../server/core/factory/DSAnnotationProcessor.java | 29 ++++++++++++++++------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
b/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
index 7d22462..bef9629 100644
--- a/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
+++ b/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
@@ -468,6 +468,19 @@ public final class DSAnnotationProcessor
             System.out.println( loadSchema );
         }
     }
+    
+    
+    private static boolean isDn( String str )
+    {
+        if ( ( Strings.isEmpty( str ) ) | ( str.length() < 3 ) )
+        {
+            return false;
+        }
+        
+        return ( ( ( str.charAt( 0 ) == 'd' ) || ( str.charAt( 0 ) == 'D' ) ) &&
+            ( ( str.charAt( 1 ) == 'n' ) || ( str.charAt( 1 ) == 'N' ) ) &&
+            ( str.charAt( 2 ) == ':' ) );
+    }
 
 
     /**
@@ -501,24 +514,24 @@ public final class DSAnnotationProcessor
         {
             String[] ldifs = applyLdifs.value();
 
-            String dnStart = "dn:";
-
             StringBuilder sb = new StringBuilder();
 
             for ( int i = 0; i < ldifs.length; )
             {
-                String s = ldifs[i++].trim();
-                if ( s.startsWith( dnStart ) )
+                String str = ldifs[i++].trim();
+                
+                if ( isDn( str ) )
                 {
-                    sb.append( s ).append( '\n' );
+                    sb.append( str ).append( '\n' );
 
                     // read the rest of lines till we encounter Dn again
                     while ( i < ldifs.length )
                     {
-                        s = ldifs[i++];
-                        if ( !s.startsWith( dnStart ) )
+                        str = ldifs[i++];
+
+                        if ( !isDn( str ) )
                         {
-                            sb.append( s ).append( '\n' );
+                            sb.append( str ).append( '\n' );
                         }
                         else
                         {


Mime
View raw message