Completed
Pull Request — master (#7490)
by Tobia
30:30 queued 16:48
created
apps/files_external/lib/Service/UserTrait.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -30,46 +30,46 @@
 block discarded – undo
30 30
  */
31 31
 trait UserTrait {
32 32
 
33
-	/** @var IUserSession */
34
-	protected $userSession;
33
+    /** @var IUserSession */
34
+    protected $userSession;
35 35
 
36
-	/**
37
-	 * User override
38
-	 *
39
-	 * @var IUser|null
40
-	 */
41
-	private $user = null;
36
+    /**
37
+     * User override
38
+     *
39
+     * @var IUser|null
40
+     */
41
+    private $user = null;
42 42
 
43
-	/**
44
-	 * @return IUser|null
45
-	 */
46
-	protected function getUser() {
47
-		if ($this->user) {
48
-			return $this->user;
49
-		}
50
-		return $this->userSession->getUser();
51
-	}
43
+    /**
44
+     * @return IUser|null
45
+     */
46
+    protected function getUser() {
47
+        if ($this->user) {
48
+            return $this->user;
49
+        }
50
+        return $this->userSession->getUser();
51
+    }
52 52
 
53
-	/**
54
-	 * Override the user from the session
55
-	 * Unset with ->resetUser() when finished!
56
-	 *
57
-	 * @param IUser
58
-	 * @return self
59
-	 */
60
-	public function setUser(IUser $user) {
61
-		$this->user = $user;
62
-		return $this;
63
-	}
53
+    /**
54
+     * Override the user from the session
55
+     * Unset with ->resetUser() when finished!
56
+     *
57
+     * @param IUser
58
+     * @return self
59
+     */
60
+    public function setUser(IUser $user) {
61
+        $this->user = $user;
62
+        return $this;
63
+    }
64 64
 
65
-	/**
66
-	 * Reset the user override
67
-	 *
68
-	 * @return self
69
-	 */
70
-	public function resetUser() {
71
-		$this->user = null;
72
-		return $this;
73
-	}
65
+    /**
66
+     * Reset the user override
67
+     *
68
+     * @return self
69
+     */
70
+    public function resetUser() {
71
+        $this->user = null;
72
+        return $this;
73
+    }
74 74
 }
75 75
 
Please login to merge, or discard this patch.
apps/files_external/lib/Service/UserStoragesService.php 1 patch
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -40,105 +40,105 @@
 block discarded – undo
40 40
  * (aka personal storages)
41 41
  */
42 42
 class UserStoragesService extends StoragesService {
43
-	use UserTrait;
43
+    use UserTrait;
44 44
 
45
-	/**
46
-	 * Create a user storages service
47
-	 *
48
-	 * @param BackendService $backendService
49
-	 * @param DBConfigService $dbConfig
50
-	 * @param IUserSession $userSession user session
51
-	 * @param IUserMountCache $userMountCache
52
-	 */
53
-	public function __construct(
54
-		BackendService $backendService,
55
-		DBConfigService $dbConfig,
56
-		IUserSession $userSession,
57
-		IUserMountCache $userMountCache
58
-	) {
59
-		$this->userSession = $userSession;
60
-		parent::__construct($backendService, $dbConfig, $userMountCache);
61
-	}
45
+    /**
46
+     * Create a user storages service
47
+     *
48
+     * @param BackendService $backendService
49
+     * @param DBConfigService $dbConfig
50
+     * @param IUserSession $userSession user session
51
+     * @param IUserMountCache $userMountCache
52
+     */
53
+    public function __construct(
54
+        BackendService $backendService,
55
+        DBConfigService $dbConfig,
56
+        IUserSession $userSession,
57
+        IUserMountCache $userMountCache
58
+    ) {
59
+        $this->userSession = $userSession;
60
+        parent::__construct($backendService, $dbConfig, $userMountCache);
61
+    }
62 62
 
63
-	protected function readDBConfig() {
64
-		return $this->dbConfig->getUserMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID());
65
-	}
63
+    protected function readDBConfig() {
64
+        return $this->dbConfig->getUserMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID());
65
+    }
66 66
 
67
-	/**
68
-	 * Triggers $signal for all applicable users of the given
69
-	 * storage
70
-	 *
71
-	 * @param StorageConfig $storage storage data
72
-	 * @param string $signal signal to trigger
73
-	 */
74
-	protected function triggerHooks(StorageConfig $storage, $signal) {
75
-		$user = $this->getUser()->getUID();
67
+    /**
68
+     * Triggers $signal for all applicable users of the given
69
+     * storage
70
+     *
71
+     * @param StorageConfig $storage storage data
72
+     * @param string $signal signal to trigger
73
+     */
74
+    protected function triggerHooks(StorageConfig $storage, $signal) {
75
+        $user = $this->getUser()->getUID();
76 76
 
77
-		// trigger hook for the current user
78
-		$this->triggerApplicableHooks(
79
-			$signal,
80
-			$storage->getMountPoint(),
81
-			\OC_Mount_Config::MOUNT_TYPE_USER,
82
-			[$user]
83
-		);
84
-	}
77
+        // trigger hook for the current user
78
+        $this->triggerApplicableHooks(
79
+            $signal,
80
+            $storage->getMountPoint(),
81
+            \OC_Mount_Config::MOUNT_TYPE_USER,
82
+            [$user]
83
+        );
84
+    }
85 85
 
