Esempio n. 1
0
 /**
  * Handles responses to the OPTIONS request.
  *
  * This method enhances the generated response to indicate WebDAV
  * compliance classes 1 and 2 and adds the methods LOCK and UNLOCK to the
  * Allow header.
  *
  * @param ezcWebdavResponse $response 
  * @return ezcWebdavResponse|null
  */
 public function generatedResponse(ezcWebdavResponse $response)
 {
     if ($response instanceof ezcWebdavOptionsResponse) {
         $response->setHeader('DAV', ezcWebdavOptionsResponse::VERSION_ONE . ',' . ezcWebdavOptionsResponse::VERSION_TWO);
         $allowHeader = $response->getHeader('Allow') . ', LOCK, UNLOCK';
         $response->setHeader('Allow', $allowHeader);
     }
 }
Esempio n. 2
0
 /**
  * Sets a property.
  *
  * This method is called when an property is to be set.
  * 
  * @param string $propertyName The name of the property to set.
  * @param mixed $propertyValue The property value.
  * @return void
  * @ignore
  *
  * @throws ezcBasePropertyNotFoundException
  *         if the given property does not exist.
  * @throws ezcBaseValueException
  *         if the value to be assigned to a property is invalid.
  * @throws ezcBasePropertyPermissionException
  *         if the property to be set is a read-only property.
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'resource':
             if (!$propertyValue instanceof ezcWebdavResource && !$propertyValue instanceof ezcWebdavCollection) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcWebdavResource or ezcWebdavCollection');
             }
             $this->properties[$propertyName] = $propertyValue;
             break;
         default:
             parent::__set($propertyName, $propertyValue);
     }
 }
Esempio n. 3
0
 /**
  * Sets a property.
  *
  * This method is called when an property is to be set.
  * 
  * @param string $propertyName The name of the property to set.
  * @param mixed $propertyValue The property value.
  * @return void
  * @ignore
  *
  * @throws ezcBasePropertyNotFoundException
  *         if the given property does not exist.
  * @throws ezcBaseValueException
  *         if the value to be assigned to a property is invalid.
  * @throws ezcBasePropertyPermissionException
  *         if the property to be set is a read-only property.
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'replaced':
             if (!is_bool($propertyValue)) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'boolean');
             }
             $this->properties[$propertyName] = $propertyValue;
             break;
         default:
             parent::__set($propertyName, $propertyValue);
     }
 }
Esempio n. 4
0
 /**
  * Sets a property.
  *
  * This method is called when an property is to be set.
  * 
  * @param string $propertyName The name of the property to set.
  * @param mixed $propertyValue The property value.
  * @return void
  * @ignore
  *
  * @throws ezcBasePropertyNotFoundException
  *         if the given property does not exist.
  * @throws ezcBaseValueException
  *         if the value to be assigned to a property is invalid.
  * @throws ezcBasePropertyPermissionException
  *         if the property to be set is a read-only property.
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'storage':
             if (!$propertyValue instanceof ezcWebdavPropertyStorage) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcWebdavPropertyStorage');
             }
             $this->properties[$propertyName] = $propertyValue;
             break;
         default:
             parent::__set($propertyName, $propertyValue);
     }
 }
Esempio n. 5
0
 /**
  * Sets a property.
  *
  * This method is called when an property is to be set.
  * 
  * @param string $propertyName The name of the property to set.
  * @param mixed $propertyValue The property value.
  * @return void
  * @ignore
  *
  * @throws ezcBasePropertyNotFoundException
  *         if the given property does not exist.
  * @throws ezcBaseValueException
  *         if the value to be assigned to a property is invalid.
  * @throws ezcBasePropertyPermissionException
  *         if the property to be set is a read-only property.
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'lockDiscovery':
             if (!$propertyValue instanceof ezcWebdavLockDiscoveryProperty) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcWebdavLockDiscoveryProperty');
             }
             break;
         default:
             parent::__set($propertyName, $propertyValue);
     }
     $this->properties[$propertyName] = $propertyValue;
 }
Esempio n. 6
0
 /**
  * Validates the headers set in this response.
  *
  * This method is called by {@link ezcWebdavServer} after the response
  * object has been created by an {@link ezcWebdavBackend}. It validates all
  * headers, specific to this response, for existance of required headers
  * and validity of all headers used. The call of the parent method is
  * *mandatory* to have common WebDAV and HTTP headers validated, too.
  *
  * @return void
  *
  * @throws ezcWebdavMissingHeaderException
  *         if a required header is missing.
  * @throws ezcWebdavInvalidHeaderException
  *         if a header is present, but its content does not validate.
  */
 public function validateHeaders()
 {
     if (!isset($this->headers['DAV'])) {
         throw new ezcWebdavMissingHeaderException('DAV');
     }
     $dav = array_map('trim', explode(',', $this->headers['DAV']));
     foreach ($dav as $number) {
         if ($number !== self::VERSION_ONE && $number !== self::VERSION_TWO && $number !== self::VERSION_ONE_EXTENDED) {
             throw new ezcWebdavInvalidHeaderException('DAV', $this->headers['DAV'], 'Components must be ezcWebdavOptionsResponse::VERSION_ONE, ezcWebdavOptionsResponse::VERSION_TWO or ezcWebdavOptionsResponse::VERSION_ONE_EXTENDED');
         }
     }
     // Unified spaces
     $this->headers['DAV'] = implode(', ', $dav);
     // Validate common HTTP/WebDAV headers
     parent::validateHeaders();
 }
