public function testShortPathTreeFromUserRoot() { $path = new Path('/foo/bar'); $this->assertEquals(array('/foo/'), $path->getFolderTreeFromUserRoot()); }
public function deleteNode(Path $p) { $stmt = $this->db->prepare(sprintf('DELETE FROM %s WHERE path = :path', $this->prefix . 'md')); $stmt->bindValue(':path', $p->getPath(), PDO::PARAM_STR); $stmt->execute(); if (1 !== $stmt->rowCount()) { throw new MetadataStorageException('unable to delete node'); } }
private function deleteFolder(Path $p) { $folderPath = $this->baseDir . $p->getPath(); if (false === @rmdir($folderPath)) { throw new DocumentStorageException('unable to delete folder'); } }
public function deleteDocument(Request $request, TokenInfo $tokenInfo) { $path = new Path($request->getUrl()->getPathInfo()); if ($path->getUserId() !== $tokenInfo->getUserId()) { throw new ForbiddenException('path does not match authorized subject'); } if (!$this->hasWriteScope($tokenInfo->getScope(), $path->getModuleName())) { throw new ForbiddenException('path does not match authorized scope'); } // need to get the version before the delete $documentVersion = $this->remoteStorage->getVersion($path); $ifMatch = $this->stripQuotes($request->getHeader('If-Match')); // if document does not exist, and we have If-Match header set we should // return a 412 instead of a 404 if (null !== $ifMatch && !in_array($documentVersion, $ifMatch)) { throw new PreconditionFailedException('version mismatch'); } if (null === $documentVersion) { throw new NotFoundException(sprintf('document "%s" not found', $path->getPath())); } $ifMatch = $this->stripQuotes($request->getHeader('If-Match')); if (null !== $ifMatch && !in_array($documentVersion, $ifMatch)) { throw new PreconditionFailedException('version mismatch'); } $x = $this->remoteStorage->deleteDocument($path, $ifMatch); $rsr = new Response(); $rsr->setHeader('ETag', '"' . $documentVersion . '"'); $rsr->setBody($x); return $rsr; }