harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r598239 [1/3] - in /harmony/enhanced/classlib/branches/java6/modules: awt/src/main/java/common/java/awt/ awt/src/main/java/common/org/apache/harmony/awt/gl/ awt/src/main/java/common/org/apache/harmony/awt/gl/font/ awt/src/main/java/unix/org...
Date Mon, 26 Nov 2007 12:14:02 GMT
Author: tellison
Date: Mon Nov 26 04:13:58 2007
New Revision: 598239

URL: http://svn.apache.org/viewvc?rev=598239&view=rev
Log:
Merge updates between classlib trunk@r596647 and r598224

Added:
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaAttrDefContextImpl.java
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/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
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaClassDefContextImpl.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/UnsolicitedNotificationImpl.java
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/UnsolicitedNotificationImpl.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/event/
      - copied from r598224, harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/event/
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/event/ECNotificationControl.java
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/event/ECNotificationControl.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/event/PersistentSearchControl.java
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/event/PersistentSearchControl.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/event/PersistentSearchResult.java
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/event/PersistentSearchResult.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContext.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContextFactory.java
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ldapURLContextFactory.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/event/
      - copied from r598224, harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/event/
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/event/PersistentSearchControlTest.java
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/event/PersistentSearchControlTest.java
    harmony/enhanced/classlib/branches/java6/modules/suncompat/src/main/java/com/sun/image/
      - copied from r598224, harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/com/sun/image/
    harmony/enhanced/classlib/branches/java6/modules/suncompat/src/main/java/com/sun/image/codec/
      - copied from r598224, harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/com/sun/image/codec/
    harmony/enhanced/classlib/branches/java6/modules/suncompat/src/main/java/com/sun/image/codec/jpeg/
      - copied from r598224, harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/com/sun/image/codec/jpeg/
    harmony/enhanced/classlib/branches/java6/modules/suncompat/src/main/java/com/sun/image/codec/jpeg/ImageFormatException.java
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/com/sun/image/codec/jpeg/ImageFormatException.java
    harmony/enhanced/classlib/branches/java6/modules/suncompat/src/main/java/sun/security/
      - copied from r598224, harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/sun/security/
    harmony/enhanced/classlib/branches/java6/modules/suncompat/src/main/java/sun/security/action/
      - copied from r598224, harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/sun/security/action/
    harmony/enhanced/classlib/branches/java6/modules/suncompat/src/main/java/sun/security/action/GetPropertyAction.java
      - copied unchanged from r598224, harmony/enhanced/classlib/trunk/modules/suncompat/src/main/java/sun/security/action/GetPropertyAction.java
Modified:
    harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java
    harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
    harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CommonGlyphVector.java
    harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CompositeFont.java
    harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
    harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
    harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxLineMetrics.java
    harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java
    harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java
    harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
    harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventHandler.java
    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/LdapClient.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/LdapResult.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/main/java/org/apache/harmony/jndi/provider/ldap/LdapSearchResult.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ModifyOp.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/ASN1Encodable.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/LdapASN1Constant.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/MockLdapClient.java
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/SearchOpTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/StringReader.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/StringWriter.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/reflect/Proxy.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/StringReaderTest.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ProxyTest.java
    harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPNameAndType.java
    harmony/enhanced/classlib/branches/java6/modules/print/src/main/java/common/org/apache/harmony/x/print/Graphics2D2PS.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
    harmony/enhanced/classlib/branches/java6/modules/swing/src/main/java/common/javax/swing/JComponent.java

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java Mon Nov 26 04:13:58 2007
@@ -318,7 +318,7 @@
         return this.createGlyphVector(frc, chars);
     }
 
