directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject [directory-ldap-api] branch master updated: Applied patch submitted by Ghenadii Batalski (DIRMINA-341)
Date Mon, 06 May 2019 21:38:02 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-ldap-api.git


The following commit(s) were added to refs/heads/master by this push:
     new cb569e7  Applied patch submitted by Ghenadii Batalski (DIRMINA-341)
cb569e7 is described below

commit cb569e72be731647413c0ef1e147028b670fb95e
Author: emmanuel lecharny <elecharny@apache.org>
AuthorDate: Mon May 6 23:37:57 2019 +0200

    Applied patch submitted by Ghenadii Batalski (DIRMINA-341)
---
 .../java/org/apache/directory/api/i18n/I18n.java   |  1 +
 .../apache/directory/api/i18n/errors.properties    | 15 ++---
 .../schema/manager/impl/DefaultSchemaManager.java  | 68 +++++++++-------------
 3 files changed, 37 insertions(+), 47 deletions(-)

diff --git a/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java b/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
index 05d5bc5..8b90d44 100644
--- a/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
+++ b/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
@@ -957,6 +957,7 @@ public enum I18n
     ERR_16077_SCHEMA_MANAGER_CANT_BE_LOADED( "ERR_16077_SCHEMA_MANAGER_CANT_BE_LOADED" ),
     ERR_16078_CANNOT_LOAD_UNKNOWN_SCHEMA( "ERR_16078_CANNOT_LOAD_UNKNOWN_SCHEMA" ),
     ERR_16079_INVALID_SCHEMA_OBJECT_CANNOT_BE_LOADED( "ERR_16079_INVALID_SCHEMA_OBJECT_CANNOT_BE_LOADED"
),
+    ERR_16080_SCHEMA_LOADER_CANT_BE_CREATED("ERR_16080_SCHEMA_LOADER_CANT_BE_CREATED"),
 
     // api-utils                        17000 - 17999
     ERR_17000_UNEXPECTED_PARSER_CONDITION( "ERR_17000_UNEXPECTED_PARSER_CONDITION" ),
diff --git a/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties b/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
index 8802ed1..4c0c052 100644
--- a/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
+++ b/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
@@ -42,7 +42,7 @@ ERR_01008_REMAINING_BYTES_FOR_DECODED_PDU=The PDU has been fully decoded
but the
 #    actions    1100 - 1199
 ERR_01100_INCORRECT_LENGTH=The expected length is incorrect, expected {0}, got {1}
 ERR_01101_NULL_LENGTH=The length should not be 0
-ERR_01102_INVALID_INTEGER=The received bytes can't be decoded to a valid integer: ''{0}''
+ERR_01102_INVALID_INTEGER=The received bytes can''t be decoded to a valid integer: ''{0}''
 
 #    grammar    1200 - 1299
 ERR_01200_BAD_TRANSITION_FROM_STATE=Bad transition from state {0}, tag {1}
@@ -198,7 +198,7 @@ ERR_04169_RESPONSE_QUEUE_EMPTIED=The response queue has been emptied,
no respons
 ERR_04170_TIMEOUT_OCCURED=TimeOut occurred
 ERR_04171_CANNOT_PARSE_MATCHED_DN=Could not parse matchedDn while transforming Codec value
to Internal: {0}
 ERR_04172_KEYSTORE_INIT_FAILURE=Keystore initialisation failure
-ERR_04173_ALGORITHM_NOT_FOUND=Not TrustManagerFactory found for algorithm '{0}'
+ERR_04173_ALGORITHM_NOT_FOUND=Not TrustManagerFactory found for algorithm ''{0}''
 
 ERR_04174_INPUT_FILE_NAME_NULL=LdapClientTrustStoreManager constructor : input file name
is null
 ERR_04175_TRUST_STORE_FILE_NULL=TrustStoreFile : file not found
@@ -275,7 +275,7 @@ ERR_05154_EMPTY_SUBSTRING_INITIAL_FILTER_PDU=The substring initial filter
is emp
 ERR_05155_FLAG_TYPE_INVALID=The types only flag {0} is invalid: {1}. It should be 0 or 255
 ERR_05156_INVALID_ATTRIBUTE_TYPE=The Attribute type {0} is invalid : {1}
 ERR_05157_INVALID_DN=The Dn {0} is invalid : {1}
