You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2016/05/14 05:33:17 UTC

svn commit: r1743786 - in /directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers: NameOrNumericIdNormalizer.java ObjectIdentifierNormalizer.java

Author: elecharny
Date: Sat May 14 05:33:17 2016
New Revision: 1743786

URL: http://svn.apache.org/viewvc?rev=1743786&view=rev
Log:
Fixed the ObjectIdentifier normalizer : we are now pulling the normalized form (ie, the OID) from the SchemaManager

Modified:
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameOrNumericIdNormalizer.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameOrNumericIdNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameOrNumericIdNormalizer.java?rev=1743786&r1=1743785&r2=1743786&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameOrNumericIdNormalizer.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameOrNumericIdNormalizer.java Sat May 14 05:33:17 2016
@@ -34,7 +34,7 @@ import org.apache.directory.api.util.Str
 /**
  * A name or numeric id normalizer.  Needs an OID registry to operate properly.
  * The OID registry is injected into this class after instantiation if a 
- * setRegistries(Registries) method is exposed.
+ * setSchemaManager(SchemaManager) method is exposed.
  * 
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java?rev=1743786&r1=1743785&r2=1743786&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ObjectIdentifierNormalizer.java Sat May 14 05:33:17 2016
@@ -24,6 +24,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.schema.Normalizer;
 import org.apache.directory.api.ldap.model.schema.PrepareString;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.util.Strings;
 
 
@@ -35,6 +36,9 @@ import org.apache.directory.api.util.Str
 @SuppressWarnings("serial")
 public class ObjectIdentifierNormalizer extends Normalizer
 {
+    /** A reference to the schema manager used to normalize the Name */
+    private SchemaManager schemaManager;
+
     /**
      * Creates a new instance of ObjectIdentifierNormalizer.
      */
@@ -48,9 +52,24 @@ public class ObjectIdentifierNormalizer
      * {@inheritDoc}
      */
     @Override
+    public void setSchemaManager( SchemaManager schemaManager )
+    {
+        this.schemaManager = schemaManager;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public String normalize( String value ) throws LdapException
     {
-        return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE );
+        if ( Strings.isEmpty( value ) )
+        {
+            return "";
+        }
+        
+        return schemaManager.getRegistries().getOid( value.trim() );
     }
 
 
@@ -67,18 +86,6 @@ public class ObjectIdentifierNormalizer
 
         String str = value.trim();
 
-        if ( str.length() == 0 )
-        {
-            return "";
-        }
-        else if ( Character.isDigit( str.charAt( 0 ) ) )
-        {
-            // We do this test to avoid a lowerCasing which cost time
-            return str;
-        }
-        else
-        {
-            return Strings.toLowerCaseAscii( str );
-        }
+        return schemaManager.getRegistries().getOid( str );
     }
 }