directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1789428 [5/5] - in /directory/shared/trunk: integ/src/test/java/org/apache/directory/api/ldap/schema/syntaxCheckers/ ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ ldap/model/src/main/java/org/apache/directory/api/ldap/mo...
Date Thu, 30 Mar 2017 03:28:29 GMT
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelexNumberSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelexNumberSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelexNumberSyntaxChecker.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelexNumberSyntaxChecker.java
Thu Mar 30 03:28:27 2017
@@ -24,8 +24,6 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -40,23 +38,57 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class TelexNumberSyntaxChecker extends SyntaxChecker
+public final class TelexNumberSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( TelexNumberSyntaxChecker.class
);
-    
     /**
      * A static instance of TelexNumberSyntaxChecker
      */
-    public static final TelexNumberSyntaxChecker INSTANCE = new TelexNumberSyntaxChecker();
+    public static final TelexNumberSyntaxChecker INSTANCE = 
+        new TelexNumberSyntaxChecker( SchemaConstants.TELEX_NUMBER_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<TelexNumberSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.TELEX_NUMBER_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of TelexNumberSyntaxChecker
+         * @return A new instance of TelexNumberSyntaxChecker
+         */
+        @Override
+        public TelexNumberSyntaxChecker build()
+        {
+            return new TelexNumberSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of TelexNumberSyntaxChecker.
+     * 
+     * @param oid the child's OID
      */
-    public TelexNumberSyntaxChecker()
+    private TelexNumberSyntaxChecker( String oid )
     {
-        super( SchemaConstants.TELEX_NUMBER_SYNTAX );
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
+     */
+    public static Builder builder()
+    {
+        return new Builder();
     }
 
 
@@ -70,7 +102,11 @@ public class TelexNumberSyntaxChecker ex
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -89,7 +125,11 @@ public class TelexNumberSyntaxChecker ex
 
         if ( strValue.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -100,7 +140,11 @@ public class TelexNumberSyntaxChecker ex
         if ( dollar <= 0 )
         {
             // No '$' => error
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -109,14 +153,22 @@ public class TelexNumberSyntaxChecker ex
         // The actualNumber must not be empty
         if ( actualNumber.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         // The actual number should be a PrintableString 
         if ( !Strings.isPrintableString( actualNumber ) )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -127,7 +179,11 @@ public class TelexNumberSyntaxChecker ex
         if ( dollar2 == -1 )
         {
             // No '$' => error
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -136,14 +192,22 @@ public class TelexNumberSyntaxChecker ex
         // The countryCode must not be empty
         if ( countryCode.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         // The country Code should be a PrintableString 
         if ( !Strings.isPrintableString( countryCode ) )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -151,7 +215,11 @@ public class TelexNumberSyntaxChecker ex
         if ( dollar2 + 1 == strValue.length() )
         {
             // The last string should not be null
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -160,20 +228,27 @@ public class TelexNumberSyntaxChecker ex
         // The answerBack should be a PrintableString 
         if ( !Strings.isPrintableString( answerBack ) )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         // Check that the mailboxType is a PrintableString
         boolean result = Strings.isPrintableString( answerBack );
 
-        if ( result )
-        {
-            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-        }
-        else
+        if ( LOG.isDebugEnabled() )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( result )
+            {
+                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            }
+            else
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
         }
 
         return result;

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UtcTimeSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UtcTimeSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UtcTimeSyntaxChecker.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UtcTimeSyntaxChecker.java
Thu Mar 30 03:28:27 2017
@@ -26,8 +26,6 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -64,11 +62,8 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class UtcTimeSyntaxChecker extends SyntaxChecker
+public final class UtcTimeSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( UtcTimeSyntaxChecker.class
);
-
     /** The GeneralizedDate pattern matching */
     private static final String UTC_TIME_PATTERN =
         // year : 00 to 99
@@ -94,17 +89,51 @@ public class UtcTimeSyntaxChecker extend
     /**
      * A static instance of UtcTimeSyntaxChecker
      */
-    public static final UtcTimeSyntaxChecker INSTANCE = new UtcTimeSyntaxChecker();
+    public static final UtcTimeSyntaxChecker INSTANCE = new UtcTimeSyntaxChecker( SchemaConstants.UTC_TIME_SYNTAX
);
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<UtcTimeSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.UTC_TIME_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of UtcTimeSyntaxChecker
+         * @return A new instance of UtcTimeSyntaxChecker
+         */
+        @Override
+        public UtcTimeSyntaxChecker build()
+        {
+            return new UtcTimeSyntaxChecker( oid );
+        }
+    }
 
     
     /**
-     * 
      * Creates a new instance of UtcTimeSyntaxChecker.
      *
+     * @param oid The OID to use for this SyntaxChecker
+     */
+    private UtcTimeSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
      */
-    public UtcTimeSyntaxChecker()
+    public static Builder builder()
     {
-        super( SchemaConstants.UTC_TIME_SYNTAX );
+        return new Builder();
     }
 
 
@@ -118,7 +147,11 @@ public class UtcTimeSyntaxChecker extend
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -138,20 +171,35 @@ public class UtcTimeSyntaxChecker extend
         // A generalized time must have a minimal length of 11 
         if ( strValue.length() < 11 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         // Start the date parsing
-        boolean result = DATE_PATTERN.matcher( strValue ).find();
+        boolean result;
+        
+        synchronized ( DATE_PATTERN )
+        {
+            result = DATE_PATTERN.matcher( strValue ).find();
+        }
 
         if ( result )
         {
-            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            }
         }
         else
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
         }
         
         return result;

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UuidSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UuidSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UuidSyntaxChecker.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/UuidSyntaxChecker.java
Thu Mar 30 03:28:27 2017
@@ -26,8 +26,6 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,23 +36,56 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class UuidSyntaxChecker extends SyntaxChecker
+public final class UuidSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( UuidSyntaxChecker.class );
-    
     /**
      * A static instance of UuidSyntaxChecker
      */
-    public static final UuidSyntaxChecker INSTANCE = new UuidSyntaxChecker();
+    public static final UuidSyntaxChecker INSTANCE = new UuidSyntaxChecker( SchemaConstants.UUID_SYNTAX
);
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<UuidSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.UUID_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of UuidSyntaxChecker
+         * @return A new instance of UuidSyntaxChecker
+         */
+        @Override
+        public UuidSyntaxChecker build()
+        {
+            return new UuidSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of UUIDSyntaxChecker.
+     * 
+     * @param oid The OID to use for this SyntaxChecker
+     */
+    private UuidSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
      */
-    public UuidSyntaxChecker()
+    public static Builder builder()
     {
-        super( SchemaConstants.UUID_SYNTAX );
+        return new Builder();
     }
 
 
@@ -66,7 +97,11 @@ public class UuidSyntaxChecker extends S
     {
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -77,7 +112,11 @@ public class UuidSyntaxChecker extends S
 
         if ( !( value instanceof String ) )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BooleanSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BooleanSyntaxCheckerTest.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BooleanSyntaxCheckerTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/BooleanSyntaxCheckerTest.java
Thu Mar 30 03:28:27 2017
@@ -46,6 +46,7 @@ public class BooleanSyntaxCheckerTest
     @Test
     public void testNullString()
     {
+        BooleanSyntaxChecker checker = BooleanSyntaxChecker.builder().setOid( "1.2.3.4" ).build();
         assertFalse( checker.isValidSyntax( null ) );
     }
 

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java
Thu Mar 30 03:28:27 2017
@@ -89,10 +89,9 @@ public class FacsimileTelephoneNumberSyn
     public void testWithNewMandatoryRegexp()
     {
         // Adding french telephone number regexp
-        checker = new FacsimileTelephoneNumberSyntaxChecker();
+        checker = FacsimileTelephoneNumberSyntaxChecker.builder().
+            setDefaultRegexp( " *0[1-8](( *|[-/.]{1})\\d\\d){4} *" ).build();
         
-        checker.setDefaultRegexp( " *0[1-8](( *|[-/.]{1})\\d\\d){4} *" );
-
         assertFalse( checker.isValidSyntax( "+ 123 ( 456 )7891   12345" ) );
         assertTrue( checker.isValidSyntax( " 01 02 03 04 05 " ) );
         assertTrue( checker.isValidSyntax( " 0102 03 04 05 " ) );

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java
Thu Mar 30 03:28:27 2017
@@ -98,8 +98,7 @@ public class TelephoneNumberSyntaxChecke
     public void testWithNewMandatoryRegexp()
     {
         // Adding french telephone number regexp
-        checker = new TelephoneNumberSyntaxChecker();
-        checker.setDefaultRegexp( " *0[1-8](( *|[-/.]{1})\\d\\d){4} *" );
+        checker = TelephoneNumberSyntaxChecker.builder().setDefaultRegexp( " *0[1-8](( *|[-/.]{1})\\d\\d){4}
*" ).build();
 
         assertFalse( checker.isValidSyntax( "+ 123 ( 456 )7891   12345" ) );
         assertTrue( checker.isValidSyntax( " 01 02 03 04 05 " ) );

Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
(original)
+++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
Thu Mar 30 03:28:27 2017
@@ -22,6 +22,7 @@ package org.apache.directory.api.ldap.sc
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -57,6 +58,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.ldap.model.schema.SchemaObject;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker.SCBuilder;
 import org.apache.directory.api.ldap.model.schema.UsageEnum;
 import org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription;
 import org.apache.directory.api.ldap.model.schema.parsers.NormalizerDescription;
@@ -312,12 +314,18 @@ public class SchemaEntityFactory impleme
         // Create the syntaxChecker instance
         try
         {
-            syntaxChecker = ( SyntaxChecker ) clazz.newInstance();
+            Method builder = clazz.getMethod( "builder", null );
+            syntaxChecker = ( SyntaxChecker ) ( ( SCBuilder ) builder.invoke( null, null
) ).setOid( oid ).build();
         }
-        catch ( InstantiationException ie )
+        catch ( NoSuchMethodException nsme )
         {
             LOG.error( "Cannot instantiate the syntax checker class constructor for class
{}", className );
-            throw new LdapSchemaException( "Cannot instantiate the syntax checker class "
+ ie.getMessage() );
+            throw new LdapSchemaException( "Cannot instantiate the syntax checker class "
+ nsme.getMessage() );
+        }
+        catch ( InvocationTargetException ite )
+        {
+            LOG.error( "Cannot instantiate the syntax checker class constructor for class
{}", className );
+            throw new LdapSchemaException( "Cannot instantiate the syntax checker class "
+ ite.getMessage() );
         }
         catch ( IllegalAccessException iae )
         {
@@ -329,9 +337,6 @@ public class SchemaEntityFactory impleme
         syntaxChecker.setBytecode( byteCodeStr );
         syntaxChecker.setFqcn( className );
 
-        // Inject the new OID, as the loaded syntaxChecker might have its own
-        syntaxChecker.setOid( oid );
-
         // Inject the SchemaManager for the comparator who needs it
         syntaxChecker.setSchemaManager( schemaManager );
 

Modified: directory/shared/trunk/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java
(original)
+++ directory/shared/trunk/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java
Thu Mar 30 03:28:27 2017
@@ -1924,7 +1924,7 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         String oid = "0.0.0";
-        SyntaxChecker syntaxChecker = new RegexSyntaxChecker( oid );
+        SyntaxChecker syntaxChecker = RegexSyntaxChecker.builder().setOid( oid ).build();
 
         assertTrue( schemaManager.add( syntaxChecker ) );
 
@@ -1949,7 +1949,7 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         String oid = "0.0.0";
-        SyntaxChecker syntaxChecker = new RegexSyntaxChecker( oid );
+        SyntaxChecker syntaxChecker = RegexSyntaxChecker.builder().setOid( oid ).build();
 
         assertTrue( schemaManager.add( syntaxChecker ) );
 
@@ -1963,7 +1963,7 @@ public class SchemaManagerAddTest
         assertEquals( nrSize + 1, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
 
-        SyntaxChecker syntaxChecker2 = new RegexSyntaxChecker( oid );
+        SyntaxChecker syntaxChecker2 = RegexSyntaxChecker.builder().setOid( oid ).build();
 
         assertFalse( schemaManager.add( syntaxChecker2 ) );
 
@@ -1991,7 +1991,7 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         String oid = "0.0.0";
-        SyntaxChecker syntaxChecker = new RegexSyntaxChecker( oid );
+        SyntaxChecker syntaxChecker = RegexSyntaxChecker.builder().setOid( oid ).build();
 
         // using java.sql.ResultSet cause it is very unlikely to get loaded
         // in ADS, as the FQCN is not the one expected

Modified: directory/shared/trunk/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java
(original)
+++ directory/shared/trunk/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java
Thu Mar 30 03:28:27 2017
@@ -1018,8 +1018,7 @@ public class SchemaManagerDelTest
         int scrSize = schemaManager.getSyntaxCheckerRegistry().size();
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
-        SyntaxChecker sc = new BooleanSyntaxChecker();
-        sc.setOid( "0.1.1" );
+        SyntaxChecker sc = BooleanSyntaxChecker.builder().setOid( "0.1.1" ).build();
         assertTrue( schemaManager.add( sc ) );
 
         assertEquals( scrSize + 1, schemaManager.getSyntaxCheckerRegistry().size() );
@@ -1051,8 +1050,7 @@ public class SchemaManagerDelTest
         int scrSize = schemaManager.getSyntaxCheckerRegistry().size();
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
-        SyntaxChecker sc = new BooleanSyntaxChecker();
-        sc.setOid( "0.0" );
+        SyntaxChecker sc = BooleanSyntaxChecker.builder().setOid( "0.0" ).build();
         assertFalse( schemaManager.delete( sc ) );
 
         List<Throwable> errors = schemaManager.getErrors();



Mime
View raw message