aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/service/storagesservice.php
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@owncloud.com>2015-08-12 20:03:11 +0100
committerRobin McCorkell <rmccorkell@owncloud.com>2015-08-19 10:05:11 +0100
commit1eeca031f863a652d07ebfa2f75339232bf60dc1 (patch)
tree2f4b046e3506d4e9e385415bf01961f9b9978d97 /apps/files_external/service/storagesservice.php
parent272a46ebe1a5e195a078dde74f5f2ad941923d9e (diff)
downloadnextcloud-server-1eeca031f863a652d07ebfa2f75339232bf60dc1.tar.gz
nextcloud-server-1eeca031f863a652d07ebfa2f75339232bf60dc1.zip
Split backend identifiers from the class name
Prior to this, the storage class name was stored in mount.json under the "class" parameter, and the auth mechanism class name under the "authMechanism" parameter. This decouples the class name from the identifier used to retrieve the backend or auth mechanism. Now, backends/auth mechanisms have a unique identifier, which is saved in the "backend" or "authMechanism" parameter in mount.json respectively. An identifier is considered unique for the object it references, but the underlying class may change (e.g. files_external gets pulled into core and namespaces are modified).
Diffstat (limited to 'apps/files_external/service/storagesservice.php')
-rw-r--r--apps/files_external/service/storagesservice.php39
1 files changed, 24 insertions, 15 deletions
diff --git a/apps/files_external/service/storagesservice.php b/apps/files_external/service/storagesservice.php
index b8a1824ba23..e89af6bc756 100644
--- a/apps/files_external/service/storagesservice.php
+++ b/apps/files_external/service/storagesservice.php
@@ -81,9 +81,9 @@ abstract class StoragesService {
$applicable,
$storageOptions
) {
- $backend = $this->backendService->getBackend($storageOptions['class']);
+ $backend = $this->backendService->getBackend($storageOptions['backend']);
if (!$backend) {
- throw new \UnexpectedValueException('Invalid backend class');
+ throw new \UnexpectedValueException('Invalid backend '.$storageOptions['backend']);
}
$storageConfig->setBackend($backend);
@@ -94,7 +94,7 @@ abstract class StoragesService {
$storageOptions['authMechanism'] = 'null'; // to make error handling easier
}
if (!$authMechanism) {
- throw new \UnexpectedValueException('Invalid authentication mechanism class');
+ throw new \UnexpectedValueException('Invalid authentication mechanism '.$storageOptions['authMechanism']);
}
$storageConfig->setAuthMechanism($authMechanism);
@@ -140,9 +140,10 @@ abstract class StoragesService {
* - $mountPath is the mount point path (where the storage must be mounted)
* - $storageOptions is a map of storage options:
* - "priority": storage priority
- * - "backend": backend class name
+ * - "backend": backend identifier
+ * - "class": LEGACY backend class name
* - "options": backend-specific options
- * - "authMechanism": authentication mechanism class name
+ * - "authMechanism": authentication mechanism identifier
* - "mountOptions": mount-specific options (ex: disable previews, scanner, etc)
*/
@@ -186,6 +187,13 @@ abstract class StoragesService {
// options might be needed for the config hash
$storageOptions['options'] = \OC_Mount_Config::decryptPasswords($storageOptions['options']);
+ if (!isset($storageOptions['backend'])) {
+ $storageOptions['backend'] = $storageOptions['class']; // legacy compat
+ }
+ if (!isset($storageOptions['authMechanism'])) {
+ $storageOptions['authMechanism'] = null; // ensure config hash works
+ }
+
if (isset($storageOptions['id'])) {
$configId = (int)$storageOptions['id'];
if (isset($storages[$configId])) {
@@ -271,8 +279,9 @@ abstract class StoragesService {
$options = [
'id' => $storageConfig->getId(),
- 'class' => $storageConfig->getBackend()->getClass(),
- 'authMechanism' => $storageConfig->getAuthMechanism()->getClass(),
+ 'backend' => $storageConfig->getBackend()->getIdentifier(),
+ //'class' => $storageConfig->getBackend()->getClass(),
+ 'authMechanism' => $storageConfig->getAuthMechanism()->getIdentifier(),
'options' => $storageConfig->getBackendOptions(),
];
@@ -350,8 +359,8 @@ abstract class StoragesService {
* Create a storage from its parameters
*
* @param string $mountPoint storage mount point
- * @param string $backendClass backend class name
- * @param string $authMechanismClass authentication mechanism class
+ * @param string $backendIdentifier backend identifier
+ * @param string $authMechanismIdentifier authentication mechanism identifier
* @param array $backendOptions backend-specific options
* @param array|null $mountOptions mount-specific options
* @param array|null $applicableUsers users for which to mount the storage
@@ -362,21 +371,21 @@ abstract class StoragesService {
*/
public function createStorage(
$mountPoint,
- $backendClass,
- $authMechanismClass,
+ $backendIdentifier,
+ $authMechanismIdentifier,
$backendOptions,
$mountOptions = null,
$applicableUsers = null,
$applicableGroups = null,
$priority = null
) {
- $backend = $this->backendService->getBackend($backendClass);
+ $backend = $this->backendService->getBackend($backendIdentifier);
if (!$backend) {
- throw new \InvalidArgumentException('Unable to get backend for backend class '.$backendClass);
+ throw new \InvalidArgumentException('Unable to get backend for '.$backendIdentifier);
}
- $authMechanism = $this->backendService->getAuthMechanism($authMechanismClass);
+ $authMechanism = $this->backendService->getAuthMechanism($authMechanismIdentifier);
if (!$authMechanism) {
- throw new \InvalidArgumentException('Unable to get authentication mechanism for class '.$authMechanismClass);
+ throw new \InvalidArgumentException('Unable to get authentication mechanism for '.$authMechanismIdentifier);
}
$newStorage = new StorageConfig();
$newStorage->setMountPoint($mountPoint);