directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r499510 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap: codec/util/LdapURL.java schema/AbstractSchemaObject.java util/AttributeUtils.java
Date Wed, 24 Jan 2007 18:31:03 GMT
Author: elecharny
Date: Wed Jan 24 10:31:03 2007
New Revision: 499510

URL: http://svn.apache.org/viewvc?view=rev&rev=499510
Log:
Porting fix from ADS 1.0.1 to 1.5 : fixing DIRSERVER-758 and some problems with referrals.

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java?view=diff&rev=499510&r1=499509&r2=499510
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
Wed Jan 24 10:31:03 2007
@@ -1153,7 +1153,7 @@
      * @param doubleEncode Set if we need to encode the comma
      * @return An encoded string
      */
-    private String urlEncode( String url, boolean doubleEncode )
+    public static String urlEncode( String url, boolean doubleEncode )
     {
         StringBuffer sb = new StringBuffer();
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java?view=diff&rev=499510&r1=499509&r2=499510
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
Wed Jan 24 10:31:03 2007
@@ -316,6 +316,6 @@
      */
     public String toString()
     {
-        return oid;
+        return "<" + oid.toString() + ", " + names[0] + ">";
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java?view=diff&rev=499510&r1=499509&r2=499510
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
Wed Jan 24 10:31:03 2007
@@ -293,6 +293,74 @@
         return false;
     }
 
+    /**
+     * Check if an attribute contains a value. The test is case insensitive,
+     * and the value is supposed to be a String. If the value is a byte[],
+     * then the case sensitivity is useless.
+     *
+     * @param attr The attribute to check
+     * @param value The value to look for
+     * @return true if the value is present in the attribute
+     * @throws NamingException
+     */
+    public final static boolean containsValueCaseIgnore( Attribute attr, Object value )
+    {
+        // quick bypass test
+        if ( attr.contains( value ) )
+        {
+            return true;
+        }
+
+        try
+        {
+            if ( value instanceof String )
+            {
+                String strVal = (String)value;
+
+                NamingEnumeration attrVals = attr.getAll();
+
+                while ( attrVals.hasMoreElements() )
+                {
+                    Object attrVal = attrVals.nextElement();
+
+                    if ( attrVal instanceof String )
+                    {
+                        if ( strVal.equalsIgnoreCase( (String)attrVal ) )
+                        {
+                            return true;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                byte[] valueBytes = ( byte[] )value;
+
+                NamingEnumeration attrVals = attr.getAll();
+
+                while ( attrVals.hasMoreElements() )
+                {
+                    Object attrVal = attrVals.nextElement();
+
+                    if ( attrVal instanceof byte[] )
+                    {
+                        if ( Arrays.equals( (byte[])attrVal, valueBytes ) )
+                        {
+                            return true;
+                        }
+
+                    }
+                }
+            }
+        }
+        catch (NamingException ne )
+        {
+            return false;
+        }
+
+        return false;
+    }
+
 
     public static boolean containsAnyValues( Attribute attr, Object[] compared, AttributeType
type )
         throws NamingException



Mime
View raw message