directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1067017 - in /directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec: ./ controls/cascade/ controls/manageDsaIT/ controls/search/entryChange/ controls/search/pagedSearch/ controls/search/persistentSearch/ co...
Date Thu, 03 Feb 2011 22:45:01 GMT
Author: akarasulu
Date: Thu Feb  3 22:45:00 2011
New Revision: 1067017

URL: http://svn.apache.org/viewvc?rev=1067017&view=rev
Log:
DIRSHARED-81:

  o more documentation
  o removed unnecessary JNDI control conversion methods in factory and 
    delegated this task to be handled by the codec service we can do the
    job so all implementors do not have to
  o clean ups

Modified:
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/IControlFactory.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/cascade/CascadeFactory.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/manageDsaIT/ManageDsaITFactory.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/entryChange/EntryChangeFactory.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/pagedSearch/PagedResultsFactory.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/persistentSearch/PersistentSearchFactory.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/subentries/SubentriesFactory.java

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java?rev=1067017&r1=1067016&r2=1067017&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
Thu Feb  3 22:45:00 2011
@@ -100,6 +100,9 @@ public class DefaultLdapCodecService imp
         SubentriesFactory subentriesFactory = new SubentriesFactory( this );
         controlFactories.put( Subentries.OID, subentriesFactory );
         
+        // @TODO - these will eventually be removed to enable plugin driven
+        // registration instead
+        
         SyncDoneValueFactory syncDoneValueFactory = new SyncDoneValueFactory( this );
         controlFactories.put( SyncDoneValue.OID, syncDoneValueFactory );
         
@@ -303,13 +306,17 @@ public class DefaultLdapCodecService imp
         
         if ( factory == null )
         {
-            AbstractControl ourControl = new OpaqueControl( control.getID() );
+            OpaqueControl ourControl = new OpaqueControl( control.getID() );
             ourControl.setCritical( control.isCritical() );
             BasicControlDecorator decorator = new BasicControlDecorator( this, ourControl
);
             decorator.setValue( control.getEncodedValue() );
             return decorator;
         }
         
-        return factory.fromJndiControl( control );
+        ICodecControl<? extends Control> ourControl = factory.newCodecControl();
+        ourControl.setCritical( control.isCritical() );
+        ourControl.setValue( control.getEncodedValue() );
+        ourControl.decode( control.getEncodedValue() );
+        return ourControl;
     }
 }

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/IControlFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/IControlFactory.java?rev=1067017&r1=1067016&r2=1067017&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/IControlFactory.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/IControlFactory.java
Thu Feb  3 22:45:00 2011
@@ -20,8 +20,6 @@
 package org.apache.directory.shared.ldap.codec;
 
 
-import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.model.message.Control;
 
 
@@ -77,20 +75,4 @@ public interface IControlFactory<C exten
      * @return
      */
     C newControl();
-
-
-    /**
-     * @TODO I also think these methods are not needed here. These can move to the
-     * codec facade interface - the codec service interface - instead. Basically the
-     * codec can grab a decorated object and generate the jndi equivalents and vice
-     * versa. We don't need tens of controls having to implement this same logic.
-     *
-     *
-     * @param modelControl
-     * @return
-     * @throws EncoderException
-     */
-    javax.naming.ldap.Control toJndiControl( C modelControl ) throws EncoderException;
-    
-    C fromJndiControl( javax.naming.ldap.Control jndiControl ) throws DecoderException;
 }

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/cascade/CascadeFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/cascade/CascadeFactory.java?rev=1067017&r1=1067016&r2=1067017&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/cascade/CascadeFactory.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/cascade/CascadeFactory.java
Thu Feb  3 22:45:00 2011
@@ -20,16 +20,10 @@
 package org.apache.directory.shared.ldap.codec.controls.cascade;
 
 
-import javax.naming.ldap.BasicControl;
-import javax.naming.ldap.Control;
-
-import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.codec.IControlFactory;
 import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.message.controls.Cascade;
 import org.apache.directory.shared.ldap.model.message.controls.CascadeImpl;
