Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 30804 invoked from network); 14 Jul 2008 09:44:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Jul 2008 09:44:43 -0000 Received: (qmail 64166 invoked by uid 500); 14 Jul 2008 09:44:43 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 64143 invoked by uid 500); 14 Jul 2008 09:44:43 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 64134 invoked by uid 99); 14 Jul 2008 09:44:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jul 2008 02:44:43 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jul 2008 09:43:51 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E1DBB2388A0A; Mon, 14 Jul 2008 02:43:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r676530 [1/3] - in /harmony/enhanced/classlib/branches/java6: depends/build/platform/ depends/oss/ modules/awt/src/main/native/lcmm/shared/ modules/awt/src/main/native/oglwrapper/shared/ modules/beans/src/main/java/java/beans/ modules/beans... Date: Mon, 14 Jul 2008 09:43:37 -0000 To: commits@harmony.apache.org From: qiuxx@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080714094344.E1DBB2388A0A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: qiuxx Date: Mon Jul 14 02:43:27 2008 New Revision: 676530 URL: http://svn.apache.org/viewvc?rev=676530&view=rev Log: Merge updates from classlib trunk@660000 since r651568 Added: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/resources/xml/MockOwner.xml - copied unchanged from r660000, harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockOwner.xml harmony/enhanced/classlib/branches/java6/modules/beans/src/test/resources/xml/MockOwner_Ambiguous.xml - copied unchanged from r660000, harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockOwner_Ambiguous.xml harmony/enhanced/classlib/branches/java6/modules/beans/src/test/resources/xml/MockOwner_Null.xml - copied unchanged from r660000, harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockOwner_Null.xml harmony/enhanced/classlib/branches/java6/modules/beans/src/test/resources/xml/MockOwner_Specific.xml - copied unchanged from r660000, harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockOwner_Specific.xml harmony/enhanced/classlib/branches/java6/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MockOwnerClass.java - copied unchanged from r660000, harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/MockOwnerClass.java harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaFilter.java - copied unchanged from r660000, harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaFilter.java harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ExtendedOpTest.java - copied unchanged from r660000, harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ExtendedOpTest.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/unpack200/Pack200UnpackerAdapter.java - copied unchanged from r660000, harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/unpack200/Pack200UnpackerAdapter.java Removed: harmony/enhanced/classlib/branches/java6/depends/oss/icu4c-3.4-harmony-includes.zip harmony/enhanced/classlib/branches/java6/depends/oss/icu4c-3.4-harmony-windows.x86_64.zip harmony/enhanced/classlib/branches/java6/depends/oss/icu4c-3.4-harmony.zip harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaAttrDefContextImpl.java harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaClassDefContextImpl.java Modified: harmony/enhanced/classlib/branches/java6/depends/build/platform/zos.s390.mk harmony/enhanced/classlib/branches/java6/depends/build/platform/zos.s390x.mk harmony/enhanced/classlib/branches/java6/depends/oss/README.txt harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/lcmm/shared/NativeCMM.c harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/oglwrapper/shared/nativelib_common.h harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java harmony/enhanced/classlib/branches/java6/modules/imageio/src/main/native/pngencoder/unix/makefile harmony/enhanced/classlib/branches/java6/modules/imageio/src/test/java/javax/imageio/stream/ImageInputStreamImplTest.java harmony/enhanced/classlib/branches/java6/modules/jndi/META-INF/MANIFEST.MF harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapAttribute.java harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextImpl.java harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextImplTest.java harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextTest.java harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectOutputStream.java harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/Handler.java harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/procimpl.c harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ByteCode.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ClassFileEntry.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/CodeAttribute.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ConstantPoolEntry.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/EnclosingMethodAttribute.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTableAttribute.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/SignatureAttribute.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/forms/ByteCodeForm.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/forms/NarrowClassRefForm.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/forms/SingleByteReferenceForm.java harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/forms/StringRefForm.java harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hyfile.c harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hyfiletext.c harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hymem.c harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hynlshelpers.c harmony/enhanced/classlib/branches/java6/modules/portlib/src/test/native/hyfile/shared/hyfile.c harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java Modified: harmony/enhanced/classlib/branches/java6/depends/build/platform/zos.s390.mk URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/depends/build/platform/zos.s390.mk?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/depends/build/platform/zos.s390.mk (original) +++ harmony/enhanced/classlib/branches/java6/depends/build/platform/zos.s390.mk Mon Jul 14 02:43:27 2008 @@ -20,7 +20,7 @@ CXX = cxx DEFINES += -DZOS -DZOS_S390 -DHYS390 -DHY_ATOE -OPT += -Wc,xplink,convlit\(ISO8859-1\),FLOAT\(IEEE,FOLD,AFP\) -Wc,"langlvl(commonc)" -Wa,goff -Wc,NOANSIALIAS -Wc,DLL,EXPORTALL +OPT += -Wc,xplink,convlit\(ISO8859-1\),FLOAT\(IEEE,FOLD,AFP\) -Wa,goff -Wc,NOANSIALIAS -Wc,DLL,EXPORTALL CFLAGS += -Wc,"SSCOMM" -Wc,"langlvl(commonc)" -Wc,gonumber CXXFLAGS += -+ -Wc,"langlvl(extended)" -Wc,gonumber @@ -32,6 +32,9 @@ MDLLIBPREFIX = MDLLIBSUFFIX = +# No need to specify STDC libs on z/OS +STDCLIBS = + # Don't use these flags on zOS DLL_LDFLAGS = Modified: harmony/enhanced/classlib/branches/java6/depends/build/platform/zos.s390x.mk URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/depends/build/platform/zos.s390x.mk?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/depends/build/platform/zos.s390x.mk (original) +++ harmony/enhanced/classlib/branches/java6/depends/build/platform/zos.s390x.mk Mon Jul 14 02:43:27 2008 @@ -20,7 +20,7 @@ CXX = cxx DEFINES += -DZOS -DZOS_S390X -DHYS390X -DHY_ATOE -OPT += -Wc,lp64,xplink,convlit\(ISO8859-1\),FLOAT\(IEEE,FOLD,AFP\) -Wc,"langlvl(commonc)" -Wa,goff -Wc,NOANSIALIAS -Wc,DLL,EXPORTALL +OPT += -Wc,lp64,xplink,convlit\(ISO8859-1\),FLOAT\(IEEE,FOLD,AFP\) -Wa,goff -Wc,NOANSIALIAS -Wc,DLL,EXPORTALL CFLAGS += -Wc,"SSCOMM" -Wc,"langlvl(commonc)" CXXFLAGS += -+ -Wc,"langlvl(extended)" @@ -32,6 +32,9 @@ MDLLIBPREFIX = MDLLIBSUFFIX = +# No need to specify STDC libs on z/OS +STDCLIBS = + # Don't use these flags on z/OS DLL_LDFLAGS = Modified: harmony/enhanced/classlib/branches/java6/depends/oss/README.txt URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/depends/oss/README.txt?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/depends/oss/README.txt (original) +++ harmony/enhanced/classlib/branches/java6/depends/oss/README.txt Mon Jul 14 02:43:27 2008 @@ -17,20 +17,6 @@ -ICU4C version 3.4 ------------------ -ICU4C is a freely available set of libraries that provide Unicode support to -C and C++ applications. The file icu4c-3.4-harmony.zip contains a set of C -header files (with .h extension) that come straight from the ICU download -available on the ICU home page. These have been grouped into a directory -called "unicode". The icu4c-3.4-harmony.zip file also contains a compiled -version of the ICU4C Windows .lib file. - -The official ICU page is located at -http://www.ibm.com/software/globalization/icu - - - FDLIBM version 5.2 ------------------ FDLIBM (Freely Distributable LIBM) is a C math library for supporting IEEE 754 Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/lcmm/shared/NativeCMM.c URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/lcmm/shared/NativeCMM.c?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/lcmm/shared/NativeCMM.c (original) +++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/lcmm/shared/NativeCMM.c Mon Jul 14 02:43:27 2008 @@ -27,7 +27,12 @@ int gl_cmsErrorHandler(int errorCode, const char *msg) { if(errorCode == LCMS_ERRC_ABORTED) { - errMsg = _strdup(msg); // Throw exception later, after returning control from cmm + // Throw exception later, after returning control from cmm +#ifndef ZOS + errMsg = _strdup(msg); +#else + errMsg = strdup(msg); +#endif } return 1; Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/oglwrapper/shared/nativelib_common.h URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/oglwrapper/shared/nativelib_common.h?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/oglwrapper/shared/nativelib_common.h (original) +++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/oglwrapper/shared/nativelib_common.h Mon Jul 14 02:43:27 2008 @@ -21,7 +21,7 @@ #ifndef NATIVELIB_COMMON_H #define NATIVELIB_COMMON_H -#if defined(LINUX) || defined(FREEBSD) || defined(AIX) || defined(MACOSX) +#if defined(LINUX) || defined(FREEBSD) || defined(AIX) || defined(MACOSX) || defined(ZOS) // common linux section-------------------------------- #include #include @@ -35,7 +35,7 @@ #define INIT_GL_GET_PROC_ADDRESS -#if !defined(__INTEL_COMPILER) && !defined(AIX) +#if !defined(__INTEL_COMPILER) && !defined(AIX) && !defined(ZOS) typedef long long __int64; #endif Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/XMLDecoder.java Mon Jul 14 02:43:27 2008 @@ -17,6 +17,7 @@ package java.beans; +import java.beans.Statement.MethodComparator; import java.io.InputStream; import java.lang.reflect.Array; import java.lang.reflect.Field; @@ -27,6 +28,7 @@ import javax.xml.parsers.SAXParserFactory; +import org.apache.harmony.beans.internal.nls.Messages; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -331,10 +333,24 @@ } Class[] c = new Class[args.size()]; for (int i = 0; i < args.size(); i++) { - c[i] = args.get(i).getClass(); + Object arg = args.get(i); + c[i] = (arg == null ? null: arg.getClass()); } - Method m = owner.getClass().getMethod(method, c); - return m.invoke(owner, args.toArray()); + + // Try actual match method + try { + Method m = owner.getClass().getMethod(method, c); + return m.invoke(owner, args.toArray()); + } catch (NoSuchMethodException e) { + // Do nothing + } + + // Find the specific method matching the parameter + Method mostSpecificMethod = findMethod( + owner instanceof Class ? (Class) owner : owner + .getClass(), method, c); + + return mostSpecificMethod.invoke(owner, args.toArray()); } // execute @@ -342,6 +358,75 @@ return exp.getValue(); } + private Method findMethod(Class clazz, String methodName, + Class[] clazzes) throws Exception { + Method[] methods = clazz.getMethods(); + ArrayList matchMethods = new ArrayList(); + + // Add all matching methods into a ArrayList + for (Method method : methods) { + if (!methodName.equals(method.getName())) { + continue; + } + Class[] parameterTypes = method.getParameterTypes(); + if (parameterTypes.length != clazzes.length) { + continue; + } + boolean match = true; + for (int i = 0; i < parameterTypes.length; i++) { + boolean isNull = (clazzes[i] == null); + boolean isPrimitive = isPrimitiveWrapper(clazzes[i], parameterTypes[i]); + boolean isAssignable = isNull? false : parameterTypes[i].isAssignableFrom(clazzes[i]); + if ( isNull || isPrimitive || isAssignable ) { + continue; + } + match = false; + } + if (match) { + matchMethods.add(method); + } + } + + int size = matchMethods.size(); + if (size == 1) { + // Only one method matches, just invoke it + return matchMethods.get(0); + } else if (size == 0) { + // Does not find any matching one, throw exception + throw new NoSuchMethodException(Messages.getString( + "beans.41", methodName)); //$NON-NLS-1$ + } + + // There are more than one method matching the signature + // Find the most specific one to invoke + MethodComparator comparator = new MethodComparator(methodName, + clazzes); + Method chosenOne = matchMethods.get(0); + matchMethods.remove(0); + for (Method method : matchMethods) { + int difference = comparator.compare(chosenOne, method); + if (difference > 0) { + chosenOne = method; + } else if (difference == 0) { + // if 2 methods have same relevance, throw exception + throw new NoSuchMethodException(Messages.getString( + "beans.62", methodName)); //$NON-NLS-1$ + } + } + return chosenOne; + } + + private boolean isPrimitiveWrapper(Class wrapper, Class base) { + return (base == boolean.class) && (wrapper == Boolean.class) + || (base == byte.class) && (wrapper == Byte.class) + || (base == char.class) && (wrapper == Character.class) + || (base == short.class) && (wrapper == Short.class) + || (base == int.class) && (wrapper == Integer.class) + || (base == long.class) && (wrapper == Long.class) + || (base == float.class) && (wrapper == Float.class) + || (base == double.class) && (wrapper == Double.class); + } + private String capitalize(String str) { StringBuffer buf = new StringBuffer(str); buf.setCharAt(0, Character.toUpperCase(buf.charAt(0))); Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties (original) +++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties Mon Jul 14 02:43:27 2008 @@ -113,3 +113,4 @@ beans.5F=Indexed write method must take a two arguments beans.60=Indexed write method must take an int as its first argument beans.61=Indexed write method is not compatible with indexed read method +beans.62=Cannot decide which method to call to match {0} Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java Mon Jul 14 02:43:27 2008 @@ -24,6 +24,7 @@ import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.util.HashMap; import java.util.Vector; import java.lang.reflect.Array; @@ -33,6 +34,7 @@ import org.apache.harmony.beans.tests.java.beans.EncoderTest.SampleBean; import org.apache.harmony.beans.tests.java.beans.XMLEncoderTest.DependencyBean; +import org.apache.harmony.beans.tests.support.MockOwnerClass; import org.apache.harmony.beans.tests.support.mock.MockBean4Codec; import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Owner; import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Target; @@ -254,6 +256,34 @@ assertEquals(1, o1.getV()); assertEquals(o1, t1.getV()); } + + public void testReadObject_Owner_Specific(){ + String expectedValue = "expected value"; + HashMap map = new HashMap(); + map.put("key", expectedValue); + + XMLDecoder decoder = new XMLDecoder(this.getClass().getResourceAsStream( + "/xml/MockOwner.xml"), map); + String actualValue = (String) decoder.readObject(); + assertEquals(expectedValue,actualValue); + + MockOwnerClass mock = new MockOwnerClass(); + expectedValue = "I_Ljava.lang.String"; + decoder = new XMLDecoder(this.getClass().getResourceAsStream( + "/xml/MockOwner_Specific.xml"), mock); + actualValue = (String) decoder.readObject(); + assertEquals(expectedValue,actualValue); + + decoder = new XMLDecoder(this.getClass().getResourceAsStream( + "/xml/MockOwner_Ambiguous.xml"), mock); + actualValue = (String) decoder.readObject(); + assertNull(actualValue); + + decoder = new XMLDecoder(this.getClass().getResourceAsStream( + "/xml/MockOwner_Null.xml"), mock); + actualValue = (String) decoder.readObject(); + assertNull(actualValue); + } public void testReadObject_Owner_WithWriteStatement() { MockBean4Owner_Owner o2 = new MockBean4Owner_Owner(); Modified: harmony/enhanced/classlib/branches/java6/modules/imageio/src/main/native/pngencoder/unix/makefile URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/imageio/src/main/native/pngencoder/unix/makefile?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/imageio/src/main/native/pngencoder/unix/makefile (original) +++ harmony/enhanced/classlib/branches/java6/modules/imageio/src/main/native/pngencoder/unix/makefile Mon Jul 14 02:43:27 2008 @@ -32,6 +32,10 @@ OSLIBS += $(STDCLIBS) +ifeq ($(HY_OS),zos) +MDLLIBFILES += $(MDLLIBZLIB) +endif + DLLNAME=../libpngencoder$(HY_SHLIB_SUFFIX) EXPNAME=HYPNGENCODER_0.1 Modified: harmony/enhanced/classlib/branches/java6/modules/imageio/src/test/java/javax/imageio/stream/ImageInputStreamImplTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/imageio/src/test/java/javax/imageio/stream/ImageInputStreamImplTest.java?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/imageio/src/test/java/javax/imageio/stream/ImageInputStreamImplTest.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/imageio/src/test/java/javax/imageio/stream/ImageInputStreamImplTest.java Mon Jul 14 02:43:27 2008 @@ -26,7 +26,7 @@ public void testReadLine() throws IOException { final ImageInputStream in = new BasicImageInputStreamImpl( - "line1\nline2\rline3\r\nline4".getBytes()); + "line1\nline2\rline3\r\nline4".getBytes("ISO8859_1")); assertEquals("line1", in.readLine()); assertEquals("line2", in.readLine()); Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/META-INF/MANIFEST.MF?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/META-INF/MANIFEST.MF (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/META-INF/MANIFEST.MF Mon Jul 14 02:43:27 2008 @@ -28,6 +28,7 @@ java.text;resolution:=optional, java.util, java.util.jar, + java.util.regex, java.util.zip;resolution:=optional, javax.accessibility;resolution:=optional, javax.net, Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties Mon Jul 14 02:43:27 2008 @@ -160,7 +160,6 @@ jndi.8E=Cannot create new entry under schema root jndi.8F=Class definition doesn'thave a numeric OID jndi.90={0} does not have a syntax associated with it -jndi.err.00=. The stack trace of the root exception is: ldap.00=Should not be null ldap.01=is not an LdapName ldap.02=Posn must be in the range [0,size()] @@ -219,3 +218,4 @@ ldap.36=Must have numeric OID ldap.37=Can't delete schema root ldap.38=Can't modify schema root +ldap.39=Can't rename schema Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapAttribute.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapAttribute.java?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapAttribute.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapAttribute.java Mon Jul 14 02:43:27 2008 @@ -1,4 +1,4 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -45,20 +45,10 @@ private static final long serialVersionUID = -6492847268062616321L; /** - * TODO: when to initialize it? - */ - private DirContext attributeDefinition = null; - - /** - * TODO: when to initialize it? - */ - private DirContext attributeSyntaxDefinition = null; - - /** * whether the value of attribute is binary */ private boolean isBinary; - + private LdapContextImpl context = null; private static HashSet BINARY_ATTRIBUTE = new HashSet(); @@ -92,7 +82,7 @@ isBinary = isBinary(id); context = ctx; } - + void setContext(LdapContextImpl ctx) { context = ctx; } @@ -112,9 +102,6 @@ Object value = enu.next(); add(value); } - - attributeDefinition = null; - attributeSyntaxDefinition = null; context = ctx; } @@ -155,37 +142,35 @@ @Override public DirContext getAttributeDefinition() throws NamingException { - if (attributeDefinition != null) { - return attributeDefinition; - } - attributeDefinition = context - .getSchemaAttributeDefinition(getID()); - return attributeDefinition; + DirContext schema = context.getSchema(""); //$NON-NLS-1$ + + return (DirContext) schema + .lookup(LdapSchemaContextImpl.ATTRIBUTE_DEFINITION + + "/" + getID()); //$NON-NLS-1$ } @Override public DirContext getAttributeSyntaxDefinition() throws NamingException { - if (attributeSyntaxDefinition != null) { - return attributeSyntaxDefinition; - } - // get the syntax id from the attribute def - DirContext schema = context.getSchema(""); - DirContext attrDef = (DirContext)schema.lookup( - LdapSchemaContextImpl.ATTRIBUTE_DEFINITION + "/" + getID()); + DirContext schema = context.getSchema(""); //$NON-NLS-1$ + DirContext attrDef = (DirContext) schema + .lookup(LdapSchemaContextImpl.ATTRIBUTE_DEFINITION + "/" //$NON-NLS-1$ + + getID()); - Attribute syntaxAttr = attrDef.getAttributes("").get("syntax"); + Attribute syntaxAttr = attrDef.getAttributes("").get("syntax"); //$NON-NLS-1$ //$NON-NLS-2$ if (syntaxAttr == null || syntaxAttr.size() == 0) { - throw new NameNotFoundException(Messages.getString("jndi.90", + // jndi.90={0} does not have a syntax associated with it + throw new NameNotFoundException(Messages.getString("jndi.90", //$NON-NLS-1$ getID())); } - String syntaxName = (String)syntaxAttr.get(); + String syntaxName = (String) syntaxAttr.get(); // look in the schema tree for the syntax definition - return (DirContext)schema.lookup( - LdapSchemaContextImpl.SYNTAX_DEFINITION + "/" + syntaxName); - + return (DirContext) schema + .lookup(LdapSchemaContextImpl.SYNTAX_DEFINITION + "/" //$NON-NLS-1$ + + syntaxName); + } private static boolean isBinary(String name) { Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java Mon Jul 14 02:43:27 2008 @@ -416,8 +416,11 @@ if (element.getID().equalsIgnoreCase("objectClass")) { element = mergeAttribute(resultAttributes .get("objectClass"), element); - if (resultAttributes.get("objectClass") != null) { - element.remove("javaContainer"); + Attribute oc = resultAttributes.get("objectClass"); + if (oc != null) { + if (!oc.contains("javaContainer") && oc.size() > 0) { + element.remove("javaContainer"); + } } resultAttributes.put(element); } else if (resultAttributes.get(element.getID()) == null) { @@ -760,8 +763,6 @@ return getAttributes(convertFromStringToName(s), as); } - public static Hashtable>> schemaTree = new Hashtable>>(); - private Hashtable schemaTable = new Hashtable(); private LdapSchemaContextImpl ldapSchemaCtx = null; @@ -874,15 +875,10 @@ while (ids.hasMoreElements()) { String schemaType = ids.nextElement(); - if (!schemaTree.contains(schemaType.toLowerCase())) { - schemaTree.put(schemaType.toLowerCase(), - new Hashtable>()); - + if (!schemaTable.contains(schemaType.toLowerCase())) { schemaTable.put(schemaType.toLowerCase(), new Hashtable()); } - Hashtable> schemaDefs = schemaTree - .get(schemaType.toLowerCase()); Hashtable schemaDef = (Hashtable) schemaTable .get(schemaType.toLowerCase()); @@ -894,10 +890,7 @@ value = (String) attribute.get(i); attrName = SchemaParser.getName(value); schemaDef.put(attrName.toLowerCase(), value); - - parseValue(schemaType, value.toLowerCase(), schemaDefs); } - } } @@ -906,219 +899,19 @@ return ldapSchemaCtx; } - Hashtable findSchemaDefInfo(String schemaType, - String className) { - Hashtable> schemaDefs = schemaTree - .get(schemaType); - Hashtable schemaDef = schemaDefs.get(className); - return schemaDef; - } - - /* - * Sample schema value from Openldap server is ( 2.5.13.8 NAME - * 'numericStringMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 ) - * - * TODO check with RFC to see whether all the schema definition has been - * catered for - */ - private static void parseValue(String schemaType, String value, - Hashtable> schemaDefs) { - StringTokenizer st = new StringTokenizer(value.toLowerCase()); - // Skip ( - st.nextToken(); - - String oid = st.nextToken(); - - Hashtable schemaDef = new Hashtable(); - schemaDef.put("orig", value); - schemaDef.put("numericoid", oid); - String token = null; - ArrayList values = null; - StringBuilder desc = new StringBuilder(); - while (st.hasMoreTokens()) { - String attrName = st.nextToken(); - if (attrName.startsWith("x-")) { - token = st.nextToken(); - // remove the ending ' symbol - token = token.substring(1, token.length() - 1); - schemaDef.put(attrName, token); - } - if (attrName.startsWith("auxiliary")) { - schemaDef.put(attrName, "true"); - } - if (attrName.startsWith("structural")) { - schemaDef.put(attrName, "true"); - } - if (attrName.equals("usage") || attrName.equals("equality") - || attrName.equals("syntax") || attrName.equals("ordering") - || attrName.equals("substr")) { - token = st.nextToken(); - schemaDef.put(attrName, token); - } - if (attrName.equals("desc")) { - token = st.nextToken(); - - // remove the leading ' symbol - if (token.startsWith("'")) - token = token.substring(1); - while (!token.endsWith("'")) { - desc.append(token).append(" "); - token = st.nextToken(); - } - - // remove the ending ' symbol - desc.append(token.substring(0, token.length() - 1)); - schemaDef.put(attrName, desc.toString()); - desc.delete(0, desc.length()); - } - if (attrName.equals("name")) { - token = st.nextToken(); - values = new ArrayList(); - // Name has multiple values - if (token.startsWith("(")) { - token = st.nextToken(); - while (!token.equals(")")) { - // remove the leading ' symbol - if (token.startsWith("'")) - token = token.substring(1); - while (!token.endsWith("'")) { - desc.append(token).append(" "); - token = st.nextToken(); - } - - // remove the ending ' symbol - desc.append(token.substring(0, token.length() - 1)); - values.add(desc.toString()); - desc.delete(0, desc.length()); - - token = st.nextToken(); - } - } else { - // remove the leading ' symbol - if (token.startsWith("'")) - token = token.substring(1); - while (!token.endsWith("'")) { - desc.append(token).append(" "); - token = st.nextToken(); - } - - // remove the ending ' symbol - desc.append(token.substring(0, token.length() - 1)); - values.add(desc.toString()); - desc.delete(0, desc.length()); - } - schemaDef.put(attrName, values); - if (schemaType - .equalsIgnoreCase(LdapSchemaContextImpl.LDAP_SYNTAXES)) { - schemaDefs.put(oid, schemaDef); - } else { - schemaDefs.put(values.get(0), schemaDef); - } - } - if (attrName.equals("must") || attrName.equals("sup") - || attrName.equals("may")) { - token = st.nextToken(); - values = new ArrayList(); - // has multiple values - if (token.startsWith("(")) { - token = st.nextToken(); - while (!token.equals(")")) { - if (!token.equals("$")) - values.add(token); - token = st.nextToken(); - } - } else { - values.add(token); - } - schemaDef.put(attrName, values); - } - if (attrName.equals("abstract") || attrName.equals("structual") - || attrName.equals("auxiliary") - || attrName.equals("single-value") - || attrName.equals("no-user-modification")) { - schemaDef.put(attrName, "true"); - } - } - if (!schemaDef.keySet().contains("name")) { - schemaDefs.put(oid, schemaDef); - } - } - public DirContext getSchema(String s) throws NamingException { return getSchema(new CompositeName(s)); } - DirContext getSchemaAttributeDefinition(String name) throws NamingException { - if (null == ldapSchemaCtx) { - getSchema(""); - } - Hashtable attrDef = findSchemaDefInfo( - LdapSchemaContextImpl.ATTRIBUTE_TYPES, name); - - return new LdapSchemaAttrDefContextImpl(new CompositeName(name), env, - attrDef, this); - } - public DirContext getSchemaClassDefinition(Name name) throws NamingException { - checkName(name); + Attributes attrs = getAttributes(name, new String[] { "objectClass" }); //$NON-NLS-1$ + Attribute attr = attrs.get("objectClass"); //$NON-NLS-1$ if (null == ldapSchemaCtx) { - getSchema(""); - } - - Hashtable> classTree = new Hashtable>(); - - SearchControls searchControls = new SearchControls(); - searchControls.setSearchScope(SearchControls.OBJECT_SCOPE); - searchControls.setReturningAttributes(new String[] { "objectClass", }); - searchControls.setReturningObjFlag(false); - FilterParser parser = new FilterParser("(objectClass=*)"); - Filter filter = null; - try { - filter = parser.parse(); - } catch (ParseException e1) { - // Should not throw this excption - } - String targetDN = getTargetDN(name, contextDn); - SearchOp search = new SearchOp(targetDN, searchControls, filter); - - try { - client.doOperation(search, requestControls); - } catch (IOException e) { - CommunicationException ex = new CommunicationException(e - .getMessage()); - ex.setRootCause(e); - if (search.getSearchResult().isEmpty()) { - throw ex; - } - search.getSearchResult().setException(ex); - } - LdapSearchResult sre = search.getSearchResult(); - Map names = sre.getEntries(); - - Set keyset = names.keySet(); - for (Iterator iterator = keyset.iterator(); iterator.hasNext();) { - String key = iterator.next(); - Attributes as = names.get(key); - NamingEnumeration ids = as.getIDs(); - - while (ids.hasMoreElements()) { - String schemaType = ids.nextElement(); - if (!classTree.contains(schemaType)) { - classTree.put(schemaType, new ArrayList()); - } - ArrayList classDefs = classTree.get(schemaType); - LdapAttribute attribute = (LdapAttribute) as.get(schemaType); - for (int i = 0; i < attribute.size(); i++) { - String value = (String) attribute.get(i); - classDefs.add(value); - } - } + getSchema(""); //$NON-NLS-1$ } - - return new LdapSchemaClassDefContextImpl(new CompositeName(targetDN), - env, classTree, this); + return ldapSchemaCtx.getClassDefinition(attr); } public DirContext getSchemaClassDefinition(String s) throws NamingException { Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextImpl.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextImpl.java?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextImpl.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextImpl.java Mon Jul 14 02:43:27 2008 @@ -16,14 +16,11 @@ */ package org.apache.harmony.jndi.provider.ldap; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Set; -import java.util.TreeSet; import javax.naming.Binding; import javax.naming.CompositeName; @@ -42,39 +39,35 @@ import javax.naming.directory.BasicAttribute; import javax.naming.directory.BasicAttributes; import javax.naming.directory.DirContext; -import javax.naming.directory.InvalidSearchFilterException; import javax.naming.directory.ModificationItem; import javax.naming.directory.SchemaViolationException; import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; import org.apache.harmony.jndi.internal.nls.Messages; -import org.apache.harmony.jndi.internal.parser.AttributeTypeAndValuePair; -import org.apache.harmony.jndi.provider.ldap.parser.FilterParser; -import org.apache.harmony.jndi.provider.ldap.parser.ParseException; import org.apache.harmony.jndi.provider.ldap.parser.SchemaParser; public class LdapSchemaContextImpl extends LdapContextImpl { - public static final String CLASS_DEFINITION = "ClassDefinition"; + public static final String CLASS_DEFINITION = "ClassDefinition"; //$NON-NLS-1$ - public static final String ATTRIBUTE_DEFINITION = "AttributeDefinition"; + public static final String ATTRIBUTE_DEFINITION = "AttributeDefinition"; //$NON-NLS-1$ - public static final String SYNTAX_DEFINITION = "SyntaxDefinition"; + public static final String SYNTAX_DEFINITION = "SyntaxDefinition"; //$NON-NLS-1$ - public static final String MATCHING_RULE = "MatchingRule"; + public static final String MATCHING_RULE = "MatchingRule"; //$NON-NLS-1$ - public static final String OBJECT_CLASSES = "objectclasses"; + public static final String OBJECT_CLASSES = "objectclasses"; //$NON-NLS-1$ - public static final String ATTRIBUTE_TYPES = "attributetypes"; + public static final String ATTRIBUTE_TYPES = "attributetypes"; //$NON-NLS-1$ - public static final String LDAP_SYNTAXES = "ldapsyntaxes"; + public static final String LDAP_SYNTAXES = "ldapsyntaxes"; //$NON-NLS-1$ - public static final String MATCHING_RULES = "matchingrules"; + public static final String MATCHING_RULES = "matchingrules"; //$NON-NLS-1$ public static final int SCHEMA_ROOT_LEVEL = 3; - protected String subschemasubentry = null; + public static final int DEFINITION_LEVEL = 2; final private static Hashtable schemaJndi2Ldap = new Hashtable(); static { @@ -93,7 +86,7 @@ schemaLdap2Jndi.put(MATCHING_RULES, MATCHING_RULE); } - private LdapContextImpl parent; + private LdapContextImpl ldapContext; private Hashtable schemaTable; @@ -102,18 +95,11 @@ private int level; public LdapSchemaContextImpl(LdapContextImpl ctx, - Hashtable env, Name dn) throws InvalidNameException { - super(ctx, env, dn.getPrefix(0).toString()); - parent = ctx; - rdn = dn; - } - - public LdapSchemaContextImpl(LdapContextImpl ctx, Hashtable env, Name dn, Hashtable schemaTable, int level) throws InvalidNameException { super(ctx, env, dn.getPrefix(0).toString()); - parent = ctx; + ldapContext = ctx; rdn = dn; this.schemaTable = schemaTable; this.level = level; @@ -171,12 +157,12 @@ String schemaLine = SchemaParser.format(attributes); - ModifyOp op = new ModifyOp(parent.subschemasubentry); + ModifyOp op = new ModifyOp(ldapContext.subschemasubentry); Name modifySchemaName = name.getPrefix(size - 1).addAll(rdn); BasicAttribute schemaEntry = new LdapAttribute(new BasicAttribute( - jndi2ldap(modifySchemaName.toString()), schemaLine), parent); - op.addModification(jndi2ldap[DirContext.ADD_ATTRIBUTE], - new LdapAttribute(schemaEntry, parent)); + jndi2ldap(modifySchemaName.toString()), schemaLine), ldapContext); + op.addModification(OperationJndi2Ldap[DirContext.ADD_ATTRIBUTE], + new LdapAttribute(schemaEntry, ldapContext)); try { doBasicOperation(op); subSchemaTree.put(subSchemaType.toLowerCase(), schemaLine); @@ -185,14 +171,12 @@ } return (DirContext) lookup(name); - } @Override public DirContext createSubcontext(String name, Attributes attributes) throws NamingException { - Name n = convertFromStringToName(name); - return createSubcontext(n, attributes); + return createSubcontext(new CompositeName(name), attributes); } @Override @@ -256,10 +240,8 @@ } @Override - public Attributes getAttributes(String attributeName) - throws NamingException { - Name name = new CompositeName(attributeName); - return getAttributes(name); + public Attributes getAttributes(String name) throws NamingException { + return getAttributes(new CompositeName(name)); } @Override @@ -268,17 +250,14 @@ return getAttributes(new CompositeName(name), as); } - private void checkName(Name name) { + @Override + public void modifyAttributes(Name name, int i, Attributes attributes) + throws NamingException { if (name == null) { // jndi.2E=The name is null throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$ } - } - - @Override - public void modifyAttributes(Name name, int i, Attributes attributes) - throws NamingException { - checkName(name); + if (attributes == null) { // jndi.13=Non-null attribute is required for modification throw new NullPointerException(Messages.getString("jndi.13")); //$NON-NLS-1$ @@ -304,7 +283,8 @@ modifyAttributes(name, items); } - private static final int jndi2ldap[] = { -1, 0, 2, 1, }; + // Mapping from DirContext's attribute operation code to server's operation code. + private static final int OperationJndi2Ldap[] = { -1, 0, 2, 1, }; @Override public void modifyAttributes(Name name, ModificationItem[] modificationItems) @@ -333,7 +313,7 @@ String schemaLine = schema.toString(); if (schema instanceof Hashtable) { - Hashtable table = (Hashtable) schema; + Hashtable table = (Hashtable) schema; schemaLine = table.get(SchemaParser.ORIG).toString(); } @@ -383,16 +363,16 @@ String newSchemaLine = SchemaParser.format(attributes); // Remove old schema, then add new schema. - ModifyOp op = new ModifyOp(parent.subschemasubentry); + ModifyOp op = new ModifyOp(ldapContext.subschemasubentry); Name modifySchemaName = name.getPrefix(size - 1).addAll(rdn); BasicAttribute schemaEntry = new LdapAttribute(new BasicAttribute( - jndi2ldap(modifySchemaName.toString()), schemaLine), parent); - op.addModification(jndi2ldap[DirContext.REMOVE_ATTRIBUTE], - new LdapAttribute(schemaEntry, parent)); + jndi2ldap(modifySchemaName.toString()), schemaLine), ldapContext); + op.addModification(OperationJndi2Ldap[DirContext.REMOVE_ATTRIBUTE], + new LdapAttribute(schemaEntry, ldapContext)); BasicAttribute addSchemaEntry = new LdapAttribute(new BasicAttribute( - jndi2ldap(modifySchemaName.toString()), newSchemaLine), parent); - op.addModification(jndi2ldap[DirContext.ADD_ATTRIBUTE], - new LdapAttribute(addSchemaEntry, parent)); + jndi2ldap(modifySchemaName.toString()), newSchemaLine), ldapContext); + op.addModification(OperationJndi2Ldap[DirContext.ADD_ATTRIBUTE], + new LdapAttribute(addSchemaEntry, ldapContext)); doBasicOperation(op); subSchemaTree.remove(subSchemaType); @@ -400,29 +380,25 @@ } @Override - public void modifyAttributes(String s, int i, Attributes attributes) + public void modifyAttributes(String name, int i, Attributes attributes) throws NamingException { - Name name = convertFromStringToName(s); - modifyAttributes(name, i, attributes); + modifyAttributes(new CompositeName(name), i, attributes); } @Override - public void modifyAttributes(String s, ModificationItem[] modificationItems) - throws NamingException { - Name name = convertFromStringToName(s); - modifyAttributes(name, modificationItems); + public void modifyAttributes(String name, + ModificationItem[] modificationItems) throws NamingException { + modifyAttributes(new CompositeName(name), modificationItems); } @Override public Context createSubcontext(Name name) throws NamingException { - DirContext subContext = createSubcontext(name, null); - return subContext; + return createSubcontext(name, null); } @Override public Context createSubcontext(String name) throws NamingException { - Name n = convertFromStringToName(name); - return createSubcontext(n); + return createSubcontext(new CompositeName(name)); } @Override @@ -452,16 +428,16 @@ String schemaLine = schema.toString(); if (schema instanceof Hashtable) { - Hashtable table = (Hashtable) schema; + Hashtable table = (Hashtable) schema; schemaLine = table.get(SchemaParser.ORIG).toString(); } - ModifyOp op = new ModifyOp(parent.subschemasubentry); + ModifyOp op = new ModifyOp(ldapContext.subschemasubentry); Name modifySchemaName = name.getPrefix(size - 1).addAll(rdn); BasicAttribute schemaEntry = new LdapAttribute(new BasicAttribute( - jndi2ldap(modifySchemaName.toString()), schemaLine), parent); - op.addModification(jndi2ldap[DirContext.REMOVE_ATTRIBUTE], - new LdapAttribute(schemaEntry, parent)); + jndi2ldap(modifySchemaName.toString()), schemaLine), ldapContext); + op.addModification(OperationJndi2Ldap[DirContext.REMOVE_ATTRIBUTE], + new LdapAttribute(schemaEntry, ldapContext)); try { doBasicOperation(op); subSchemaTree.remove(subSchemaType); @@ -472,25 +448,7 @@ @Override public void destroySubcontext(String name) throws NamingException { - destroySubcontext(convertFromStringToName(name)); - } - - private String ldap2jndi(String jndiName) { - String ldapName = schemaLdap2Jndi.get(jndiName); - if (null == ldapName) { - ldapName = jndiName; - } - - return ldapName; - } - - private String jndi2ldap(String ldapName) { - String jndiName = schemaJndi2Ldap.get(ldapName.toLowerCase()); - if (null == jndiName) { - jndiName = ldapName; - } - - return jndiName.toLowerCase(); + destroySubcontext(new CompositeName(name)); } @Override @@ -520,11 +478,6 @@ @Override protected Name convertFromStringToName(String s) throws InvalidNameException { - if (s == null) { - // jndi.2E=The name is null - throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$ - } - CompositeName name = new CompositeName(s); return name; } @@ -532,7 +485,7 @@ @Override public NamingEnumeration list(String name) throws NamingException { - return list(convertFromStringToName(name)); + return list(new CompositeName(name)); } @Override @@ -562,7 +515,7 @@ @Override public NamingEnumeration listBindings(String name) throws NamingException { - return listBindings(convertFromStringToName(name)); + return listBindings(new CompositeName(name)); } private Hashtable cachedSubSchemas = new Hashtable(); @@ -582,7 +535,7 @@ Hashtable newSchemaTable = doLookup(name, size); - cachedSchema = new LdapSchemaContextImpl(parent, env, targetDN, + cachedSchema = new LdapSchemaContextImpl(ldapContext, env, targetDN, newSchemaTable, level - size); cachedSubSchemas.put(targetDN, cachedSchema); @@ -621,303 +574,280 @@ @Override public Object lookup(String name) throws NamingException { - return lookup(convertFromStringToName(name)); + return lookup(new CompositeName(name)); } + @Override public void rename(Name nOld, Name nNew) throws NamingException { - throw new SchemaViolationException(Messages.getString("jndi.err.01")); + // ldap.39=Can't rename schema + throw new SchemaViolationException(Messages.getString("ldap.39")); //$NON-NLS-1$ } + @Override public void rename(String sOld, String sNew) throws NamingException { - throw new SchemaViolationException(Messages.getString("jndi.err.01")); + // ldap.39=Can't rename schema + throw new SchemaViolationException(Messages.getString("ldap.39")); //$NON-NLS-1$ } + @Override public NamingEnumeration search(Name name, Attributes attributes) throws NamingException { return search(name, attributes, null); } + @Override public NamingEnumeration search(Name name, - // Used to filter attribute value - Attributes attributes, - // Used to filter attribute name - String[] as) throws NamingException { - checkName(name); - - Name targetDN = name.addAll(rdn); - - /* - * Formalize attributes, change all ids to lowercase, if attributes is - * non-null - */ - - boolean hasMatchingAttributes = (null != attributes && 0 != attributes - .size()); - boolean hasAttributes2Return = (null != as && 0 != as.length); - - // Attribute matcher - BasicAttributes attrMatcher = new BasicAttributes(true); - if (hasMatchingAttributes) { - NamingEnumeration attrEnum = attributes - .getAll(); - while (attrEnum.hasMore()) { - Attribute old = attrEnum.next(); - BasicAttribute newAttr = new BasicAttribute(old.getID() - .toLowerCase()); - for (int i = 0; i < old.size(); i++) { - if (old.get(i) instanceof String) { - newAttr.add(((String) old.get(i)).toLowerCase()); - } else { - newAttr.add(old.get(i)); - } - } - attrMatcher.put(newAttr); - } - } + Attributes matchingAttributes, String[] attributesToReturn) + throws NamingException { + int size = name.size(); - // Attribute selector - TreeSet attrSel = new TreeSet(); + Hashtable subschemaTable = doLookup(name, size); - // Construct result NamingEnumeration LdapNamingEnumeration enumeration = new LdapNamingEnumeration( null, null); - String schemaType = null; + SearchResult searchResult; + Attributes schemaAttributes; + String schemaName; + Set keyset; - LinkedList attrValues = new LinkedList(); - int size = targetDN.size(); - switch (size) { - case 0: - /* - * Name is a empty string, search against root, may return schema - * types: (classdefinition, attributedefinition, syntaxdefinition, - * matchingrule) - */ - attrValues.addAll(LdapContextImpl.schemaTree.keySet()); - /* - * Filter attribute names - whether the single attribute name - * 'objectclass' is chosen. - */ - int objectclassIndex = -1; - if (hasAttributes2Return) { - for (int i = 0; i < as.length; i++) { - if (as[i].equalsIgnoreCase("objectclass")) { - objectclassIndex = i; - break; - } + if (level - size > 1) { + keyset = subschemaTable.keySet(); + for (Iterator i = keyset.iterator(); i.hasNext();) { + schemaName = ldap2jndi(i.next()); + Name tempName = (Name) name.clone(); + schemaAttributes = getAttributes(tempName.add(schemaName)); + + if (isMatch(schemaAttributes, matchingAttributes)) { + schemaAttributes = filterAttributes(schemaAttributes, + attributesToReturn); + searchResult = new SearchResult(ldap2jndi(schemaName), this + .getClass().getName(), null, schemaAttributes); + enumeration.add(searchResult); } } - attrSel.add("objectclass"); + } + return enumeration; + } - /* - * Filter attribute values - choose from (classdefinition, - * attributedefinition, syntaxdefinition, matchingrule) - */ - if (hasMatchingAttributes) { - Attribute attribute = attrMatcher.get("objectclass"); - if (null == attribute) { - return enumeration; - } - for (int i = 0; i < attrValues.size(); i++) { - schemaType = schemaLdap2Jndi.get(attrValues.get(i)); - /* - * RI's behavior is odd here - it only retrieves the first - * encountered attribute value, - */ - if (attribute.contains(schemaType)) { - BasicAttributes basicAttributes = new BasicAttributes( - true); - /* - * if(objectclassIndex == -1), then No name was choose, - * which means SearchResult will have empty - * BasicAttributes. - */ - if (objectclassIndex != -1) { - basicAttributes.put("objectclass", schemaType); - } - SearchResult pair = new SearchResult(schemaType, null, - basicAttributes); - enumeration.add(pair); - break; - } - } - } else { - for (int i = 0; i < attrValues.size(); i++) { - schemaType = schemaLdap2Jndi.get(attrValues.get(i)); - BasicAttributes basicAttributes = new BasicAttributes(true); - /* - * if(objectclassIndex == -1), then No name was choose, - * which means SearchResult will have empty BasicAttributes. - */ - if (objectclassIndex != -1) { - basicAttributes.put("objectclass", schemaType); - } - SearchResult pair = new SearchResult(schemaType, null, - basicAttributes); - enumeration.add(pair); - } - } - break; - case 1: - if (hasAttributes2Return) { - attrSel.addAll(Arrays.asList(as)); - } - schemaType = schemaJndi2Ldap.get(name.get(0).toLowerCase()); - if (null == schemaType) { - throw new NameNotFoundException(name.toString()); - } - Hashtable> schemas = LdapContextImpl.schemaTree - .get(schemaType); - attrValues.addAll(schemas.keySet()); - BasicAttributes basicAttributes = null; - if (hasMatchingAttributes) { - for (int i = 0; i < attrValues.size(); i++) { - NamingEnumeration filters = attrMatcher.getAll(); - String id = attrValues.get(i); - Hashtable schemaDef = schemas.get(id); - boolean matched = true; - while (filters.hasMore()) { - Attribute filter = filters.next(); - Object values = schemaDef.get(filter.getID()); - /* - * Attribute definition will only be retrieved when it - * is designated in attrFilter - */ - if (values == null || !match(filter, values)) { - matched = false; - break; - } - } - if (matched) { - basicAttributes = new BasicAttributes(true); - for (Iterator iterator = schemaDef.keySet() - .iterator(); iterator.hasNext();) { - String key = iterator.next(); - if (key.equals("orig")) { - continue; - } - if (hasAttributes2Return && attrSel.contains(key) - || !hasAttributes2Return) { - basicAttributes.put(key, schemaDef.get(key)); - } - } - SearchResult pair = new SearchResult(id, null, - basicAttributes); - enumeration.add(pair); - } + @Override + public NamingEnumeration search(Name name, String filter, + SearchControls searchControls) throws NamingException { + return search(name, filter, null, searchControls); + } + + @Override + public NamingEnumeration search(Name name, String filter, + Object[] filterArgs, SearchControls searchControls) + throws NamingException { + + HashSet searchResults = new HashSet(); + Iterator iterator; + SearchResult searchResult; + + Attributes schemaAttributes; + + // Default search scope is ONELEVEL_SCOPE. + if (searchControls == null + || searchControls.getSearchScope() == SearchControls.ONELEVEL_SCOPE) { + searchResults = doSimpleSearch(name, false); + + } + // SearchControls.SUBTREE_SCOPE + else if (searchControls.getSearchScope() == SearchControls.SUBTREE_SCOPE) { + searchResults = doSimpleSearch(name, true); + } + + // SearchControls.OBJECT_SCOPE. + else { + schemaAttributes = getAttributes(name); + searchResult = new SearchResult(ldap2jndi(name.toString()), this + .getClass().getName(), null, schemaAttributes); + searchResults.add(searchResult); + } + + LdapSchemaFilter schemaFilter = new LdapSchemaFilter(filter, filterArgs); + searchResults = schemaFilter.filter(searchResults); + + if (searchControls != null + && searchControls.getReturningAttributes() != null) { + String[] attributesToReturn = searchControls + .getReturningAttributes(); + // Take the 0 as special case to improve perfomance. + if (attributesToReturn.length > 0) { + iterator = searchResults.iterator(); + while (iterator.hasNext()) { + searchResult = iterator.next(); + schemaAttributes = filterAttributes(searchResult + .getAttributes(), attributesToReturn); + searchResult.setAttributes(schemaAttributes); } } else { - for (int i = 0; i < attrValues.size(); i++) { - Hashtable schemaDef = schemas - .get(attrValues.get(i)); - basicAttributes = new BasicAttributes(true); - for (Iterator iterator = schemaDef.keySet() - .iterator(); iterator.hasNext();) { - String key = iterator.next(); - if (key.equals("orig")) { - continue; - } - if (hasAttributes2Return && attrSel.contains(key) - || !hasAttributes2Return) { - basicAttributes.put(key, schemaDef.get(key)); - } - } - SearchResult pair = new SearchResult(attrValues.get(i), - null, basicAttributes); - enumeration.add(pair); + iterator = searchResults.iterator(); + while (iterator.hasNext()) { + searchResult = iterator.next(); + searchResult.setAttributes(new BasicAttributes(true)); } } - break; + } - default: - schemaType = schemaJndi2Ldap.get(name.getPrefix(1).toString() - .toLowerCase()); - if (null == schemaType) { - throw new NameNotFoundException(name.toString()); - } - search(name.getSuffix(1), attributes, as); + LdapNamingEnumeration enumeration = new LdapNamingEnumeration( + null, null); + + iterator = searchResults.iterator(); + while (iterator.hasNext()) { + enumeration.add(iterator.next()); } + return enumeration; + } + + @Override + public NamingEnumeration search(String name, Attributes attributes, String[] as) throws NamingException { + return search(new CompositeName(name), attributes, as); + } + @Override + public NamingEnumeration search(String name, Attributes attributes) throws NamingException { + return search(new CompositeName(name), attributes); } - private boolean match(Attribute filter, Object values) + @Override + public NamingEnumeration search(String name, String filter, Object[] objs, SearchControls searchControls) throws NamingException { + return search(new CompositeName(name), filter, objs, searchControls); + } + + @Override + public NamingEnumeration search(String name, String filter, SearchControls searchControls) throws NamingException { + return search(new CompositeName(name), filter, searchControls); + } + + protected DirContext getClassDefinition(Attribute objectclassAttr) throws NamingException { - NamingEnumeration attrValues = filter.getAll(); - ArrayList v = null; - if (values instanceof ArrayList) { - v = (ArrayList) values; - } else { - v = new ArrayList(); - v.add(values); + Hashtable definitionTable = new Hashtable(); + Hashtable allDefinitionTable = (Hashtable) schemaTable + .get(OBJECT_CLASSES); + + if (objectclassAttr != null) { + NamingEnumeration ne = objectclassAttr.getAll(); + String attributeType; + while (ne.hasMore()) { + attributeType = ne.next().toString().toLowerCase(); + definitionTable.put(attributeType, allDefinitionTable + .get(attributeType)); + } + } + + return new LdapSchemaContextImpl(this, env, new CompositeName( + OBJECT_CLASSES), definitionTable, + LdapSchemaContextImpl.DEFINITION_LEVEL); + } + + private HashSet doSimpleSearch(Name name, + boolean searchSubTree) throws NamingException { + int size = name.size(); + Hashtable subschemaTable = doLookup(name, size); + + HashSet searchResults = new HashSet(); + HashSet tempResults; + SearchResult searchResult; + Attributes schemaAttributes; + String schemaName; + Set keyset; + + keyset = subschemaTable.keySet(); + for (Iterator i = keyset.iterator(); i.hasNext();) { + schemaName = ldap2jndi(i.next()); + Name tempName = (Name) name.clone(); + tempName = tempName.add(schemaName); + if (tempName.size() < level) { + schemaAttributes = getAttributes(tempName); + searchResult = new SearchResult(tempName.toString(), this + .getClass().getName(), null, schemaAttributes); + searchResults.add(searchResult); + + if (searchSubTree) { + tempResults = doSimpleSearch(tempName, searchSubTree); + searchResults.addAll(tempResults); + } + } + } + return searchResults; + } + + private Attributes filterAttributes(Attributes attributes, + String[] attributesToReturn) { + if (attributesToReturn == null) { + return attributes; } - while (attrValues.hasMore()) { - Object attrValue = attrValues.next(); - for (int i = 0; i < v.size(); i++) { - if (attrValue.equals("*") || attrValue.equals(v.get(i))) { - return true; + Attribute attribute; + Attributes filteredAttrs = new BasicAttributes(true); + for (int i = 0; i < attributesToReturn.length; i++) { + if (attributesToReturn[i] != null) { + attribute = attributes.get(attributesToReturn[i]); + if (attribute != null) { + filteredAttrs.put(attribute); } } } - return false; + + return filteredAttrs; } - public NamingEnumeration search(Name name, String filter, - Object[] objs, SearchControls searchControls) - throws NamingException { + private boolean isMatch(Attributes schemaAttributes, + Attributes matchingAttributes) throws NamingException { + if (matchingAttributes == null) { + return true; + } - checkName(name); + NamingEnumeration enumeration = matchingAttributes + .getAll(); + Attribute matchAttribute; + Attribute schemaAttribute; + String id; + while (enumeration.hasMore()) { + matchAttribute = enumeration.next(); + id = matchAttribute.getID(); + schemaAttribute = schemaAttributes.get(id); + if (schemaAttribute == null) { + return false; + } - if (filter == null) { - throw new NullPointerException(Messages.getString("ldap.28")); //$NON-NLS-1$ - } - if (filter.length() == 0) { - throw new StringIndexOutOfBoundsException(); + NamingEnumeration singleEnu = matchAttribute.getAll(); + while (singleEnu.hasMore()) { + if (!schemaAttribute.contains(singleEnu.next())) { + return false; + } + } } - if (!filter.startsWith("(")) { - StringBuilder filterWrapper = new StringBuilder("("); - filterWrapper.append(filter).append(")"); - filter = filterWrapper.toString(); + + return true; + } + + // Convert ldap name to jndi name. + private String ldap2jndi(String jndiName) { + String ldapName = schemaLdap2Jndi.get(jndiName); + if (null == ldapName) { + ldapName = jndiName; } - if (null == searchControls) { - searchControls = new SearchControls(); + return ldapName; + } + + // Convert jndi name to ldap name. + private String jndi2ldap(String jndiName) { + // If the parameter indeed is ldapName, convert it to jndiName to avoid + // confusion. + String ldapName = schemaLdap2Jndi.get(jndiName); + if (null != ldapName) { + return ldapName; } - FilterParser filterParser = new FilterParser(filter); - filterParser.setArgs(objs); - Filter f = null; - try { - f = filterParser.parse(); - } catch (ParseException e) { - InvalidSearchFilterException ex = new InvalidSearchFilterException( - Messages.getString("ldap.29")); //$NON-NLS-1$ - ex.setRootCause(e); - throw ex; - } - - BasicAttributes matchingAttrs = new BasicAttributes(true); - extractMatchingAttributes(f, matchingAttrs); - - return search(name, matchingAttrs, searchControls - .getReturningAttributes()); - } - - private void extractMatchingAttributes(Filter f, - BasicAttributes matchingAttrs) { - if (!f.isLeaf()) { - List children = f.getChildren(); - for (Iterator iter = children.iterator(); iter.hasNext();) { - extractMatchingAttributes(iter.next(), matchingAttrs); - } - } else { - Object value = f.getValue(); - if (value instanceof AttributeTypeAndValuePair) { - AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) value; - matchingAttrs.put(pair.getType(), pair.getValue()); - } else { - matchingAttrs.put((String) value, "*"); - } + ldapName = schemaJndi2Ldap.get(jndiName.toLowerCase()); + if (null == ldapName) { + ldapName = jndiName; } + + return ldapName.toLowerCase(); } } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextImplTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextImplTest.java?rev=676530&r1=676529&r2=676530&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextImplTest.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextImplTest.java Mon Jul 14 02:43:27 2008 @@ -674,6 +674,74 @@ assertEquals("bind", attribute.get(0)); } + public void test_bind_LAttributes() throws Exception { + MockLdapClient client = new MockLdapClient(); + Hashtable env = new Hashtable(); + + context = new LdapContextImpl(client, env, "cn=test"); + + Attributes attrs = new BasicAttributes(); + attrs.put("objectClass", "cn"); + attrs.put("cn", "testBind"); + context.bind("cn=testBind", "object", attrs); + + AddOp op = (AddOp) client.getRequest(); + assertEquals("cn=testBind,cn=test", op.getEntry()); + List attrList = op.getAttributeList(); + // has attribute: objectClass, javaClassNames, javaClassName, + // javaSerializedData, cn + assertEquals(5, attrList.size()); + Map map = new HashMap(); + for (Iterator iter = attrList.iterator(); iter.hasNext();) { + LdapAttribute attr = (LdapAttribute) iter.next(); + map.put(attr.getID(), attr); + } + + assertTrue(map.containsKey("objectClass")); + Attribute attribute = map.get("objectClass"); + NamingEnumeration enu = attribute.getAll(); + HashSet valueSet = new HashSet(); + while (enu.hasMore()) { + valueSet.add(enu.next()); + } + // objectClass has values: top, cn, javaObject, + // javaSerializedObject + assertEquals(4, valueSet.size()); + assertTrue(valueSet.contains("top")); + assertTrue(valueSet.contains("cn")); + assertTrue(valueSet.contains("javaObject")); + assertTrue(valueSet.contains("javaSerializedObject")); + + assertTrue(map.containsKey("javaClassNames")); + attribute = map.get("javaClassNames"); + enu = attribute.getAll(); + valueSet = new HashSet(); + while (enu.hasMore()) { + valueSet.add(enu.next()); + } + + assertEquals(5, valueSet.size()); + assertTrue(valueSet.contains("java.io.Serializable")); + assertTrue(valueSet.contains("java.lang.CharSequence")); + assertTrue(valueSet.contains("java.lang.Comparable")); + assertTrue(valueSet.contains("java.lang.Object")); + assertTrue(valueSet.contains("java.lang.String")); + + assertTrue(map.containsKey("javaClassName")); + attribute = map.get("javaClassName"); + assertEquals(1, attribute.size()); + assertEquals(String.class.getName(), attribute.get(0)); + + assertTrue(map.containsKey("javaSerializedData")); + assertEquals(1, attribute.size()); + attribute = map.get("javaSerializedData"); + + assertTrue(map.containsKey("cn")); + attribute = map.get("cn"); + assertEquals(1, attribute.size()); + assertEquals("testBind", attribute.get(0)); + } + public void test_lookup() throws Exception { MockLdapClient client = new MockLdapClient(); Hashtable env = new Hashtable();