86
-	/**
87
-	 * Triggers signal_create_mount or signal_delete_mount to
88
-	 * accommodate for additions/deletions in applicableUsers
89
-	 * and applicableGroups fields.
90
-	 *
91
-	 * @param StorageConfig $oldStorage old storage data
92
-	 * @param StorageConfig $newStorage new storage data
93
-	 */
94
-	protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) {
95
-		// if mount point changed, it's like a deletion + creation
96
-		if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) {
97
-			$this->triggerHooks($oldStorage, Filesystem::signal_delete_mount);
98
-			$this->triggerHooks($newStorage, Filesystem::signal_create_mount);
99
-		}
100
-	}
86
+    /**
87
+     * Triggers signal_create_mount or signal_delete_mount to
88
+     * accommodate for additions/deletions in applicableUsers
89
+     * and applicableGroups fields.
90
+     *
91
+     * @param StorageConfig $oldStorage old storage data
92
+     * @param StorageConfig $newStorage new storage data
93
+     */
94
+    protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) {
95
+        // if mount point changed, it's like a deletion + creation
96
+        if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) {
97
+            $this->triggerHooks($oldStorage, Filesystem::signal_delete_mount);
98
+            $this->triggerHooks($newStorage, Filesystem::signal_create_mount);
99
+        }
100
+    }
101 101
 
102
-	protected function getType() {
103
-		return DBConfigService::MOUNT_TYPE_PERSONAl;
104
-	}
102
+    protected function getType() {
103
+        return DBConfigService::MOUNT_TYPE_PERSONAl;
104
+    }
105 105
 
106
-	/**
107
-	 * Add new storage to the configuration
108
-	 *
109
-	 * @param StorageConfig $newStorage storage attributes
110
-	 *
111
-	 * @return StorageConfig storage config, with added id
112
-	 */
113
-	public function addStorage(StorageConfig $newStorage) {
114
-		$newStorage->setApplicableUsers([$this->getUser()->getUID()]);
115
-		$config = parent::addStorage($newStorage);
116
-		return $config;
117
-	}
106
+    /**
107
+     * Add new storage to the configuration
108
+     *
109
+     * @param StorageConfig $newStorage storage attributes
110
+     *
111
+     * @return StorageConfig storage config, with added id
112
+     */
113
+    public function addStorage(StorageConfig $newStorage) {
114
+        $newStorage->setApplicableUsers([$this->getUser()->getUID()]);
115
+        $config = parent::addStorage($newStorage);
116
+        return $config;
117
+    }
118 118
 
119
-	/**
120
-	 * Update storage to the configuration
121
-	 *
122
-	 * @param StorageConfig $updatedStorage storage attributes
123
-	 *
124
-	 * @return StorageConfig storage config
125
-	 * @throws NotFoundException if the given storage does not exist in the config
126
-	 */
127
-	public function updateStorage(StorageConfig $updatedStorage) {
128
-		$updatedStorage->setApplicableUsers([$this->getUser()->getUID()]);
129
-		return parent::updateStorage($updatedStorage);
130
-	}
119
+    /**
120
+     * Update storage to the configuration
121
+     *
122
+     * @param StorageConfig $updatedStorage storage attributes
123
+     *
124
+     * @return StorageConfig storage config
125
+     * @throws NotFoundException if the given storage does not exist in the config
126
+     */
127
+    public function updateStorage(StorageConfig $updatedStorage) {
128
+        $updatedStorage->setApplicableUsers([$this->getUser()->getUID()]);
129
+        return parent::updateStorage($updatedStorage);
130
+    }
131 131
 
132
-	/**
133
-	 * Get the visibility type for this controller, used in validation
134
-	 *
135
-	 * @return string BackendService::VISIBILITY_* constants
136
-	 */
137
-	public function getVisibilityType() {
138
-		return BackendService::VISIBILITY_PERSONAL;
139
-	}
132
+    /**
133
+     * Get the visibility type for this controller, used in validation
134
+     *
135
+     * @return string BackendService::VISIBILITY_* constants
136
+     */
137
+    public function getVisibilityType() {
138
+        return BackendService::VISIBILITY_PERSONAL;
139
+    }
140 140
 
141
-	protected function isApplicable(StorageConfig $config) {
142
-		return ($config->getApplicableUsers() === [$this->getUser()->getUID()]) && $config->getType() === StorageConfig::MOUNT_TYPE_PERSONAl;
143
-	}
141
+    protected function isApplicable(StorageConfig $config) {
142
+        return ($config->getApplicableUsers() === [$this->getUser()->getUID()]) && $config->getType() === StorageConfig::MOUNT_TYPE_PERSONAl;
143
+    }
144 144
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Config/ConfigAdapter.php 1 patch
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -45,143 +45,143 @@
 block discarded – undo
45 45
  */
