directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1063981 - 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/persistentSearch/ shared/trunk/ldap/src/test/java...
Date Thu, 27 Jan 2011 04:13:51 GMT
Author: akarasulu
Date: Thu Jan 27 04:13:51 2011
New Revision: 1063981

URL: http://svn.apache.org/viewvc?rev=1063981&view=rev
Log:
moving cleaned up control interfaces and simple implementations to model

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/persistentSearch/PersistentSearchContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchDecoder.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchStates.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.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=1063981&r1=1063980&r2=1063981&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:13:51 2011
@@ -444,7 +444,7 @@ public abstract class ServerContext impl
                 control = new PersistentSearchDecorator();
                 PersistentSearchDecoder persistentSearchDecoder = new PersistentSearchDecoder();
                 PersistentSearchContainer persistentSearchContainer = new PersistentSearchContainer();
-                persistentSearchContainer.setPSearchDecorator( ( PersistentSearchDecorator
) control );
+                persistentSearchContainer.setPersistentSearchDecorator( ( PersistentSearchDecorator
) 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/persistentSearch/PersistentSearchContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchContainer.java?rev=1063981&r1=1063980&r2=1063981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchContainer.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchContainer.java
Thu Jan 27 04:13:51 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.PersistentSearch;
 
 
 /**
@@ -46,9 +47,43 @@ public class PersistentSearchContainer e
 
 
     /**
+     * Creates a new PSearchControlContainer object pre-populated with a
+     * decorator wrapping the supplied control, or using the supplied control if
+     * it already is a decorator.
+     *
+     * @param control The PersistentSearch Control or a decorating wrapper.
+     */
+    public PersistentSearchContainer( PersistentSearch control )
+    {
+        this();
+        decorate( control );
+    }
+
+
+    /**
+     * Conditionally decorates a control if is not a decorator already.
+     *
+     * @param control The PersistentSearch Control to decorate if it already is not
+     * a decorator, if it is then the object is set as this container's decorator.
+     */
+    public void decorate( PersistentSearch control )
+    {
+        if ( control instanceof PersistentSearchDecorator )
+        {
+            this.decorator = ( PersistentSearchDecorator ) control;
+        }
+        else
+        {
+            this.decorator = new PersistentSearchDecorator( control );
+        }
+    }
+
+
+
+    /**
      * @return Returns the persistent search decorator.
      */
-    public PersistentSearchDecorator getPSearchDecorator()
+    public PersistentSearchDecorator getPersistentSearchDecorator()
     {
 
         return decorator;
@@ -61,11 +96,12 @@ public class PersistentSearchContainer e
      * 
      * @param decorator the PSearchControl to set.
      */
-    public void setPSearchDecorator( PersistentSearchDecorator decorator )
+    public void setPersistentSearchDecorator( PersistentSearchDecorator decorator )
     {
         this.decorator = decorator;
     }
 
+
     /**
      * Clean the container
      */

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchDecoder.java?rev=1063981&r1=1063980&r2=1063981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchDecoder.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchDecoder.java
Thu Jan 27 04:13:51 2011
@@ -27,6 +27,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.DecoderException;
 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.PersistentSearch;
 
 
 /**
@@ -52,10 +53,8 @@ public class PersistentSearchDecoder ext
     public Asn1Object decode( byte[] controlBytes, Control control ) throws DecoderException
     {
         ByteBuffer bb = ByteBuffer.wrap( controlBytes );
-        PersistentSearchContainer container = new PersistentSearchContainer();
-        container.setPSearchDecorator( ( PersistentSearchDecorator ) control );
-
+        PersistentSearchContainer container = new PersistentSearchContainer( ( PersistentSearch
) control );
         decoder.decode( bb, container );
-        return container.getPSearchDecorator();
+        return container.getPersistentSearchDecorator();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchDecorator.java?rev=1063981&r1=1063980&r2=1063981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchDecorator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchDecorator.java
Thu Jan 27 04:13:51 2011
@@ -28,6 +28,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.controls.ControlDecorator;
+import org.apache.directory.shared.ldap.model.message.controls.ChangeType;
 import org.apache.directory.shared.ldap.model.message.controls.PersistentSearch;
 import org.apache.directory.shared.ldap.model.message.controls.SimplePersistentSearch;
 
@@ -37,19 +38,31 @@ import org.apache.directory.shared.ldap.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PersistentSearchDecorator extends ControlDecorator
+public class PersistentSearchDecorator extends ControlDecorator implements PersistentSearch
 {
     /** A temporary storage for a psearch length */
     private int psearchSeqLength;
 
 
     /**
-     * Default constructor
-     *
+     * Default constructor creates a PersistentSearch Control automatically
+     * wrapped in a decorator object inside this container.
      */
     public PersistentSearchDecorator()
     {
-        super( new SimplePersistentSearch(), new PersistentSearchDecoder() );
+        this( new SimplePersistentSearch() );
+    }
+
+
+    /**
+     * Creates a PersistentSearch Control wrapping a supplied PersistentSearch
+     * Control.
+     *
+     * @param control The PersistentSearch Control to wrap.
+     */
+    public PersistentSearchDecorator( PersistentSearch control )
+    {
+        super( control, new PersistentSearchDecoder() );
     }
 
 
@@ -69,7 +82,7 @@ public class PersistentSearchDecorator e
      */
     public int computeLength()
     {
-        int changeTypesLength = 1 + 1 + Value.getNbBytes( ( ( PersistentSearch ) getDecorated()
).getChangeTypes() );
+        int changeTypesLength = 1 + 1 + Value.getNbBytes( getChangeTypes() );
         int changesOnlyLength = 1 + 1 + 1;
         int returnRCsLength = 1 + 1 + 1;
 
@@ -106,9 +119,9 @@ public class PersistentSearchDecorator e
         buffer.put( UniversalTag.SEQUENCE.getValue() );
         buffer.put( TLV.getBytes( psearchSeqLength ) );
 
-        Value.encode( buffer, ( ( PersistentSearch ) getDecorated() ).getChangeTypes() );
-        Value.encode( buffer, ( ( PersistentSearch ) getDecorated() ).isChangesOnly() );
-        Value.encode( buffer, ( ( PersistentSearch ) getDecorated() ).isReturnECs() );
+        Value.encode( buffer, getChangeTypes() );
+        Value.encode( buffer, isChangesOnly() );
+        Value.encode( buffer, isReturnECs() );
         
         return buffer;
     }
@@ -130,9 +143,9 @@ public class PersistentSearchDecorator e
                 buffer.put( UniversalTag.SEQUENCE.getValue() );
                 buffer.put( TLV.getBytes( psearchSeqLength ) );
 
-                Value.encode( buffer, ( ( PersistentSearch ) getDecorated() ).getChangeTypes()
);
-                Value.encode( buffer, ( ( PersistentSearch ) getDecorated() ).isChangesOnly()
);
-                Value.encode( buffer, ( ( PersistentSearch ) getDecorated() ).isReturnECs()
);
+                Value.encode( buffer, getChangeTypes() );
+                Value.encode( buffer, isChangesOnly() );
+                Value.encode( buffer, isReturnECs() );
 
                 getDecorated().setValue( buffer.array() );
             }
@@ -144,4 +157,59 @@ public class PersistentSearchDecorator e
         
         return getDecorated().getValue();
     }
