directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1072248 - in /directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap: ./ handlers/ handlers/extended/
Date Sat, 19 Feb 2011 04:47:12 GMT
Author: akarasulu
Date: Sat Feb 19 04:47:12 2011
New Revision: 1072248

URL: http://svn.apache.org/viewvc?rev=1072248&view=rev
Log:
DIRSHARED-86: generics and cleanup of codec implementation usages

Modified:
    directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
    directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
    directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java
    directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
    directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.java

Modified: directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java?rev=1072248&r1=1072247&r2=1072248&view=diff
==============================================================================
--- directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
(original)
+++ directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
Sat Feb 19 04:47:12 2011
@@ -769,9 +769,9 @@ public class LdapServer extends Director
      * request handler
      * @return the exnteded operation handler
      */
-    public ExtendedOperationHandler getExtendedOperationHandler( String oid )
+    public ExtendedOperationHandler<ExtendedRequest> getExtendedOperationHandler( String
oid )
     {
-        for ( ExtendedOperationHandler h : extendedOperationHandlers )
+        for ( ExtendedOperationHandler<ExtendedRequest> h : extendedOperationHandlers
)
         {
             if ( h.getOid().equals( oid ) )
             {

Modified: directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java?rev=1072248&r1=1072247&r2=1072248&view=diff
==============================================================================
--- directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
(original)
+++ directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
Sat Feb 19 04:47:12 2011
@@ -38,7 +38,8 @@ public class ExtendedHandler extends Lda
 {
     public void handle( LdapSession session, ExtendedRequest req ) throws Exception
     {
-        ExtendedOperationHandler handler = getLdapServer().getExtendedOperationHandler( req.getRequestName()
);
+        ExtendedOperationHandler<ExtendedRequest> handler = 
+            getLdapServer().getExtendedOperationHandler( req.getRequestName() );
 
         if ( handler == null )
         {

Modified: directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java?rev=1072248&r1=1072247&r2=1072248&view=diff
==============================================================================
--- directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java
(original)
+++ directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java
Sat Feb 19 04:47:12 2011
@@ -31,7 +31,6 @@ import org.apache.directory.server.i18n.
 import org.apache.directory.server.ldap.ExtendedOperationHandler;
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.ldap.LdapSession;
-import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.extras.extended.GracefulDisconnect;
 import org.apache.directory.shared.ldap.extras.extended.GracefulShutdownRequest;
@@ -48,7 +47,7 @@ import org.slf4j.LoggerFactory;
  * @todo : missing Javadoc
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class GracefulShutdownHandler implements ExtendedOperationHandler
+public class GracefulShutdownHandler implements ExtendedOperationHandler<GracefulShutdownRequest>
 {
     private static final Logger LOG = LoggerFactory.getLogger( GracefulShutdownHandler.class
);
     public static final Set<String> EXTENSION_OIDS;
@@ -69,7 +68,7 @@ public class GracefulShutdownHandler imp
     }
 
 
-    public void handleExtendedOperation( LdapSession requestor, ExtendedRequest req ) throws
Exception
+    public void handleExtendedOperation( LdapSession requestor, GracefulShutdownRequest req
) throws Exception
     {
         // make sue only the administrator can issue this shutdown request if 
         // not we respond to the requestor with with insufficientAccessRights(50)
@@ -93,16 +92,15 @@ public class GracefulShutdownHandler imp
         IoAcceptor acceptor = ( IoAcceptor ) requestor.getIoSession().getService();
         List<IoSession> sessions = new ArrayList<IoSession>(
                 acceptor.getManagedSessions().values() );
-        GracefulShutdownRequest gsreq = ( GracefulShutdownRequest ) req;
 
         // build the graceful disconnect message with replicationContexts
-        GracefulDisconnect notice = getGracefulDisconnect( gsreq.getTimeOffline(), gsreq.getDelay()
);
+        GracefulDisconnect notice = getGracefulDisconnect( req.getTimeOffline(), req.getDelay()
);
 
         // send (synch) the GracefulDisconnect to each client before unbinding
         sendGracefulDisconnect( sessions, notice, requestor.getIoSession() );
 
         // wait for the specified delay before we unbind the service 
-        waitForDelay( gsreq.getDelay() );
+        waitForDelay( req.getDelay() );
 
         // -------------------------------------------------------------------
         // unbind the server socket for the LDAP service here so no new 

Modified: directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java?rev=1072248&r1=1072247&r2=1072248&view=diff
==============================================================================
--- directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
(original)
+++ directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
Sat Feb 19 04:47:12 2011
@@ -57,7 +57,7 @@ import org.slf4j.LoggerFactory;
  * @see <a href="http://www.ietf.org/rfc/rfc2830.txt">RFC 2830</a>
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StartTlsHandler implements ExtendedOperationHandler
+public class StartTlsHandler implements ExtendedOperationHandler<ExtendedRequest>
 {
     public static final String EXTENSION_OID = "1.3.6.1.4.1.1466.20037";
 

Modified: directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.java?rev=1072248&r1=1072247&r2=1072248&view=diff
==============================================================================
--- directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.java
(original)
+++ directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.java
Sat Feb 19 04:47:12 2011
@@ -20,8 +20,7 @@
 package org.apache.directory.server.ldap.handlers.extended;
 
 
-import java.io.Serializable;
-import java.nio.ByteBuffer;
+import java.io.Serializable; 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -37,26 +36,18 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.ldap.ExtendedOperationHandler;
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.ldap.LdapSession;
-import org.apache.directory.shared.asn1.ber.Asn1Decoder;
-import org.apache.directory.shared.asn1.ber.Asn1Container;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedure;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedureContainer;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedureDecoder;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedure.StoredProcedureParameter;
-import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
 import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
 import org.apache.directory.shared.ldap.extras.extended.StoredProcedureRequest;
 import org.apache.directory.shared.ldap.extras.extended.StoredProcedureResponse;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.sp.LdapContextParameter;
-import org.apache.directory.shared.util.Strings;
 
 
 /**
  * @todo : Missing Javadoc
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoredProcedureExtendedOperationHandler implements ExtendedOperationHandler
+public class StoredProcedureExtendedOperationHandler implements ExtendedOperationHandler<StoredProcedureRequest>
 {
     private StoredProcExecutionManager manager;
     private static final Object[] EMPTY_CLASS_ARRAY = new Object[0];
@@ -75,21 +66,18 @@ public class StoredProcedureExtendedOper
     }
 
 
-    public void handleExtendedOperation( LdapSession session, ExtendedRequest req ) throws
Exception
+    public void handleExtendedOperation( LdapSession session, StoredProcedureRequest req
) throws Exception
     {
-        StoredProcedure spBean = decodeBean( req.getRequestValue() );
-
-        String procedure = Strings.utf8ToString(spBean.getProcedure());
+        String procedure = req.getProcedureSpecification();
         ClonedServerEntry spUnit = manager.findStoredProcUnit( session.getCoreSession(),
procedure );
         StoredProcEngine engine = manager.getStoredProcEngineInstance( spUnit );
 
-        List<Object> valueList = new ArrayList<Object>( spBean.getParameters().size()
);
-
-        for ( StoredProcedureParameter pPojo : spBean.getParameters() )
+        List<Object> valueList = new ArrayList<Object>( req.size() );
+        for ( int ii = 0; ii < req.size(); ii++ )
         {
-            byte[] serializedValue = pPojo.getValue();
+            byte[] serializedValue = ( byte[] ) req.getParameterValue( ii );
             Object value = SerializationUtils.deserialize( serializedValue );
-
+            
             if ( value.getClass().equals( LdapContextParameter.class ) )
             {
                 String paramCtx = ( ( LdapContextParameter ) value ).getValue();
@@ -98,39 +86,18 @@ public class StoredProcedureExtendedOper
 
             valueList.add( value );
         }
-
+        
         Object[] values = valueList.toArray( EMPTY_CLASS_ARRAY );
-
         Object response = engine.invokeProcedure( session.getCoreSession(), procedure, values
);
-
         byte[] serializedResponse = SerializationUtils.serialize( ( Serializable ) response
);
         ( ( ExtendedResponse ) ( req.getResultResponse() ) ).setResponseValue( serializedResponse
);
         session.getIoSession().write( req.getResultResponse() );
-
     }
 
-
-    private StoredProcedure decodeBean( byte[] payload )
-    {
-        Asn1Decoder storedProcedureDecoder = new StoredProcedureDecoder();
-        ByteBuffer stream = ByteBuffer.wrap( payload );
-        Asn1Container storedProcedureContainer = new StoredProcedureContainer();
-
-        try
-        {
-            storedProcedureDecoder.decode( stream, storedProcedureContainer );
-        }
-        catch ( Exception de )
-        {
-            de.printStackTrace();
-        }
-
-        StoredProcedure spBean = ( ( StoredProcedureContainer ) storedProcedureContainer
).getStoredProcedure();
-
-        return spBean;
-    }
-
-
+    
+    /**
+     * {@inheritDoc}
+     */
     public String getOid()
     {
         return StoredProcedureRequest.EXTENSION_OID;
@@ -147,12 +114,18 @@ public class StoredProcedureExtendedOper
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public Set<String> getExtensionOids()
     {
         return EXTENSION_OIDS;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setLdapServer( LdapServer ldapServer )
     {
     }



Mime
View raw message