-ERR_05158_INVALID_REQUEST_VALUE=The encoded value '{0}' cannot be decoded
+ERR_05158_INVALID_REQUEST_VALUE=The encoded value ''{0}'' cannot be decoded
 ERR_05159_INVALID_RESPONSE_NAME_OID=The Response name is not a valid OID : {0} ({1}) is invalid
 
 # api-ldap-codec-core api       5200-5299
@@ -526,7 +526,7 @@ ERR_13243_ENTRY_IMMUTABLE_CANT_DESERIALIZE=Cannot deserialize the entry
{0} is i
 ERR_13244_ID_AT_NOT_COMPATIBLE=ID ''{0}'' and AttributeType ''{1}'' are not compatible
 ERR_13245_AT_PARAMETER_NULL=The AttributeType parameter should not be null
 ERR_13246_INVALID_VALUE_PER_SYNTAX=Invalid upValue per syntax
-ERR_13247_INVALID_VALUE_CANT_NORMALIZE=Invalid upValue, it can't be normalized
+ERR_13247_INVALID_VALUE_CANT_NORMALIZE=Invalid upValue, it can''t be normalized
 ERR_13248_CANNOT_READ_ENTRY=Cannot read an entry
 ERR_13249_NO_COMPARATOR_FOR_AT=No comparator for attributeType {0}
 ERR_13250_VALUE_MISSING_AT_THE_END=A value is missing at the end
@@ -644,7 +644,7 @@ ERR_13509_UNEXPECTED_SCOPE=Unexpected scope {0}
 ERR_13510_UNKNOWN_DEREF_MODE=Unknown derefmode {0}
 ERR_13511_INVALID_PROXIED_AUTHZ_NULL=Invalid proxied authz value: cannot be null
 ERR_13512_INVALID_PROXIED_AUTHZ_BAD_DN=Invalid proxied authz value: the DN is not valid
-ERR_13513_INVALID_PROXIED_AUTHZ_NO_DN_OR_U=Invalid proxied authz value: should start with
'dn:' or 'u:'
+ERR_13513_INVALID_PROXIED_AUTHZ_NO_DN_OR_U=Invalid proxied authz value: should start with
''dn:'' or ''u:''
 ERR_13514_UNKNOWN_SORT_RESPONSE_RESULT=Unknown sort response result code {0}
 ERR_13515_UNEXPECTED_MOD_OP=Unexpected ModificationOperation
 ERR_13516_UNEXPECTED_MESSAGE_TYPE=Unexpected MessageTypeEnum {0}
@@ -776,7 +776,7 @@ ERR_13791_KEYCHAR_EXPECTED=keychar expected, got {0} (line {1}, col {2})
 ERR_13792_SIMPLE_QUOTE_EXPECTED_AT_END=Simple quote expected at the end of a descr (line
{0}, col {1})
 ERR_13793_NO_CLOSING_PAREN=No closing '')'' (line {0}, col {1})
 ERR_13794_MORE_OIDS_EXPECTED=more OIDs expected (line {0}, col {1})
