directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1065427 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
Date Sun, 30 Jan 2011 23:43:42 GMT
Author: elecharny
Date: Sun Jan 30 23:43:42 2011
New Revision: 1065427

URL: http://svn.apache.org/viewvc?rev=1065427&view=rev
Log:
Added the handling of unknown contorls

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java?rev=1065427&r1=1065426&r2=1065427&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
Sun Jan 30 23:43:42 2011
@@ -20,11 +20,13 @@
 package org.apache.directory.shared.ldap.codec;
 
 
-import java.lang.reflect.Field; 
+import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
+import javax.naming.ldap.BasicControl;
+
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.codec.controls.CascadeFactory;
@@ -168,6 +170,7 @@ public class DefaultLdapCodecService imp
             Field f = clazz.getField( "OID" );
             String oid = ( String ) f.get( null );
             IControlFactory<?,?> factory = controlFactories.get( oid );
+            
             return ( E ) factory.newControl();
         }
         catch ( IllegalAccessException e )
@@ -202,6 +205,12 @@ public class DefaultLdapCodecService imp
         try
         {
             IControlFactory<?,?> factory = controlFactories.get( oid );
+            
+            if ( factory == null )
+            {
+                return (E)new BasicControl( oid );
+            }
+            
             return ( E ) factory.newControl();
         }
         catch ( SecurityException e )
@@ -218,6 +227,12 @@ public class DefaultLdapCodecService imp
         try
         {
             IControlFactory factory = controlFactories.get( control.getOid() );
+            
+            if ( factory == null )
+            {
+                return null; // Here, instanciate a default factory
+            }
+            
             return factory.decorate( control );
         }
         catch ( SecurityException e )



Mime
View raw message