move filesystem expceptions to global namespace

This commit is contained in:
Robin Appelman 2013-09-10 19:44:23 +02:00
parent 315344eb9c
commit e271a55783
10 changed files with 99 additions and 57 deletions

View file

@ -8,12 +8,12 @@
namespace OC\Files\Node;
use OC\Files\NotPermittedException;
use OCP\Files\NotPermittedException;
class File extends Node implements \OCP\Files\Node\File {
class File extends Node implements \OCP\Files\File {
/**
* @return string
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
*/
public function getContent() {
if ($this->checkPermissions(\OCP\PERMISSION_READ)) {
@ -28,7 +28,7 @@ class File extends Node implements \OCP\Files\Node\File {
/**
* @param string $data
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
*/
public function putContent($data) {
if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) {
@ -50,7 +50,7 @@ class File extends Node implements \OCP\Files\Node\File {
/**
* @param string $mode
* @return resource
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
*/
public function fopen($mode) {
$preHooks = array();
@ -101,7 +101,7 @@ class File extends Node implements \OCP\Files\Node\File {
/**
* @param string $targetPath
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
*/
public function copy($targetPath) {
@ -123,7 +123,7 @@ class File extends Node implements \OCP\Files\Node\File {
/**
* @param string $targetPath
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
*/
public function move($targetPath) {

View file

@ -10,14 +10,14 @@ namespace OC\Files\Node;
use OC\Files\Cache\Cache;
use OC\Files\Cache\Scanner;
use OC\Files\NotFoundException;
use OC\Files\NotPermittedException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
class Folder extends Node implements \OCP\Files\Node\Folder {
class Folder extends Node implements \OCP\Files\Folder {
/**
* @param string $path path relative to the folder
* @return string
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
*/
public function getFullPath($path) {
if (!$this->isValidPath($path)) {
@ -28,7 +28,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder {
/**
* @param string $path
* @throws \OC\Files\NotFoundException
* @throws \OCP\Files\NotFoundException
* @return string
*/
public function getRelativePath($path) {
@ -60,7 +60,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder {
/**
* get the content of this directory
*
* @throws \OC\Files\NotFoundException
* @throws \OCP\Files\NotFoundException
* @return Node[]
*/
public function getDirectoryListing() {
@ -164,7 +164,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder {
*
* @param string $path
* @return \OC\Files\Node\Node
* @throws \OC\Files\NotFoundException
* @throws \OCP\Files\NotFoundException
*/
public function get($path) {
return $this->root->get($this->getFullPath($path));
@ -185,8 +185,8 @@ class Folder extends Node implements \OCP\Files\Node\Folder {
/**
* @param string $path
* @return Folder
* @throws NotPermittedException
* @return \OC\Files\Node\Folder
* @throws \OCP\Files\NotPermittedException
*/
public function newFolder($path) {
if ($this->checkPermissions(\OCP\PERMISSION_CREATE)) {
@ -206,8 +206,8 @@ class Folder extends Node implements \OCP\Files\Node\Folder {
/**
* @param string $path
* @return File
* @throws NotPermittedException
* @return \OC\Files\Node\File
* @throws \OCP\Files\NotPermittedException
*/
public function newFile($path) {
if ($this->checkPermissions(\OCP\PERMISSION_CREATE)) {
@ -229,7 +229,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder {
* search for files with the name matching $query
*
* @param string $query
* @return Node[]
* @return \OC\Files\Node\Node[]
*/
public function search($query) {
return $this->searchCommon('%' . $query . '%', 'search');
@ -248,7 +248,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder {
/**
* @param string $query
* @param string $method
* @return Node[]
* @return \OC\Files\Node\Node[]
*/
private function searchCommon($query, $method) {
$files = array();
@ -298,7 +298,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder {
/**
* @param $id
* @return Node[]
* @return \OC\Files\Node\Node[]
*/
public function getById($id) {
$nodes = $this->root->getById($id);
@ -337,7 +337,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder {
/**
* @param string $targetPath
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
*/
public function copy($targetPath) {
@ -359,7 +359,7 @@ class Folder extends Node implements \OCP\Files\Node\Folder {
/**
* @param string $targetPath
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
*/
public function move($targetPath) {

View file

@ -10,12 +10,10 @@ namespace OC\Files\Node;
use OC\Files\Cache\Cache;
use OC\Files\Cache\Scanner;
use OC\Files\NotFoundException;
use OC\Files\NotPermittedException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
require_once 'files/exceptions.php';
class Node implements \OCP\Files\Node\Node {
class Node implements \OCP\Files\Node {
/**
* @var \OC\Files\View $view
*/
@ -61,7 +59,7 @@ class Node implements \OCP\Files\Node\Node {
/**
* @param string $targetPath
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
*/
public function move($targetPath) {
@ -82,7 +80,7 @@ class Node implements \OCP\Files\Node\Node {
/**
* @param int $mtime
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
*/
public function touch($mtime = null) {
if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) {
@ -96,7 +94,7 @@ class Node implements \OCP\Files\Node\Node {
/**
* @return \OC\Files\Storage\Storage
* @throws \OC\Files\NotFoundException
* @throws \OCP\Files\NotFoundException
*/
public function getStorage() {
list($storage,) = $this->view->resolvePath($this->path);

View file

@ -8,12 +8,12 @@
namespace OC\Files\Node;
use OC\Files\NotFoundException;
use OCP\Files\NotFoundException;
class NonExistingFile extends File {
/**
* @param string $newPath
* @throws \OC\Files\NotFoundException
* @throws \OCP\Files\NotFoundException
*/
public function rename($newPath) {
throw new NotFoundException();

View file

@ -8,12 +8,12 @@
namespace OC\Files\Node;
use OC\Files\NotFoundException;
use OCP\Files\NotFoundException;
class NonExistingFolder extends Folder {
/**
* @param string $newPath
* @throws \OC\Files\NotFoundException
* @throws \OCP\Files\NotFoundException
*/
public function rename($newPath) {
throw new NotFoundException();

View file

@ -12,8 +12,8 @@ use OC\Files\Cache\Cache;
use OC\Files\Cache\Scanner;
use OC\Files\Mount\Manager;
use OC\Files\Mount\Mount;
use OC\Files\NotFoundException;
use OC\Files\NotPermittedException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OC\Hooks\Emitter;
use OC\Hooks\PublicEmitter;
@ -21,18 +21,18 @@ use OC\Hooks\PublicEmitter;
* Class Root
*
* Hooks available in scope \OC\Files
* - preWrite(\OC\Files\Node\Node $node)
* - postWrite(\OC\Files\Node\Node $node)
* - preCreate(\OC\Files\Node\Node $node)
* - postCreate(\OC\Files\Node\Node $node)
* - preDelete(\OC\Files\Node\Node $node)
* - postDelete(\OC\Files\Node\Node $node)
* - preTouch(\OC\Files\Node\Node $node, int $mtime)
* - postTouch(\OC\Files\Node\Node $node)
* - preCopy(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target)
* - postCopy(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target)
* - preRename(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target)
* - postRename(\OC\Files\Node\Node $source, \OC\Files\Node\Node $target)
* - preWrite(\OCP\Files\Node $node)
* - postWrite(\OCP\Files\Node $node)
* - preCreate(\OCP\Files\Node $node)
* - postCreate(\OCP\Files\Node $node)
* - preDelete(\OCP\Files\Node $node)
* - postDelete(\OCP\Files\Node $node)
* - preTouch(\OC\FilesP\Node $node, int $mtime)
* - postTouch(\OCP\Files\Node $node)
* - preCopy(\OCP\Files\Node $source, \OCP\Files\Node $target)
* - postCopy(\OCP\Files\Node $source, \OCP\Files\Node $target)
* - preRename(\OCP\Files\Node $source, \OCP\Files\Node $target)
* - postRename(\OCP\Files\Node $source, \OCP\Files\Node $target)
*
* @package OC\Files\Node
*/
@ -152,8 +152,8 @@ class Root extends Folder implements Emitter {
/**
* @param string $path
* @throws \OC\Files\NotFoundException
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotFoundException
* @throws \OCP\Files\NotPermittedException
* @return Node
*/
public function get($path) {
@ -177,7 +177,7 @@ class Root extends Folder implements Emitter {
* can exist in different places
*
* @param int $id
* @throws \OC\Files\NotFoundException
* @throws \OCP\Files\NotFoundException
* @return Node[]
*/
public function getById($id) {
@ -200,7 +200,7 @@ class Root extends Folder implements Emitter {
/**
* @param string $targetPath
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
*/
public function rename($targetPath) {
@ -213,7 +213,7 @@ class Root extends Folder implements Emitter {
/**
* @param string $targetPath
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
*/
public function copy($targetPath) {
@ -222,7 +222,7 @@ class Root extends Folder implements Emitter {
/**
* @param int $mtime
* @throws \OC\Files\NotPermittedException
* @throws \OCP\Files\NotPermittedException
*/
public function touch($mtime = null) {
throw new NotPermittedException();
@ -230,7 +230,7 @@ class Root extends Folder implements Emitter {
/**
* @return \OC\Files\Storage\Storage
* @throws \OC\Files\NotFoundException
* @throws \OCP\Files\NotFoundException
*/
public function getStorage() {
throw new NotFoundException();
@ -322,7 +322,7 @@ class Root extends Folder implements Emitter {
/**
* @return Node
* @throws \OC\Files\NotFoundException
* @throws \OCP\Files\NotFoundException
*/
public function getParent() {
throw new NotFoundException();

View file

@ -0,0 +1,11 @@
<?php
/**
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCP\Files;
class AlreadyExistsException extends \Exception {}

View file

@ -0,0 +1,11 @@
<?php
/**
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCP\Files;
class NotEnoughSpaceException extends \Exception {}

View file

@ -0,0 +1,11 @@
<?php
/**
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCP\Files;
class NotFoundException extends \Exception {}

View file

@ -0,0 +1,11 @@
<?php
/**
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCP\Files;
class NotPermittedException extends \Exception {}