Exemplo n.º 1
0
 /**
  * Creates a lock-null resource.
  *
  * In case a LOCK request is issued on a resource, that does not exists, a
  * so-called lock-null resource is created. This resource must support some
  * of the WebDAV requests, but not all. In case an MKCOL or PUT request is
  * issued to such a resource, it is switched to be a real resource. In case
  * the lock is released, all null-lock resources in it are removed.
  * 
  * @param ezcWebdavLockRequest $request 
  * @return ezcWebdavResponse
  */
 protected function createLockNullResource(ezcWebdavLockRequest $request)
 {
     $backend = ezcWebdavServer::getInstance()->backend;
     // Check parent directory for locks and other violations
     $violation = $this->tools->checkViolations(new ezcWebdavLockCheckInfo(dirname($request->requestUri), ezcWebdavRequest::DEPTH_ZERO, $request->getHeader('If'), $request->getHeader('Authorization'), ezcWebdavAuthorizer::ACCESS_WRITE));
     if ($violation !== null) {
         return $this->createLockError($violation);
     }
     // Create lock null resource
     $putReq = new ezcWebdavPutRequest($request->requestUri, '');
     ezcWebdavLockTools::cloneRequestHeaders($request, $putReq, array('If'));
     $putReq->setHeader('Content-Length', '0');
     $putReq->validateHeaders();
     $putRes = $backend->put($putReq);
     if (!$putRes instanceof ezcWebdavPutResponse) {
         return $this->createLockError($putRes);
     }
     // Attention, recursion!
     $res = $this->acquireLock($request);
     if ($res->status !== ezcWebdavResponse::STATUS_200) {
         return $res;
     }
     $res->status = ezcWebdavResponse::STATUS_201;
     return $res;
 }
Exemplo n.º 2
0
 /**
  * Returns a new active lock element according to the given data.
  *
  * Creates a new instance of {@link
  * ezcWebdavLockDiscoveryPropertyActiveLock} that can be used with an
  * {@link ezcWebdavLockDiscoveryProperty}. Most information for this
  * property content is fetched from the given $request. The $lockToken for
  * the acquired lock must be provided in addition. Information used is:
  * 
  * @param ezcWebdavLockRequest $request 
  * @param string $lockToken 
  * @return ezcWebdavLockDiscoveryPropertyActiveLock
  */
 public function generateActiveLock(ezcWebdavLockRequest $request, $lockToken)
 {
     return new ezcWebdavLockDiscoveryPropertyActiveLock($request->lockInfo->lockType, $request->lockInfo->lockScope, $request->getHeader('Depth'), $request->lockInfo->owner, $this->getTimeoutValue(($timeouts = $request->getHeader('Timeout')) === null ? array() : $timeouts), new ezcWebdavPotentialUriContent($lockToken, true), null, new ezcWebdavDateTime());
 }