-import org.apache.directory.shared.util.StringConstants;
 
 
 /**
@@ -89,22 +83,4 @@ public class CascadeFactory implements I
     {
         return new CascadeImpl();
     }
-
-    
-    /**
-     * {@inheritDoc}
-     */
-    public Control toJndiControl( Cascade control ) throws EncoderException
-    {
-        return new BasicControl( Cascade.OID, control.isCritical(), StringConstants.EMPTY_BYTES
);
-    }
-
-    
-    /**
-     * {@inheritDoc}
-     */
-    public Cascade fromJndiControl( Control control ) throws DecoderException
-    {
-        return new CascadeImpl( control.isCritical() );
-    }
 }

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/manageDsaIT/ManageDsaITFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/manageDsaIT/ManageDsaITFactory.java?rev=1067017&r1=1067016&r2=1067017&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/manageDsaIT/ManageDsaITFactory.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/manageDsaIT/ManageDsaITFactory.java
Thu Feb  3 22:45:00 2011
@@ -20,16 +20,10 @@
 package org.apache.directory.shared.ldap.codec.controls.manageDsaIT;
 
 
-import javax.naming.ldap.BasicControl;
-import javax.naming.ldap.Control;
-
-import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.codec.IControlFactory;
 import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
 import org.apache.directory.shared.ldap.model.message.controls.ManageDsaITImpl;
-import org.apache.directory.shared.util.StringConstants;
 
 
 /**
@@ -89,22 +83,4 @@ public class ManageDsaITFactory implemen
     {
         return new ManageDsaITImpl();
     }
-
-    
-    /**
-     * {@inheritDoc}
-     */
-    public Control toJndiControl( ManageDsaIT control ) throws EncoderException
-    {
-        return new BasicControl( ManageDsaIT.OID, control.isCritical(), StringConstants.EMPTY_BYTES
);
-    }
-
-    
-    /**
-     * {@inheritDoc}
-     */
-    public ManageDsaIT fromJndiControl( Control control ) throws DecoderException
-    {
-        return new ManageDsaITImpl( control.isCritical() );
-    }
 }

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/entryChange/EntryChangeFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/entryChange/EntryChangeFactory.java?rev=1067017&r1=1067016&r2=1067017&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/entryChange/EntryChangeFactory.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/entryChange/EntryChangeFactory.java
Thu Feb  3 22:45:00 2011
@@ -20,13 +20,6 @@
 package org.apache.directory.shared.ldap.codec.controls.search.entryChange;
 
 
-import java.nio.ByteBuffer;
-
-import javax.naming.ldap.BasicControl;
-import javax.naming.ldap.Control;
-
-import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.codec.IControlFactory;
 import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.message.controls.EntryChange;
@@ -90,28 +83,4 @@ public class EntryChangeFactory implemen
     {
         return new EntryChangeImpl();
     }
-    
-
-    /**
-     * {@inheritDoc}
-     */
-    public Control toJndiControl( EntryChange control ) throws EncoderException
-    {
-        EntryChangeDecorator decorator = decorate( control );
-        ByteBuffer bb = ByteBuffer.allocate( decorator.computeLength() );
-        decorator.encode( bb );
-        bb.flip();
-        return new BasicControl( EntryChange.OID, control.isCritical(), bb.array() );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public EntryChange fromJndiControl( Control control ) throws DecoderException
-    {
-        EntryChangeDecorator decorator = new EntryChangeDecorator( codec );
-        decorator.setValue( control.getEncodedValue() );
-        return decorator;
-    }
 }

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/pagedSearch/PagedResultsFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/pagedSearch/PagedResultsFactory.java?rev=1067017&r1=1067016&r2=1067017&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/pagedSearch/PagedResultsFactory.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/pagedSearch/PagedResultsFactory.java
Thu Feb  3 22:45:00 2011
@@ -20,13 +20,6 @@
 package org.apache.directory.shared.ldap.codec.controls.search.pagedSearch;
 
 
-import java.nio.ByteBuffer; 
-
-import javax.naming.ldap.BasicControl;
-import javax.naming.ldap.Control;
-
-import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.codec.IControlFactory;
 import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.message.controls.PagedResults;
@@ -90,28 +83,4 @@ public class PagedResultsFactory impleme
     {
         return new PagedResultsImpl();
     }
