Author: ts
Date: Wed Oct 17 16:56:48 2007
New Revision: 6506

Log:
- Fixed RFC test cases after fix of memory backend.

Modified:
    trunk/Webdav/src/plugin_parameters.php
    trunk/Webdav/src/plugin_registry.php
    trunk/Webdav/src/transport.php
    trunk/Webdav/tests/clients/rfc/propfind_allprop/response/body.xml
    trunk/Webdav/tests/clients/rfc/propfind_propname/response/body.xml
    trunk/Webdav/tests/plugin_registry_test.php

Modified: trunk/Webdav/src/plugin_parameters.php
==============================================================================
--- trunk/Webdav/src/plugin_parameters.php [iso-8859-1] (original)
+++ trunk/Webdav/src/plugin_parameters.php [iso-8859-1] Wed Oct 17 16:56:48 2007
@@ -26,9 +26,9 @@
      * 
      * @return void
      */
-    public function __construct()
+    public function __construct( array $data = null )
     {
-        $parameters = array();
+        $parameters = ( $data === null ? array() : $data );
         parent::__construct( $parameters );
     }
 }

Modified: trunk/Webdav/src/plugin_registry.php
==============================================================================
--- trunk/Webdav/src/plugin_registry.php [iso-8859-1] (original)
+++ trunk/Webdav/src/plugin_registry.php [iso-8859-1] Wed Oct 17 16:56:48 2007
@@ -107,7 +107,7 @@
             $this->createHook( 'ezcWebdavTransport', $method, 'after' );
         }
         // Add additional Transport layer hooks
-        $this->createHook( 'ezcWebdavTransport', 'processUnknownRequest' );
+        $this->createHook( 'ezcWebdavTransport', 'parseUnknownRequest' );
         $this->createHook( 'ezcWebdavTransport', 'handleUnknownResponse' );
 
         // Property related hooks
@@ -290,6 +290,9 @@
      * method is marked private. Receives the name of the class issuing the
      * $hook and the $params that may be used for information extraction and
      * _careful_ possible manipulation.
+     *
+     * This method is declared private, because the announcement of hooks is
+     * only allowed by component internal classes.
      * 
      * @param string $class
      * @param string $hook 
@@ -300,6 +303,8 @@
      *         in case a plugin threw an exception. The original one can be
      *         accessed for processing through the public $originalException
      *         attribute.
+     *
+     * @private
      */
     public final function announceHook( $class, $hook, 
ezcWebdavPluginParameters $params )
     {

Modified: trunk/Webdav/src/transport.php
==============================================================================
--- trunk/Webdav/src/transport.php [iso-8859-1] (original)
+++ trunk/Webdav/src/transport.php [iso-8859-1] Wed Oct 17 16:56:48 2007
@@ -251,23 +251,39 @@
         $body = $this->retreiveBody();
         $path = $this->pathFactory->parseUriToPath( $uri );
 
-        if ( isset( self::$parsingMap[$_SERVER['REQUEST_METHOD']] ) === false )
-        {
-            // @todo: parseUnknownRequest hook should be dispatched here.
-            return new ezcWebdavErrorResponse(
-                ezcWebdavResponse::STATUS_501,
-                $uri
-            );
-        }
-        
-        try
-        {
-            $request = call_user_func( array( $this, 
self::$parsingMap[$_SERVER['REQUEST_METHOD']] ), $path, $body );
-            $request->validateHeaders();
-        }
-        catch ( Exception $e )
-        {
-            return $this->handleException( $e, $uri );
+        if ( isset( self::$parsingMap[$_SERVER['REQUEST_METHOD']] )  )
+        {
+            try
+            {
+                $request = call_user_func( array( $this, 
self::$parsingMap[$_SERVER['REQUEST_METHOD']] ), $path, $body );
+                $request->validateHeaders();
+            }
+            catch ( Exception $e )
+            {
+                return $this->handleException( $e, $uri );
+            }
+        }
+        else
+        {
+            // Plugin hook
+            $request = ezcWebdavServer::getInstance()->plugins->announceHook(
+                __CLASS__,
+                'parseUnkownRequest',
+                new ezcWebdavPluginParameters(
+                    array(
+                        'uri'  => $uri,
+                        'body' => $body,
+                    )
+                )
+            );
+
+            if ( !( $request instanceof ezcWebdavRequest ) && !( $request 
instanceof ezcWebdavResponse )  )
+            {
+                return new ezcWebdavErrorResponse(
+                    ezcWebdavResponse::STATUS_501,
+                    $uri
+                );
+            }
         }
         
         return $request;
@@ -296,6 +312,7 @@
         // Set the Server header with information about eZ Components version
         // and transport implementation.
         $serverSoftwareHeaders = $this->parseHeaders( array( 'Server' ) );
+
         $response->setHeader(
             'Server',
             ( count( $serverSoftwareHeaders ) > 0 ? 
$serverSoftwareHeaders['Server'] . '/' : '' )
@@ -304,6 +321,7 @@
                 . '/'
                 . get_class( $this )
         );
+
         try
         {
             $response->validateHeaders();
@@ -404,8 +422,19 @@
     {
         if ( isset( self::$handlingMap[( $responseClass = get_class( $response 
) )] ) === false )
         {
-            // @todo: The processResponse plugin hook should be announced here.
-            return processResponse( new ezcWebdavErrorResponse( 
ezcWebdavResponse::STATUS_500 ) );
+            $result = ezcWebdavServer::getInstance()->plugins->announceHook(
+                __CLASS__,
+                'processUnkownResponse',
+                new ezcWebdavPluginParameters(
+                    array(
+                        'response'  => $response,
+                    )
+                )
+            );
+            if ( $result === null )
+            {
+                return processResponse( new ezcWebdavErrorResponse( 
ezcWebdavResponse::STATUS_500 ) );
+            }
         }
         
         return call_user_func( array( $this, self::$handlingMap[( 
$responseClass = get_class( $response ) )] ), $response );

Modified: trunk/Webdav/tests/clients/rfc/propfind_allprop/response/body.xml
==============================================================================
Binary files - no diff available.

Modified: trunk/Webdav/tests/clients/rfc/propfind_propname/response/body.xml
==============================================================================
Binary files - no diff available.

Modified: trunk/Webdav/tests/plugin_registry_test.php
==============================================================================
--- trunk/Webdav/tests/plugin_registry_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/plugin_registry_test.php [iso-8859-1] Wed Oct 17 
16:56:48 2007
@@ -619,7 +619,7 @@
                     'afterProcessPropPatchResponse'       => true,
                     'beforeProcessPutResponse'            => true,
                     'afterProcessPutResponse'             => true,
-                    'processUnknownRequest'               => true,
+                    'parseUnknownRequest'                 => true,
                     'handleUnknownResponse'               => true,
                     'beforeExtractLiveProperty'           => true,
                     'afterExtractLiveProperty'            => true,


-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to