-    public GlyphVector createGlyphVector(FontRenderContext frc, int[] glyphCodes) throws org.apache.harmony.luni.util.NotImplementedException {
+    public GlyphVector createGlyphVector(FontRenderContext frc, int[] glyphCodes){
         int length = glyphCodes.length;        
         char[] chars = new char[length];        
         FontPeerImpl peer = (FontPeerImpl) getPeer();
@@ -748,6 +748,7 @@
         Rectangle2D bounds;
 
         AffineTransform transform = getTransform();
+        AffineTransform frcTransform = frc.getTransform();
 
         // XXX: for transforms where an angle between basis vectors is not 90
         // degrees Rectanlge2D class doesn't fit as Logical bounds.
@@ -766,7 +767,10 @@
             System.arraycopy(chars, start, subChars, 0, len);
             bounds = createGlyphVector(frc, subChars).getLogicalBounds();
         }
-
+        
+        if (!(frcTransform.isIdentity()))
+            return frcTransform.createTransformedShape(bounds).getBounds2D();
+        
         return bounds;
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java Mon Nov 26 04:13:58 2007
@@ -28,6 +28,7 @@
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
 import java.awt.Image;
 import java.awt.Paint;
 import java.awt.PaintContext;
@@ -158,7 +159,7 @@
     protected Stroke stroke = new BasicStroke();
 
     //TODO: Think more about FontRenderContext
-    protected FontRenderContext frc = new FontRenderContext(null, false, false);
+    protected FontRenderContext frc = null;
 
     protected JavaShapeRasterizer jsr = new JavaShapeRasterizer();
 
@@ -782,6 +783,22 @@
 
     @Override
     public FontRenderContext getFontRenderContext() {
+        AffineTransform at;
+        if (frc == null){
+            GraphicsConfiguration gc = getDeviceConfiguration();
+            if (gc != null){
+                at = gc.getDefaultTransform();
+                at.concatenate(gc.getNormalizingTransform());
+            }
+            else 
+                at = null;
+
+            boolean isAa = (hints.get(RenderingHints.KEY_TEXT_ANTIALIASING) == 
+                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+            boolean isFm = (hints.get(RenderingHints.KEY_FRACTIONALMETRICS) == 
+                RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+            frc = new FontRenderContext(at,isAa,isFm);
+        }
         return frc;
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CommonGlyphVector.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CommonGlyphVector.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CommonGlyphVector.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CommonGlyphVector.java Mon Nov 26 04:13:58 2007
@@ -118,7 +118,7 @@
         visualPositions = new float[(len+1)<<1];
         defaultPositions = new float[(len+1)<<1];
 
-        glsTransforms = new AffineTransform[len];
+//        glsTransforms = new AffineTransform[len];
 
         this.charVector = chars;
         this.vectorFRC = frc;
@@ -486,7 +486,7 @@
     @Override
     public Rectangle getGlyphPixelBounds(int glyphIndex, FontRenderContext frc,
             float x, float y) {
-        // TODO : need to be implemented with FontRenderContext
+
         if ((glyphIndex < 0) || (glyphIndex >= this.getNumGlyphs())) {
             // awt.43=glyphIndex is out of vector's limits
             throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
@@ -507,8 +507,16 @@
 
         if (frc != null){
             at.concatenate(frc.getTransform());
+        
+/*          if (frc.usesFractionalMetrics()){
+                shape.transform(at);
+                Rectangle2D bounds = shape.getBounds2D();
+                Rectangle rect = new Rectangle();
+                rect.setRect(bounds);
+                return rect;
+            }*/
         }
-
+        
         shape.transform(at);
 
         Rectangle bounds = shape.getBounds();

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CompositeFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CompositeFont.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CompositeFont.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CompositeFont.java Mon Nov 26 04:13:58 2007
@@ -161,13 +161,20 @@
      * @param frc specified FontRenderContext 
      * @param at specified AffineTransform
      */
-     @Override
+    @Override
     public LineMetrics getLineMetrics(String str, FontRenderContext frc , AffineTransform at){
+        AffineTransform frcAt = null;
         LineMetricsImpl lm = (LineMetricsImpl)(this.nlm.clone());
         lm.setNumChars(str.length());
-
+        if (frc != null)
+            frcAt = frc.getTransform();
+        
         if ((at != null) && (!at.isIdentity())){
+            if (frcAt != null)
+                at.concatenate(frcAt);
             lm.scale((float)at.getScaleX(), (float)at.getScaleY());
+        } else if ((frcAt != null) && (!frcAt.isIdentity())){
+            lm.scale((float)frcAt.getScaleX(), (float)frcAt.getScaleY());
         }
 
         return lm;
@@ -315,7 +322,11 @@
      */
     public Rectangle2D getStringBounds(char[] chars, int start, int end, FontRenderContext frc){
 
-        LineMetrics lm = getLineMetrics();
+        if (nlm == null){
+            setDefaultLineMetrics("", frc); //$NON-NLS-1$
+        }
+
+        LineMetrics lm = nlm;
         float minY = -lm.getAscent();
         float minX = 0;
         float height = lm.getHeight();

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java Mon Nov 26 04:13:58 2007
@@ -371,7 +371,11 @@
      * @param frc specified FontRenderContext
      */
     public Rectangle2D getMaxCharBounds(FontRenderContext frc) {
-        return maxCharBounds;
+        if (frc != null){
+            AffineTransform at = frc.getTransform();
+            return at.createTransformedShape(maxCharBounds).getBounds2D();
+        } else 
+            return maxCharBounds;
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java Mon Nov 26 04:13:58 2007
@@ -89,7 +89,7 @@
                 this.italicAngle = LinuxNativeFont.getItalicAngleNative(pFont, this.fontType);
         }
         
-        this.nlm = new LinuxLineMetrics(this, null, " "); //$NON-NLS-1$
+        this.nlm = new LinuxLineMetrics(this, " "); //$NON-NLS-1$
 
         this.ascent = nlm.getLogicalAscent();
         this.descent = nlm.getLogicalDescent();
@@ -119,16 +119,22 @@
     }
 
     public LineMetrics getLineMetrics(String str, FontRenderContext frc, AffineTransform at) {
-        //TODO: frc isn't used now
         
+        AffineTransform frcAt = null;
         // Initialize baseline offsets
         nlm.getBaselineOffsets();
+        if (frc != null)
+            frcAt = frc.getTransform();
         
         LineMetricsImpl lm = (LineMetricsImpl)(this.nlm.clone());
         lm.setNumChars(str.length());
 
         if ((at != null) && (!at.isIdentity())){
+            if (frcAt != null) 
+                at.concatenate(frcAt);
             lm.scale((float)at.getScaleX(), (float)at.getScaleY());
+        } else if ((frcAt != null) && (!frcAt.isIdentity())) {
+            lm.scale((float)frcAt.getScaleX(), (float)frcAt.getScaleY());
         }
 
         return lm;

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxLineMetrics.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxLineMetrics.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxLineMetrics.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxLineMetrics.java Mon Nov 26 04:13:58 2007
@@ -36,10 +36,8 @@
     /**
      * Constructor
      */
-    public LinuxLineMetrics(    LinuxFont fnt,
-                                FontRenderContext frc,
-                                String str){
-        // TODO : FontRenderContext isn't used now
+    public LinuxLineMetrics(LinuxFont fnt, String str){
+
         float[] metrics = LinuxNativeFont.getNativeLineMetrics(fnt.getFontHandle(), fnt.getSize(), false, false, fnt.fontType);
 
         if (metrics == null){

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java Mon Nov 26 04:13:58 2007
@@ -343,6 +343,19 @@
             Color bgcolor,
             MultiRectArea clip
     ) {
+
+        if(dstX < 0){
+            width += dstX;
+            dstX = 0;
+        }
+
+        if(dstY < 0){
+            height += dstY;
+            dstY = 0;
+        }
+
+        if(width <= 0 || height <= 0) return;
+
         XSurface xDstSurf = ((XSurface) dstSurf);
 
         boolean srcNoAlpha =

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java Mon Nov 26 04:13:58 2007
@@ -62,24 +62,7 @@
     }
 
     void setRoi(Rectangle2D roi) {
-        if (roi.getX() < 0 || roi.getY() < 0) {
-            double x = roi.getX();
-            double y = roi.getY();
-            double width = roi.getWidth();
-            double height = (int) roi.getHeight();
-            if (x < 0) {
-                width += x;
-                x = 0;
-            }
-            if (y < 0) {
-                height += y;
-                y = 0;
-            }
-
-            this.roi = new Rectangle2D.Double(x, y, width, height);
-        } else {
-            this.roi = roi;
-        }
+        this.roi = roi;
     }
 
     public ColorModel getColorModel() {

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java Mon Nov 26 04:13:58 2007
@@ -330,11 +330,19 @@
      */
     @Override
     public LineMetrics getLineMetrics(String str, FontRenderContext frc, AffineTransform at) {
+        AffineTransform frcAt = null;
         LineMetricsImpl lm = getDefaultLineMetrics();
         lm.setNumChars(str.length());
+        
+        if (frc != null)
+            frcAt = frc.getTransform();
 
         if ((at != null) && (!at.isIdentity())){
+            if (frcAt != null) 
+                at.concatenate(frcAt);
             lm.scale((float)at.getScaleX(), (float)at.getScaleY());
+        } else if ((frcAt != null) && (!frcAt.isIdentity())){
+            lm.scale((float)frcAt.getScaleX(), (float)frcAt.getScaleY());
         }
 
         return lm;

Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventHandler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventHandler.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventHandler.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/EventHandler.java Mon Nov 26 04:13:58 2007
@@ -21,6 +21,9 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Proxy;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.StringTokenizer;
 
 import org.apache.harmony.beans.internal.nls.Messages;
@@ -35,6 +38,8 @@
 
     private String listenerMethodName;
 
+    final private AccessControlContext context; 
+
     public EventHandler(Object target, String action, String eventPropertyName,
             String listenerMethodName) {
         if (target == null || action == null) {
@@ -44,9 +49,18 @@
         this.action = action;
         this.eventPropertyName = eventPropertyName;
         this.listenerMethodName = listenerMethodName;
+        this.context = AccessController.getContext();
+    }
+
+    public Object invoke(final Object proxy, final Method method, final Object[] arguments) {
+        return AccessController.doPrivileged(new PrivilegedAction<Object>() {
+            public Object run() {
+                return invokeImpl(proxy, method, arguments);
+            }
+        }, context);
     }
 
-    public Object invoke(Object proxy, Method method, Object[] arguments) {
+    private Object invokeImpl(Object proxy, Method method, Object[] arguments) {
         Class<?> proxyClass;
         Object result = null;
 

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=598239&r1=598238&r2=598239&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 Nov 26 04:13:58 2007
@@ -159,6 +159,7 @@
 jndi.8D=Must supply attributes describing schema
 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

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=598239&r1=598238&r2=598239&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 Nov 26 04:13:58 2007
@@ -22,12 +22,14 @@
 import java.util.HashSet;
 import java.util.List;
 
+import javax.naming.NameNotFoundException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.DirContext;
 
+import org.apache.harmony.accessibility.internal.nls.Messages;
 import org.apache.harmony.jndi.provider.ldap.asn1.ASN1Decodable;
 import org.apache.harmony.jndi.provider.ldap.asn1.ASN1Encodable;
 import org.apache.harmony.jndi.provider.ldap.asn1.Utils;
@@ -156,9 +158,9 @@
         if (attributeDefinition != null) {
             return attributeDefinition;
         }
-        // TODO: Not yet implemented
-        throw new NotYetImplementedException();
-
+        attributeDefinition = context
+                .getSchemaAttributeDefinition(getID());
+        return attributeDefinition;
     }
 
     @Override
@@ -166,8 +168,24 @@
         if (attributeSyntaxDefinition != null) {
             return attributeSyntaxDefinition;
         }
-        // TODO: Not yet implemented
-        throw new NotYetImplementedException();
+        //      get the syntax id from the attribute def
+        DirContext schema = context.getSchema("");
+        DirContext attrDef = (DirContext)schema.lookup(
+                LdapSchemaContextImpl.ATTRIBUTE_DEFINITION + "/" + getID());
+
+        Attribute syntaxAttr = attrDef.getAttributes("").get("syntax");
+
+        if (syntaxAttr == null || syntaxAttr.size() == 0) {
+            throw new NameNotFoundException(Messages.getString("jndi.90",
+                    getID()));
+        }
+
+        String syntaxName = (String)syntaxAttr.get();
+
+        // look in the schema tree for the syntax definition
+        return (DirContext)schema.lookup(
+                LdapSchemaContextImpl.SYNTAX_DEFINITION + "/" + syntaxName);
+        
     }
 
     private static boolean isBinary(String name) {

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapClient.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapClient.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapClient.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapClient.java Mon Nov 26 04:13:58 2007
@@ -22,7 +22,9 @@
 import java.io.OutputStream;
 import java.net.Socket;
 import java.net.UnknownHostException;
+import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
 
 import javax.naming.CommunicationException;
 import javax.naming.ConfigurationException;
@@ -34,9 +36,13 @@
 import javax.net.ssl.SSLSocketFactory;
 
 import org.apache.harmony.jndi.internal.nls.Messages;
+import org.apache.harmony.jndi.provider.ldap.LdapContextImpl.UnsolicitedListener;
 import org.apache.harmony.jndi.provider.ldap.asn1.ASN1Decodable;
 import org.apache.harmony.jndi.provider.ldap.asn1.ASN1Encodable;
 import org.apache.harmony.jndi.provider.ldap.asn1.LdapASN1Constant;
+import org.apache.harmony.jndi.provider.ldap.event.ECNotificationControl;
+import org.apache.harmony.jndi.provider.ldap.event.PersistentSearchControl;
+import org.apache.harmony.jndi.provider.ldap.event.PersistentSearchResult;
 import org.apache.harmony.security.asn1.ASN1Integer;
 
 /**
@@ -84,6 +90,11 @@
      */
     private Dispatcher dispatcher;
 
+    /**
+     * registered UnsolicitedListener
+     */
+    private List<UnsolicitedListener> unls = new ArrayList<UnsolicitedListener>();
+
     // constructor for test
     public LdapClient() {
         // do nothing
@@ -163,8 +174,7 @@
 
                             // Unsolicited Notification
                             if (messageId == 0) {
-                                // TODO return instance of
-                                // UnsolicitedNotificationImpl
+                                return new UnsolicitedNotificationImpl();
                             }
 
                             // get response operation according messageId
@@ -211,7 +221,7 @@
         private void processResponse(LdapMessage response, Exception ex) {
             // unsolicited notification
             if (response.getMessageId() == 0) {
-                // TODO notify unsolicited listeners
+                notifyUnls(response);
                 return;
             }
 
@@ -224,7 +234,7 @@
                 // persistent search response
                 if (element.lock == null) {
 
-                    // TODO notify persistent search listeners
+                    notifyPersistenSearchListener(element);
 
                 } else {
                     /*
@@ -260,6 +270,14 @@
         } // end of processResponse
     } // Dispatcher
 
+    private void notifyUnls(LdapMessage response) {
+        UnsolicitedNotificationImpl un = (UnsolicitedNotificationImpl) response
+                .getResponseOp();
+        for (UnsolicitedListener listener : unls) {
+            listener.receiveNotification(un, response.getControls());
+        }
+    }
+
     /**
      * Carry out the ldap operation encapsulated in operation with controls.
      * 
@@ -410,6 +428,34 @@
         out.flush();
     }
 
+    public int addPersistentSearch(SearchOp op) throws IOException {
+        LdapMessage request = new LdapMessage(
+                LdapASN1Constant.OP_SEARCH_REQUEST, op.getRequest(),
+                new Control[] { new PersistentSearchControl() });
+
+        Integer messageID = Integer.valueOf(request.getMessageId());
+
+        // set lock to null, indicate this is persistent search
+        requests.put(messageID, new Element(null, new LdapMessage(op
+                .getResponse())));
+        try {
+            out.write(request.encode());
+            out.flush();
+            return request.getMessageId();
+        } catch (IOException e) {
+            // send request faild, remove request from list
+            requests.remove(messageID);
+            throw e;
+        }
+
+    }
+
+    public void removePersistentSearch(int messageId, Control[] controls)
+            throws IOException {
+        requests.remove(Integer.valueOf(messageId));
+        abandon(messageId, controls);
+    }
+
     /**
      * Close network connection, stop dispather thread, and release all other
      * resources
@@ -639,4 +685,36 @@
         this.dispatcher = new Dispatcher();
         this.dispatcher.start();
     }
+
+    public void addUnsolicitedListener(UnsolicitedListener listener) {
+        if (unls == null) {
+            unls = new ArrayList<UnsolicitedListener>();
+        }
+
+        if (!unls.contains(listener)) {
+            unls.add(listener);
+        }
+    }
+
+    private void notifyPersistenSearchListener(Element element) {
+        PersistentSearchResult psr = (PersistentSearchResult) ((SearchOp) element.response
+                .getResponseOp()).getSearchResult();
+        // test error
+        if (psr.getResult() != null) {
+            psr.receiveNotificationHook(psr.getResult());
+        }
+
+        // notify listener
+        Control[] cs = element.response.getControls();
+        if (cs != null) {
+            for (int i = 0; i < cs.length; i++) {
+                Control control = cs[i];
+                if (ECNotificationControl.OID.equals(control.getID())) {
+                    psr.receiveNotificationHook(new ECNotificationControl(
+                            control.getEncodedValue()));
+                }
+            }
+        }
+    }
+
 }

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=598239&r1=598238&r2=598239&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 Nov 26 04:13:58 2007
@@ -19,6 +19,9 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
@@ -26,10 +29,12 @@
 import java.util.Set;
 import java.util.StringTokenizer;
 
+import javax.naming.AuthenticationNotSupportedException;
 import javax.naming.Binding;
 import javax.naming.CannotProceedException;
 import javax.naming.CommunicationException;
 import javax.naming.CompositeName;
+import javax.naming.ConfigurationException;
 import javax.naming.Context;
 import javax.naming.InvalidNameException;
 import javax.naming.Name;
@@ -48,6 +53,13 @@
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
+import javax.naming.event.EventContext;
+import javax.naming.event.EventDirContext;
+import javax.naming.event.NamespaceChangeListener;
+import javax.naming.event.NamingEvent;
+import javax.naming.event.NamingExceptionEvent;
+import javax.naming.event.NamingListener;
+import javax.naming.event.ObjectChangeListener;
 import javax.naming.ldap.Control;
 import javax.naming.ldap.ControlFactory;
 import javax.naming.ldap.ExtendedRequest;
@@ -56,6 +68,8 @@
 import javax.naming.ldap.LdapName;
 import javax.naming.ldap.ManageReferralControl;
 import javax.naming.ldap.Rdn;
+import javax.naming.ldap.UnsolicitedNotificationEvent;
+import javax.naming.ldap.UnsolicitedNotificationListener;
 import javax.naming.spi.DirectoryManager;
 import javax.naming.spi.NamingManager;
 
@@ -63,6 +77,8 @@
 import org.apache.harmony.jndi.internal.parser.AttributeTypeAndValuePair;
 import org.apache.harmony.jndi.internal.parser.LdapNameParser;
 import org.apache.harmony.jndi.provider.ldap.asn1.Utils;
+import org.apache.harmony.jndi.provider.ldap.event.ECNotificationControl;
+import org.apache.harmony.jndi.provider.ldap.event.PersistentSearchResult;
 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.sasl.SaslBind;
@@ -71,12 +87,14 @@
  * This context implements LdapContext, it's main entry point of all JNDI ldap
  * operations.
  */
-public class LdapContextImpl implements LdapContext {
+public class LdapContextImpl implements LdapContext, EventDirContext {
 
     /**
      * ldap connection
      */
     private LdapClient client;
+    
+    private boolean isClosed;
 
     /**
      * name of the context
@@ -102,6 +120,10 @@
      */
     private Control[] connCtls;
 
+    private HashMap<NamingListener, List<Integer>> listeners;
+
+    private List<UnsolicitedNotificationListener> unls;
+
     private static final Control NON_CRITICAL_MANAGE_REF_CONTROL = new ManageReferralControl(
             Control.NONCRITICAL);
 
@@ -112,6 +134,23 @@
     private static final String LDAP_TYPES_ONLY = "java.naming.ldap.typesOnly"; //$NON-NLS-1$
 
     /**
+     * Some properties, such as 'java.naming.security.authentication', changed
+     * by <code>Context.addToEnvironment</code> or
+     * <code>Context.removeFromEnvironment</code> may affect connection with
+     * LDAP server. This variable contains all such properties, which need
+     * re-communication with LDAP server after changing.
+     */
+    private static final HashSet<String> connectionProperties = new HashSet<String>();
+
+    static {
+        connectionProperties.add(Context.SECURITY_AUTHENTICATION);
+        connectionProperties.add(Context.SECURITY_CREDENTIALS);
+        connectionProperties.add(Context.SECURITY_PRINCIPAL);
+        connectionProperties.add(Context.SECURITY_PROTOCOL);
+        connectionProperties.add("java.naming.ldap.factory.socket");
+    }
+
+    /**
      * construct a new inherit <code>LdapContextImpl</code>
      * 
      * @param context
@@ -515,11 +554,18 @@
             names = sre.getEntries();
 
             keyset = names.keySet();
-            for (Iterator<String> iterator = keyset.iterator(); iterator
+            schemaRoot: for (Iterator<String> iterator = keyset.iterator(); iterator
                     .hasNext();) {
                 String key = iterator.next();
                 Attributes as = names.get(key);
-                subschemasubentry = (String) as.get("subschemasubentry").get();
+                NamingEnumeration<String> ids = as.getIDs();
+                while (ids.hasMore()) {
+                    String id = ids.next();
+                    if (id.equalsIgnoreCase("subschemasubentry")) {
+                        subschemasubentry = (String) as.get(id).get();
+                        break schemaRoot;
+                    }
+                }
             }
         }
 
@@ -563,16 +609,16 @@
 
             while (ids.hasMoreElements()) {
                 String schemaType = ids.nextElement();
-                if (!schemaTree.contains(schemaType)) {
-                    schemaTree.put(schemaType,
+                if (!schemaTree.contains(schemaType.toLowerCase())) {
+                    schemaTree.put(schemaType.toLowerCase(),
                             new Hashtable<String, Hashtable<String, Object>>());
                 }
                 Hashtable<String, Hashtable<String, Object>> schemaDefs = schemaTree
-                        .get(schemaType);
+                        .get(schemaType.toLowerCase());
                 LdapAttribute attribute = (LdapAttribute) as.get(schemaType);
                 for (int i = 0; i < attribute.size(); i++) {
                     String value = (String) attribute.get(i);
-                    parseValue(value, schemaDefs);
+                    parseValue(schemaType, value.toLowerCase(), schemaDefs);
                 }
             }
         }
@@ -593,7 +639,8 @@
      * '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 value,
+    private static void parseValue(String schemaType,
+            String value,
             Hashtable<String, Hashtable<String, Object>> schemaDefs) {
         StringTokenizer st = new StringTokenizer(value);
         // Skip (
@@ -644,18 +691,42 @@
                 if (token.startsWith("(")) {
                     token = st.nextToken();
                     while (!token.equals(")")) {
-                        // remove enclosing quotation
-                        token = token.substring(1, token.length() - 1);
-                        values.add(token);
+                        // 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 enclosing quotation
-                    token = token.substring(1, token.length() - 1);
-                    values.add(token);
+                    // 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);
-                schemaDefs.put(values.get(0), schemaDef);
+                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")) {
@@ -690,10 +761,74 @@
         return getSchema(new CompositeName(s));
     }
 
+    DirContext getSchemaAttributeDefinition(String name) throws NamingException {
+        if (null == ldapSchemaCtx) {
+            getSchema("");
+        }
+        Hashtable<String, Object> attrDef = findSchemaDefInfo(
+                LdapSchemaContextImpl.ATTRIBUTE_TYPES, name);
+
+        return new LdapSchemaAttrDefContextImpl(new CompositeName(name), env,
+                attrDef, this);
+    }
     public DirContext getSchemaClassDefinition(Name name)
             throws NamingException {
-        // TODO not yet implemented
-        throw new NotYetImplementedException();
+        if (null == ldapSchemaCtx) {
+            getSchema(name);
+        }
+
+        Hashtable<String, ArrayList<String>> classTree = new Hashtable<String, ArrayList<String>>();
+
+        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<String, Attributes> names = sre.getEntries();
+
+        Set<String> keyset = names.keySet();
+        for (Iterator<String> iterator = keyset.iterator(); iterator.hasNext();) {
+            String key = iterator.next();
+            Attributes as = names.get(key);
+            NamingEnumeration<String> ids = as.getIDs();
+
+            while (ids.hasMoreElements()) {
+                String schemaType = ids.nextElement();
+                if (!classTree.contains(schemaType)) {
+                    classTree.put(schemaType, new ArrayList());
+                }
+                ArrayList<String> 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);
+                }
+            }
+        }
+
+        return new LdapSchemaClassDefContextImpl(new CompositeName(targetDN),
+                env, classTree, this);
     }
 
     public DirContext getSchemaClassDefinition(String s) throws NamingException {
@@ -1039,8 +1174,17 @@
     }
 
     public Object addToEnvironment(String s, Object o) throws NamingException {
-        // TODO not yet implemented
-        throw new NotYetImplementedException();
+        Object preValue = env.put(s, o);
+
+        // if preValue equals o, do nothing
+        if ((preValue != null && preValue.equals(o))
+                || (preValue == null && o == null)) {
+            return preValue;
+        }
+
+        updateEnvironment(s);
+
+        return preValue;
     }
 
     public void bind(Name n, Object o) throws NamingException {
@@ -1052,8 +1196,10 @@
     }
 
     public void close() throws NamingException {
-        // TODO not yet implemented
-        throw new NotYetImplementedException();
+        if (!isClosed) {
+            isClosed = true;
+            client = null;
+        }
     }
 
     /**
@@ -1401,8 +1547,40 @@
     }
 
     public Object removeFromEnvironment(String s) throws NamingException {
-        // TODO not yet implemented
-        throw new NotYetImplementedException();
+        Object preValue = env.remove(s);
+
+        // if s doesn't exist in env
+        if (preValue == null) {
+            return preValue;
+        }
+
+        updateEnvironment(s);
+
+        return preValue;
+    }
+
+    private void updateEnvironment(String propName) throws NamingException,
+            AuthenticationNotSupportedException, CommunicationException,
+            ConfigurationException {
+        if (connectionProperties.contains(propName)) {
+            if (propName.equals("java.naming.ldap.factory.socket")) {
+                // use new socket factory to connect server
+                String address = client.getAddress();
+                int port = client.getPort();
+
+                client = LdapClient.newInstance(address, port, env);
+                try {
+                    doBindOperation(connCtls);
+                } catch (IOException e) {
+                    CommunicationException ex = new CommunicationException();
+                    ex.setRootCause(e);
+                    throw ex;
+                }
+            } else {
+
+                reconnect(connCtls);
+            }
+        }
     }
 
     public void rename(Name nOld, Name nNew) throws NamingException {
@@ -1529,5 +1707,365 @@
             // jndi.2E=The name is null
             throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$
         }
+    }
+
+    @Override
+    protected void finalize() {
+        try {
+            close();
+        } catch (NamingException e) {
+            // ignore
+        }
+    }
+
+    public void addNamingListener(Name name, String filter,
+            Object[] filterArgs, SearchControls searchControls,
+            NamingListener namingListener) throws NamingException {
+        checkName(name);
+
+        if (namingListener == null) {
+            return;
+        }
+
+        if (!(name instanceof LdapName)) {
+            if (name instanceof CompositeName && name.size() == 1) {
+                name = name.getPrefix(1);
+            } else {
+                // FIXME: read message from file
+                throw new InvalidNameException(
+                        "Target cannot span multiple namespaces: "
+                                + name.toString());
+            }
+        }
+
+        if (namingListener instanceof UnsolicitedNotificationListener) {
+            if (unls == null) {
+                unls = new ArrayList<UnsolicitedNotificationListener>();
+                addUnsolicitedListener();
+            }
+
+            unls.add((UnsolicitedNotificationListener) namingListener);
+
+            if (!(namingListener instanceof NamespaceChangeListener)
+                    && !(namingListener instanceof ObjectChangeListener)) {
+                return;
+            }
+        }
+
+        if (filter == null) {
+            throw new NullPointerException(Messages.getString("ldap.28")); //$NON-NLS-1$
+        }
+
+        if (filterArgs == null) {
+            filterArgs = new Object[0];
+        }
+
+        if (searchControls == null) {
+            searchControls = new SearchControls();
+        }
+
+        FilterParser filterParser = new FilterParser(filter);
+        filterParser.setArgs(filterArgs);
+        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;
+        }
+
+        String targetDN = getTargetDN(name, contextDn);
+
+        Name tempName = new LdapName(contextDn.toString());
+        tempName.addAll(name);
+        String baseDN = tempName.toString();
+
+        int messageId = doPersistentSearch(targetDN, baseDN, f, searchControls,
+                namingListener);
+
+        if (listeners == null) {
+            listeners = new HashMap<NamingListener, List<Integer>>();
+        }
+
+        List<Integer> idList = listeners.get(namingListener);
+        if (idList == null) {
+            idList = new ArrayList<Integer>();
+        }
+
+        idList.add(Integer.valueOf(messageId));
+    }
+
+    public void addNamingListener(Name name, String filter,
+            SearchControls searchControls, NamingListener namingListener)
+            throws NamingException {
+        addNamingListener(name, filter, new Object[0], searchControls,
+                namingListener);
+    }
+
+    public void addNamingListener(String name, String filter,
+            Object[] filterArgs, SearchControls searchControls,
+            NamingListener namingListener) throws NamingException {
+        addNamingListener(convertFromStringToName(name), filter, filterArgs,
+                searchControls, namingListener);
+    }
+
+    public void addNamingListener(String name, String filter,
+            SearchControls searchControls, NamingListener namingListener)
+            throws NamingException {
+        addNamingListener(convertFromStringToName(name), filter,
+                searchControls, namingListener);
+    }
+
+    public static interface UnsolicitedListener {
+        public void receiveNotification(UnsolicitedNotificationImpl un,
+                Control[] cs);
+    }
+
+    public void addNamingListener(Name name, int scope,
+            NamingListener namingListener) throws NamingException {
+        checkName(name);
+
+        if (namingListener == null) {
+            return;
+        }
+
+        // only ldap name is supportted
+        if (!(name instanceof LdapName)) {
+            if (name instanceof CompositeName && name.size() == 1) {
+                name = name.getPrefix(0);
+            } else {
+                // ldap.32=Target cannot span multiple namespaces: {0}
+                throw new InvalidNameException(Messages.getString("ldap.32", //$NON-NLS-1$
+                        new Object[] { name.toString() }));
+            }
+        }
+
+        if (namingListener instanceof UnsolicitedNotificationListener) {
+            if (unls == null) {
+                unls = new ArrayList<UnsolicitedNotificationListener>();
+                addUnsolicitedListener();
+            }
+
+            unls.add((UnsolicitedNotificationListener) namingListener);
+
+            if (!(namingListener instanceof NamespaceChangeListener)
+                    && !(namingListener instanceof ObjectChangeListener)) {
+                return;
+            }
+        }
+
+        // ri is silent in this case
+        if (scope != EventContext.OBJECT_SCOPE
+                && scope != EventContext.ONELEVEL_SCOPE
+                && scope != EventContext.SUBTREE_SCOPE) {
+            // ldap.33=Scope should be one of 'OBJECT_SCOPE', 'ONELEVEL_SCOPE'
+            // or 'SUBTREE_SCOPE'
+            throw new IllegalArgumentException(Messages.getString("ldap.33")); //$NON-NLS-1$
+        }
+
+        String targetDN = getTargetDN(name, contextDn);
+
+        Filter filter = new Filter(Filter.PRESENT_FILTER);
+        filter.setValue("objectClass");
+
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope(scope);
+
+        Name tempName = new LdapName(contextDn.toString());
+        tempName.addAll(name);
+        String baseDN = tempName.toString();
+
+        int messageId = doPersistentSearch(targetDN, baseDN, filter, controls,
+                namingListener);
+
+        if (listeners == null) {
+            listeners = new HashMap<NamingListener, List<Integer>>();
+        }
+
+        List<Integer> idList = listeners.get(namingListener);
+        if (idList == null) {
+            idList = new ArrayList<Integer>();
+            listeners.put(namingListener, idList);
+        }
+
+        idList.add(Integer.valueOf(messageId));
+
+    }
+
+    private void addUnsolicitedListener() {
+        client.addUnsolicitedListener(new UnsolicitedListener() {
+
+            public void receiveNotification(UnsolicitedNotificationImpl un,
+                    Control[] cs) {
+                EventObject event = null;
+                try {
+                    un.setControls(narrowingControls(cs));
+                    event = new UnsolicitedNotificationEvent(this, un);
+                } catch (NamingException e) {
+                    event = new NamingExceptionEvent(LdapContextImpl.this, e);
+                }
+
+                for (UnsolicitedNotificationListener listener : unls) {
+                    notifyNamingListener(listener, event);
+                }
+
+            }
+
+        });
+    }
+
+    private int doPersistentSearch(String targetDN, final String baseDN,
+            Filter filter, SearchControls controls,
+            NamingListener namingListener) throws CommunicationException {
+
+        SearchOp op = new SearchOp(targetDN, controls, filter);
+
+        final NamingListener listener = namingListener;
+        op.setSearchResult(new PersistentSearchResult() {
+
+            @Override
+            public void receiveNotificationHook(Object obj) {
+                EventObject event = null;
+                // construct event
+                if (obj instanceof ECNotificationControl) {
+                    ECNotificationControl control = (ECNotificationControl) obj;
+                    event = constructNamingEvent(this, control, baseDN);
+                }
+
+                if (obj instanceof LdapResult) {
+                    LdapResult ldapResult = (LdapResult) obj;
+                    NamingException ex = LdapUtils
+                            .getExceptionFromResult(ldapResult);
+                    // may not happen
+                    if (ex == null) {
+                        return;
+                    }
+
+                    event = new NamingExceptionEvent(LdapContextImpl.this, ex);
+                }
+
+                // notify listener
+                notifyNamingListener(listener, event);
+            }
+
+        });
+
+        try {
+            return client.addPersistentSearch(op);
+        } catch (IOException e) {
+            CommunicationException ex = new CommunicationException();
+            ex.setRootCause(e);
+            throw ex;
+        }
+    }
+
+    private void notifyNamingListener(final NamingListener listener,
+            final EventObject event) {
+        /*
+         * start new thread to notify listener, so user code may not affect
+         * dispatcher thread
+         */
+        Thread thread = new Thread(new Runnable() {
+
+            public void run() {
+                if (event instanceof NamingEvent) {
+                    NamingEvent namingEvent = (NamingEvent) event;
+                    namingEvent.dispatch(listener);
+                } else if (event instanceof NamingExceptionEvent) {
+                    NamingExceptionEvent exceptionEvent = (NamingExceptionEvent) event;
+                    listener.namingExceptionThrown(exceptionEvent);
+                } else if (event instanceof UnsolicitedNotificationEvent) {
+                    UnsolicitedNotificationEvent namingEvent = (UnsolicitedNotificationEvent) event;
+                    namingEvent
+                            .dispatch((UnsolicitedNotificationListener) listener);
+                }
+
+            }
+
+        });
+
+        thread.start();
+    }
+
+    public void addNamingListener(String s, int i, NamingListener namingListener)
+            throws NamingException {
+        addNamingListener(convertFromStringToName(s), i, namingListener);
+    }
+
+    public void removeNamingListener(NamingListener namingListener)
+            throws NamingException {
+        if (listeners == null || !listeners.containsKey(namingListener)) {
+            return;
+        }
+
+        if (namingListener instanceof UnsolicitedNotificationListener) {
+            unls.remove(namingListener);
+        }
+
+        List<Integer> idList = listeners.remove(namingListener);
+        if (idList == null) {
+            return;
+        }
+
+        try {
+            for (Integer id : idList) {
+                client.removePersistentSearch(id.intValue(), requestControls);
+            }
+        } catch (IOException e) {
+            CommunicationException ex = new CommunicationException();
+            ex.setRootCause(e);
+        }
+    }
+
+    public boolean targetMustExist() throws NamingException {
+        // FIXME
+        return false;
+    }
+
+    private NamingEvent constructNamingEvent(PersistentSearchResult result,
+            ECNotificationControl control, String baseDN) {
+        Binding newBinding = null;
+        Binding oldBinding = null;
+
+        switch (control.getChangeType()) {
+        case ECNotificationControl.ADD:
+            String newName = convertToRelativeName(result.getDn(), baseDN);
+            newBinding = new Binding(newName, null);
+            newBinding.setNameInNamespace(result.getDn());
+            break;
+        case ECNotificationControl.DELETE:
+            String deleteName = convertToRelativeName(result.getDn(), baseDN);
+            oldBinding = new Binding(deleteName, null);
+            oldBinding.setNameInNamespace(result.getDn());
+            break;
+        case ECNotificationControl.MODIFY_DN:
+            if (result.getDn() != null) {
+                newBinding = new Binding(convertToRelativeName(result.getDn(),
+                        baseDN), null);
+                newBinding.setNameInNamespace(result.getDn());
+            }
+
+            if (control.getPreviousDN() != null) {
+                oldBinding = new Binding(convertToRelativeName(control
+                        .getPreviousDN(), baseDN), null);
+                oldBinding.setNameInNamespace(control.getPreviousDN());
+            }
+            break;
+        case ECNotificationControl.MODIFY:
+            String relativeName = convertToRelativeName(result.getDn(), baseDN);
+            newBinding = new Binding(relativeName, null);
+            newBinding.setNameInNamespace(result.getDn());
+            // FIXME: how to get old binding?
+            oldBinding = new Binding(relativeName, null);
+            oldBinding.setNameInNamespace(result.getDn());
+        }
+
+        NamingEvent event = new NamingEvent(this, control.getJNDIChangeType(),
+                newBinding, oldBinding, Integer.valueOf(control
+                        .getChangeNumber()));
+
+        return event;
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapResult.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapResult.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapResult.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapResult.java Mon Nov 26 04:13:58 2007
@@ -143,7 +143,7 @@
      * Retrieves the referrals.
      * 
      * @return A prossibly null array. <code>null</code> means no referrals
-     *         retrieves from server
+     *         retrieved from server
      */
     public String[] getReferrals() {
         return referrals;

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=598239&r1=598238&r2=598239&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 Nov 26 04:13:58 2007
@@ -17,12 +17,12 @@
 package org.apache.harmony.jndi.provider.ldap;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -49,6 +49,7 @@
 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;
 
@@ -69,7 +70,7 @@
     public static final String LDAP_SYNTAXES = "ldapsyntaxes";
 
     public static final String MATCHING_RULES = "matchingrules";
-    
+
     protected String subschemasubentry = null;
 
     final private static Hashtable<String, String> schemaJndi2Ldap = new Hashtable<String, String>();
@@ -94,8 +95,8 @@
 
     private BasicAttributes schemaAttributes;
 
-    public LdapSchemaContextImpl(LdapContextImpl ctx, Hashtable<Object, Object> env,
-            Name dn) throws InvalidNameException {
+    public LdapSchemaContextImpl(LdapContextImpl ctx,
+            Hashtable<Object, Object> env, Name dn) throws InvalidNameException {
         super(ctx, env, dn.getPrefix(0).toString());
         parent = ctx;
         rdn = dn;
@@ -291,7 +292,7 @@
         ModifyOp op = new ModifyOp(targetDN);
         Hashtable<String, Object> classDef = parent.findSchemaDefInfo(
                 schemaJndi2Ldap.get(name.get(0).toLowerCase()), name.get(1));
-        if(null ==classDef) {
+        if (null == classDef) {
             throw new NameNotFoundException(name.toString());
         }
         String oldValue = (String) classDef.get("orig");
@@ -364,7 +365,7 @@
 
         try {
             doBasicOperation(op);
-        } catch(Exception e) {
+        } catch (Exception e) {
             // TODO need to handle referal exception in the future
         }
     }
@@ -440,11 +441,6 @@
     }
 
     public NamingEnumeration<SearchResult> search(Name name,
-            Attributes attributes) throws NamingException {
-        return search(name, attributes, null);
-    }
-
-    public NamingEnumeration<SearchResult> search(Name name,
     // Used to filter attribute value
             Attributes attributes,
             // Used to filter attribute name
@@ -481,7 +477,7 @@
                 attrMatcher.put(newAttr);
             }
         }
-        
+
         // Attribute selector
         TreeSet<String> attrSel = new TreeSet<String>();
 
@@ -490,7 +486,7 @@
                 null, null);
         String schemaType = null;
 
-        LinkedList<String> attrValues = new LinkedList<String>();;
+        LinkedList<String> attrValues = new LinkedList<String>();
         int size = targetDN.size();
         switch (size) {
         case 0:
@@ -564,6 +560,9 @@
             }
             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());
@@ -577,33 +576,41 @@
                     NamingEnumeration<Attribute> filters = attrMatcher.getAll();
                     String id = attrValues.get(i);
                     Hashtable<String, Object> 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 (match(filter, values)) {
-                            basicAttributes = new BasicAttributes();
-                            for (Iterator<String> iterator = schemaDef.keySet()
-                                    .iterator(); iterator.hasNext();) {
-                                String key = iterator.next();
-                                if (key.equals("orig")) {
-                                    continue;
-                                }
-                                Object value = schemaDef.get(key);
-                                basicAttributes.put(key, value);
+                        /*
+                         * 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();
+                        for (Iterator<String> 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);
                         }
+                        SearchResult pair = new SearchResult(id, null,
+                                basicAttributes);
+                        enumeration.add(pair);
                     }
                 }
             } else {
                 for (int i = 0; i < attrValues.size(); i++) {
-                    Hashtable<String, Object> schemaDef = schemas.get(attrValues.get(i));
+                    Hashtable<String, Object> schemaDef = schemas
+                            .get(attrValues.get(i));
                     basicAttributes = new BasicAttributes();
                     for (Iterator<String> iterator = schemaDef.keySet()
                             .iterator(); iterator.hasNext();) {
@@ -611,11 +618,13 @@
                         if (key.equals("orig")) {
                             continue;
                         }
-                        Object value = schemaDef.get(key);
-                        basicAttributes.put(key, value);
+                        if (hasAttributes2Return && attrSel.contains(key)
+                                || !hasAttributes2Return) {
+                            basicAttributes.put(key, schemaDef.get(key));
+                        }
                     }
-                    SearchResult pair = new SearchResult(attrValues.get(i), null,
-                            basicAttributes);
+                    SearchResult pair = new SearchResult(attrValues.get(i),
+                            null, basicAttributes);
                     enumeration.add(pair);
                 }
             }
@@ -647,7 +656,7 @@
         while (attrValues.hasMore()) {
             Object attrValue = attrValues.next();
             for (int i = 0; i < v.size(); i++) {
-                if (attrValue.equals(v.get(i))) {
+                if (attrValue.equals("*") || attrValue.equals(v.get(i))) {
                     return true;
                 }
             }
@@ -658,22 +667,25 @@
     public NamingEnumeration<SearchResult> search(Name name, String filter,
             Object[] objs, SearchControls searchControls)
             throws NamingException {
+
         checkName(name);
 
         if (filter == null) {
             throw new NullPointerException(Messages.getString("ldap.28")); //$NON-NLS-1$
         }
-
-        if (objs == null) {
-            objs = new Object[0];
+        if (filter.length() == 0) {
+            throw new StringIndexOutOfBoundsException();
+        }
+        if (!filter.startsWith("(")) {
+            StringBuilder filterWrapper = new StringBuilder("(");
+            filterWrapper.append(filter).append(")");
+            filter = filterWrapper.toString();
         }
 
-        if (searchControls == null) {
+        if (null == searchControls) {
             searchControls = new SearchControls();
         }
 
-        // get absolute dn name
-        String targetDN = getTargetDN(name, contextDn);
         FilterParser filterParser = new FilterParser(filter);
         filterParser.setArgs(objs);
         Filter f = null;
@@ -686,20 +698,28 @@
             throw ex;
         }
 
-        LdapSearchResult result = doSearch(targetDN, f, searchControls);
-
-        List<SearchResult> list = new ArrayList<SearchResult>();
-        Map<String, Attributes> entries = result.getEntries();
-        for (String dn : entries.keySet()) {
-            String relativeName = convertToRelativeName(dn, rdn.toString());
-            SearchResult sr = new SearchResult(relativeName, null, entries
-                    .get(dn));
-            sr.setNameInNamespace(dn);
-            list.add(sr);
-        }
+        BasicAttributes matchingAttrs = new BasicAttributes();
+        extractMatchingAttributes(f, matchingAttrs);
 
-        return new LdapNamingEnumeration<SearchResult>(list, result
-                .getException());
+        return search(name, matchingAttrs, searchControls
+                .getReturningAttributes());
     }
 
+    private void extractMatchingAttributes(Filter f,
+            BasicAttributes matchingAttrs) {
+        if (!f.isLeaf()) {
+            List<Filter> children = f.getChildren();
+            for (Iterator iter = children.iterator(); iter.hasNext();) {
+                extractMatchingAttributes((Filter) 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, "*");
+            }
+        }
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSearchResult.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSearchResult.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSearchResult.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapSearchResult.java Mon Nov 26 04:13:58 2007
@@ -63,19 +63,19 @@
         }
     }
 
-    private void decodeDone(Object value) {
+    protected void decodeDone(Object value) {
         result = new LdapResult();
         result.decodeValues((Object[]) value);
     }
 
-    private void decodeRef(Object value) {
+    protected void decodeRef(Object value) {
         Collection<byte[]> list = (Collection<byte[]>) value;
         for (byte[] bs : list) {
             refURLs.add(Utils.getString(bs));
         }
     }
 
-    private void decodeEntry(Object value) {
+    protected void decodeEntry(Object value) {
         Object[] values = (Object[]) value;
         String name = Utils.getString((byte[]) values[0]);
 

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ModifyOp.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ModifyOp.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ModifyOp.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ModifyOp.java Mon Nov 26 04:13:58 2007
@@ -59,6 +59,13 @@
         values[1] = modifications;
     }
 
+    /**
+     * 
+     * @param type
+     *            ldap modify type, must be one of ModifyOp.ADD, ModifyOp.DELETE
+     *            or ModifyOp.REPLACE
+     * @param attr
+     */
     public void addModification(int type, LdapAttribute attr) {
         if (type >= 0 && type <= 2 && attr != null) {
             modifications.add(new Modification(type, attr));

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/ASN1Encodable.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/ASN1Encodable.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/ASN1Encodable.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/ASN1Encodable.java Mon Nov 26 04:13:58 2007
@@ -31,8 +31,8 @@
  * OCTET STRING         byte[] (encode: Utils.getBytes(String s)    decode: getString(byte[] bytes))
  * ENUMERATED           byte[] (encode: ASN1Integer.fromIntValue(int value)  decode: ASN1Integer.toIntValue(Object decoded))
  * SEQUENCE             Object[] or ASN1Encodable
- * SEQUENCE OF          Collection
- * SET OF               Collection
+ * SEQUENCE OF          java.util.List
+ * SET OF               java.util.List
  * CHOICE               Object[] or ChosenValue
  * </code>
  * 

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/LdapASN1Constant.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/LdapASN1Constant.java?rev=598239&r1=598238&r2=598239&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/LdapASN1Constant.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/LdapASN1Constant.java Mon Nov 26 04:13:58 2007
@@ -72,21 +72,21 @@
     public static final int OP_EXTENDED_REQUEST = 18;
 
     public static final int OP_EXTENDED_RESPONSE = 19;
-    
+
     public static final ASN1Type Attribute = new ASN1SequenceWrap(
             new ASN1Type[] { ASN1OctetString.getInstance(), // type
                     new ASN1SetOf(ASN1OctetString.getInstance()) }); // vals
-    
+
     public static final ASN1Type AttributeList = new ASN1SequenceOf(
             new ASN1SequenceWrap(new ASN1Type[] {
                     ASN1OctetString.getInstance(), // type
                     new ASN1SetOf(ASN1OctetString.getInstance()) })); // values
-    
+
     public static final ASN1Type AddRequest = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 8, new ASN1SequenceWrap(
                     new ASN1Type[] { ASN1OctetString.getInstance(), // entry
                             AttributeList })); // attributes
-    
+
     public static final ASN1Type SaslCredentials = new ASN1SequenceWrap(
             new ASN1Type[] { ASN1OctetString.getInstance(), // mechanism
                     ASN1OctetString.getInstance() }) { // credentials
@@ -94,14 +94,14 @@
             setOptional(1); // credentials is optional
         }
     };
-    
+
     public static final ASN1Type AuthenticationChoice = new ASN1ChoiceWrap(
             new ASN1Type[] {
                     new ASN1Implicit(ASN1Constants.CLASS_CONTEXTSPECIFIC, 0, // simple
                             ASN1OctetString.getInstance()),
                     new ASN1Implicit(ASN1Constants.CLASS_CONTEXTSPECIFIC, 3, // sasl
                             SaslCredentials) });
-    
+
     public static final ASN1Type LDAPResult = new ASN1SequenceWrap(
             new ASN1Type[] { ASN1Enumerated.getInstance(), // resultCode
                     ASN1OctetString.getInstance(), // matchedDN
@@ -115,7 +115,7 @@
     
     public static final ASN1Type AddResponse = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 9, LDAPResult);
-    
+
     public static final ASN1Type Control = new ASN1SequenceWrap(new ASN1Type[] {
             ASN1OctetString.getInstance(), // controlType
             ASN1Boolean.getInstance(), // criticality
@@ -131,7 +131,7 @@
                     new ASN1Type[] { ASN1Integer.getInstance(), // version
                             ASN1OctetString.getInstance(), // name
                             AuthenticationChoice })); // authentication
-    
+
     public static final ASN1Type BindResponse = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 1, Utils.conjoinSequence(
                     (ASN1Sequence) LDAPResult, // result
@@ -142,30 +142,28 @@
                             setOptional(0); // serverSaslCreds is optional
                         }
                     }));
-    
+
     public static final ASN1Type UnbindRequest = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 2, ASN1Null.getInstance());
-    
+
     public static final ASN1Type AttributeValueAssertion = new ASN1SequenceWrap(
             new ASN1Type[] { ASN1OctetString.getInstance(), // attributeDesc
                     ASN1OctetString.getInstance() }); // assertionValue
-    
+
     public static final ASN1Type AbandonRequest = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 16, ASN1Integer.getInstance());
-    
+
     public static final ASN1Type CompareRequest = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 14, new ASN1SequenceWrap(
                     new ASN1Type[] { ASN1OctetString.getInstance(), // entry
                             AttributeValueAssertion })); // ava
 
-
     public static final ASN1Type CompareResponse = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 15, LDAPResult);
     
     public static final ASN1Type DelRequest = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 10, ASN1OctetString.getInstance());
-    
-    
+
     public static final ASN1Type DelResponse = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 11, LDAPResult);
     
@@ -183,7 +181,6 @@
                 }
             });
 
-
     public static final ASN1Type ExtendedResponse = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 24, Utils.conjoinSequence(
                     (ASN1Sequence) LDAPResult, // LDAPResult
@@ -199,7 +196,7 @@
                             setOptional(1);
                         }
                     }));
-    
+
     public static final ASN1Type ModifyDNRequest = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 12, new ASN1SequenceWrap(
                     new ASN1Type[] {
@@ -214,14 +211,13 @@
                 }
             });
 
-
     public static final ASN1Type ModifyDNResponse = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 13, LDAPResult);
-    
+
     public static final ASN1Type AttributeTypeAndValues = new ASN1SequenceWrap(
             new ASN1Type[] { ASN1OctetString.getInstance(), // type
                     new ASN1SetOf(ASN1OctetString.getInstance()) }); // vals
-    
+
     public static final ASN1Type ModifyRequest = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 6, new ASN1SequenceWrap(
                     new ASN1Type[] {
@@ -231,7 +227,6 @@
                                             ASN1Enumerated.getInstance(), // operation
                                             AttributeTypeAndValues })) })); // modification
 
