adding additional exceptions for special cases where creating a file might not be allowed
This commit is contained in:
parent
1e47468c53
commit
730c80ff9c
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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 {}
|
|
@ -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 {}
|
|
@ -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 {}
|
Loading…
Reference in New Issue