directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1075077 - in /directory/shared/branches/akarasulu: ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/ ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/
Date Sun, 27 Feb 2011 15:34:17 GMT
Author: akarasulu
Date: Sun Feb 27 15:34:16 2011
New Revision: 1075077

URL: http://svn.apache.org/viewvc?rev=1075077&view=rev
Log:
fixing null pointer exception and delegating ext op instantiation to codec service

Modified:
    directory/shared/branches/akarasulu/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
    directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/InitExtendedRequest.java
    directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/StoreExtendedRequestName.java

Modified: directory/shared/branches/akarasulu/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java?rev=1075077&r1=1075076&r2=1075077&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
(original)
+++ directory/shared/branches/akarasulu/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
Sun Feb 27 15:34:16 2011
@@ -931,7 +931,14 @@ public class StandaloneLdapCodecService 
         ExtendedRequestFactory<?,?> extendedRequestFactory = extReqFactories.get( oid
);
         if ( extendedRequestFactory != null )
         {
-            req = extendedRequestFactory.newRequest( value );
+            if ( value == null )
+            {
+                req = extendedRequestFactory.newRequest();
+            }
+            else
+            {
+                req = extendedRequestFactory.newRequest( value );
+            }
         }
         else
         {

Modified: directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/InitExtendedRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/InitExtendedRequest.java?rev=1075077&r1=1075076&r2=1075077&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/InitExtendedRequest.java
(original)
+++ directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/InitExtendedRequest.java
Sun Feb 27 15:34:16 2011
@@ -24,9 +24,6 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.ldap.codec.api.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.api.ExtendedRequestDecorator;
-import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
-import org.apache.directory.shared.ldap.model.message.ExtendedRequestImpl;
-import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,13 +55,18 @@ public class InitExtendedRequest extends
      */
     public void action( LdapMessageContainer<ExtendedRequestDecorator<?,?>> container
) throws DecoderException
     {
-        // Now, we can allocate the ExtendedRequest Object
-        ExtendedRequestDecorator<?,?> extendedRequest = 
-            new ExtendedRequestDecorator<ExtendedRequest<ExtendedResponse>,ExtendedResponse>(
-                container.getLdapCodecService(), 
-                new ExtendedRequestImpl( container.getMessageId() ) );
-        container.setMessage( extendedRequest );
-
-        LOG.debug( "Extended request" );
+        /*
+         * It is the responsibility of the LdapCodecService to instantiate new
+         * extended requests and responses. So we must delegate this task over
+         * to it instead of creating the requests and responses manually. This
+         * is because we use a plugin model that allows us to use specific 
+         * types for extended requests and responses rather than using a 
+         * generic type.
+         * 
+         * So we have to wait until we at least get our hands on ExtendedRequest 
+         * OID before we can delegate instantiation to the LdapCodecService.
+         */
+        
+        LOG.debug( "Extended request being processed ..." );
     }
 }

Modified: directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/StoreExtendedRequestName.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/StoreExtendedRequestName.java?rev=1075077&r1=1075076&r2=1075077&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/StoreExtendedRequestName.java
(original)
+++ directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/extendedRequest/StoreExtendedRequestName.java
Sun Feb 27 15:34:16 2011
@@ -25,8 +25,10 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.util.OID;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.api.LdapCodecServiceFactory;
 import org.apache.directory.shared.ldap.codec.api.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.api.ExtendedRequestDecorator;
+import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
 import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -63,9 +65,8 @@ public class StoreExtendedRequestName ex
      */
     public void action( LdapMessageContainer<ExtendedRequestDecorator<?,?>> container
) throws DecoderException
     {
-        // We can allocate the ExtendedRequest Object
-        ExtendedRequestDecorator<?,?> extendedRequest = container.getMessage();
-
+        ExtendedRequest<?> req;
+        
         // Get the Value and store it in the ExtendedRequest
         TLV tlv = container.getCurrentTLV();
 
@@ -98,7 +99,8 @@ public class StoreExtendedRequestName ex
                     throw new DecoderException( msg );
                 }
 
-                extendedRequest.setRequestName( requestName );
+                req = LdapCodecServiceFactory.getSingleton().newExtendedRequest( requestName,
null );
+                container.setMessage( LdapCodecServiceFactory.getSingleton().decorate( req
) );
             }
             catch ( DecoderException de )
             {
@@ -117,7 +119,7 @@ public class StoreExtendedRequestName ex
 
         if ( IS_DEBUG )
         {
-            LOG.debug( "OID read : {}", extendedRequest.getRequestName() );
+            LOG.debug( "OID read : {}", req.getRequestName() );
         }
     }
 }



Mime
View raw message