-
     public static final ASN1Type ModifyResponse = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 7, LDAPResult);
     
@@ -272,7 +267,7 @@
             setDefault(Boolean.FALSE, 3);
         }
     };
-    
+
     public static final ASN1Type Filter = new ASN1ChoiceWrap(new ASN1Type[] {
             new ASN1Implicit(ASN1Constants.CLASS_CONTEXTSPECIFIC, 0,
                     new ASN1SetOf(new ASN1LdapFilter())),
@@ -294,7 +289,7 @@
                     AttributeValueAssertion),
             new ASN1Implicit(ASN1Constants.CLASS_CONTEXTSPECIFIC, 9,
                     MatchingRuleAssertion) });
-    
+
     public static final ASN1Type SearchRequest = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 3,
             new ASN1SequenceWrap(new ASN1Type[] {
@@ -306,24 +301,24 @@
                     ASN1Boolean.getInstance(), // typesonly
                     Filter, // Filter
                     new ASN1SequenceOf(ASN1OctetString.getInstance()) })); // attributes
-    
+
     public static final ASN1Type PartialAttributeList = new ASN1SequenceOf(
             new ASN1SequenceWrap(new ASN1Type[] {
                     ASN1OctetString.getInstance(), // type
                     new ASN1SetOf(ASN1OctetString.getInstance()) })); // vals
