directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1063986 - in /directory: apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/ shared/trunk/ldap/src/test/java/org/a...
Date Thu, 27 Jan 2011 04:40:04 GMT
Author: akarasulu
Date: Thu Jan 27 04:40:03 2011
New Revision: 1063986

URL: http://svn.apache.org/viewvc?rev=1063986&view=rev
Log:
cleaned up control codec classes after changes in subentries control classes

Modified:
    directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesDecoder.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesGrammar.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java

Modified: directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=1063986&r1=1063985&r2=1063986&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
(original)
+++ directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
Thu Jan 27 04:40:03 2011
@@ -456,7 +456,7 @@ public abstract class ServerContext impl
                 control = new SubentriesDecorator();
                 SubentriesDecoder decoder = new SubentriesDecoder();
                 SubentriesContainer subentriesContainer = new SubentriesContainer();
-                subentriesContainer.setSubEntryControl( ( SubentriesDecorator ) control );
+                subentriesContainer.setSubentriesDecorator( ( SubentriesDecorator ) control
);
                 bb = ByteBuffer.allocate( jndiControl.getEncodedValue().length );
                 bb.put( jndiControl.getEncodedValue() ).flip();
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesContainer.java?rev=1063986&r1=1063985&r2=1063986&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesContainer.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesContainer.java
Thu Jan 27 04:40:03 2011
@@ -21,6 +21,7 @@ package org.apache.directory.shared.ldap
 
 
 import org.apache.directory.shared.asn1.ber.AbstractContainer;
+import org.apache.directory.shared.ldap.model.message.controls.Subentries;
 
 
 /**
@@ -33,7 +34,7 @@ public class SubentriesContainer extends
 
 
     /**
-     * Creates a new SubEntryControlContainer object. 
+     * Creates a new SubEntryControlContainer object.
      */
     public SubentriesContainer()
     {
@@ -45,9 +46,47 @@ public class SubentriesContainer extends
 
 
     /**
+     * Creates a new SubEntryControlContainer object, pre-populating it with the
+     * supplied Subentries control, and optionally wrapping it with a decorator
+     * if it is not a decorator instance.
+     *
+     * @param control The Subentries Control to decorate and add to this
+     * container, or if the Control already is a ControlDecorator it is directly
+     * added.
+     */
+    public SubentriesContainer( Subentries control )
+    {
+        this();
+        decorate( control );
+
+    }
+
+
+    /**
+     * Conditionally decorates the supplied Subentries Control if it is not already
+     * a decorator, and if already a decorator, then it is set as this container's
+     * ControlDecorator.
+     *
+     * @param control The Subentries Control to set if it is already a decorator, or
+     * if it is not already, the Control is decorated and set.
+     */
+    public void decorate( Subentries control )
+    {
+        if ( control instanceof SubentriesDecorator )
+        {
+            this.decorator = ( SubentriesDecorator ) control;
+        }
+        else
+        {
+            this.decorator = new SubentriesDecorator( control );
+        }
+    }
+
+
+    /**
      * @return Returns the persistent search control.
      */
-    public SubentriesDecorator getSubEntryControl()
+    public SubentriesDecorator getSubentriesControl()
     {
         return decorator;
     }
@@ -59,11 +98,12 @@ public class SubentriesContainer extends
      * 
      * @param decorator the SubEntryControl to set.
      */
-    public void setSubEntryControl( SubentriesDecorator decorator )
+    public void setSubentriesDecorator( SubentriesDecorator decorator )
     {
         this.decorator = decorator;
     }
 
+
     /**
      * Clean the current container
      */

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesDecoder.java?rev=1063986&r1=1063985&r2=1063986&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesDecoder.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesDecoder.java
Thu Jan 27 04:40:03 2011
@@ -27,6 +27,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.ldap.codec.controls.ControlDecoder;
 import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.message.controls.Subentries;
 
 
 /**
@@ -52,10 +53,8 @@ public class SubentriesDecoder extends A
     public Asn1Object decode( byte[] controlBytes, Control control ) throws DecoderException
     {
         ByteBuffer bb = ByteBuffer.wrap( controlBytes );
-        SubentriesContainer container = new SubentriesContainer();
-        container.setSubEntryControl( (SubentriesDecorator )control );
-
+        SubentriesContainer container = new SubentriesContainer( ( Subentries ) control );
         decoder.decode( bb, container );
-        return container.getSubEntryControl();
+        return container.getSubentriesControl();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesDecorator.java?rev=1063986&r1=1063985&r2=1063986&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesDecorator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesDecorator.java
Thu Jan 27 04:40:03 2011
@@ -33,19 +33,37 @@ import org.apache.directory.shared.ldap.
 
 
 /**
- * A searchRequest control : Subentries
+ * A Subentries Control implementation which wraps and decorates Subentries
+ * Controls to enable them to be encoded and decoded by the codec.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class SubentriesDecorator extends ControlDecorator
+public class SubentriesDecorator extends ControlDecorator implements Subentries
 {
     /**
      * Default constructor
-     *
      */
     public SubentriesDecorator()
     {
-        super( new SimpleSubentries(), new SubentriesDecoder() );
+        this( new SimpleSubentries() );
+    }
+
+
+    /**
+     * Creates a Subentries decorating implementation for use with the codec,
+     * while decorating the supplied Subentries control.
+     *
+     * @param control The Subentries Control to wrap with this decorator.
+     */
+    public SubentriesDecorator( Subentries control )
+    {
+        super( control, new SubentriesDecoder() );
+    }
+
+
+    public Subentries getSubentries()
+    {
+        return ( Subentries ) getDecorated();
     }
 
 
@@ -84,7 +102,7 @@ public class SubentriesDecorator extends
         buffer.put( TLV.getBytes( valueLength ) );
 
         // Now encode the Subentries specific part
-        Value.encode( buffer, ( ( Subentries ) getDecorated() ).isVisible() );
+        Value.encode( buffer, isVisible() );
 
         return buffer;
     }