-ERR_13795_OPENED_BRACKET_NOT_CLOSED=Opened ''{'' hasn't been closed (line {0}, col {1})
+ERR_13795_OPENED_BRACKET_NOT_CLOSED=Opened ''{'' hasn''t been closed (line {0}, col {1})
 ERR_13796_USAGE_EXPECTED=Expected an USAGE (line {0}, col {1})
 ERR_13797_USAGE_UNKNOWN=The USAGE value is unknown (line {0}, col {1})
 ERR_13798_AT_DESCRIPTION_INVALID=Error, AttributeType definition invalid (line {0}, col {1})
@@ -947,9 +947,10 @@ ERR_16073_CANNOT_INST_NORM_CLASS=Cannot instantiate the normalizer class:
{0}
 ERR_16074_CANNOT_ACCESS_NORM_CTOR_CLASS=Cannot access the normalizer class constructor for
class {0}
 ERR_16075_CANNOT_ACCESS_NORM_CTOR=Cannot access the normalizer class constructor: {0}
 ERR_16076_NOT_A_SCHEMA_DEFINITION=The first entry in the LDIF file is not a schema definition
-ERR_16077_SCHEMA_MANAGER_CANT_BE_LOADED=SchemaManager can't be loaded: {0}
+ERR_16077_SCHEMA_MANAGER_CANT_BE_LOADED=SchemaManager can''t be loaded: {0}
 ERR_16078_CANNOT_LOAD_UNKNOWN_SCHEMA=Cannot load the unknown schema {0}
 ERR_16079_INVALID_SCHEMA_OBJECT_CANNOT_BE_LOADED=the SchemaObject {0} cannot be added, it''s
not a valid LoadableSchemaObject.
+ERR_16080_SCHEMA_LOADER_CANT_BE_CREATED=Default SchemaLoader cannot be created {0}
 
 # api-utils     17000 - 17999
 ERR_17000_UNEXPECTED_PARSER_CONDITION=Unexpected parser condition throwing IllegalStateException.
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManager.java
b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManager.java
index bf9ef43..4d72542 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManager.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManager.java
@@ -129,29 +129,18 @@ public class DefaultSchemaManager implements SchemaManager
     private SchemaErrorHandler errorHandler;
 
     /**
-     * Creates a new instance of DefaultSchemaManager with the default schema schemaLoader
+     * Creates a new instance of DefaultSchemaManager with LDIF based SchemaLoader,
+     * Strict schema validation
      */
     public DefaultSchemaManager()
     {
-        // Default to the the root (one schemaManager for all the entries
-        namingContext = Dn.ROOT_DSE;
-        registries = new Registries();
-        factory = new SchemaEntityFactory();
-        isRelaxed = STRICT;
-        setErrorHandler( new LoggingSchemaErrorHandler() );
+        this( STRICT, jarLdifSchemaLoader().getAllSchemas() );
         
         try
         {
-            SchemaLoader schemaLoader = new JarLdifSchemaLoader();
-            
-            for ( Schema schema : schemaLoader.getAllSchemas() )
-            {
-                schemaMap.put( schema.getSchemaName(), schema );
-            }
-            
             loadAllEnabled();
         }
-        catch ( LdapException | IOException e )
+        catch ( LdapException e )
         {
             LOG.error( I18n.err( I18n.ERR_16077_SCHEMA_MANAGER_CANT_BE_LOADED, e.getMessage()
) );
             throw new RuntimeException( e.getMessage() );
@@ -159,47 +148,46 @@ public class DefaultSchemaManager implements SchemaManager
     }
 
     
+    /*
+     * Static helper factory Create LDIF based SchemaLoader
+     */
+    private static SchemaLoader jarLdifSchemaLoader()
+    {
+        try
+        {
+            return new JarLdifSchemaLoader();
+        }
+        catch ( LdapException | IOException e )
+        {
+            LOG.error( I18n.err( I18n.ERR_16080_SCHEMA_LOADER_CANT_BE_CREATED, e.getMessage()
) );
+            throw new RuntimeException( e.getMessage() );
+        }
+    }
+
+
+    
     /**
      * Creates a new instance of DefaultSchemaManager with the default schema schemaLoader
+     * Strict schema validation
      * 
      * @param schemas The list of schema to load
      */
     public DefaultSchemaManager( Collection<Schema> schemas )
     {
-        // Default to the the root (one schemaManager for all the entries
-        namingContext = Dn.ROOT_DSE;
-        
-        for ( Schema schema : schemas )
-        {
-            schemaMap.put( schema.getSchemaName(), schema );
-        }
-        
-        registries = new Registries();
-        factory = new SchemaEntityFactory();
-        isRelaxed = STRICT;
-        setErrorHandler( new LoggingSchemaErrorHandler() );
+        this( STRICT, schemas );
     }
 
     
     /**
-     * Creates a new instance of DefaultSchemaManager with the default schema schemaLoader
+     * Creates a new instance of DefaultSchemaManager with the given schemaLoader
+     *
+     * Schema validation strictness (i.e. relaxed/strict) controlled by the given schemaLoader
      * 
      * @param schemaLoader The schemaLoader containing the schemas to load
      */
     public DefaultSchemaManager( SchemaLoader schemaLoader )
     {
-        // Default to the the root (one schemaManager for all the entries
-        namingContext = Dn.ROOT_DSE;
-        
-        for ( Schema schema : schemaLoader.getAllSchemas() )
-        {
-            schemaMap.put( schema.getSchemaName(), schema );
-        }
-        
-        registries = new Registries();
-        factory = new SchemaEntityFactory();
-        isRelaxed = STRICT;
-        setErrorHandler( new LoggingSchemaErrorHandler() );
+        this( schemaLoader.isRelaxed(), schemaLoader.getAllSchemas() );
     }
     
 


Mime
View raw message