From e271a55783dafd605791d02ca718b463fa19d58d Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Tue, 10 Sep 2013 19:44:23 +0200
Subject: [PATCH] move filesystem expceptions to global namespace

---
 lib/files/node/file.php                      | 14 +++----
 lib/files/node/folder.php                    | 32 +++++++-------
 lib/files/node/node.php                      | 14 +++----
 lib/files/node/nonexistingfile.php           |  4 +-
 lib/files/node/nonexistingfolder.php         |  4 +-
 lib/files/node/root.php                      | 44 ++++++++++----------
 lib/public/files/alreadyexistsexception.php  | 11 +++++
 lib/public/files/notenoughspaceexception.php | 11 +++++
 lib/public/files/notfoundexception.php       | 11 +++++
 lib/public/files/notpermittedexception.php   | 11 +++++
 10 files changed, 99 insertions(+), 57 deletions(-)
 create mode 100644 lib/public/files/alreadyexistsexception.php
 create mode 100644 lib/public/files/notenoughspaceexception.php
 create mode 100644 lib/public/files/notfoundexception.php
 create mode 100644 lib/public/files/notpermittedexception.php

diff --git a/lib/files/node/file.php b/lib/files/node/file.php
index f13b474aa6c..75d5e0166b6 100644
--- a/lib/files/node/file.php
+++ b/lib/files/node/file.php
@@ -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) {
diff --git a/lib/files/node/folder.php b/lib/files/node/folder.php
index daf75d7c23e..923f53821b2 100644
--- a/lib/files/node/folder.php
+++ b/lib/files/node/folder.php
@@ -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) {
diff --git a/lib/files/node/node.php b/lib/files/node/node.php
index 5ee9f23161f..063e2424a64 100644
--- a/lib/files/node/node.php
+++ b/lib/files/node/node.php
@@ -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);
diff --git a/lib/files/node/nonexistingfile.php b/lib/files/node/nonexistingfile.php
index 6f18450efee..d45076f7fee 100644
--- a/lib/files/node/nonexistingfile.php
+++ b/lib/files/node/nonexistingfile.php
@@ -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();
diff --git a/lib/files/node/nonexistingfolder.php b/lib/files/node/nonexistingfolder.php
index 0249a026245..0346cbf1e21 100644
--- a/lib/files/node/nonexistingfolder.php
+++ b/lib/files/node/nonexistingfolder.php
@@ -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();
diff --git a/lib/files/node/root.php b/lib/files/node/root.php
index f88d8c294c7..e3d58476e9c 100644
--- a/lib/files/node/root.php
+++ b/lib/files/node/root.php
@@ -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();
diff --git a/lib/public/files/alreadyexistsexception.php b/lib/public/files/alreadyexistsexception.php
new file mode 100644
index 00000000000..32947c7a5c3
--- /dev/null
+++ b/lib/public/files/alreadyexistsexception.php
@@ -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 {}
diff --git a/lib/public/files/notenoughspaceexception.php b/lib/public/files/notenoughspaceexception.php
new file mode 100644
index 00000000000..e51806666ad
--- /dev/null
+++ b/lib/public/files/notenoughspaceexception.php
@@ -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 {}
diff --git a/lib/public/files/notfoundexception.php b/lib/public/files/notfoundexception.php
new file mode 100644
index 00000000000..1ff426a40c6
--- /dev/null
+++ b/lib/public/files/notfoundexception.php
@@ -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 {}
diff --git a/lib/public/files/notpermittedexception.php b/lib/public/files/notpermittedexception.php
new file mode 100644
index 00000000000..0509de7e829
--- /dev/null
+++ b/lib/public/files/notpermittedexception.php
@@ -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 {}
-- 
GitLab