@@ -103,7 +121,7 @@ public class SubentriesDecorator extends
                 ByteBuffer buffer = ByteBuffer.allocate( valueLength );
                 
                 // Now encode the Subentries specific part
-                Value.encode( buffer, ( ( Subentries ) getDecorated() ).isVisible() );
+                Value.encode( buffer, isVisible() );
                 
                 getDecorated().setValue( buffer.array() );
             }
@@ -115,4 +133,16 @@ public class SubentriesDecorator extends
         
         return getDecorated().getValue();
     }
+
+
+    public boolean isVisible()
+    {
+        return getSubentries().isVisible();
+    }
+
+
+    public void setVisibility( boolean visibility )
+    {
+        getSubentries().setVisibility( visibility );
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesGrammar.java?rev=1063986&r1=1063985&r2=1063986&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesGrammar.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesGrammar.java
Thu Jan 27 04:40:03 2011
@@ -32,7 +32,6 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.BooleanDecoder;
 import org.apache.directory.shared.asn1.ber.tlv.BooleanDecoderException;
 import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.model.message.controls.Subentries;
 import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -71,7 +70,6 @@ public final class SubentriesGrammar ext
                 public void action( Asn1Container container ) throws DecoderException
                 {
                     SubentriesContainer subEntryContainer = ( SubentriesContainer ) container;
-                    SubentriesDecorator decorator = subEntryContainer.getSubEntryControl();
 
                     TLV tlv = subEntryContainer.getCurrentTLV();
 
@@ -85,14 +83,14 @@ public final class SubentriesGrammar ext
 
                     try
                     {
-                        ( ( Subentries ) decorator.getDecorated() ).setVisibility( BooleanDecoder.parse(
value ) );
+                        subEntryContainer.getSubentriesControl().setVisibility( BooleanDecoder.parse(
value ) );
 
                         // We can have an END transition
                         container.setGrammarEndAllowed( true );
                     }
                     catch ( BooleanDecoderException bde )
                     {
-                        LOG.error( I18n.err( I18n.ERR_04054, Strings.dumpBytes(value.getData()),
bde.getMessage() ) );
+                        LOG.error( I18n.err( I18n.ERR_04054, Strings.dumpBytes( value.getData()),
bde.getMessage() ) );
 
                         // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( bde.getMessage() );

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java?rev=1063986&r1=1063985&r2=1063986&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java
Thu Jan 27 04:40:03 2011
@@ -65,7 +65,7 @@ public class SubEntryControlTest
         bb.flip();
 
         SubentriesContainer container = new SubentriesContainer();
-        container.setSubEntryControl( new SubentriesDecorator() );
+        container.setSubentriesDecorator( new SubentriesDecorator() );
         
         try
         {
@@ -77,7 +77,7 @@ public class SubEntryControlTest
             fail( de.getMessage() );
         }
 
-        SubentriesDecorator decorator = container.getSubEntryControl();
+        SubentriesDecorator decorator = container.getSubentriesControl();
         assertTrue( ( ( Subentries ) decorator.getDecorated() ).isVisible() );
         // test encoding
         try
@@ -123,7 +123,7 @@ public class SubEntryControlTest
         bb.flip();
 
         SubentriesContainer container = new SubentriesContainer();
-        container.setSubEntryControl( new SubentriesDecorator() );
+        container.setSubentriesDecorator( new SubentriesDecorator() );
 
         try
         {
@@ -135,7 +135,7 @@ public class SubEntryControlTest
             fail( de.getMessage() );
         }
 
-        SubentriesDecorator decorator = container.getSubEntryControl();
+        SubentriesDecorator decorator = container.getSubentriesControl();
         assertFalse( ( ( Subentries ) decorator.getDecorated() ).isVisible() );
         
         // test encoding
@@ -185,7 +185,7 @@ public class SubEntryControlTest
 
         // Allocate a LdapMessage Container
         SubentriesContainer container = new SubentriesContainer();
-        container.setSubEntryControl( new SubentriesDecorator() );
+        container.setSubentriesDecorator( new SubentriesDecorator() );
 
         // Decode a SubEntryControl PDU
         try
@@ -218,7 +218,7 @@ public class SubEntryControlTest
 
         // Allocate a LdapMessage Container
         SubentriesContainer container = new SubentriesContainer();
-        container.setSubEntryControl( new SubentriesDecorator() );
+        container.setSubentriesDecorator( new SubentriesDecorator() );
 
         // Decode a SubEntryControl PDU
         try



Mime
View raw message