46 46
 class ConfigAdapter implements IMountProvider {
47 47
 
48
-	/** @var UserStoragesService */
49
-	private $userStoragesService;
50
-
51
-	/** @var UserGlobalStoragesService */
52
-	private $userGlobalStoragesService;
53
-	/** @var StorageMigrator  */
54
-	private $migrator;
55
-
56
-	/**
57
-	 * @param UserStoragesService $userStoragesService
58
-	 * @param UserGlobalStoragesService $userGlobalStoragesService
59
-	 * @param StorageMigrator $migrator
60
-	 */
61
-	public function __construct(
62
-		UserStoragesService $userStoragesService,
63
-		UserGlobalStoragesService $userGlobalStoragesService,
64
-		StorageMigrator $migrator
65
-	) {
66
-		$this->userStoragesService = $userStoragesService;
67
-		$this->userGlobalStoragesService = $userGlobalStoragesService;
68
-		$this->migrator = $migrator;
69
-	}
70
-
71
-	/**
72
-	 * Process storage ready for mounting
73
-	 *
74
-	 * @param StorageConfig $storage
75
-	 * @param IUser $user
76
-	 */
77
-	private function prepareStorageConfig(StorageConfig &$storage, IUser $user) {
78
-		foreach ($storage->getBackendOptions() as $option => $value) {
79
-			$storage->setBackendOption($option, \OC_Mount_Config::setUserVars(
80
-				$user->getUID(), $value
81
-			));
82
-		}
83
-
84
-		$objectStore = $storage->getBackendOption('objectstore');
85
-		if ($objectStore) {
86
-			$objectClass = $objectStore['class'];
87
-			if (!is_subclass_of($objectClass, '\OCP\Files\ObjectStore\IObjectStore')) {
88
-				throw new \InvalidArgumentException('Invalid object store');
89
-			}
90
-			$storage->setBackendOption('objectstore', new $objectClass($objectStore));
91
-		}
92
-
93
-		$storage->getAuthMechanism()->manipulateStorageConfig($storage, $user);
94
-		$storage->getBackend()->manipulateStorageConfig($storage, $user);
95
-	}
96
-
97
-	/**
98
-	 * Construct the storage implementation
99
-	 *
100
-	 * @param StorageConfig $storageConfig
101
-	 * @return Storage
102
-	 */
103
-	private function constructStorage(StorageConfig $storageConfig) {
104
-		$class = $storageConfig->getBackend()->getStorageClass();
105
-		$storage = new $class($storageConfig->getBackendOptions());
106
-
107
-		// auth mechanism should fire first
108
-		$storage = $storageConfig->getBackend()->wrapStorage($storage);
109
-		$storage = $storageConfig->getAuthMechanism()->wrapStorage($storage);
110
-
111
-		return $storage;
112
-	}
113
-
114
-	/**
115
-	 * Get all mountpoints applicable for the user
116
-	 *
117
-	 * @param \OCP\IUser $user
118
-	 * @param \OCP\Files\Storage\IStorageFactory $loader
119
-	 * @return \OCP\Files\Mount\IMountPoint[]
120
-	 */
121
-	public function getMountsForUser(IUser $user, IStorageFactory $loader) {
122
-		$this->migrator->migrateUser($user);
123
-
124
-		$this->userStoragesService->setUser($user);
125
-		$this->userGlobalStoragesService->setUser($user);
126
-
127
-		$storageConfigs = $this->userGlobalStoragesService->getAllStoragesForUser();
128
-
129
-		$storages = array_map(function(StorageConfig $storageConfig) use ($user) {
130
-			try {
131
-				$this->prepareStorageConfig($storageConfig, $user);
132
-				return $this->constructStorage($storageConfig);
133
-			} catch (\Exception $e) {
134
-				// propagate exception into filesystem
135
-				return new FailedStorage(['exception' => $e]);
136
-			}
137
-		}, $storageConfigs);
138
-
139
-
140
-		\OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function(Storage\IStorage $storage) {
141
-			return $storage->getId();
142
-		}, $storages));
143
-
144
-		$availableStorages = array_map(function (Storage\IStorage $storage, StorageConfig $storageConfig) {
145
-			try {
146
-				$availability = $storage->getAvailability();
147
-				if (!$availability['available'] && !Availability::shouldRecheck($availability)) {
148
-					$storage = new FailedStorage([
149
-						'exception' => new StorageNotAvailableException('Storage with mount id ' . $storageConfig->getId() . ' is not available')
150
-					]);
151
-				}
152
-			} catch (\Exception $e) {
153
-				// propagate exception into filesystem
154
-				$storage = new FailedStorage(['exception' => $e]);
155
-			}
156
-			return $storage;
157
-		}, $storages, $storageConfigs);
158
-
159
-		$mounts = array_map(function(StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
160
-			if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
161
-				return new PersonalMount(
162
-					$this->userStoragesService,
163
-					$storageConfig->getId(),
164
-					$storage,
165
-					'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
166
-					null,
167
-					$loader,
168
-					$storageConfig->getMountOptions()
169
-				);
170
-			} else {
171
-				return new MountPoint(
172
-					$storage,
173
-					'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
174
-					null,
175
-					$loader,
176
-					$storageConfig->getMountOptions(),
177
-					$storageConfig->getId()
178
-				);
179
-			}
180
-		}, $storageConfigs, $availableStorages);
181
-
182
-		$this->userStoragesService->resetUser();
183
-		$this->userGlobalStoragesService->resetUser();
184
-
185
-		return $mounts;
186
-	}
48
+    /** @var UserStoragesService */
49
+    private $userStoragesService;
50
+
51
+    /** @var UserGlobalStoragesService */
52
+    private $userGlobalStoragesService;
53
+    /** @var StorageMigrator  */
54
+    private $migrator;
55
+
56
+    /**
57
+     * @param UserStoragesService $userStoragesService
58
+     * @param UserGlobalStoragesService $userGlobalStoragesService
59
+     * @param StorageMigrator $migrator
60
+     */
61
+    public function __construct(
62
+        UserStoragesService $userStoragesService,
63
+        UserGlobalStoragesService $userGlobalStoragesService,
64
+        StorageMigrator $migrator
65
+    ) {
66
+        $this->userStoragesService = $userStoragesService;
67
+        $this->userGlobalStoragesService = $userGlobalStoragesService;
68
+        $this->migrator = $migrator;
69
+    }
70
+
71
+    /**
72
+     * Process storage ready for mounting
73
+     *
74
+     * @param StorageConfig $storage
75
+     * @param IUser $user
76
+     */
77
+    private function prepareStorageConfig(StorageConfig &$storage, IUser $user) {
78
+        foreach ($storage->getBackendOptions() as $option => $value) {
79
+            $storage->setBackendOption($option, \OC_Mount_Config::setUserVars(
80
+                $user->getUID(), $value
81
+            ));
82
+        }
83
+
84
+        $objectStore = $storage->getBackendOption('objectstore');
85
+        if ($objectStore) {
86
+            $objectClass = $objectStore['class'];
87
+            if (!is_subclass_of($objectClass, '\OCP\Files\ObjectStore\IObjectStore')) {
88
+                throw new \InvalidArgumentException('Invalid object store');
89
+            }
90
+            $storage->setBackendOption('objectstore', new $objectClass($objectStore));
91
+        }
92
+
93
+        $storage->getAuthMechanism()->manipulateStorageConfig($storage, $user);
94
+        $storage->getBackend()->manipulateStorageConfig($storage, $user);
95
+    }
96
+
97
+    /**
98
+     * Construct the storage implementation
99
+     *
100
+     * @param StorageConfig $storageConfig
101
+     * @return Storage
102
+     */
103
+    private function constructStorage(StorageConfig $storageConfig) {
104
+        $class = $storageConfig->getBackend()->getStorageClass();
105
+        $storage = new $class($storageConfig->getBackendOptions());
106
+
107
+        // auth mechanism should fire first
108
+        $storage = $storageConfig->getBackend()->wrapStorage($storage);
109
+        $storage = $storageConfig->getAuthMechanism()->wrapStorage($storage);
110
+
111
+        return $storage;
112
+    }
113
+
114
+    /**
115
+     * Get all mountpoints applicable for the user
116
+     *
117
+     * @param \OCP\IUser $user
118
+     * @param \OCP\Files\Storage\IStorageFactory $loader
119
+     * @return \OCP\Files\Mount\IMountPoint[]
120
+     */
121
+    public function getMountsForUser(IUser $user, IStorageFactory $loader) {
122
+        $this->migrator->migrateUser($user);
123
+
124
+        $this->userStoragesService->setUser($user);
125
+        $this->userGlobalStoragesService->setUser($user);
126
+
127
+        $storageConfigs = $this->userGlobalStoragesService->getAllStoragesForUser();
128
+
129
+        $storages = array_map(function(StorageConfig $storageConfig) use ($user) {
130
+            try {
131
+                $this->prepareStorageConfig($storageConfig, $user);
132
+                return $this->constructStorage($storageConfig);
133
+            } catch (\Exception $e) {
134
+                // propagate exception into filesystem
135
+                return new FailedStorage(['exception' => $e]);
136
+            }
137
+        }, $storageConfigs);
138
+
139
+
140
+        \OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function(Storage\IStorage $storage) {
141
+            return $storage->getId();
142
+        }, $storages));
143
+
144
+        $availableStorages = array_map(function (Storage\IStorage $storage, StorageConfig $storageConfig) {
145
+            try {
146
+                $availability = $storage->getAvailability();
147
+                if (!$availability['available'] && !Availability::shouldRecheck($availability)) {
148
+                    $storage = new FailedStorage([
149
+                        'exception' => new StorageNotAvailableException('Storage with mount id ' . $storageConfig->getId() . ' is not available')
150
+                    ]);
151
+                }
152
+            } catch (\Exception $e) {
153
+                // propagate exception into filesystem
154
+                $storage = new FailedStorage(['exception' => $e]);
155
+            }
156
+            return $storage;
157
+        }, $storages, $storageConfigs);
158
+
159
+        $mounts = array_map(function(StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
160
+            if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
161
+                return new PersonalMount(
162
+                    $this->userStoragesService,
163
+                    $storageConfig->getId(),
164
+                    $storage,
165
+                    '/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
166
+                    null,
167
+                    $loader,
168
+                    $storageConfig->getMountOptions()
169
+                );
170
+            } else {
171
+                return new MountPoint(
172
+                    $storage,
173
+                    '/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
174
+                    null,
175
+                    $loader,
176
+                    $storageConfig->getMountOptions(),
177
+                    $storageConfig->getId()
178
+                );
179
+            }
180
+        }, $storageConfigs, $availableStorages);
181
+
182
+        $this->userStoragesService->resetUser();
183
+        $this->userGlobalStoragesService->resetUser();
184
+
185
+        return $mounts;
186
+    }
187 187
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Migration/DummyUserSession.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -28,26 +28,26 @@
 block discarded – undo
