directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1065450 - in /directory/shared/trunk: dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/ dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/ ldap/src/main/java/org/apache/directory/shared/ldap/codec/
Date Mon, 31 Jan 2011 00:48:54 GMT
Author: elecharny
Date: Mon Jan 31 00:48:54 2011
New Revision: 1065450

URL: http://svn.apache.org/viewvc?rev=1065450&view=rev
Log:
Fixed the basic control

Modified:
    directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
    directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/AddRequestTest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/BasicControlDecorator.java

Modified: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java?rev=1065450&r1=1065449&r2=1065450&view=diff
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
(original)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
Mon Jan 31 00:48:54 2011
@@ -2747,8 +2747,7 @@ public final class Dsmlv2Grammar extends
                     throw new XmlPullParserException( I18n.err( I18n.ERR_03034 ), xpp, null
);
                 }
 
-                Control decoratedControl = codec.newControl( attributeValue );
-                control = codec.decorate( decoratedControl );
+                control = codec.decorate( (Control)codec.newControl( attributeValue ) );
                 container.getBatchRequest().getCurrentRequest().addControl( control );
             }
             else

Modified: directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/AddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/AddRequestTest.java?rev=1065450&r1=1065449&r2=1065450&view=diff
==============================================================================
--- directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/AddRequestTest.java
(original)
+++ directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/AddRequestTest.java
Mon Jan 31 00:48:54 2011
@@ -34,6 +34,7 @@ import org.apache.directory.junit.tools.
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
 import org.apache.directory.shared.dsmlv2.AbstractTest;
 import org.apache.directory.shared.dsmlv2.Dsmlv2Parser;
+import org.apache.directory.shared.ldap.codec.controls.ControlDecorator;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.model.entry.Value;
@@ -157,7 +158,7 @@ public class AddRequestTest extends Abst
         assertNotNull( control );
         assertTrue( control.isCritical() );
         assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
-        assertEquals( "Some text", Strings.utf8ToString((byte[]) getCodec().decorate( control
).getValue()) );
+        assertEquals( "Some text", Strings.utf8ToString( ((ControlDecorator<Control>)control).getValue()
) );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/BasicControlDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/BasicControlDecorator.java?rev=1065450&r1=1065449&r2=1065450&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/BasicControlDecorator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/BasicControlDecorator.java
Mon Jan 31 00:48:54 2011
@@ -20,13 +20,11 @@
 package org.apache.directory.shared.ldap.codec;
 
 
-import java.nio.ByteBuffer;
-
 import org.apache.directory.shared.asn1.Asn1Object;
 import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.codec.controls.ControlDecorator;
 import org.apache.directory.shared.ldap.model.message.controls.BasicControl;
+import org.apache.directory.shared.util.Strings;
 
 
 /**
@@ -37,65 +35,22 @@ import org.apache.directory.shared.ldap.
  */
 public class BasicControlDecorator extends ControlDecorator<BasicControl>
 {
-    private byte[] value;
-    
-    private BasicControl control;
     private ILdapCodecService codec;
-    
-    
-    public BasicControlDecorator( ILdapCodecService codec, BasicControl control )
-    {
-        super( codec, control );
-    }
-    
-    
-    public String getOid()
-    {
-        return control.getOid();
-    }
-
-    
-    public boolean isCritical()
-    {
-        return control.isCritical();
-    }
-
-    
-    public void setCritical( boolean isCritical )
-    {
-        control.setCritical( isCritical );
-    }
-
-    
-    public BasicControl getDecorated()
-    {
-        return control;
-    }
 
-    
-    public int computeLength()
-    {
-        return 0;
-    }
+    /** The control value */
+    private byte[] value;
 
-    
-    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    public BasicControlDecorator( ILdapCodecService codec, BasicControl control )
     {
-        return null;
+        super( codec, control );
     }
 
-    
-    public ILdapCodecService getCodecService()
-    {
-        return codec;
-    }
 
-    
-    /**
-     * {@inheritDoc}
-     */
+    @Override
     public Asn1Object decode( byte[] controlBytes ) throws DecoderException
     {
+        setValue( controlBytes );
+        
         return null;
     }
 
@@ -123,6 +78,12 @@ public class BasicControlDecorator exten
      */
     public void setValue( byte[] value )
     {
+        if ( ! Strings.isEmpty( value ) )
+        {
+            byte[] copy = new byte[value.length];
+            System.arraycopy( value, 0, copy, 0, value.length );
+        }
+        
         this.value = value;
     }
 }



Mime
View raw message