+
+
+
+    private PersistentSearch getPersistentSearch()
+    {
+        return ( PersistentSearch ) getDecorated();
+    }
+
+
+    public void setChangesOnly( boolean changesOnly )
+    {
+        getPersistentSearch().setChangesOnly( changesOnly );
+    }
+
+
+    public boolean isChangesOnly()
+    {
+        return getPersistentSearch().isChangesOnly();
+    }
+
+
+    public void setReturnECs( boolean returnECs )
+    {
+        getPersistentSearch().setReturnECs( returnECs );
+    }
+
+
+    public boolean isReturnECs()
+    {
+        return getPersistentSearch().isReturnECs();
+    }
+
+
+    public void setChangeTypes( int changeTypes )
+    {
+        getPersistentSearch().setChangeTypes( changeTypes );
+    }
+
+
+    public int getChangeTypes()
+    {
+        return getPersistentSearch().getChangeTypes();
+    }
+
+
+    public boolean isNotificationEnabled( ChangeType changeType )
+    {
+        return getPersistentSearch().isNotificationEnabled( changeType );
+    }
+
+
+    public void enableNotification( ChangeType changeType )
+    {
+        getPersistentSearch().enableNotification( changeType );
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchGrammar.java?rev=1063981&r1=1063980&r2=1063981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchGrammar.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchGrammar.java
Thu Jan 27 04:13:51 2011
@@ -120,9 +120,7 @@ public final class PersistentSearchGramm
                             LOG.debug( "changeTypes = " + changeTypes );
                         }
 
-                        PersistentSearch persistentSearch = ( PersistentSearch )
-                                psearchContainer.getPSearchDecorator().getDecorated();
-                        persistentSearch.setChangeTypes( changeTypes );
+                        psearchContainer.getPersistentSearchDecorator().setChangeTypes( changeTypes
);
                     }
                     catch ( IntegerDecoderException e )
                     {
@@ -161,9 +159,7 @@ public final class PersistentSearchGramm
                             LOG.debug( "changesOnly = " + changesOnly );
                         }
 
