directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1065651 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesFactory.java
Date Mon, 31 Jan 2011 15:21:50 GMT
Author: akarasulu
Date: Mon Jan 31 15:21:49 2011
New Revision: 1065651

URL: http://svn.apache.org/viewvc?rev=1065651&view=rev
Log:
adding missing toJndi/fromJndi methods to SubentriesFactory

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesFactory.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesFactory.java?rev=1065651&r1=1065650&r2=1065651&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesFactory.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesFactory.java
Mon Jan 31 15:21:49 2011
@@ -20,6 +20,9 @@
 package org.apache.directory.shared.ldap.codec.search.controls.subentries;
 
 
+import java.nio.ByteBuffer;
+
+import javax.naming.ldap.BasicControl;
 import javax.naming.ldap.Control;
 
 import org.apache.directory.shared.asn1.DecoderException;
@@ -78,11 +81,29 @@ public class SubentriesFactory implement
 
     public Control toJndiControl( Subentries control ) throws EncoderException
     {
-        return null;
+        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()
);
     }
+    
 
     public Subentries fromJndiControl( Control control ) throws DecoderException
     {
-        return null;
+        SubentriesDecorator decorator = new SubentriesDecorator( codec );
+        decorator.decode( control.getEncodedValue() );
+        return decorator.getDecorated();
     }
 }



Mime
View raw message