summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesús Macias <jmacias@solidgear.es>2015-11-26 17:51:47 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-12-03 09:59:45 +0100
commit98f5c50aa47207d98d99dde97f56204ef53d066c (patch)
tree774722abdf050d43745cf0d9d330fc87f10308d9
parent4ead2bc8610d11802c8814976bd80c544459235e (diff)
downloadnextcloud-server-98f5c50aa47207d98d99dde97f56204ef53d066c.tar.gz
nextcloud-server-98f5c50aa47207d98d99dde97f56204ef53d066c.zip
Migrate storate status code to storagenotavailablexception
-rw-r--r--apps/files_external/controller/storagescontroller.php5
-rw-r--r--apps/files_external/lib/config.php12
-rw-r--r--apps/files_external/service/storagesservice.php3
-rw-r--r--lib/public/files/storagenotavailableexception.php3
4 files changed, 12 insertions, 11 deletions
diff --git a/apps/files_external/controller/storagescontroller.php b/apps/files_external/controller/storagescontroller.php
index 76096f76656..da17f76cc64 100644
--- a/apps/files_external/controller/storagescontroller.php
+++ b/apps/files_external/controller/storagescontroller.php
@@ -38,6 +38,7 @@ use \OCA\Files_External\Lib\Auth\AuthMechanism;
use \OCP\Files\StorageNotAvailableException;
use \OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
use \OCA\Files_External\Service\BackendService;
+use \OCP\Files\StorageNotAvailableException;
/**
* Base class for storages controllers
@@ -238,7 +239,7 @@ abstract class StoragesController extends Controller {
);
} catch (InsufficientDataForMeaningfulAnswerException $e) {
$storage->setStatus(
- \OC_Mount_Config::STATUS_INDETERMINATE,
+ StorageNotAvailableException::STATUS_INDETERMINATE,
$this->l10n->t('Insufficient data: %s', [$e->getMessage()])
);
} catch (StorageNotAvailableException $e) {
@@ -249,7 +250,7 @@ abstract class StoragesController extends Controller {
} catch (\Exception $e) {
// FIXME: convert storage exceptions to StorageNotAvailableException
$storage->setStatus(
- \OC_Mount_Config::STATUS_ERROR,
+ StorageNotAvailableException::STATUS_ERROR,
get_class($e).': '.$e->getMessage()
);
}
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 1e96fac8145..7a869847a63 100644
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -36,6 +36,7 @@ use \OCA\Files_External\Appinfo\Application;
use \OCA\Files_External\Lib\Backend\LegacyBackend;
use \OCA\Files_External\Lib\StorageConfig;
use \OCA\Files_External\Lib\Backend\Backend;
+use \OCP\Files\StorageNotAvailableException;
/**
* Class to configure mount.json globally and for users
@@ -48,11 +49,6 @@ class OC_Mount_Config {
const MOUNT_TYPE_USER = 'user';
const MOUNT_TYPE_PERSONAL = 'personal';
- // getBackendStatus return types
- const STATUS_SUCCESS = 0;
- const STATUS_ERROR = 1;
- const STATUS_INDETERMINATE = 2;
-
// whether to skip backend test (for unit tests, as this static class is not mockable)
public static $skipTest = false;
@@ -219,7 +215,7 @@ class OC_Mount_Config {
*/
public static function getBackendStatus($class, $options, $isPersonal) {
if (self::$skipTest) {
- return self::STATUS_SUCCESS;
+ return StorageNotAvailableException::STATUS_SUCCESS;
}
foreach ($options as &$option) {
$option = self::setUserVars(OCP\User::getUser(), $option);
@@ -233,7 +229,7 @@ class OC_Mount_Config {
$result = $storage->test($isPersonal);
$storage->setAvailability($result);
if ($result) {
- return self::STATUS_SUCCESS;
+ return StorageNotAvailableException::STATUS_SUCCESS;
}
} catch (\Exception $e) {
$storage->setAvailability(false);
@@ -244,7 +240,7 @@ class OC_Mount_Config {
throw $exception;
}
}
- return self::STATUS_ERROR;
+ return StorageNotAvailableException::STATUS_ERROR;
}
/**
diff --git a/apps/files_external/service/storagesservice.php b/apps/files_external/service/storagesservice.php
index 3446ed0dab3..c847930ba2d 100644
--- a/apps/files_external/service/storagesservice.php
+++ b/apps/files_external/service/storagesservice.php
@@ -31,6 +31,7 @@ use \OCA\Files_external\NotFoundException;
use \OCA\Files_External\Service\BackendService;
use \OCA\Files_External\Lib\Backend\Backend;
use \OCA\Files_External\Lib\Auth\AuthMechanism;
+use \OCP\Files\StorageNotAvailableException;
/**
* Service class to manage external storages
@@ -411,7 +412,7 @@ abstract class StoragesService {
$this->triggerHooks($newStorage, Filesystem::signal_create_mount);
- $newStorage->setStatus(\OC_Mount_Config::STATUS_SUCCESS);
+ $newStorage->setStatus(StorageNotAvailableException::STATUS_SUCCESS);
return $newStorage;
}
diff --git a/lib/public/files/storagenotavailableexception.php b/lib/public/files/storagenotavailableexception.php
index fe270e76b4e..323f5d9b7f8 100644
--- a/lib/public/files/storagenotavailableexception.php
+++ b/lib/public/files/storagenotavailableexception.php
@@ -37,6 +37,9 @@ use OC\HintException;
*/
class StorageNotAvailableException extends HintException {
+ const STATUS_SUCCESS = 0;
+ const STATUS_ERROR = 1;
+ const STATUS_INDETERMINATE = 2;
const STATUS_INCOMPLETE_CONF = 3;
const STATUS_UNAUTHORIZED = 4;
const STATUS_TIMEOUT = 5;