-                        PersistentSearch persistentSearch = ( PersistentSearch )
-                                psearchContainer.getPSearchDecorator().getDecorated();
-                        persistentSearch.setChangesOnly( changesOnly );
+                        psearchContainer.getPersistentSearchDecorator().setChangesOnly( changesOnly
);
                     }
                     catch ( BooleanDecoderException e )
                     {
@@ -202,9 +198,7 @@ public final class PersistentSearchGramm
                             LOG.debug( "returnECs = " + returnECs );
                         }
 
-                        PersistentSearch persistentSearch = ( PersistentSearch )
-                                psearchContainer.getPSearchDecorator().getDecorated();
-                        persistentSearch.setReturnECs( returnECs );
+                        psearchContainer.getPersistentSearchDecorator().setReturnECs( returnECs
);
 
                         // We can have an END transition
                         psearchContainer.setGrammarEndAllowed( true );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchStates.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchStates.java?rev=1063981&r1=1063980&r2=1063981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchStates.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchStates.java
Thu Jan 27 04:13:51 2011
@@ -63,10 +63,9 @@ public enum PersistentSearchStates imple
     /**
      * Get the grammar name
      * 
-     * @param grammar The grammar code
      * @return The grammar name
      */
-    public String getGrammarName( int grammar )
+    public String getGrammarName()
     {
         return "PSEARCH_GRAMMAR";
     }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java?rev=1063981&r1=1063980&r2=1063981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java
Thu Jan 27 04:13:51 2011
@@ -102,7 +102,7 @@ public class PSearchControlTest
         bb.flip();
 
         PersistentSearchContainer container = new PersistentSearchContainer();
-        container.setPSearchDecorator( new PersistentSearchDecorator() );
+        container.setPersistentSearchDecorator( new PersistentSearchDecorator() );
 
         try
         {
@@ -113,7 +113,7 @@ public class PSearchControlTest
             fail( de.getMessage() );
         }
 
-        PersistentSearch ctrl = ( PersistentSearch ) container.getPSearchDecorator().getDecorated();
+        PersistentSearch ctrl = ( PersistentSearch ) container.getPersistentSearchDecorator().getDecorated();
         int changeTypes = ctrl.getChangeTypes();
         assertTrue( ChangeType.ADD.presentIn( changeTypes ) );
         assertTrue( ChangeType.MODDN.presentIn( changeTypes ) );
@@ -140,7 +140,7 @@ public class PSearchControlTest
         bb.flip();
 
         PersistentSearchContainer container = new PersistentSearchContainer();
-        container.setPSearchDecorator( new PersistentSearchDecorator() );
+        container.setPersistentSearchDecorator( new PersistentSearchDecorator() );
         
         try
         {
@@ -172,7 +172,7 @@ public class PSearchControlTest
         bb.flip();
 
         PersistentSearchContainer container = new PersistentSearchContainer();
-        container.setPSearchDecorator( new PersistentSearchDecorator() );
+        container.setPersistentSearchDecorator( new PersistentSearchDecorator() );
 
         try
         {
@@ -200,7 +200,7 @@ public class PSearchControlTest
         bb.flip();
 
         PersistentSearchContainer container = new PersistentSearchContainer();
-        container.setPSearchDecorator( new PersistentSearchDecorator() );
+        container.setPersistentSearchDecorator( new PersistentSearchDecorator() );
 
         try
         {
@@ -230,7 +230,7 @@ public class PSearchControlTest
         bb.flip();
 
         PersistentSearchContainer container = new PersistentSearchContainer();
-        container.setPSearchDecorator( new PersistentSearchDecorator() );
+        container.setPersistentSearchDecorator( new PersistentSearchDecorator() );
 
         try
         {
@@ -260,7 +260,7 @@ public class PSearchControlTest
         bb.flip();
 
         PersistentSearchContainer container = new PersistentSearchContainer();
-        container.setPSearchDecorator( new PersistentSearchDecorator() );
+        container.setPersistentSearchDecorator( new PersistentSearchDecorator() );
 
         try
         {
@@ -290,7 +290,7 @@ public class PSearchControlTest
         bb.flip();
 
         PersistentSearchContainer container = new PersistentSearchContainer();
-        container.setPSearchDecorator( new PersistentSearchDecorator() );
+        container.setPersistentSearchDecorator( new PersistentSearchDecorator() );
 
         try
         {



Mime
View raw message