Esempio n. 7
0
 /**
  * Sets a property.
  *
  * This method is called when an property is to be set.
  * 
  * @param string $propertyName The name of the property to set.
  * @param mixed $propertyValue The property value.
  * @return void
  * @ignore
  *
  * @throws ezcBasePropertyNotFoundException
  *         if the given property does not exist.
  * @throws ezcBaseValueException
  *         if the value to be assigned to a property is invalid.
  * @throws ezcBasePropertyPermissionException
  *         if the property to be set is a read-only property.
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'requestUri':
             if (!is_string($propertyValue)) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'string');
             }
             $this->properties[$propertyName] = $propertyValue;
             break;
         case 'responseDescription':
             if ($this->responseDescription !== null) {
                 $this->setHeader('Warning', 'eZComponents error "' . $this->responseDescription . '"');
             }
             parent::__set($propertyName, $propertyValue);
             break;
         default:
             parent::__set($propertyName, $propertyValue);
     }
 }
Esempio n. 8
0
 /**
  * Creates a new response object.
  * 
  * @return void
  */
 public function __construct()
 {
     parent::__construct(ezcWebdavResponse::STATUS_201);
 }
Esempio n. 9
0
 /**
  * Sets a property.
  *
  * This method is called when an property is to be set.
  * 
  * @param string $propertyName The name of the property to set.
  * @param mixed $propertyValue The property value.
  * @return void
  * @ignore
  *
  * @throws ezcBasePropertyNotFoundException
  *         if the given property does not exist.
  * @throws ezcBaseValueException
  *         if the value to be assigned to a property is invalid.
  * @throws ezcBasePropertyPermissionException
  *         if the property to be set is a read-only property.
  */
 public function __set($propertyName, $propertyValue)
 {
     switch ($propertyName) {
         case 'responses':
             if (!is_array($propertyValue)) {
                 throw new ezcBaseValueException($propertyName, $propertyValue, 'array( ezcWebdavResponse )');
             }
             count($propertyValue) > 0 ? $this->setHeader('Content-Type', 'text/xml; charset="utf-8"') : $this->setHeader('Content-Type', null);
             $this->properties[$propertyName] = $propertyValue;
             break;
         default:
             parent::__set($propertyName, $propertyValue);
     }
 }
Esempio n. 10
0
 /**
  * Handle a response and send it to the WebDAV client.
  *
  * This method is part of the integral communication API between the WebDAV
  * client and the {@link ezcWebdavServer}. It is declared final to ensure a
  * minimal compatibile API between the extended classes and it is
  * responsible to dispatch the {@link ezcWebdavPluginRegistry} hooks. NOTE:
  * The plugin API is not public, yet, and will be part of a next release.
  *
  * It currently just maps internally to {@link processResponse()} and
  * passes the result to {@ $this->sendResponse()}. It is not recommended
  * that the {@link $this->processResponse()} method is overwritten, because
  * this one takes care about the dispatching. The {@link
  * $this->sendResponse()} may be overwritten, mainly for debugging, testing
  * and logging purposes.
  * 
  * @param ezcWebdavResponse $response
  * @return void
  */
 public final function handleResponse(ezcWebdavResponse $response)
 {
     // Set the Server header with information about eZ Components version
     // and transport implementation.
     $headers = ezcWebdavServer::getInstance()->headerHandler->parseHeaders(array('Server'));
     $response->setHeader('Server', (isset($headers['Server']) && strlen($headers['Server']) > 0 ? $headers['Server'] . '/' : '') . 'eZComponents/' . (self::VERSION === '//auto' . 'gentag//' ? 'dev' : self::VERSION) . '/' . get_class($this));
     try {
         $response->validateHeaders();
         $this->sendResponse($this->flattenResponse($this->processResponse($response)));
     } catch (Exception $e) {
         if ($response instanceof ezcWebdavErrorResponse) {
             // Attention: Recursion detected!
             throw $e;
         }
         $this->handleResponse($this->handleException($e));
         throw $e;
     }
 }