-    
-
-    /**
-     * {@inheritDoc}
-     */
-    public Control toJndiControl( PagedResults control ) throws EncoderException
-    {
-        PagedResultsDecorator decorator = decorate( control );
-        ByteBuffer bb = ByteBuffer.allocate( decorator.computeLength() );
-        decorator.encode( bb );
-        bb.flip();
-        return new BasicControl( PagedResults.OID, control.isCritical(), bb.array() );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public PagedResults fromJndiControl( Control control ) throws DecoderException
-    {
-        PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
-        decorator.setValue( control.getEncodedValue() );
-        return decorator;
-    }
 }

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/persistentSearch/PersistentSearchFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/persistentSearch/PersistentSearchFactory.java?rev=1067017&r1=1067016&r2=1067017&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/persistentSearch/PersistentSearchFactory.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/persistentSearch/PersistentSearchFactory.java
Thu Feb  3 22:45:00 2011
@@ -20,13 +20,6 @@
 package org.apache.directory.shared.ldap.codec.controls.search.persistentSearch;
 
 
-import java.nio.ByteBuffer;
-
-import javax.naming.ldap.BasicControl;
-import javax.naming.ldap.Control;
-
-import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.codec.IControlFactory;
 import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.message.controls.PersistentSearch;
@@ -48,19 +41,29 @@ public class PersistentSearchFactory imp
     {
         this.codec = codec;
     }
+
     
+    /**
+     * {@inheritDoc}
+     */
     public String getOid()
     {
         return PersistentSearch.OID;
     }
 
     
+    /**
+     * {@inheritDoc}
+     */
     public PersistentSearchDecorator newCodecControl()
     {
         return new PersistentSearchDecorator( codec );
     }
 
     
+    /**
+     * {@inheritDoc}
+     */
     public PersistentSearchDecorator decorate( PersistentSearch control )
     {
         // protect against double decoration
@@ -75,29 +78,11 @@ public class PersistentSearchFactory imp
     }
 
     
+    /**
+     * {@inheritDoc}
+     */
     public PersistentSearch newControl()
     {
         return new PersistentSearchImpl();
     }
-    
-    
-    public Control toJndiControl( PersistentSearch control ) throws EncoderException
-    {
-        PersistentSearchDecorator decorator = decorate( control );
-        ByteBuffer buf = ByteBuffer.allocate( decorator.computeLength() );
-        decorator.encode( buf );
-        buf.flip();
-        return new BasicControl( control.getOid(), control.isCritical(), buf.array() );
-    }
-    
-    
-    public PersistentSearch fromJndiControl( Control jndi ) throws DecoderException
-    {
-        PersistentSearchDecorator decorator = newCodecControl();
-        decorator.setCritical( jndi.isCritical() );
-        decorator.setValue( jndi.getEncodedValue() );
-        byte[] controlBytes = new byte[decorator.computeLength()];
-        decorator.decode( controlBytes );
-        return decorator.getDecorated();
-    }
 }

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/subentries/SubentriesFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/subentries/SubentriesFactory.java?rev=1067017&r1=1067016&r2=1067017&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/subentries/SubentriesFactory.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/search/subentries/SubentriesFactory.java
Thu Feb  3 22:45:00 2011
@@ -20,13 +20,6 @@
 package org.apache.directory.shared.ldap.codec.controls.search.subentries;
 
 
-import java.nio.ByteBuffer;
-
-import javax.naming.ldap.BasicControl;
-import javax.naming.ldap.Control;
-
-import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.codec.IControlFactory;
 import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.message.controls.Subentries;
@@ -100,41 +93,4 @@ public class SubentriesFactory implement
         
         return new SubentriesDecorator( codec, control );
     }
-    
-
-    /**
-     * 
-     * {@inheritDoc}
-     */
-    public Control toJndiControl( Subentries control ) throws EncoderException
-    {
-        SubentriesDecorator decorator = null;
-        
-        if ( control instanceof SubentriesDecorator )
-        {
-            decorator = ( SubentriesDecorator ) control;
-        }
-        else
-        {
-            decorator = new SubentriesDecorator( codec, control );
-        }
-        
-        ByteBuffer bb = ByteBuffer.allocate( decorator.computeLength() );
-        decorator.encode( bb );
-        bb.flip();
-        
-        return new BasicControl( control.getOid(), control.isCritical(), decorator.getValue()
);
-    }
-    
-
-    /**
-     * 
-     * {@inheritDoc}
-     */
-    public Subentries fromJndiControl( Control control ) throws DecoderException
-    {
-        SubentriesDecorator decorator = new SubentriesDecorator( codec );
-        decorator.decode( control.getEncodedValue() );
-        return decorator.getDecorated();
-    }
 }



Mime
View raw message