-    
+
     public static final ASN1Type SearchResultEntry = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 4, new ASN1SequenceWrap(
                     new ASN1Type[] { ASN1OctetString.getInstance(), // objectName
                             PartialAttributeList })); // attributes
-    
+
     public static final ASN1Type SearchResultReference = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 19, new ASN1SequenceOf(
                     ASN1OctetString.getInstance()));
-    
+
     public static final ASN1Type SearchResultDone = new ASN1Implicit(
             ASN1Constants.CLASS_APPLICATION, 5, LDAPResult);
-    
+
     public static final ASN1Type LDAPMessage = new ASN1SequenceWrap(
             new ASN1Type[] {
                     ASN1Integer.getInstance(),
@@ -352,6 +347,21 @@
                     new ASN1Implicit(ASN1Constants.CLASS_CONTEXTSPECIFIC, 0,
                             new ASN1SequenceOf(Control)) }) {
         {
+            setOptional(2);
+        }
+    };
+
+    public static final ASN1Type PersistentSearchControl = new ASN1SequenceWrap(
+            new ASN1Type[] { new ASN1Integer(), // changeTypes
+                    new ASN1Boolean(), // changesOnly
+                    new ASN1Boolean() }); // returnECs
+
+    public static final ASN1Type EntryChangeNotificationControl = new ASN1SequenceWrap(
+            new ASN1Type[] { new ASN1Enumerated(), // changeType
+                    new ASN1OctetString(), // previousDN
+                    new ASN1Integer() }) { // changeNumber
+        {
+            setOptional(1);
             setOptional(2);
         }
     };



Mime
View raw message