]> source.dussan.org Git - nextcloud-server.git/commitdiff
adding additional exceptions for special cases where creating a file might not be...
authorThomas Müller <thomas.mueller@tmit.eu>
Mon, 7 Oct 2013 13:11:47 +0000 (15:11 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Mon, 7 Oct 2013 13:11:47 +0000 (15:11 +0200)
lib/private/connector/sabre/exception/entitytoolarge.php [new file with mode: 0644]
lib/private/connector/sabre/exception/unsupportedmediatype.php [new file with mode: 0644]
lib/private/connector/sabre/file.php
lib/public/files/entitytoolargeexception.php [new file with mode: 0644]
lib/public/files/invalidcontentexception.php [new file with mode: 0644]
lib/public/files/invalidpathexception.php [new file with mode: 0644]

diff --git a/lib/private/connector/sabre/exception/entitytoolarge.php b/lib/private/connector/sabre/exception/entitytoolarge.php
new file mode 100644 (file)
index 0000000..aa9b37a
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * EntityTooLarge
+ *
+ * This exception is thrown whenever a user tries to upload a file which exceeds hard limitations
+ *
+ */
+class OC_Connector_Sabre_Exception_EntityTooLarge extends Sabre_DAV_Exception {
+
+    /**
+     * Returns the HTTP statuscode for this exception
+     *
+     * @return int
+     */
+    public function getHTTPCode() {
+
+//        return 413;
+
+           return 450;
+    }
+
+}
diff --git a/lib/private/connector/sabre/exception/unsupportedmediatype.php b/lib/private/connector/sabre/exception/unsupportedmediatype.php
new file mode 100644 (file)
index 0000000..a8b5612
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Unsupported Media Type
+ *
+ * This exception is thrown whenever a user tries to upload a file which holds content which is not allowed
+ *
+ */
+class OC_Connector_Sabre_Exception_UnsupportedMediaType extends Sabre_DAV_Exception {
+
+    /**
+     * Returns the HTTP status code for this exception
+     *
+     * @return int
+     */
+    public function getHTTPCode() {
+
+        return 415;
+
+    }
+
+}
index 8ffec371e3f4e94a2589fc300a3e88105129c7bb..3c19da7c6181a55fce16b61e22775cfe223939f1 100644 (file)
@@ -88,6 +88,13 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
                        }
                } catch (\OCP\Files\NotPermittedException $e) {
                        throw new Sabre_DAV_Exception_Forbidden();
+               } catch (\OCP\Files\EntityTooLargeException $e) {
+                       throw new OC_Connector_Sabre_Exception_EntityTooLarge();
+               } catch (\OCP\Files\InvalidContentException $e) {
+                       throw new OC_Connector_Sabre_Exception_UnsupportedMediaType();
+               } catch (\OCP\Files\InvalidPathException $e) {
+                       // TODO: add specific exception here
+                       throw new Sabre_DAV_Exception_Forbidden();
                }
 
                // rename to correct path
diff --git a/lib/public/files/entitytoolargeexception.php b/lib/public/files/entitytoolargeexception.php
new file mode 100644 (file)
index 0000000..3dff41b
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Müller <thomas.mueller@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 EntityTooLargeException extends \Exception {}
diff --git a/lib/public/files/invalidcontentexception.php b/lib/public/files/invalidcontentexception.php
new file mode 100644 (file)
index 0000000..184ec4d
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Müller <thomas.mueller@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 InvalidContentException extends \Exception {}
diff --git a/lib/public/files/invalidpathexception.php b/lib/public/files/invalidpathexception.php
new file mode 100644 (file)
index 0000000..36090ae
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Müller <thomas.mueller@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 InvalidPathException extends \Exception {}