28 28
 
29 29
 class DummyUserSession implements IUserSession {
30 30
 
31
-	/**
32
-	 * @var IUser
33
-	 */
34
-	private $user;
31
+    /**
32
+     * @var IUser
33
+     */
34
+    private $user;
35 35
 
36
-	public function login($user, $password) {
37
-	}
36
+    public function login($user, $password) {
37
+    }
38 38
 
39
-	public function logout() {
40
-	}
39
+    public function logout() {
40
+    }
41 41
 
42
-	public function setUser($user) {
43
-		$this->user = $user;
44
-	}
42
+    public function setUser($user) {
43
+        $this->user = $user;
44
+    }
45 45
 
46
-	public function getUser() {
47
-		return $this->user;
48
-	}
46
+    public function getUser() {
47
+        return $this->user;
48
+    }
49 49
 
50
-	public function isLoggedIn() {
51
-		return !is_null($this->user);
52
-	}
50
+    public function isLoggedIn() {
51
+        return !is_null($this->user);
52
+    }
53 53
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Export.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -30,30 +30,30 @@
 block discarded – undo
30 30
 
31 31
 class Export extends ListCommand {
32 32
 
33
-	protected function configure() {
34
-		$this
35
-			->setName('files_external:export')
36
-			->setDescription('Export mount configurations')
37
-			->addArgument(
38
-				'user_id',
39
-				InputArgument::OPTIONAL,
40
-				'user id to export the personal mounts for, if no user is provided admin mounts will be exported'
41
-			)->addOption(
42
-				'all',
43
-				'a',
44
-				InputOption::VALUE_NONE,
45
-				'show both system wide mounts and all personal mounts'
46
-			);
47
-	}
33
+    protected function configure() {
34
+        $this
35
+            ->setName('files_external:export')
36
+            ->setDescription('Export mount configurations')
37
+            ->addArgument(
38
+                'user_id',
39
+                InputArgument::OPTIONAL,
40
+                'user id to export the personal mounts for, if no user is provided admin mounts will be exported'
41
+            )->addOption(
42
+                'all',
43
+                'a',
44
+                InputOption::VALUE_NONE,
45
+                'show both system wide mounts and all personal mounts'
46
+            );
47
+    }
48 48
 
49
-	protected function execute(InputInterface $input, OutputInterface $output) {
50
-		$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
51
-		$listInput = new ArrayInput([], $listCommand->getDefinition());
52
-		$listInput->setArgument('user_id', $input->getArgument('user_id'));
53
-		$listInput->setOption('all', $input->getOption('all'));
54
-		$listInput->setOption('output', 'json_pretty');
55
-		$listInput->setOption('show-password', true);
56
-		$listInput->setOption('full', true);
57
-		$listCommand->execute($listInput, $output);
58
-	}
49
+    protected function execute(InputInterface $input, OutputInterface $output) {
50
+        $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
51
+        $listInput = new ArrayInput([], $listCommand->getDefinition());
52
+        $listInput->setArgument('user_id', $input->getArgument('user_id'));
53
+        $listInput->setOption('all', $input->getOption('all'));
54
+        $listInput->setOption('output', 'json_pretty');
55
+        $listInput->setOption('show-password', true);
56
+        $listInput->setOption('full', true);
57
+        $listCommand->execute($listInput, $output);
58
+    }
59 59
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Verify.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -37,108 +37,108 @@
 block discarded – undo
37 37
 use Symfony\Component\Console\Output\OutputInterface;
38 38
 
39 39
 class Verify extends Base {
40
-	/**
41
-	 * @var GlobalStoragesService
42
-	 */
43
-	protected $globalService;
40
+    /**
41
+     * @var GlobalStoragesService
42
+     */
43
+    protected $globalService;
44 44
 
45
-	function __construct(GlobalStoragesService $globalService) {
46
-		parent::__construct();
47
-		$this->globalService = $globalService;
48
-	}
45
+    function __construct(GlobalStoragesService $globalService) {
46
+        parent::__construct();
47
+        $this->globalService = $globalService;
48
+    }
49 49
 
50
-	protected function configure() {
51
-		$this
52
-			->setName('files_external:verify')
53
-			->setDescription('Verify mount configuration')
54
-			->addArgument(
55
-				'mount_id',
56
-				InputArgument::REQUIRED,
57
-				'The id of the mount to check'
58
-			)->addOption(
59
-				'config',
60
-				'c',
61
-				InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
62
-				'Additional config option to set before checking in key=value pairs, required for certain auth backends such as login credentails'
63
-			);
64
-		parent::configure();
65
-	}
50
+    protected function configure() {
51
+        $this
52
+            ->setName('files_external:verify')
53
+            ->setDescription('Verify mount configuration')
54
+            ->addArgument(
55
+                'mount_id',
56
+                InputArgument::REQUIRED,
57
+                'The id of the mount to check'
58
+            )->addOption(
59
+                'config',
60
+                'c',
61
+                InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
62
+                'Additional config option to set before checking in key=value pairs, required for certain auth backends such as login credentails'
63
+            );
64
+        parent::configure();
65
+    }
66 66
 
67
-	protected function execute(InputInterface $input, OutputInterface $output) {
68
-		$mountId = $input->getArgument('mount_id');
69
-		$configInput = $input->getOption('config');
67
+    protected function execute(InputInterface $input, OutputInterface $output) {
68
+        $mountId = $input->getArgument('mount_id');
69
+        $configInput = $input->getOption('config');
70 70
 
71
-		try {
72
-			$mount = $this->globalService->getStorage($mountId);
73
-		} catch (NotFoundException $e) {
74
-			$output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
75
-			return 404;
76
-		}
71
+        try {
72
+            $mount = $this->globalService->getStorage($mountId);
73
+        } catch (NotFoundException $e) {
74
+            $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
75
+            return 404;
76
+        }
77 77
 
78
-		$this->updateStorageStatus($mount, $configInput, $output);
78
+        $this->updateStorageStatus($mount, $configInput, $output);
79 79
 
80
-		$this->writeArrayInOutputFormat($input, $output, [
81
-			'status' => StorageNotAvailableException::getStateCodeName($mount->getStatus()),
82
-			'code' => $mount->getStatus(),
83
-			'message' => $mount->getStatusMessage()
84
-		]);
85
-	}
80
+        $this->writeArrayInOutputFormat($input, $output, [
81
+            'status' => StorageNotAvailableException::getStateCodeName($mount->getStatus()),
82
+            'code' => $mount->getStatus(),
83
+            'message' => $mount->getStatusMessage()
84
+        ]);
85
+    }
86 86
 
87
-	private function manipulateStorageConfig(StorageConfig $storage) {
88
-		/** @var AuthMechanism */
89
-		$authMechanism = $storage->getAuthMechanism();
90
-		$authMechanism->manipulateStorageConfig($storage);
91
-		/** @var Backend */
92
-		$backend = $storage->getBackend();
93
-		$backend->manipulateStorageConfig($storage);
94
-	}
87
+    private function manipulateStorageConfig(StorageConfig $storage) {
88
+        /** @var AuthMechanism */
89
+        $authMechanism = $storage->getAuthMechanism();
90
+        $authMechanism->manipulateStorageConfig($storage);
91
+        /** @var Backend */
92
+        $backend = $storage->getBackend();
93
+        $backend->manipulateStorageConfig($storage);
94
+    }
95 95
 
96
-	private function updateStorageStatus(StorageConfig &$storage, $configInput, OutputInterface $output) {
97
-		try {
98
-			try {
99
-				$this->manipulateStorageConfig($storage);
100
-			} catch (InsufficientDataForMeaningfulAnswerException $e) {
101
-				if (count($configInput) === 0) { // extra config options might solve the error
102
-					throw $e;
103
-				}
104
-			}
96
+    private function updateStorageStatus(StorageConfig &$storage, $configInput, OutputInterface $output) {
97
+        try {
98
+            try {
99
+                $this->manipulateStorageConfig($storage);
100
+            } catch (InsufficientDataForMeaningfulAnswerException $e) {
101
+                if (count($configInput) === 0) { // extra config options might solve the error
102
+                    throw $e;
103
+                }
104
+            }
105 105
 
106
-			foreach ($configInput as $configOption) {
107
-				if (!strpos($configOption, '=')) {
108
-					$output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
109
-					return;
110
-				}
111
-				list($key, $value) = explode('=', $configOption, 2);
112
-				$storage->setBackendOption($key, $value);
113
-			}
106
+            foreach ($configInput as $configOption) {
107
+                if (!strpos($configOption, '=')) {
108
+                    $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
109
+                    return;
110
+                }
111
+                list($key, $value) = explode('=', $configOption, 2);
112
+                $storage->setBackendOption($key, $value);
113
+            }
114 114
 
115
-			/** @var Backend */
116
-			$backend = $storage->getBackend();
117
-			// update status (can be time-consuming)
118
-			$storage->setStatus(
119
-				\OC_Mount_Config::getBackendStatus(
120
-					$backend->getStorageClass(),
121
-					$storage->getBackendOptions(),
122
-					false
123
-				)
124
-			);
125
-		} catch (InsufficientDataForMeaningfulAnswerException $e) {
126
-			$status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE;
127
-			$storage->setStatus(
128
-				$status,
129
-				$e->getMessage()
130
-			);
131
-		} catch (StorageNotAvailableException $e) {
132
-			$storage->setStatus(
133
-				$e->getCode(),
134
-				$e->getMessage()
135
-			);
136
-		} catch (\Exception $e) {
137
-			// FIXME: convert storage exceptions to StorageNotAvailableException
138
-			$storage->setStatus(
139
-				StorageNotAvailableException::STATUS_ERROR,
140
-				get_class($e) . ': ' . $e->getMessage()
141
-			);
142
-		}
143
-	}
115
+            /** @var Backend */
116
+            $backend = $storage->getBackend();
117
+            // update status (can be time-consuming)
118
+            $storage->setStatus(
119
+                \OC_Mount_Config::getBackendStatus(
120
+                    $backend->getStorageClass(),
121
+                    $storage->getBackendOptions(),
122
+                    false
123
+                )
124
+            );
125
+        } catch (InsufficientDataForMeaningfulAnswerException $e) {
126
+            $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE;
127
+            $storage->setStatus(
128
+                $status,
129
+                $e->getMessage()
130
+            );
131
+        } catch (StorageNotAvailableException $e) {
132
+            $storage->setStatus(
133
+                $e->getCode(),
134
+                $e->getMessage()
135
+            );
136
+        } catch (\Exception $e) {
137
+            // FIXME: convert storage exceptions to StorageNotAvailableException
138
+            $storage->setStatus(
139
+                StorageNotAvailableException::STATUS_ERROR,
140
+                get_class($e) . ': ' . $e->getMessage()
141
+            );
142
+        }
143
+    }
144 144
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Option.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -28,50 +28,50 @@
 block discarded – undo
28 28
 use Symfony\Component\Console\Output\OutputInterface;
29 29
 
30 30
 class Option extends Config {
31
-	protected function configure() {
32
-		$this
33
-			->setName('files_external:option')
34
-			->setDescription('Manage mount options for a mount')
35
-			->addArgument(
36
-				'mount_id',
37
-				InputArgument::REQUIRED,
38
-				'The id of the mount to edit'
39
-			)->addArgument(
40
-				'key',
41
-				InputArgument::REQUIRED,
42
-				'key of the mount option to set/get'
43
-			)->addArgument(
44
-				'value',
45
-				InputArgument::OPTIONAL,
46
-				'value to set the mount option to, when no value is provided the existing value will be printed'
47
-			);
48
-	}
31
+    protected function configure() {
32
+        $this
33
+            ->setName('files_external:option')
34
+            ->setDescription('Manage mount options for a mount')
35
+            ->addArgument(
36
+                'mount_id',
37
+                InputArgument::REQUIRED,
38
+                'The id of the mount to edit'
39
+            )->addArgument(
40
+                'key',
41
+                InputArgument::REQUIRED,
42
+                'key of the mount option to set/get'
43
+            )->addArgument(
44
+                'value',
45
+                InputArgument::OPTIONAL,
46
+                'value to set the mount option to, when no value is provided the existing value will be printed'
47
+            );
48
+    }
49 49
 
50
-	/**
51
-	 * @param StorageConfig $mount
52
-	 * @param string $key
53
-	 * @param OutputInterface $output
54
-	 */
55
-	protected function getOption(StorageConfig $mount, $key, OutputInterface $output) {
56
-		$value = $mount->getMountOption($key);
57
-		if (!is_string($value)) { // show bools and objects correctly
58
-			$value = json_encode($value);
59
-		}
60
-		$output->writeln($value);
61
-	}
50
+    /**
51
+     * @param StorageConfig $mount
52
+     * @param string $key
53
+     * @param OutputInterface $output
54
+     */
55
+    protected function getOption(StorageConfig $mount, $key, OutputInterface $output) {
56
+        $value = $mount->getMountOption($key);
57
+        if (!is_string($value)) { // show bools and objects correctly
58
+            $value = json_encode($value);
59
+        }
60
+        $output->writeln($value);
61
+    }
62 62
 
63
-	/**
64
-	 * @param StorageConfig $mount
65
-	 * @param string $key
66
-	 * @param string $value
67
-	 * @param OutputInterface $output
68
-	 */
69
-	protected function setOption(StorageConfig $mount, $key, $value, OutputInterface $output) {
70
-		$decoded = json_decode($value, true);
71
-		if (!is_null($decoded)) {
72
-			$value = $decoded;
73
-		}
74
-		$mount->setMountOption($key, $value);
75
-		$this->globalService->updateStorage($mount);
76
-	}
63
+    /**
64
+     * @param StorageConfig $mount
65
+     * @param string $key
66
+     * @param string $value
67
+     * @param OutputInterface $output
68
+     */
69
+    protected function setOption(StorageConfig $mount, $key, $value, OutputInterface $output) {
70
+        $decoded = json_decode($value, true);
71
+        if (!is_null($decoded)) {
72
+            $value = $decoded;
73
+        }
74
+        $mount->setMountOption($key, $value);
75
+        $this->globalService->updateStorage($mount);
76
+    }
77 77
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Backends.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -32,91 +32,91 @@
 block discarded – undo
32 32
 use Symfony\Component\Console\Output\OutputInterface;
33 33
 
34 34
 class Backends extends Base {
35
-	/** @var BackendService */
36
-	private $backendService;
35
+    /** @var BackendService */
36
+    private $backendService;
37 37
 
38
-	function __construct(BackendService $backendService
39
-	) {
40
-		parent::__construct();
38
+    function __construct(BackendService $backendService
39
+    ) {
40
+        parent::__construct();
41 41
 
42
-		$this->backendService = $backendService;
43
-	}
42
+        $this->backendService = $backendService;
43
+    }
44 44
 
45
-	protected function configure() {
46
-		$this
47
-			->setName('files_external:backends')
48
-			->setDescription('Show available authentication and storage backends')
49
-			->addArgument(
50
-				'type',
51
-				InputArgument::OPTIONAL,
52
-				'only show backends of a certain type. Possible values are "authentication" or "storage"'
53
-			)->addArgument(
54
-				'backend',
55
-				InputArgument::OPTIONAL,
56
-				'only show information of a specific backend'
57
-			);
58
-		parent::configure();
59
-	}
45
+    protected function configure() {
46
+        $this
47
+            ->setName('files_external:backends')
48
+            ->setDescription('Show available authentication and storage backends')
49
+            ->addArgument(
50
+                'type',
51
+                InputArgument::OPTIONAL,
52
+                'only show backends of a certain type. Possible values are "authentication" or "storage"'
53
+            )->addArgument(
54
+                'backend',
55
+                InputArgument::OPTIONAL,
56
+                'only show information of a specific backend'
57
+            );
58
+        parent::configure();
59
+    }
60 60
 
61
-	protected function execute(InputInterface $input, OutputInterface $output) {
62
-		$authBackends = $this->backendService->getAuthMechanisms();
63
-		$storageBackends = $this->backendService->getBackends();
61
+    protected function execute(InputInterface $input, OutputInterface $output) {
62
+        $authBackends = $this->backendService->getAuthMechanisms();
63
+        $storageBackends = $this->backendService->getBackends();
64 64
 
65
-		$data = [
66
-			'authentication' => array_map([$this, 'serializeAuthBackend'], $authBackends),
67
-			'storage' => array_map([$this, 'serializeAuthBackend'], $storageBackends)
68
-		];
65
+        $data = [
66
+            'authentication' => array_map([$this, 'serializeAuthBackend'], $authBackends),
67
+            'storage' => array_map([$this, 'serializeAuthBackend'], $storageBackends)
68
+        ];
69 69
 
70
-		$type = $input->getArgument('type');
71
-		$backend = $input->getArgument('backend');
72
-		if ($type) {
73
-			if (!isset($data[$type])) {
74
-				$output->writeln('<error>Invalid type "' . $type . '". Possible values are "authentication" or "storage"</error>');
75
-				return 1;
76
-			}
77
-			$data = $data[$type];
70
+        $type = $input->getArgument('type');
71
+        $backend = $input->getArgument('backend');
72
+        if ($type) {
73
+            if (!isset($data[$type])) {
74
+                $output->writeln('<error>Invalid type "' . $type . '". Possible values are "authentication" or "storage"</error>');
75
+                return 1;
76
+            }
77
+            $data = $data[$type];
78 78
 
79
-			if ($backend) {
80
-				if (!isset($data[$backend])) {
81
-					$output->writeln('<error>Unknown backend "' . $backend . '" of type  "' . $type . '"</error>');
82
-					return 1;
83
-				}
84
-				$data = $data[$backend];
85
-			}
86
-		}
79
+            if ($backend) {
80
+                if (!isset($data[$backend])) {
81
+                    $output->writeln('<error>Unknown backend "' . $backend . '" of type  "' . $type . '"</error>');
82
+                    return 1;
83
+                }
84
+                $data = $data[$backend];
85
+            }
86
+        }
87 87
 
88
-		$this->writeArrayInOutputFormat($input, $output, $data);
89
-	}
88
+        $this->writeArrayInOutputFormat($input, $output, $data);
89
+    }
90 90
 
91
-	private function serializeAuthBackend(\JsonSerializable $backend) {
92
-		$data = $backend->jsonSerialize();
93
-		$result = [
94
-			'name' => $data['name'],
95
-			'identifier' => $data['identifier'],
96
-			'configuration' => $this->formatConfiguration($data['configuration'])
97
-		];
98
-		if ($backend instanceof Backend) {
99
-			$result['storage_class'] = $backend->getStorageClass();
100
-			$authBackends = $this->backendService->getAuthMechanismsByScheme(array_keys($backend->getAuthSchemes()));
101
-			$result['supported_authentication_backends'] = array_keys($authBackends);
102
-			$authConfig = array_map(function (AuthMechanism $auth) {
103
-				return $this->serializeAuthBackend($auth)['configuration'];
104
-			}, $authBackends);
105
-			$result['authentication_configuration'] = array_combine(array_keys($authBackends), $authConfig);
106
-		}
107
-		return $result;
108
-	}
91
+    private function serializeAuthBackend(\JsonSerializable $backend) {
92
+        $data = $backend->jsonSerialize();
93
+        $result = [
94
+            'name' => $data['name'],
95
+            'identifier' => $data['identifier'],
96
+            'configuration' => $this->formatConfiguration($data['configuration'])
97
+        ];
98
+        if ($backend instanceof Backend) {
99
+            $result['storage_class'] = $backend->getStorageClass();
100
+            $authBackends = $this->backendService->getAuthMechanismsByScheme(array_keys($backend->getAuthSchemes()));
101
+            $result['supported_authentication_backends'] = array_keys($authBackends);
102
+            $authConfig = array_map(function (AuthMechanism $auth) {
103
+                return $this->serializeAuthBackend($auth)['configuration'];
104
+            }, $authBackends);
105
+            $result['authentication_configuration'] = array_combine(array_keys($authBackends), $authConfig);
106
+        }
107
+        return $result;
108
+    }
109 109
 
110
-	/**
111
-	 * @param DefinitionParameter[] $parameters
112
-	 * @return string[]
113
-	 */
114
-	private function formatConfiguration(array $parameters) {
115
-		$configuration = array_filter($parameters, function (DefinitionParameter $parameter) {
116
-			return $parameter->getType() !== DefinitionParameter::VALUE_HIDDEN;
117
-		});
118
-		return array_map(function (DefinitionParameter $parameter) {
119
-			return $parameter->getTypeName();
120
-		}, $configuration);
121
-	}
110
+    /**
111
+     * @param DefinitionParameter[] $parameters
112
+     * @return string[]
113
+     */
114
+    private function formatConfiguration(array $parameters) {
115
+        $configuration = array_filter($parameters, function (DefinitionParameter $parameter) {
116
+            return $parameter->getType() !== DefinitionParameter::VALUE_HIDDEN;
117
+        });
118
+        return array_map(function (DefinitionParameter $parameter) {
119
+            return $parameter->getTypeName();
120
+        }, $configuration);
121
+    }
122 122
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Settings/Section.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,55 +28,55 @@
 block discarded – undo
28 28
 use OCP\Settings\IIconSection;
29 29
 
30 30
 class Section implements IIconSection {
31
-	/** @var IL10N */
32
-	private $l;
33
-	/** @var IURLGenerator */
34
-	private $url;
31
+    /** @var IL10N */
32
+    private $l;
33
+    /** @var IURLGenerator */
34
+    private $url;
35 35
 
36
-	/**
37
-	 * @param IURLGenerator $url
38
-	 * @param IL10N $l
39
-	 */
40
-	public function __construct(IURLGenerator $url, IL10N $l) {
41
-		$this->url = $url;
42
-		$this->l = $l;
43
-	}
36
+    /**
37
+     * @param IURLGenerator $url
38
+     * @param IL10N $l
39
+     */
40
+    public function __construct(IURLGenerator $url, IL10N $l) {
41
+        $this->url = $url;
42
+        $this->l = $l;
43
+    }
44 44
 
45
-	/**
46
-	 * returns the ID of the section. It is supposed to be a lower case string,
47
-	 * e.g. 'ldap'
48
-	 *
49
-	 * @returns string
50
-	 */
51
-	public function getID() {
52
-		return 'externalstorages';
53
-	}
45
+    /**
46
+     * returns the ID of the section. It is supposed to be a lower case string,
47
+     * e.g. 'ldap'
48
+     *
49
+     * @returns string
50
+     */
51
+    public function getID() {
52
+        return 'externalstorages';
53
+    }
54 54
 
55
-	/**
56
-	 * returns the translated name as it should be displayed, e.g. 'LDAP / AD
57
-	 * integration'. Use the L10N service to translate it.
58
-	 *
59
-	 * @return string
60
-	 */
61
-	public function getName() {
62
-		return $this->l->t('External storages');
63
-	}
55
+    /**
56
+     * returns the translated name as it should be displayed, e.g. 'LDAP / AD
57
+     * integration'. Use the L10N service to translate it.
58
+     *
59
+     * @return string
60
+     */
61
+    public function getName() {
62
+        return $this->l->t('External storages');
63
+    }
64 64
 
65
-	/**
66
-	 * @return int whether the form should be rather on the top or bottom of
67
-	 * the settings navigation. The sections are arranged in ascending order of
68
-	 * the priority values. It is required to return a value between 0 and 99.
69
-	 *
70
-	 * E.g.: 70
71
-	 */
72
-	public function getPriority() {
73
-		return 10;
74
-	}
65
+    /**
66
+     * @return int whether the form should be rather on the top or bottom of
67
+     * the settings navigation. The sections are arranged in ascending order of
68
+     * the priority values. It is required to return a value between 0 and 99.
69
+     *
70
+     * E.g.: 70
71
+     */
72
+    public function getPriority() {
73
+        return 10;
74
+    }
75 75
 
76
-	/**
77
-	 * {@inheritdoc}
78
-	 */
79
-	public function getIcon() {
80
-		return $this->url->imagePath('files_external', 'app-dark.svg');
81
-	}
76
+    /**
77
+     * {@inheritdoc}
78
+     */
79
+    public function getIcon() {
80
+        return $this->url->imagePath('files_external', 'app-dark.svg');
81
+    }
82 82
 }
Please login to merge, or discard this patch.