Author: ts
Date: Wed Sep 19 16:08:53 2007
New Revision: 6204

Log:
- Added parsing of MOVE request.

Added:
    trunk/Webdav/tests/clients/rfc/move_collection/request/result.ser   (with 
props)
    trunk/Webdav/tests/clients/rfc/move_resource/request/result.ser   (with 
props)
Modified:
    trunk/Webdav/src/transport.php

Modified: trunk/Webdav/src/transport.php
==============================================================================
--- trunk/Webdav/src/transport.php [iso-8859-1] (original)
+++ trunk/Webdav/src/transport.php [iso-8859-1] Wed Sep 19 16:08:53 2007
@@ -55,6 +55,8 @@
                 return $this->parsePropFindRequest( $uri, $body );
             case 'COPY':
                 return $this->parseCopyRequest( $uri, $body );
+            case 'MOVE':
+                return $this->parseMoveRequest( $uri, $body );
             case 'DELETE':
                 return $this->parseDeleteRequest( $uri, $body );
             case 'LOCK':
@@ -214,6 +216,59 @@
             );
         }
         
+        return $this->parsePropertyBehaviourContent( $dom, $request );
+    }
+
+    // MOVE
+
+    /**
+     * Parses the MOVE request and returns a request object.
+     * This method is responsible for parsing the MOVE request. It
+     * retrieves the current request URI in $uri and the request body as $body.
+     * The return value, if no exception is thrown, is a valid [EMAIL 
PROTECTED]
+     * ezcWebdavMoveRequest} object.
+     * 
+     * @param string $uri 
+     * @param string $body 
+     * @return ezcWebdavMoveRequest
+     */
+    protected function parseMoveRequest( $uri, $body )
+    {
+        $headers = $this->parseHeaders(
+            array( 'Destination', 'Depth', 'Overwrite' )
+        );
+
+        $request = new ezcWebdavMoveRequest( $uri, $headers['Destination'] );
+
+        $request->setHeaders( $headers );
+
+        if ( trim( $body ) === '' )
+        {
+            // No body present
+            return $request;
+        }
+
+        if ( ( $dom = $this->loadDom( $body ) ) === false )
+        {
+            throw new ezcWebdavInvalidRequestBodyException(
+                'MOVE',
+                "Could not open XML as DOMDocument: '{$body}'."
+            );
+        }
+        
+        if ( $dom->documentElement->localName !== 'propertybehavior' )
+        {
+            throw new ezcWebdavInvalidRequestBodyException(
+                'MOVE',
+                "Expected XML element <propertybehavior />, received 
<{$dom->documentElement->localName} />."
+            );
+        }
+        
+        return $this->parsePropertyBehaviourContent( $dom, $request );
+    }
+
+    protected function parsePropertyBehaviourContent( DOMDocument $dom, 
ezcWebdavRequest $request )
+    {
         $propertyBehaviourNode = $dom->documentElement;
 
         $request->propertyBehaviour = new 
ezcWebdavRequestPropertyBehaviourContent();

Added: trunk/Webdav/tests/clients/rfc/move_collection/request/result.ser
==============================================================================
Binary file - no diff available.

Propchange: trunk/Webdav/tests/clients/rfc/move_collection/request/result.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: trunk/Webdav/tests/clients/rfc/move_resource/request/result.ser
==============================================================================
Binary file - no diff available.

Propchange: trunk/Webdav/tests/clients/rfc/move_resource/request/result.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


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

Reply via email to