/** * Parses the PROPFIND request and returns a request object. * * This method is responsible for parsing the PROPFIND request. It * retrieves the current request URI in $path and the request body as * $body. The return value, if no exception is thrown, is a valid {@link * ezcWebdavPropFindRequest} object. * * This method may be overwritten to adjust it to special client behaviour. * * @param string $path * @param string $body * @return ezcWebdavPropFindRequest */ protected function parsePropFindRequest($path, $body) { $request = new ezcWebdavPropFindRequest($path); $request->setHeaders(ezcWebdavServer::getInstance()->headerHandler->parseHeaders(array('Depth'))); if (empty($body)) { throw new ezcWebdavInvalidRequestBodyException('PROPFIND', "Could not open XML as DOMDocument: '{$body}'."); } try { $dom = ezcWebdavServer::getInstance()->xmlTool->createDom($body); } catch (ezcWebdavInvalidXmlException $e) { throw new ezcWebdavInvalidRequestBodyException('PROPFIND', $e->getMessage()); } if ($dom->documentElement->localName !== 'propfind') { throw new ezcWebdavInvalidRequestBodyException('PROPFIND', "Expected XML element <propfind />, received <{$dom->documentElement->localName} />."); } if ($dom->documentElement->firstChild === null) { throw new ezcWebdavInvalidRequestBodyException('PROPFIND', "Element <propfind /> does not have a child element."); } switch ($dom->documentElement->firstChild->localName) { case 'allprop': $request->allProp = true; break; case 'propname': $request->propName = true; break; case 'prop': $request->prop = new ezcWebdavBasicPropertyStorage(); try { ezcWebdavServer::getInstance()->propertyHandler->extractProperties($dom->documentElement->firstChild->childNodes, $request->prop); } catch (ezcBaseValueException $e) { throw new ezcWebdavInvalidRequestBodyException('PROPFIND', "Property extraction produced value exception: '{$e->getMessage()}'."); } break; default: throw new ezcWebdavInvalidRequestBodyException('PROPFIND', "XML element <{$dom->documentElement->firstChild->nodeName} /> is not a valid child element for <propfind />."); } return $request; }