@@ -31,35 +31,35 @@ |
||
31 | 31 | */ |
32 | 32 | class DeleteOrphanedSharesJob extends TimedJob { |
33 | 33 | |
34 | - /** |
|
35 | - * Default interval in minutes |
|
36 | - * |
|
37 | - * @var int $defaultIntervalMin |
|
38 | - **/ |
|
39 | - protected $defaultIntervalMin = 15; |
|
34 | + /** |
|
35 | + * Default interval in minutes |
|
36 | + * |
|
37 | + * @var int $defaultIntervalMin |
|
38 | + **/ |
|
39 | + protected $defaultIntervalMin = 15; |
|
40 | 40 | |
41 | - /** |
|
42 | - * sets the correct interval for this timed job |
|
43 | - */ |
|
44 | - public function __construct() { |
|
45 | - $this->interval = $this->defaultIntervalMin * 60; |
|
46 | - } |
|
41 | + /** |
|
42 | + * sets the correct interval for this timed job |
|
43 | + */ |
|
44 | + public function __construct() { |
|
45 | + $this->interval = $this->defaultIntervalMin * 60; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Makes the background job do its work |
|
50 | - * |
|
51 | - * @param array $argument unused argument |
|
52 | - */ |
|
53 | - public function run($argument) { |
|
54 | - $connection = \OC::$server->getDatabaseConnection(); |
|
55 | - $logger = \OC::$server->getLogger(); |
|
48 | + /** |
|
49 | + * Makes the background job do its work |
|
50 | + * |
|
51 | + * @param array $argument unused argument |
|
52 | + */ |
|
53 | + public function run($argument) { |
|
54 | + $connection = \OC::$server->getDatabaseConnection(); |
|
55 | + $logger = \OC::$server->getLogger(); |
|
56 | 56 | |
57 | - $sql = |
|
58 | - 'DELETE FROM `*PREFIX*share` ' . |
|
59 | - 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
60 | - 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
|
57 | + $sql = |
|
58 | + 'DELETE FROM `*PREFIX*share` ' . |
|
59 | + 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
60 | + 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
|
61 | 61 | |
62 | - $deletedEntries = $connection->executeUpdate($sql); |
|
63 | - $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']); |
|
64 | - } |
|
62 | + $deletedEntries = $connection->executeUpdate($sql); |
|
63 | + $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']); |
|
64 | + } |
|
65 | 65 | } |
@@ -55,8 +55,8 @@ |
||
55 | 55 | $logger = \OC::$server->getLogger(); |
56 | 56 | |
57 | 57 | $sql = |
58 | - 'DELETE FROM `*PREFIX*share` ' . |
|
59 | - 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
58 | + 'DELETE FROM `*PREFIX*share` '. |
|
59 | + 'WHERE `item_type` in (\'file\', \'folder\') '. |
|
60 | 60 | 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
61 | 61 | |
62 | 62 | $deletedEntries = $connection->executeUpdate($sql); |
@@ -36,60 +36,60 @@ |
||
36 | 36 | */ |
37 | 37 | class SetPasswordColumn implements IRepairStep { |
38 | 38 | |
39 | - /** @var IDBConnection */ |
|
40 | - private $connection; |
|
39 | + /** @var IDBConnection */ |
|
40 | + private $connection; |
|
41 | 41 | |
42 | - /** @var IConfig */ |
|
43 | - private $config; |
|
42 | + /** @var IConfig */ |
|
43 | + private $config; |
|
44 | 44 | |
45 | 45 | |
46 | - public function __construct(IDBConnection $connection, IConfig $config) { |
|
47 | - $this->connection = $connection; |
|
48 | - $this->config = $config; |
|
49 | - } |
|
46 | + public function __construct(IDBConnection $connection, IConfig $config) { |
|
47 | + $this->connection = $connection; |
|
48 | + $this->config = $config; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Returns the step's name |
|
53 | - * |
|
54 | - * @return string |
|
55 | - * @since 9.1.0 |
|
56 | - */ |
|
57 | - public function getName() { |
|
58 | - return 'Copy the share password into the dedicated column'; |
|
59 | - } |
|
51 | + /** |
|
52 | + * Returns the step's name |
|
53 | + * |
|
54 | + * @return string |
|
55 | + * @since 9.1.0 |
|
56 | + */ |
|
57 | + public function getName() { |
|
58 | + return 'Copy the share password into the dedicated column'; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param IOutput $output |
|
63 | - */ |
|
64 | - public function run(IOutput $output) { |
|
65 | - if (!$this->shouldRun()) { |
|
66 | - return; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @param IOutput $output |
|
63 | + */ |
|
64 | + public function run(IOutput $output) { |
|
65 | + if (!$this->shouldRun()) { |
|
66 | + return; |
|
67 | + } |
|
68 | 68 | |
69 | - $query = $this->connection->getQueryBuilder(); |
|
70 | - $query |
|
71 | - ->update('share') |
|
72 | - ->set('password', 'share_with') |
|
73 | - ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK))) |
|
74 | - ->andWhere($query->expr()->isNotNull('share_with')); |
|
75 | - $result = $query->execute(); |
|
69 | + $query = $this->connection->getQueryBuilder(); |
|
70 | + $query |
|
71 | + ->update('share') |
|
72 | + ->set('password', 'share_with') |
|
73 | + ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK))) |
|
74 | + ->andWhere($query->expr()->isNotNull('share_with')); |
|
75 | + $result = $query->execute(); |
|
76 | 76 | |
77 | - if ($result === 0) { |
|
78 | - // No link updated, no need to run the second query |
|
79 | - return; |
|
80 | - } |
|
77 | + if ($result === 0) { |
|
78 | + // No link updated, no need to run the second query |
|
79 | + return; |
|
80 | + } |
|
81 | 81 | |
82 | - $clearQuery = $this->connection->getQueryBuilder(); |
|
83 | - $clearQuery |
|
84 | - ->update('share') |
|
85 | - ->set('share_with', $clearQuery->createNamedParameter(null)) |
|
86 | - ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK))); |
|
82 | + $clearQuery = $this->connection->getQueryBuilder(); |
|
83 | + $clearQuery |
|
84 | + ->update('share') |
|
85 | + ->set('share_with', $clearQuery->createNamedParameter(null)) |
|
86 | + ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK))); |
|
87 | 87 | |
88 | - $clearQuery->execute(); |
|
89 | - } |
|
88 | + $clearQuery->execute(); |
|
89 | + } |
|
90 | 90 | |
91 | - protected function shouldRun() { |
|
92 | - $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
93 | - return version_compare($appVersion, '1.4.0', '<'); |
|
94 | - } |
|
91 | + protected function shouldRun() { |
|
92 | + $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
93 | + return version_compare($appVersion, '1.4.0', '<'); |
|
94 | + } |
|
95 | 95 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected function getPath($user, $path) { |
102 | 102 | $node = $this->rootFolder->getUserFolder($user)->get($path); |
103 | - return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/')); |
|
103 | + return 'files/'.md5($node->getStorage()->getId().'::'.trim($node->getInternalPath(), '/')); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | try { |
138 | 138 | $lockingProvider->acquireLock($path, $type); |
139 | - $this->config->setAppValue('testing', 'locking_' . $path, $type); |
|
139 | + $this->config->setAppValue('testing', 'locking_'.$path, $type); |
|
140 | 140 | return new DataResponse(); |
141 | 141 | } catch (LockedException $e) { |
142 | 142 | throw new OCSException('', Http::STATUS_LOCKED, $e); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | try { |
165 | 165 | $lockingProvider->changeLock($path, $type); |
166 | - $this->config->setAppValue('testing', 'locking_' . $path, $type); |
|
166 | + $this->config->setAppValue('testing', 'locking_'.$path, $type); |
|
167 | 167 | return new DataResponse(); |
168 | 168 | } catch (LockedException $e) { |
169 | 169 | throw new OCSException('', Http::STATUS_LOCKED, $e); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | try { |
192 | 192 | $lockingProvider->releaseLock($path, $type); |
193 | - $this->config->deleteAppValue('testing', 'locking_' . $path); |
|
193 | + $this->config->deleteAppValue('testing', 'locking_'.$path); |
|
194 | 194 | return new DataResponse(); |
195 | 195 | } catch (LockedException $e) { |
196 | 196 | throw new OCSException('', Http::STATUS_LOCKED, $e); |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | if (strpos($lock, 'locking_') === 0) { |
234 | 234 | $path = substr($lock, strlen('locking_')); |
235 | 235 | |
236 | - if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) { |
|
236 | + if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int) $this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) { |
|
237 | 237 | $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
238 | - } elseif ($type === ILockingProvider::LOCK_SHARED && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) { |
|
238 | + } elseif ($type === ILockingProvider::LOCK_SHARED && (int) $this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) { |
|
239 | 239 | $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
240 | 240 | } else { |
241 | 241 | $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
@@ -39,208 +39,208 @@ |
||
39 | 39 | |
40 | 40 | class LockingController extends OCSController { |
41 | 41 | |
42 | - /** @var ILockingProvider */ |
|
43 | - protected $lockingProvider; |
|
44 | - |
|
45 | - /** @var FakeDBLockingProvider */ |
|
46 | - protected $fakeDBLockingProvider; |
|
47 | - |
|
48 | - /** @var IDBConnection */ |
|
49 | - protected $connection; |
|
50 | - |
|
51 | - /** @var IConfig */ |
|
52 | - protected $config; |
|
53 | - |
|
54 | - /** @var IRootFolder */ |
|
55 | - protected $rootFolder; |
|
56 | - |
|
57 | - /** |
|
58 | - * @param string $appName |
|
59 | - * @param IRequest $request |
|
60 | - * @param ILockingProvider $lockingProvider |
|
61 | - * @param FakeDBLockingProvider $fakeDBLockingProvider |
|
62 | - * @param IDBConnection $connection |
|
63 | - * @param IConfig $config |
|
64 | - * @param IRootFolder $rootFolder |
|
65 | - */ |
|
66 | - public function __construct($appName, |
|
67 | - IRequest $request, |
|
68 | - ILockingProvider $lockingProvider, |
|
69 | - FakeDBLockingProvider $fakeDBLockingProvider, |
|
70 | - IDBConnection $connection, |
|
71 | - IConfig $config, |
|
72 | - IRootFolder $rootFolder) { |
|
73 | - parent::__construct($appName, $request); |
|
74 | - |
|
75 | - $this->lockingProvider = $lockingProvider; |
|
76 | - $this->fakeDBLockingProvider = $fakeDBLockingProvider; |
|
77 | - $this->connection = $connection; |
|
78 | - $this->config = $config; |
|
79 | - $this->rootFolder = $rootFolder; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @return ILockingProvider |
|
84 | - * @throws \RuntimeException |
|
85 | - */ |
|
86 | - protected function getLockingProvider() { |
|
87 | - if ($this->lockingProvider instanceof DBLockingProvider) { |
|
88 | - return $this->fakeDBLockingProvider; |
|
89 | - } |
|
90 | - throw new \RuntimeException('Lock provisioning is only possible using the DBLockingProvider'); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param string $user |
|
95 | - * @param string $path |
|
96 | - * @return string |
|
97 | - * @throws NotFoundException |
|
98 | - */ |
|
99 | - protected function getPath($user, $path) { |
|
100 | - $node = $this->rootFolder->getUserFolder($user)->get($path); |
|
101 | - return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/')); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * @return DataResponse |
|
106 | - * @throws OCSException |
|
107 | - */ |
|
108 | - public function isLockingEnabled() { |
|
109 | - try { |
|
110 | - $this->getLockingProvider(); |
|
111 | - return new DataResponse(); |
|
112 | - } catch (\RuntimeException $e) { |
|
113 | - throw new OCSException($e->getMessage(), Http::STATUS_NOT_IMPLEMENTED, $e); |
|
114 | - } |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @param int $type |
|
119 | - * @param string $user |
|
120 | - * @param string $path |
|
121 | - * @return DataResponse |
|
122 | - * @throws OCSException |
|
123 | - */ |
|
124 | - public function acquireLock($type, $user, $path) { |
|
125 | - try { |
|
126 | - $path = $this->getPath($user, $path); |
|
127 | - } catch (NoUserException $e) { |
|
128 | - throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e); |
|
129 | - } catch (NotFoundException $e) { |
|
130 | - throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e); |
|
131 | - } |
|
132 | - |
|
133 | - $lockingProvider = $this->getLockingProvider(); |
|
134 | - |
|
135 | - try { |
|
136 | - $lockingProvider->acquireLock($path, $type); |
|
137 | - $this->config->setAppValue('testing', 'locking_' . $path, $type); |
|
138 | - return new DataResponse(); |
|
139 | - } catch (LockedException $e) { |
|
140 | - throw new OCSException('', Http::STATUS_LOCKED, $e); |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * @param int $type |
|
146 | - * @param string $user |
|
147 | - * @param string $path |
|
148 | - * @return DataResponse |
|
149 | - * @throws OCSException |
|
150 | - */ |
|
151 | - public function changeLock($type, $user, $path) { |
|
152 | - try { |
|
153 | - $path = $this->getPath($user, $path); |
|
154 | - } catch (NoUserException $e) { |
|
155 | - throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e); |
|
156 | - } catch (NotFoundException $e) { |
|
157 | - throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e); |
|
158 | - } |
|
159 | - |
|
160 | - $lockingProvider = $this->getLockingProvider(); |
|
161 | - |
|
162 | - try { |
|
163 | - $lockingProvider->changeLock($path, $type); |
|
164 | - $this->config->setAppValue('testing', 'locking_' . $path, $type); |
|
165 | - return new DataResponse(); |
|
166 | - } catch (LockedException $e) { |
|
167 | - throw new OCSException('', Http::STATUS_LOCKED, $e); |
|
168 | - } |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * @param int $type |
|
173 | - * @param string $user |
|
174 | - * @param string $path |
|
175 | - * @return DataResponse |
|
176 | - * @throws OCSException |
|
177 | - */ |
|
178 | - public function releaseLock($type, $user, $path) { |
|
179 | - try { |
|
180 | - $path = $this->getPath($user, $path); |
|
181 | - } catch (NoUserException $e) { |
|
182 | - throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e); |
|
183 | - } catch (NotFoundException $e) { |
|
184 | - throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e); |
|
185 | - } |
|
186 | - |
|
187 | - $lockingProvider = $this->getLockingProvider(); |
|
188 | - |
|
189 | - try { |
|
190 | - $lockingProvider->releaseLock($path, $type); |
|
191 | - $this->config->deleteAppValue('testing', 'locking_' . $path); |
|
192 | - return new DataResponse(); |
|
193 | - } catch (LockedException $e) { |
|
194 | - throw new OCSException('', Http::STATUS_LOCKED, $e); |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * @param int $type |
|
200 | - * @param string $user |
|
201 | - * @param string $path |
|
202 | - * @return DataResponse |
|
203 | - * @throws OCSException |
|
204 | - */ |
|
205 | - public function isLocked($type, $user, $path) { |
|
206 | - try { |
|
207 | - $path = $this->getPath($user, $path); |
|
208 | - } catch (NoUserException $e) { |
|
209 | - throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e); |
|
210 | - } catch (NotFoundException $e) { |
|
211 | - throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e); |
|
212 | - } |
|
213 | - |
|
214 | - $lockingProvider = $this->getLockingProvider(); |
|
215 | - |
|
216 | - if ($lockingProvider->isLocked($path, $type)) { |
|
217 | - return new DataResponse(); |
|
218 | - } |
|
219 | - |
|
220 | - throw new OCSException('', Http::STATUS_LOCKED); |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * @param int $type |
|
225 | - * @return DataResponse |
|
226 | - */ |
|
227 | - public function releaseAll($type = null) { |
|
228 | - $lockingProvider = $this->getLockingProvider(); |
|
229 | - |
|
230 | - foreach ($this->config->getAppKeys('testing') as $lock) { |
|
231 | - if (strpos($lock, 'locking_') === 0) { |
|
232 | - $path = substr($lock, strlen('locking_')); |
|
233 | - |
|
234 | - if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) { |
|
235 | - $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
|
236 | - } elseif ($type === ILockingProvider::LOCK_SHARED && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) { |
|
237 | - $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
|
238 | - } else { |
|
239 | - $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - return new DataResponse(); |
|
245 | - } |
|
42 | + /** @var ILockingProvider */ |
|
43 | + protected $lockingProvider; |
|
44 | + |
|
45 | + /** @var FakeDBLockingProvider */ |
|
46 | + protected $fakeDBLockingProvider; |
|
47 | + |
|
48 | + /** @var IDBConnection */ |
|
49 | + protected $connection; |
|
50 | + |
|
51 | + /** @var IConfig */ |
|
52 | + protected $config; |
|
53 | + |
|
54 | + /** @var IRootFolder */ |
|
55 | + protected $rootFolder; |
|
56 | + |
|
57 | + /** |
|
58 | + * @param string $appName |
|
59 | + * @param IRequest $request |
|
60 | + * @param ILockingProvider $lockingProvider |
|
61 | + * @param FakeDBLockingProvider $fakeDBLockingProvider |
|
62 | + * @param IDBConnection $connection |
|
63 | + * @param IConfig $config |
|
64 | + * @param IRootFolder $rootFolder |
|
65 | + */ |
|
66 | + public function __construct($appName, |
|
67 | + IRequest $request, |
|
68 | + ILockingProvider $lockingProvider, |
|
69 | + FakeDBLockingProvider $fakeDBLockingProvider, |
|
70 | + IDBConnection $connection, |
|
71 | + IConfig $config, |
|
72 | + IRootFolder $rootFolder) { |
|
73 | + parent::__construct($appName, $request); |
|
74 | + |
|
75 | + $this->lockingProvider = $lockingProvider; |
|
76 | + $this->fakeDBLockingProvider = $fakeDBLockingProvider; |
|
77 | + $this->connection = $connection; |
|
78 | + $this->config = $config; |
|
79 | + $this->rootFolder = $rootFolder; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @return ILockingProvider |
|
84 | + * @throws \RuntimeException |
|
85 | + */ |
|
86 | + protected function getLockingProvider() { |
|
87 | + if ($this->lockingProvider instanceof DBLockingProvider) { |
|
88 | + return $this->fakeDBLockingProvider; |
|
89 | + } |
|
90 | + throw new \RuntimeException('Lock provisioning is only possible using the DBLockingProvider'); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param string $user |
|
95 | + * @param string $path |
|
96 | + * @return string |
|
97 | + * @throws NotFoundException |
|
98 | + */ |
|
99 | + protected function getPath($user, $path) { |
|
100 | + $node = $this->rootFolder->getUserFolder($user)->get($path); |
|
101 | + return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/')); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * @return DataResponse |
|
106 | + * @throws OCSException |
|
107 | + */ |
|
108 | + public function isLockingEnabled() { |
|
109 | + try { |
|
110 | + $this->getLockingProvider(); |
|
111 | + return new DataResponse(); |
|
112 | + } catch (\RuntimeException $e) { |
|
113 | + throw new OCSException($e->getMessage(), Http::STATUS_NOT_IMPLEMENTED, $e); |
|
114 | + } |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @param int $type |
|
119 | + * @param string $user |
|
120 | + * @param string $path |
|
121 | + * @return DataResponse |
|
122 | + * @throws OCSException |
|
123 | + */ |
|
124 | + public function acquireLock($type, $user, $path) { |
|
125 | + try { |
|
126 | + $path = $this->getPath($user, $path); |
|
127 | + } catch (NoUserException $e) { |
|
128 | + throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e); |
|
129 | + } catch (NotFoundException $e) { |
|
130 | + throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e); |
|
131 | + } |
|
132 | + |
|
133 | + $lockingProvider = $this->getLockingProvider(); |
|
134 | + |
|
135 | + try { |
|
136 | + $lockingProvider->acquireLock($path, $type); |
|
137 | + $this->config->setAppValue('testing', 'locking_' . $path, $type); |
|
138 | + return new DataResponse(); |
|
139 | + } catch (LockedException $e) { |
|
140 | + throw new OCSException('', Http::STATUS_LOCKED, $e); |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * @param int $type |
|
146 | + * @param string $user |
|
147 | + * @param string $path |
|
148 | + * @return DataResponse |
|
149 | + * @throws OCSException |
|
150 | + */ |
|
151 | + public function changeLock($type, $user, $path) { |
|
152 | + try { |
|
153 | + $path = $this->getPath($user, $path); |
|
154 | + } catch (NoUserException $e) { |
|
155 | + throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e); |
|
156 | + } catch (NotFoundException $e) { |
|
157 | + throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e); |
|
158 | + } |
|
159 | + |
|
160 | + $lockingProvider = $this->getLockingProvider(); |
|
161 | + |
|
162 | + try { |
|
163 | + $lockingProvider->changeLock($path, $type); |
|
164 | + $this->config->setAppValue('testing', 'locking_' . $path, $type); |
|
165 | + return new DataResponse(); |
|
166 | + } catch (LockedException $e) { |
|
167 | + throw new OCSException('', Http::STATUS_LOCKED, $e); |
|
168 | + } |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * @param int $type |
|
173 | + * @param string $user |
|
174 | + * @param string $path |
|
175 | + * @return DataResponse |
|
176 | + * @throws OCSException |
|
177 | + */ |
|
178 | + public function releaseLock($type, $user, $path) { |
|
179 | + try { |
|
180 | + $path = $this->getPath($user, $path); |
|
181 | + } catch (NoUserException $e) { |
|
182 | + throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e); |
|
183 | + } catch (NotFoundException $e) { |
|
184 | + throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e); |
|
185 | + } |
|
186 | + |
|
187 | + $lockingProvider = $this->getLockingProvider(); |
|
188 | + |
|
189 | + try { |
|
190 | + $lockingProvider->releaseLock($path, $type); |
|
191 | + $this->config->deleteAppValue('testing', 'locking_' . $path); |
|
192 | + return new DataResponse(); |
|
193 | + } catch (LockedException $e) { |
|
194 | + throw new OCSException('', Http::STATUS_LOCKED, $e); |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * @param int $type |
|
200 | + * @param string $user |
|
201 | + * @param string $path |
|
202 | + * @return DataResponse |
|
203 | + * @throws OCSException |
|
204 | + */ |
|
205 | + public function isLocked($type, $user, $path) { |
|
206 | + try { |
|
207 | + $path = $this->getPath($user, $path); |
|
208 | + } catch (NoUserException $e) { |
|
209 | + throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e); |
|
210 | + } catch (NotFoundException $e) { |
|
211 | + throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e); |
|
212 | + } |
|
213 | + |
|
214 | + $lockingProvider = $this->getLockingProvider(); |
|
215 | + |
|
216 | + if ($lockingProvider->isLocked($path, $type)) { |
|
217 | + return new DataResponse(); |
|
218 | + } |
|
219 | + |
|
220 | + throw new OCSException('', Http::STATUS_LOCKED); |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * @param int $type |
|
225 | + * @return DataResponse |
|
226 | + */ |
|
227 | + public function releaseAll($type = null) { |
|
228 | + $lockingProvider = $this->getLockingProvider(); |
|
229 | + |
|
230 | + foreach ($this->config->getAppKeys('testing') as $lock) { |
|
231 | + if (strpos($lock, 'locking_') === 0) { |
|
232 | + $path = substr($lock, strlen('locking_')); |
|
233 | + |
|
234 | + if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) { |
|
235 | + $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
|
236 | + } elseif ($type === ILockingProvider::LOCK_SHARED && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) { |
|
237 | + $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
|
238 | + } else { |
|
239 | + $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + return new DataResponse(); |
|
245 | + } |
|
246 | 246 | } |
@@ -29,30 +29,30 @@ |
||
29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
30 | 30 | |
31 | 31 | class Export extends ListCommand { |
32 | - protected function configure() { |
|
33 | - $this |
|
34 | - ->setName('files_external:export') |
|
35 | - ->setDescription('Export mount configurations') |
|
36 | - ->addArgument( |
|
37 | - 'user_id', |
|
38 | - InputArgument::OPTIONAL, |
|
39 | - 'user id to export the personal mounts for, if no user is provided admin mounts will be exported' |
|
40 | - )->addOption( |
|
41 | - 'all', |
|
42 | - 'a', |
|
43 | - InputOption::VALUE_NONE, |
|
44 | - 'show both system wide mounts and all personal mounts' |
|
45 | - ); |
|
46 | - } |
|
32 | + protected function configure() { |
|
33 | + $this |
|
34 | + ->setName('files_external:export') |
|
35 | + ->setDescription('Export mount configurations') |
|
36 | + ->addArgument( |
|
37 | + 'user_id', |
|
38 | + InputArgument::OPTIONAL, |
|
39 | + 'user id to export the personal mounts for, if no user is provided admin mounts will be exported' |
|
40 | + )->addOption( |
|
41 | + 'all', |
|
42 | + 'a', |
|
43 | + InputOption::VALUE_NONE, |
|
44 | + 'show both system wide mounts and all personal mounts' |
|
45 | + ); |
|
46 | + } |
|
47 | 47 | |
48 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
49 | - $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
50 | - $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
51 | - $listInput->setArgument('user_id', $input->getArgument('user_id')); |
|
52 | - $listInput->setOption('all', $input->getOption('all')); |
|
53 | - $listInput->setOption('output', 'json_pretty'); |
|
54 | - $listInput->setOption('show-password', true); |
|
55 | - $listInput->setOption('full', true); |
|
56 | - $listCommand->execute($listInput, $output); |
|
57 | - } |
|
48 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
49 | + $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
50 | + $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
51 | + $listInput->setArgument('user_id', $input->getArgument('user_id')); |
|
52 | + $listInput->setOption('all', $input->getOption('all')); |
|
53 | + $listInput->setOption('output', 'json_pretty'); |
|
54 | + $listInput->setOption('show-password', true); |
|
55 | + $listInput->setOption('full', true); |
|
56 | + $listCommand->execute($listInput, $output); |
|
57 | + } |
|
58 | 58 | } |
@@ -37,108 +37,108 @@ |
||
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 | - public function __construct(GlobalStoragesService $globalService) { |
|
46 | - parent::__construct(); |
|
47 | - $this->globalService = $globalService; |
|
48 | - } |
|
45 | + public 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 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | try { |
72 | 72 | $mount = $this->globalService->getStorage($mountId); |
73 | 73 | } catch (NotFoundException $e) { |
74 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
74 | + $output->writeln('<error>Mount with id "'.$mountId.' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
75 | 75 | return 404; |
76 | 76 | } |
77 | 77 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | foreach ($configInput as $configOption) { |
107 | 107 | if (!strpos($configOption, '=')) { |
108 | - $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>'); |
|
108 | + $output->writeln('<error>Invalid mount configuration option "'.$configOption.'"</error>'); |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 | list($key, $value) = explode('=', $configOption, 2); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | // FIXME: convert storage exceptions to StorageNotAvailableException |
138 | 138 | $storage->setStatus( |
139 | 139 | StorageNotAvailableException::STATUS_ERROR, |
140 | - get_class($e) . ': ' . $e->getMessage() |
|
140 | + get_class($e).': '.$e->getMessage() |
|
141 | 141 | ); |
142 | 142 | } |
143 | 143 | } |
@@ -197,7 +197,7 @@ |
||
197 | 197 | } catch (NotFoundException $e) { |
198 | 198 | return new DataResponse( |
199 | 199 | [ |
200 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
200 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
201 | 201 | ], |
202 | 202 | Http::STATUS_NOT_FOUND |
203 | 203 | ); |
@@ -44,183 +44,183 @@ |
||
44 | 44 | * User storages controller |
45 | 45 | */ |
46 | 46 | class UserStoragesController extends StoragesController { |
47 | - /** |
|
48 | - * @var IUserSession |
|
49 | - */ |
|
50 | - private $userSession; |
|
51 | - |
|
52 | - /** |
|
53 | - * Creates a new user storages controller. |
|
54 | - * |
|
55 | - * @param string $AppName application name |
|
56 | - * @param IRequest $request request object |
|
57 | - * @param IL10N $l10n l10n service |
|
58 | - * @param UserStoragesService $userStoragesService storage service |
|
59 | - * @param IUserSession $userSession |
|
60 | - * @param ILogger $logger |
|
61 | - */ |
|
62 | - public function __construct( |
|
63 | - $AppName, |
|
64 | - IRequest $request, |
|
65 | - IL10N $l10n, |
|
66 | - UserStoragesService $userStoragesService, |
|
67 | - IUserSession $userSession, |
|
68 | - ILogger $logger |
|
69 | - ) { |
|
70 | - parent::__construct( |
|
71 | - $AppName, |
|
72 | - $request, |
|
73 | - $l10n, |
|
74 | - $userStoragesService, |
|
75 | - $logger |
|
76 | - ); |
|
77 | - $this->userSession = $userSession; |
|
78 | - } |
|
79 | - |
|
80 | - protected function manipulateStorageConfig(StorageConfig $storage) { |
|
81 | - /** @var AuthMechanism */ |
|
82 | - $authMechanism = $storage->getAuthMechanism(); |
|
83 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
84 | - /** @var Backend */ |
|
85 | - $backend = $storage->getBackend(); |
|
86 | - $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Get all storage entries |
|
91 | - * |
|
92 | - * @NoAdminRequired |
|
93 | - * |
|
94 | - * @return DataResponse |
|
95 | - */ |
|
96 | - public function index() { |
|
97 | - return parent::index(); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Return storage |
|
102 | - * |
|
103 | - * @NoAdminRequired |
|
104 | - * |
|
105 | - * {@inheritdoc} |
|
106 | - */ |
|
107 | - public function show($id, $testOnly = true) { |
|
108 | - return parent::show($id, $testOnly); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Create an external storage entry. |
|
113 | - * |
|
114 | - * @param string $mountPoint storage mount point |
|
115 | - * @param string $backend backend identifier |
|
116 | - * @param string $authMechanism authentication mechanism identifier |
|
117 | - * @param array $backendOptions backend-specific options |
|
118 | - * @param array $mountOptions backend-specific mount options |
|
119 | - * |
|
120 | - * @return DataResponse |
|
121 | - * |
|
122 | - * @NoAdminRequired |
|
123 | - */ |
|
124 | - public function create( |
|
125 | - $mountPoint, |
|
126 | - $backend, |
|
127 | - $authMechanism, |
|
128 | - $backendOptions, |
|
129 | - $mountOptions |
|
130 | - ) { |
|
131 | - $newStorage = $this->createStorage( |
|
132 | - $mountPoint, |
|
133 | - $backend, |
|
134 | - $authMechanism, |
|
135 | - $backendOptions, |
|
136 | - $mountOptions |
|
137 | - ); |
|
138 | - if ($newStorage instanceof DataResponse) { |
|
139 | - return $newStorage; |
|
140 | - } |
|
141 | - |
|
142 | - $response = $this->validate($newStorage); |
|
143 | - if (!empty($response)) { |
|
144 | - return $response; |
|
145 | - } |
|
146 | - |
|
147 | - $newStorage = $this->service->addStorage($newStorage); |
|
148 | - $this->updateStorageStatus($newStorage); |
|
149 | - |
|
150 | - return new DataResponse( |
|
151 | - $this->formatStorageForUI($newStorage), |
|
152 | - Http::STATUS_CREATED |
|
153 | - ); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Update an external storage entry. |
|
158 | - * |
|
159 | - * @param int $id storage id |
|
160 | - * @param string $mountPoint storage mount point |
|
161 | - * @param string $backend backend identifier |
|
162 | - * @param string $authMechanism authentication mechanism identifier |
|
163 | - * @param array $backendOptions backend-specific options |
|
164 | - * @param array $mountOptions backend-specific mount options |
|
165 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
166 | - * |
|
167 | - * @return DataResponse |
|
168 | - * |
|
169 | - * @NoAdminRequired |
|
170 | - */ |
|
171 | - public function update( |
|
172 | - $id, |
|
173 | - $mountPoint, |
|
174 | - $backend, |
|
175 | - $authMechanism, |
|
176 | - $backendOptions, |
|
177 | - $mountOptions, |
|
178 | - $testOnly = true |
|
179 | - ) { |
|
180 | - $storage = $this->createStorage( |
|
181 | - $mountPoint, |
|
182 | - $backend, |
|
183 | - $authMechanism, |
|
184 | - $backendOptions, |
|
185 | - $mountOptions |
|
186 | - ); |
|
187 | - if ($storage instanceof DataResponse) { |
|
188 | - return $storage; |
|
189 | - } |
|
190 | - $storage->setId($id); |
|
191 | - |
|
192 | - $response = $this->validate($storage); |
|
193 | - if (!empty($response)) { |
|
194 | - return $response; |
|
195 | - } |
|
196 | - |
|
197 | - try { |
|
198 | - $storage = $this->service->updateStorage($storage); |
|
199 | - } catch (NotFoundException $e) { |
|
200 | - return new DataResponse( |
|
201 | - [ |
|
202 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
203 | - ], |
|
204 | - Http::STATUS_NOT_FOUND |
|
205 | - ); |
|
206 | - } |
|
207 | - |
|
208 | - $this->updateStorageStatus($storage, $testOnly); |
|
209 | - |
|
210 | - return new DataResponse( |
|
211 | - $this->formatStorageForUI($storage), |
|
212 | - Http::STATUS_OK |
|
213 | - ); |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * Delete storage |
|
218 | - * |
|
219 | - * @NoAdminRequired |
|
220 | - * |
|
221 | - * {@inheritdoc} |
|
222 | - */ |
|
223 | - public function destroy($id) { |
|
224 | - return parent::destroy($id); |
|
225 | - } |
|
47 | + /** |
|
48 | + * @var IUserSession |
|
49 | + */ |
|
50 | + private $userSession; |
|
51 | + |
|
52 | + /** |
|
53 | + * Creates a new user storages controller. |
|
54 | + * |
|
55 | + * @param string $AppName application name |
|
56 | + * @param IRequest $request request object |
|
57 | + * @param IL10N $l10n l10n service |
|
58 | + * @param UserStoragesService $userStoragesService storage service |
|
59 | + * @param IUserSession $userSession |
|
60 | + * @param ILogger $logger |
|
61 | + */ |
|
62 | + public function __construct( |
|
63 | + $AppName, |
|
64 | + IRequest $request, |
|
65 | + IL10N $l10n, |
|
66 | + UserStoragesService $userStoragesService, |
|
67 | + IUserSession $userSession, |
|
68 | + ILogger $logger |
|
69 | + ) { |
|
70 | + parent::__construct( |
|
71 | + $AppName, |
|
72 | + $request, |
|
73 | + $l10n, |
|
74 | + $userStoragesService, |
|
75 | + $logger |
|
76 | + ); |
|
77 | + $this->userSession = $userSession; |
|
78 | + } |
|
79 | + |
|
80 | + protected function manipulateStorageConfig(StorageConfig $storage) { |
|
81 | + /** @var AuthMechanism */ |
|
82 | + $authMechanism = $storage->getAuthMechanism(); |
|
83 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
84 | + /** @var Backend */ |
|
85 | + $backend = $storage->getBackend(); |
|
86 | + $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Get all storage entries |
|
91 | + * |
|
92 | + * @NoAdminRequired |
|
93 | + * |
|
94 | + * @return DataResponse |
|
95 | + */ |
|
96 | + public function index() { |
|
97 | + return parent::index(); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Return storage |
|
102 | + * |
|
103 | + * @NoAdminRequired |
|
104 | + * |
|
105 | + * {@inheritdoc} |
|
106 | + */ |
|
107 | + public function show($id, $testOnly = true) { |
|
108 | + return parent::show($id, $testOnly); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Create an external storage entry. |
|
113 | + * |
|
114 | + * @param string $mountPoint storage mount point |
|
115 | + * @param string $backend backend identifier |
|
116 | + * @param string $authMechanism authentication mechanism identifier |
|
117 | + * @param array $backendOptions backend-specific options |
|
118 | + * @param array $mountOptions backend-specific mount options |
|
119 | + * |
|
120 | + * @return DataResponse |
|
121 | + * |
|
122 | + * @NoAdminRequired |
|
123 | + */ |
|
124 | + public function create( |
|
125 | + $mountPoint, |
|
126 | + $backend, |
|
127 | + $authMechanism, |
|
128 | + $backendOptions, |
|
129 | + $mountOptions |
|
130 | + ) { |
|
131 | + $newStorage = $this->createStorage( |
|
132 | + $mountPoint, |
|
133 | + $backend, |
|
134 | + $authMechanism, |
|
135 | + $backendOptions, |
|
136 | + $mountOptions |
|
137 | + ); |
|
138 | + if ($newStorage instanceof DataResponse) { |
|
139 | + return $newStorage; |
|
140 | + } |
|
141 | + |
|
142 | + $response = $this->validate($newStorage); |
|
143 | + if (!empty($response)) { |
|
144 | + return $response; |
|
145 | + } |
|
146 | + |
|
147 | + $newStorage = $this->service->addStorage($newStorage); |
|
148 | + $this->updateStorageStatus($newStorage); |
|
149 | + |
|
150 | + return new DataResponse( |
|
151 | + $this->formatStorageForUI($newStorage), |
|
152 | + Http::STATUS_CREATED |
|
153 | + ); |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Update an external storage entry. |
|
158 | + * |
|
159 | + * @param int $id storage id |
|
160 | + * @param string $mountPoint storage mount point |
|
161 | + * @param string $backend backend identifier |
|
162 | + * @param string $authMechanism authentication mechanism identifier |
|
163 | + * @param array $backendOptions backend-specific options |
|
164 | + * @param array $mountOptions backend-specific mount options |
|
165 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
166 | + * |
|
167 | + * @return DataResponse |
|
168 | + * |
|
169 | + * @NoAdminRequired |
|
170 | + */ |
|
171 | + public function update( |
|
172 | + $id, |
|
173 | + $mountPoint, |
|
174 | + $backend, |
|
175 | + $authMechanism, |
|
176 | + $backendOptions, |
|
177 | + $mountOptions, |
|
178 | + $testOnly = true |
|
179 | + ) { |
|
180 | + $storage = $this->createStorage( |
|
181 | + $mountPoint, |
|
182 | + $backend, |
|
183 | + $authMechanism, |
|
184 | + $backendOptions, |
|
185 | + $mountOptions |
|
186 | + ); |
|
187 | + if ($storage instanceof DataResponse) { |
|
188 | + return $storage; |
|
189 | + } |
|
190 | + $storage->setId($id); |
|
191 | + |
|
192 | + $response = $this->validate($storage); |
|
193 | + if (!empty($response)) { |
|
194 | + return $response; |
|
195 | + } |
|
196 | + |
|
197 | + try { |
|
198 | + $storage = $this->service->updateStorage($storage); |
|
199 | + } catch (NotFoundException $e) { |
|
200 | + return new DataResponse( |
|
201 | + [ |
|
202 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
203 | + ], |
|
204 | + Http::STATUS_NOT_FOUND |
|
205 | + ); |
|
206 | + } |
|
207 | + |
|
208 | + $this->updateStorageStatus($storage, $testOnly); |
|
209 | + |
|
210 | + return new DataResponse( |
|
211 | + $this->formatStorageForUI($storage), |
|
212 | + Http::STATUS_OK |
|
213 | + ); |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Delete storage |
|
218 | + * |
|
219 | + * @NoAdminRequired |
|
220 | + * |
|
221 | + * {@inheritdoc} |
|
222 | + */ |
|
223 | + public function destroy($id) { |
|
224 | + return parent::destroy($id); |
|
225 | + } |
|
226 | 226 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } catch (NotFoundException $e) { |
123 | 123 | return new DataResponse( |
124 | 124 | [ |
125 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
125 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
126 | 126 | ], |
127 | 127 | Http::STATUS_NOT_FOUND |
128 | 128 | ); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | } else { |
163 | 163 | return new DataResponse( |
164 | 164 | [ |
165 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id]) |
|
165 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" is not user editable', [$id]) |
|
166 | 166 | ], |
167 | 167 | Http::STATUS_FORBIDDEN |
168 | 168 | ); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } catch (NotFoundException $e) { |
171 | 171 | return new DataResponse( |
172 | 172 | [ |
173 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
173 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
174 | 174 | ], |
175 | 175 | Http::STATUS_NOT_FOUND |
176 | 176 | ); |
@@ -46,163 +46,163 @@ |
||
46 | 46 | * User global storages controller |
47 | 47 | */ |
48 | 48 | class UserGlobalStoragesController extends StoragesController { |
49 | - /** |
|
50 | - * @var IUserSession |
|
51 | - */ |
|
52 | - private $userSession; |
|
53 | - |
|
54 | - /** |
|
55 | - * Creates a new user global storages controller. |
|
56 | - * |
|
57 | - * @param string $AppName application name |
|
58 | - * @param IRequest $request request object |
|
59 | - * @param IL10N $l10n l10n service |
|
60 | - * @param UserGlobalStoragesService $userGlobalStoragesService storage service |
|
61 | - * @param IUserSession $userSession |
|
62 | - */ |
|
63 | - public function __construct( |
|
64 | - $AppName, |
|
65 | - IRequest $request, |
|
66 | - IL10N $l10n, |
|
67 | - UserGlobalStoragesService $userGlobalStoragesService, |
|
68 | - IUserSession $userSession, |
|
69 | - ILogger $logger |
|
70 | - ) { |
|
71 | - parent::__construct( |
|
72 | - $AppName, |
|
73 | - $request, |
|
74 | - $l10n, |
|
75 | - $userGlobalStoragesService, |
|
76 | - $logger |
|
77 | - ); |
|
78 | - $this->userSession = $userSession; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Get all storage entries |
|
83 | - * |
|
84 | - * @return DataResponse |
|
85 | - * |
|
86 | - * @NoAdminRequired |
|
87 | - */ |
|
88 | - public function index() { |
|
89 | - $storages = $this->formatStoragesForUI($this->service->getUniqueStorages()); |
|
90 | - |
|
91 | - // remove configuration data, this must be kept private |
|
92 | - foreach ($storages as $storage) { |
|
93 | - $this->sanitizeStorage($storage); |
|
94 | - } |
|
95 | - |
|
96 | - return new DataResponse( |
|
97 | - $storages, |
|
98 | - Http::STATUS_OK |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - protected function manipulateStorageConfig(StorageConfig $storage) { |
|
103 | - /** @var AuthMechanism */ |
|
104 | - $authMechanism = $storage->getAuthMechanism(); |
|
105 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
106 | - /** @var Backend */ |
|
107 | - $backend = $storage->getBackend(); |
|
108 | - $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Get an external storage entry. |
|
113 | - * |
|
114 | - * @param int $id storage id |
|
115 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
116 | - * @return DataResponse |
|
117 | - * |
|
118 | - * @NoAdminRequired |
|
119 | - */ |
|
120 | - public function show($id, $testOnly = true) { |
|
121 | - try { |
|
122 | - $storage = $this->service->getStorage($id); |
|
123 | - |
|
124 | - $this->updateStorageStatus($storage, $testOnly); |
|
125 | - } catch (NotFoundException $e) { |
|
126 | - return new DataResponse( |
|
127 | - [ |
|
128 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
129 | - ], |
|
130 | - Http::STATUS_NOT_FOUND |
|
131 | - ); |
|
132 | - } |
|
133 | - |
|
134 | - $this->sanitizeStorage($storage); |
|
135 | - |
|
136 | - return new DataResponse( |
|
137 | - $this->formatStorageForUI($storage), |
|
138 | - Http::STATUS_OK |
|
139 | - ); |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Update an external storage entry. |
|
144 | - * Only allows setting user provided backend fields |
|
145 | - * |
|
146 | - * @param int $id storage id |
|
147 | - * @param array $backendOptions backend-specific options |
|
148 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
149 | - * |
|
150 | - * @return DataResponse |
|
151 | - * |
|
152 | - * @NoAdminRequired |
|
153 | - */ |
|
154 | - public function update( |
|
155 | - $id, |
|
156 | - $backendOptions, |
|
157 | - $testOnly = true |
|
158 | - ) { |
|
159 | - try { |
|
160 | - $storage = $this->service->getStorage($id); |
|
161 | - $authMechanism = $storage->getAuthMechanism(); |
|
162 | - if ($authMechanism instanceof IUserProvided || $authMechanism instanceof UserGlobalAuth) { |
|
163 | - $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); |
|
164 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
165 | - } else { |
|
166 | - return new DataResponse( |
|
167 | - [ |
|
168 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id]) |
|
169 | - ], |
|
170 | - Http::STATUS_FORBIDDEN |
|
171 | - ); |
|
172 | - } |
|
173 | - } catch (NotFoundException $e) { |
|
174 | - return new DataResponse( |
|
175 | - [ |
|
176 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
177 | - ], |
|
178 | - Http::STATUS_NOT_FOUND |
|
179 | - ); |
|
180 | - } |
|
181 | - |
|
182 | - $this->updateStorageStatus($storage, $testOnly); |
|
183 | - $this->sanitizeStorage($storage); |
|
184 | - |
|
185 | - return new DataResponse( |
|
186 | - $this->formatStorageForUI($storage), |
|
187 | - Http::STATUS_OK |
|
188 | - ); |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Remove sensitive data from a StorageConfig before returning it to the user |
|
193 | - * |
|
194 | - * @param StorageConfig $storage |
|
195 | - */ |
|
196 | - protected function sanitizeStorage(StorageConfig $storage) { |
|
197 | - $storage->setBackendOptions([]); |
|
198 | - $storage->setMountOptions([]); |
|
199 | - |
|
200 | - if ($storage->getAuthMechanism() instanceof IUserProvided) { |
|
201 | - try { |
|
202 | - $storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
203 | - } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
204 | - // not configured yet |
|
205 | - } |
|
206 | - } |
|
207 | - } |
|
49 | + /** |
|
50 | + * @var IUserSession |
|
51 | + */ |
|
52 | + private $userSession; |
|
53 | + |
|
54 | + /** |
|
55 | + * Creates a new user global storages controller. |
|
56 | + * |
|
57 | + * @param string $AppName application name |
|
58 | + * @param IRequest $request request object |
|
59 | + * @param IL10N $l10n l10n service |
|
60 | + * @param UserGlobalStoragesService $userGlobalStoragesService storage service |
|
61 | + * @param IUserSession $userSession |
|
62 | + */ |
|
63 | + public function __construct( |
|
64 | + $AppName, |
|
65 | + IRequest $request, |
|
66 | + IL10N $l10n, |
|
67 | + UserGlobalStoragesService $userGlobalStoragesService, |
|
68 | + IUserSession $userSession, |
|
69 | + ILogger $logger |
|
70 | + ) { |
|
71 | + parent::__construct( |
|
72 | + $AppName, |
|
73 | + $request, |
|
74 | + $l10n, |
|
75 | + $userGlobalStoragesService, |
|
76 | + $logger |
|
77 | + ); |
|
78 | + $this->userSession = $userSession; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Get all storage entries |
|
83 | + * |
|
84 | + * @return DataResponse |
|
85 | + * |
|
86 | + * @NoAdminRequired |
|
87 | + */ |
|
88 | + public function index() { |
|
89 | + $storages = $this->formatStoragesForUI($this->service->getUniqueStorages()); |
|
90 | + |
|
91 | + // remove configuration data, this must be kept private |
|
92 | + foreach ($storages as $storage) { |
|
93 | + $this->sanitizeStorage($storage); |
|
94 | + } |
|
95 | + |
|
96 | + return new DataResponse( |
|
97 | + $storages, |
|
98 | + Http::STATUS_OK |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + protected function manipulateStorageConfig(StorageConfig $storage) { |
|
103 | + /** @var AuthMechanism */ |
|
104 | + $authMechanism = $storage->getAuthMechanism(); |
|
105 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
106 | + /** @var Backend */ |
|
107 | + $backend = $storage->getBackend(); |
|
108 | + $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Get an external storage entry. |
|
113 | + * |
|
114 | + * @param int $id storage id |
|
115 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
116 | + * @return DataResponse |
|
117 | + * |
|
118 | + * @NoAdminRequired |
|
119 | + */ |
|
120 | + public function show($id, $testOnly = true) { |
|
121 | + try { |
|
122 | + $storage = $this->service->getStorage($id); |
|
123 | + |
|
124 | + $this->updateStorageStatus($storage, $testOnly); |
|
125 | + } catch (NotFoundException $e) { |
|
126 | + return new DataResponse( |
|
127 | + [ |
|
128 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
129 | + ], |
|
130 | + Http::STATUS_NOT_FOUND |
|
131 | + ); |
|
132 | + } |
|
133 | + |
|
134 | + $this->sanitizeStorage($storage); |
|
135 | + |
|
136 | + return new DataResponse( |
|
137 | + $this->formatStorageForUI($storage), |
|
138 | + Http::STATUS_OK |
|
139 | + ); |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Update an external storage entry. |
|
144 | + * Only allows setting user provided backend fields |
|
145 | + * |
|
146 | + * @param int $id storage id |
|
147 | + * @param array $backendOptions backend-specific options |
|
148 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
149 | + * |
|
150 | + * @return DataResponse |
|
151 | + * |
|
152 | + * @NoAdminRequired |
|
153 | + */ |
|
154 | + public function update( |
|
155 | + $id, |
|
156 | + $backendOptions, |
|
157 | + $testOnly = true |
|
158 | + ) { |
|
159 | + try { |
|
160 | + $storage = $this->service->getStorage($id); |
|
161 | + $authMechanism = $storage->getAuthMechanism(); |
|
162 | + if ($authMechanism instanceof IUserProvided || $authMechanism instanceof UserGlobalAuth) { |
|
163 | + $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); |
|
164 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
165 | + } else { |
|
166 | + return new DataResponse( |
|
167 | + [ |
|
168 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id]) |
|
169 | + ], |
|
170 | + Http::STATUS_FORBIDDEN |
|
171 | + ); |
|
172 | + } |
|
173 | + } catch (NotFoundException $e) { |
|
174 | + return new DataResponse( |
|
175 | + [ |
|
176 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
177 | + ], |
|
178 | + Http::STATUS_NOT_FOUND |
|
179 | + ); |
|
180 | + } |
|
181 | + |
|
182 | + $this->updateStorageStatus($storage, $testOnly); |
|
183 | + $this->sanitizeStorage($storage); |
|
184 | + |
|
185 | + return new DataResponse( |
|
186 | + $this->formatStorageForUI($storage), |
|
187 | + Http::STATUS_OK |
|
188 | + ); |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Remove sensitive data from a StorageConfig before returning it to the user |
|
193 | + * |
|
194 | + * @param StorageConfig $storage |
|
195 | + */ |
|
196 | + protected function sanitizeStorage(StorageConfig $storage) { |
|
197 | + $storage->setBackendOptions([]); |
|
198 | + $storage->setMountOptions([]); |
|
199 | + |
|
200 | + if ($storage->getAuthMechanism() instanceof IUserProvided) { |
|
201 | + try { |
|
202 | + $storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
203 | + } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
204 | + // not configured yet |
|
205 | + } |
|
206 | + } |
|
207 | + } |
|
208 | 208 | } |
@@ -29,31 +29,31 @@ |
||
29 | 29 | */ |
30 | 30 | trait PriorityTrait { |
31 | 31 | |
32 | - /** @var int initial priority */ |
|
33 | - protected $priority = BackendService::PRIORITY_DEFAULT; |
|
32 | + /** @var int initial priority */ |
|
33 | + protected $priority = BackendService::PRIORITY_DEFAULT; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return int |
|
37 | - */ |
|
38 | - public function getPriority() { |
|
39 | - return $this->priority; |
|
40 | - } |
|
35 | + /** |
|
36 | + * @return int |
|
37 | + */ |
|
38 | + public function getPriority() { |
|
39 | + return $this->priority; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param int $priority |
|
44 | - * @return self |
|
45 | - */ |
|
46 | - public function setPriority($priority) { |
|
47 | - $this->priority = $priority; |
|
48 | - return $this; |
|
49 | - } |
|
42 | + /** |
|
43 | + * @param int $priority |
|
44 | + * @return self |
|
45 | + */ |
|
46 | + public function setPriority($priority) { |
|
47 | + $this->priority = $priority; |
|
48 | + return $this; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param PriorityTrait $a |
|
53 | - * @param PriorityTrait $b |
|
54 | - * @return int |
|
55 | - */ |
|
56 | - public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) { |
|
57 | - return ($a->getPriority() - $b->getPriority()); |
|
58 | - } |
|
51 | + /** |
|
52 | + * @param PriorityTrait $a |
|
53 | + * @param PriorityTrait $b |
|
54 | + * @return int |
|
55 | + */ |
|
56 | + public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) { |
|
57 | + return ($a->getPriority() - $b->getPriority()); |
|
58 | + } |
|
59 | 59 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
51 | 51 | ]) |
52 | 52 | ->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK) |
53 | - ->setLegacyAuthMechanismCallback(function (array $params) use ($openstackAuth, $rackspaceAuth) { |
|
53 | + ->setLegacyAuthMechanismCallback(function(array $params) use ($openstackAuth, $rackspaceAuth) { |
|
54 | 54 | if (isset($params['options']['key']) && $params['options']['key']) { |
55 | 55 | return $rackspaceAuth; |
56 | 56 | } |
@@ -33,30 +33,30 @@ |
||
33 | 33 | use OCP\IL10N; |
34 | 34 | |
35 | 35 | class Swift extends Backend { |
36 | - use LegacyDependencyCheckPolyfill; |
|
36 | + use LegacyDependencyCheckPolyfill; |
|
37 | 37 | |
38 | - public function __construct(IL10N $l, OpenStackV2 $openstackAuth, Rackspace $rackspaceAuth) { |
|
39 | - $this |
|
40 | - ->setIdentifier('swift') |
|
41 | - ->addIdentifierAlias('\OC\Files\Storage\Swift') // legacy compat |
|
42 | - ->setStorageClass('\OCA\Files_External\Lib\Storage\Swift') |
|
43 | - ->setText($l->t('OpenStack Object Storage')) |
|
44 | - ->addParameters([ |
|
45 | - (new DefinitionParameter('service_name', $l->t('Service name'))) |
|
46 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
47 | - (new DefinitionParameter('region', $l->t('Region'))) |
|
48 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
49 | - new DefinitionParameter('bucket', $l->t('Bucket')), |
|
50 | - (new DefinitionParameter('timeout', $l->t('Request timeout (seconds)'))) |
|
51 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
52 | - ]) |
|
53 | - ->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK) |
|
54 | - ->setLegacyAuthMechanismCallback(function (array $params) use ($openstackAuth, $rackspaceAuth) { |
|
55 | - if (isset($params['options']['key']) && $params['options']['key']) { |
|
56 | - return $rackspaceAuth; |
|
57 | - } |
|
58 | - return $openstackAuth; |
|
59 | - }) |
|
60 | - ; |
|
61 | - } |
|
38 | + public function __construct(IL10N $l, OpenStackV2 $openstackAuth, Rackspace $rackspaceAuth) { |
|
39 | + $this |
|
40 | + ->setIdentifier('swift') |
|
41 | + ->addIdentifierAlias('\OC\Files\Storage\Swift') // legacy compat |
|
42 | + ->setStorageClass('\OCA\Files_External\Lib\Storage\Swift') |
|
43 | + ->setText($l->t('OpenStack Object Storage')) |
|
44 | + ->addParameters([ |
|
45 | + (new DefinitionParameter('service_name', $l->t('Service name'))) |
|
46 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
47 | + (new DefinitionParameter('region', $l->t('Region'))) |
|
48 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
49 | + new DefinitionParameter('bucket', $l->t('Bucket')), |
|
50 | + (new DefinitionParameter('timeout', $l->t('Request timeout (seconds)'))) |
|
51 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
52 | + ]) |
|
53 | + ->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK) |
|
54 | + ->setLegacyAuthMechanismCallback(function (array $params) use ($openstackAuth, $rackspaceAuth) { |
|
55 | + if (isset($params['options']['key']) && $params['options']['key']) { |
|
56 | + return $rackspaceAuth; |
|
57 | + } |
|
58 | + return $openstackAuth; |
|
59 | + }) |
|
60 | + ; |
|
61 | + } |
|
62 | 62 | } |