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/06/02 05:08:34 UTC

svn commit: r1746522 - in /directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema: MutableAttributeType.java normalizers/ConcreteNameComponentNormalizer.java normalizers/NameComponentNormalizer.java

Author: elecharny
Date: Thu Jun  2 05:08:34 2016
New Revision: 1746522

URL: http://svn.apache.org/viewvc?rev=1746522&view=rev
Log:
o Pass an AttributeType to the MutableAttributeType.setSuperior() method
o Added a normalizeByName( AttributeType, XXX) method, for when we already have the AttributeType.

Modified:
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableAttributeType.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ConcreteNameComponentNormalizer.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameComponentNormalizer.java

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableAttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableAttributeType.java?rev=1746522&r1=1746521&r2=1746522&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableAttributeType.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/MutableAttributeType.java Thu Jun  2 05:08:34 2016
@@ -311,7 +311,7 @@ public class MutableAttributeType extend
      *
      * @param superior The superior for this AttributeType
      */
-    public void setSuperior( MutableAttributeType superior )
+    public void setSuperior( AttributeType superior )
     {
         if ( locked )
         {

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ConcreteNameComponentNormalizer.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/ConcreteNameComponentNormalizer.java?rev=1746522&r1=1746521&r2=1746522&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ConcreteNameComponentNormalizer.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/ConcreteNameComponentNormalizer.java Thu Jun  2 05:08:34 2016
@@ -121,7 +121,37 @@ public class ConcreteNameComponentNormal
 
             return normalizer.normalize( unescaped );
         }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Object normalizeByName( AttributeType attributeType, String value ) throws LdapException
+    {
+        MatchingRule mrule = attributeType.getEquality();
+        Normalizer normalizer;
+            
+        if ( mrule == null )
+        {
+            return new NoOpNormalizer( attributeType.getOid() );
+        }
+        else
+        {
+            normalizer = attributeType.getEquality().getNormalizer();
+        }
 
+        if ( attributeType.getSyntax().isHumanReadable() )
+        {
+            return normalizer.normalize( value );
+        }
+        else
+        {
+            String unescaped = unescape( value );
+
+            return normalizer.normalize( unescaped );
+        }
     }
 
 

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameComponentNormalizer.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/NameComponentNormalizer.java?rev=1746522&r1=1746521&r2=1746522&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameComponentNormalizer.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/normalizers/NameComponentNormalizer.java Thu Jun  2 05:08:34 2016
@@ -22,6 +22,7 @@ package org.apache.directory.api.ldap.mo
 
 
 import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.schema.AttributeType;
 
 
 /**
@@ -67,6 +68,18 @@ public interface NameComponentNormalizer
 
 
     /**
+     * Normalizes an attribute's value given the name of the attribute - short
+     * names like 'cn' as well as 'commonName' should work here.
+     * 
+     * @param attributeType the attributeType
+     * @param value the value of the attribute to normalize
+     * @return the normalized value
+     * @throws LdapException if there is a recognition problem or a syntax issue
+     */
+    Object normalizeByName( AttributeType attributeType, String value ) throws LdapException;
+
+
+    /**
      * Normalizes an attribute's value given the name of the attribute - short
      * names like 'cn' as well as 'commonName' should work here.
      *