@@ -47,298 +47,298 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | abstract class StoragesController extends Controller { |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * L10N service |
|
| 52 | - * |
|
| 53 | - * @var IL10N |
|
| 54 | - */ |
|
| 55 | - protected $l10n; |
|
| 50 | + /** |
|
| 51 | + * L10N service |
|
| 52 | + * |
|
| 53 | + * @var IL10N |
|
| 54 | + */ |
|
| 55 | + protected $l10n; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Storages service |
|
| 59 | - * |
|
| 60 | - * @var StoragesService |
|
| 61 | - */ |
|
| 62 | - protected $service; |
|
| 57 | + /** |
|
| 58 | + * Storages service |
|
| 59 | + * |
|
| 60 | + * @var StoragesService |
|
| 61 | + */ |
|
| 62 | + protected $service; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @var ILogger |
|
| 66 | - */ |
|
| 67 | - protected $logger; |
|
| 64 | + /** |
|
| 65 | + * @var ILogger |
|
| 66 | + */ |
|
| 67 | + protected $logger; |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Creates a new storages controller. |
|
| 71 | - * |
|
| 72 | - * @param string $AppName application name |
|
| 73 | - * @param IRequest $request request object |
|
| 74 | - * @param IL10N $l10n l10n service |
|
| 75 | - * @param StoragesService $storagesService storage service |
|
| 76 | - * @param ILogger $logger |
|
| 77 | - */ |
|
| 78 | - public function __construct( |
|
| 79 | - $AppName, |
|
| 80 | - IRequest $request, |
|
| 81 | - IL10N $l10n, |
|
| 82 | - StoragesService $storagesService, |
|
| 83 | - ILogger $logger |
|
| 84 | - ) { |
|
| 85 | - parent::__construct($AppName, $request); |
|
| 86 | - $this->l10n = $l10n; |
|
| 87 | - $this->service = $storagesService; |
|
| 88 | - $this->logger = $logger; |
|
| 89 | - } |
|
| 69 | + /** |
|
| 70 | + * Creates a new storages controller. |
|
| 71 | + * |
|
| 72 | + * @param string $AppName application name |
|
| 73 | + * @param IRequest $request request object |
|
| 74 | + * @param IL10N $l10n l10n service |
|
| 75 | + * @param StoragesService $storagesService storage service |
|
| 76 | + * @param ILogger $logger |
|
| 77 | + */ |
|
| 78 | + public function __construct( |
|
| 79 | + $AppName, |
|
| 80 | + IRequest $request, |
|
| 81 | + IL10N $l10n, |
|
| 82 | + StoragesService $storagesService, |
|
| 83 | + ILogger $logger |
|
| 84 | + ) { |
|
| 85 | + parent::__construct($AppName, $request); |
|
| 86 | + $this->l10n = $l10n; |
|
| 87 | + $this->service = $storagesService; |
|
| 88 | + $this->logger = $logger; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Create a storage from its parameters |
|
| 93 | - * |
|
| 94 | - * @param string $mountPoint storage mount point |
|
| 95 | - * @param string $backend backend identifier |
|
| 96 | - * @param string $authMechanism authentication mechanism identifier |
|
| 97 | - * @param array $backendOptions backend-specific options |
|
| 98 | - * @param array|null $mountOptions mount-specific options |
|
| 99 | - * @param array|null $applicableUsers users for which to mount the storage |
|
| 100 | - * @param array|null $applicableGroups groups for which to mount the storage |
|
| 101 | - * @param int|null $priority priority |
|
| 102 | - * |
|
| 103 | - * @return StorageConfig|DataResponse |
|
| 104 | - */ |
|
| 105 | - protected function createStorage( |
|
| 106 | - $mountPoint, |
|
| 107 | - $backend, |
|
| 108 | - $authMechanism, |
|
| 109 | - $backendOptions, |
|
| 110 | - $mountOptions = null, |
|
| 111 | - $applicableUsers = null, |
|
| 112 | - $applicableGroups = null, |
|
| 113 | - $priority = null |
|
| 114 | - ) { |
|
| 115 | - try { |
|
| 116 | - return $this->service->createStorage( |
|
| 117 | - $mountPoint, |
|
| 118 | - $backend, |
|
| 119 | - $authMechanism, |
|
| 120 | - $backendOptions, |
|
| 121 | - $mountOptions, |
|
| 122 | - $applicableUsers, |
|
| 123 | - $applicableGroups, |
|
| 124 | - $priority |
|
| 125 | - ); |
|
| 126 | - } catch (\InvalidArgumentException $e) { |
|
| 127 | - $this->logger->logException($e); |
|
| 128 | - return new DataResponse( |
|
| 129 | - [ |
|
| 130 | - 'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class') |
|
| 131 | - ], |
|
| 132 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 133 | - ); |
|
| 134 | - } |
|
| 135 | - } |
|
| 91 | + /** |
|
| 92 | + * Create a storage from its parameters |
|
| 93 | + * |
|
| 94 | + * @param string $mountPoint storage mount point |
|
| 95 | + * @param string $backend backend identifier |
|
| 96 | + * @param string $authMechanism authentication mechanism identifier |
|
| 97 | + * @param array $backendOptions backend-specific options |
|
| 98 | + * @param array|null $mountOptions mount-specific options |
|
| 99 | + * @param array|null $applicableUsers users for which to mount the storage |
|
| 100 | + * @param array|null $applicableGroups groups for which to mount the storage |
|
| 101 | + * @param int|null $priority priority |
|
| 102 | + * |
|
| 103 | + * @return StorageConfig|DataResponse |
|
| 104 | + */ |
|
| 105 | + protected function createStorage( |
|
| 106 | + $mountPoint, |
|
| 107 | + $backend, |
|
| 108 | + $authMechanism, |
|
| 109 | + $backendOptions, |
|
| 110 | + $mountOptions = null, |
|
| 111 | + $applicableUsers = null, |
|
| 112 | + $applicableGroups = null, |
|
| 113 | + $priority = null |
|
| 114 | + ) { |
|
| 115 | + try { |
|
| 116 | + return $this->service->createStorage( |
|
| 117 | + $mountPoint, |
|
| 118 | + $backend, |
|
| 119 | + $authMechanism, |
|
| 120 | + $backendOptions, |
|
| 121 | + $mountOptions, |
|
| 122 | + $applicableUsers, |
|
| 123 | + $applicableGroups, |
|
| 124 | + $priority |
|
| 125 | + ); |
|
| 126 | + } catch (\InvalidArgumentException $e) { |
|
| 127 | + $this->logger->logException($e); |
|
| 128 | + return new DataResponse( |
|
| 129 | + [ |
|
| 130 | + 'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class') |
|
| 131 | + ], |
|
| 132 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 133 | + ); |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Validate storage config |
|
| 139 | - * |
|
| 140 | - * @param StorageConfig $storage storage config |
|
| 141 | - *1 |
|
| 142 | - * @return DataResponse|null returns response in case of validation error |
|
| 143 | - */ |
|
| 144 | - protected function validate(StorageConfig $storage) { |
|
| 145 | - $mountPoint = $storage->getMountPoint(); |
|
| 146 | - if ($mountPoint === '') { |
|
| 147 | - return new DataResponse( |
|
| 148 | - array( |
|
| 149 | - 'message' => (string)$this->l10n->t('Invalid mount point') |
|
| 150 | - ), |
|
| 151 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 152 | - ); |
|
| 153 | - } |
|
| 137 | + /** |
|
| 138 | + * Validate storage config |
|
| 139 | + * |
|
| 140 | + * @param StorageConfig $storage storage config |
|
| 141 | + *1 |
|
| 142 | + * @return DataResponse|null returns response in case of validation error |
|
| 143 | + */ |
|
| 144 | + protected function validate(StorageConfig $storage) { |
|
| 145 | + $mountPoint = $storage->getMountPoint(); |
|
| 146 | + if ($mountPoint === '') { |
|
| 147 | + return new DataResponse( |
|
| 148 | + array( |
|
| 149 | + 'message' => (string)$this->l10n->t('Invalid mount point') |
|
| 150 | + ), |
|
| 151 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 152 | + ); |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - if ($storage->getBackendOption('objectstore')) { |
|
| 156 | - // objectstore must not be sent from client side |
|
| 157 | - return new DataResponse( |
|
| 158 | - array( |
|
| 159 | - 'message' => (string)$this->l10n->t('Objectstore forbidden') |
|
| 160 | - ), |
|
| 161 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 162 | - ); |
|
| 163 | - } |
|
| 155 | + if ($storage->getBackendOption('objectstore')) { |
|
| 156 | + // objectstore must not be sent from client side |
|
| 157 | + return new DataResponse( |
|
| 158 | + array( |
|
| 159 | + 'message' => (string)$this->l10n->t('Objectstore forbidden') |
|
| 160 | + ), |
|
| 161 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 162 | + ); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - /** @var Backend */ |
|
| 166 | - $backend = $storage->getBackend(); |
|
| 167 | - /** @var AuthMechanism */ |
|
| 168 | - $authMechanism = $storage->getAuthMechanism(); |
|
| 169 | - if ($backend->checkDependencies()) { |
|
| 170 | - // invalid backend |
|
| 171 | - return new DataResponse( |
|
| 172 | - array( |
|
| 173 | - 'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [ |
|
| 174 | - $backend->getIdentifier() |
|
| 175 | - ]) |
|
| 176 | - ), |
|
| 177 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 178 | - ); |
|
| 179 | - } |
|
| 165 | + /** @var Backend */ |
|
| 166 | + $backend = $storage->getBackend(); |
|
| 167 | + /** @var AuthMechanism */ |
|
| 168 | + $authMechanism = $storage->getAuthMechanism(); |
|
| 169 | + if ($backend->checkDependencies()) { |
|
| 170 | + // invalid backend |
|
| 171 | + return new DataResponse( |
|
| 172 | + array( |
|
| 173 | + 'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [ |
|
| 174 | + $backend->getIdentifier() |
|
| 175 | + ]) |
|
| 176 | + ), |
|
| 177 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 178 | + ); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - if (!$backend->isVisibleFor($this->service->getVisibilityType())) { |
|
| 182 | - // not permitted to use backend |
|
| 183 | - return new DataResponse( |
|
| 184 | - array( |
|
| 185 | - 'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [ |
|
| 186 | - $backend->getIdentifier() |
|
| 187 | - ]) |
|
| 188 | - ), |
|
| 189 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 190 | - ); |
|
| 191 | - } |
|
| 192 | - if (!$authMechanism->isVisibleFor($this->service->getVisibilityType())) { |
|
| 193 | - // not permitted to use auth mechanism |
|
| 194 | - return new DataResponse( |
|
| 195 | - array( |
|
| 196 | - 'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [ |
|
| 197 | - $authMechanism->getIdentifier() |
|
| 198 | - ]) |
|
| 199 | - ), |
|
| 200 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 201 | - ); |
|
| 202 | - } |
|
| 181 | + if (!$backend->isVisibleFor($this->service->getVisibilityType())) { |
|
| 182 | + // not permitted to use backend |
|
| 183 | + return new DataResponse( |
|
| 184 | + array( |
|
| 185 | + 'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [ |
|
| 186 | + $backend->getIdentifier() |
|
| 187 | + ]) |
|
| 188 | + ), |
|
| 189 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 190 | + ); |
|
| 191 | + } |
|
| 192 | + if (!$authMechanism->isVisibleFor($this->service->getVisibilityType())) { |
|
| 193 | + // not permitted to use auth mechanism |
|
| 194 | + return new DataResponse( |
|
| 195 | + array( |
|
| 196 | + 'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [ |
|
| 197 | + $authMechanism->getIdentifier() |
|
| 198 | + ]) |
|
| 199 | + ), |
|
| 200 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 201 | + ); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - if (!$backend->validateStorage($storage)) { |
|
| 205 | - // unsatisfied parameters |
|
| 206 | - return new DataResponse( |
|
| 207 | - array( |
|
| 208 | - 'message' => (string)$this->l10n->t('Unsatisfied backend parameters') |
|
| 209 | - ), |
|
| 210 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 211 | - ); |
|
| 212 | - } |
|
| 213 | - if (!$authMechanism->validateStorage($storage)) { |
|
| 214 | - // unsatisfied parameters |
|
| 215 | - return new DataResponse( |
|
| 216 | - [ |
|
| 217 | - 'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters') |
|
| 218 | - ], |
|
| 219 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 220 | - ); |
|
| 221 | - } |
|
| 204 | + if (!$backend->validateStorage($storage)) { |
|
| 205 | + // unsatisfied parameters |
|
| 206 | + return new DataResponse( |
|
| 207 | + array( |
|
| 208 | + 'message' => (string)$this->l10n->t('Unsatisfied backend parameters') |
|
| 209 | + ), |
|
| 210 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 211 | + ); |
|
| 212 | + } |
|
| 213 | + if (!$authMechanism->validateStorage($storage)) { |
|
| 214 | + // unsatisfied parameters |
|
| 215 | + return new DataResponse( |
|
| 216 | + [ |
|
| 217 | + 'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters') |
|
| 218 | + ], |
|
| 219 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 220 | + ); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - return null; |
|
| 224 | - } |
|
| 223 | + return null; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - protected function manipulateStorageConfig(StorageConfig $storage) { |
|
| 227 | - /** @var AuthMechanism */ |
|
| 228 | - $authMechanism = $storage->getAuthMechanism(); |
|
| 229 | - $authMechanism->manipulateStorageConfig($storage); |
|
| 230 | - /** @var Backend */ |
|
| 231 | - $backend = $storage->getBackend(); |
|
| 232 | - $backend->manipulateStorageConfig($storage); |
|
| 233 | - } |
|
| 226 | + protected function manipulateStorageConfig(StorageConfig $storage) { |
|
| 227 | + /** @var AuthMechanism */ |
|
| 228 | + $authMechanism = $storage->getAuthMechanism(); |
|
| 229 | + $authMechanism->manipulateStorageConfig($storage); |
|
| 230 | + /** @var Backend */ |
|
| 231 | + $backend = $storage->getBackend(); |
|
| 232 | + $backend->manipulateStorageConfig($storage); |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - /** |
|
| 236 | - * Check whether the given storage is available / valid. |
|
| 237 | - * |
|
| 238 | - * Note that this operation can be time consuming depending |
|
| 239 | - * on whether the remote storage is available or not. |
|
| 240 | - * |
|
| 241 | - * @param StorageConfig $storage storage configuration |
|
| 242 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
| 243 | - */ |
|
| 244 | - protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true) { |
|
| 245 | - try { |
|
| 246 | - $this->manipulateStorageConfig($storage); |
|
| 235 | + /** |
|
| 236 | + * Check whether the given storage is available / valid. |
|
| 237 | + * |
|
| 238 | + * Note that this operation can be time consuming depending |
|
| 239 | + * on whether the remote storage is available or not. |
|
| 240 | + * |
|
| 241 | + * @param StorageConfig $storage storage configuration |
|
| 242 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
| 243 | + */ |
|
| 244 | + protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true) { |
|
| 245 | + try { |
|
| 246 | + $this->manipulateStorageConfig($storage); |
|
| 247 | 247 | |
| 248 | - /** @var Backend */ |
|
| 249 | - $backend = $storage->getBackend(); |
|
| 250 | - // update status (can be time-consuming) |
|
| 251 | - $storage->setStatus( |
|
| 252 | - \OC_Mount_Config::getBackendStatus( |
|
| 253 | - $backend->getStorageClass(), |
|
| 254 | - $storage->getBackendOptions(), |
|
| 255 | - false, |
|
| 256 | - $testOnly |
|
| 257 | - ) |
|
| 258 | - ); |
|
| 259 | - } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
| 260 | - $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE; |
|
| 261 | - $storage->setStatus( |
|
| 262 | - $status, |
|
| 263 | - $this->l10n->t('Insufficient data: %s', [$e->getMessage()]) |
|
| 264 | - ); |
|
| 265 | - } catch (StorageNotAvailableException $e) { |
|
| 266 | - $storage->setStatus( |
|
| 267 | - $e->getCode(), |
|
| 268 | - $this->l10n->t('%s', [$e->getMessage()]) |
|
| 269 | - ); |
|
| 270 | - } catch (\Exception $e) { |
|
| 271 | - // FIXME: convert storage exceptions to StorageNotAvailableException |
|
| 272 | - $storage->setStatus( |
|
| 273 | - StorageNotAvailableException::STATUS_ERROR, |
|
| 274 | - get_class($e).': '.$e->getMessage() |
|
| 275 | - ); |
|
| 276 | - } |
|
| 277 | - } |
|
| 248 | + /** @var Backend */ |
|
| 249 | + $backend = $storage->getBackend(); |
|
| 250 | + // update status (can be time-consuming) |
|
| 251 | + $storage->setStatus( |
|
| 252 | + \OC_Mount_Config::getBackendStatus( |
|
| 253 | + $backend->getStorageClass(), |
|
| 254 | + $storage->getBackendOptions(), |
|
| 255 | + false, |
|
| 256 | + $testOnly |
|
| 257 | + ) |
|
| 258 | + ); |
|
| 259 | + } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
| 260 | + $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE; |
|
| 261 | + $storage->setStatus( |
|
| 262 | + $status, |
|
| 263 | + $this->l10n->t('Insufficient data: %s', [$e->getMessage()]) |
|
| 264 | + ); |
|
| 265 | + } catch (StorageNotAvailableException $e) { |
|
| 266 | + $storage->setStatus( |
|
| 267 | + $e->getCode(), |
|
| 268 | + $this->l10n->t('%s', [$e->getMessage()]) |
|
| 269 | + ); |
|
| 270 | + } catch (\Exception $e) { |
|
| 271 | + // FIXME: convert storage exceptions to StorageNotAvailableException |
|
| 272 | + $storage->setStatus( |
|
| 273 | + StorageNotAvailableException::STATUS_ERROR, |
|
| 274 | + get_class($e).': '.$e->getMessage() |
|
| 275 | + ); |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - /** |
|
| 280 | - * Get all storage entries |
|
| 281 | - * |
|
| 282 | - * @return DataResponse |
|
| 283 | - */ |
|
| 284 | - public function index() { |
|
| 285 | - $storages = $this->service->getStorages(); |
|
| 279 | + /** |
|
| 280 | + * Get all storage entries |
|
| 281 | + * |
|
| 282 | + * @return DataResponse |
|
| 283 | + */ |
|
| 284 | + public function index() { |
|
| 285 | + $storages = $this->service->getStorages(); |
|
| 286 | 286 | |
| 287 | - return new DataResponse( |
|
| 288 | - $storages, |
|
| 289 | - Http::STATUS_OK |
|
| 290 | - ); |
|
| 291 | - } |
|
| 287 | + return new DataResponse( |
|
| 288 | + $storages, |
|
| 289 | + Http::STATUS_OK |
|
| 290 | + ); |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - /** |
|
| 294 | - * Get an external storage entry. |
|
| 295 | - * |
|
| 296 | - * @param int $id storage id |
|
| 297 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
| 298 | - * |
|
| 299 | - * @return DataResponse |
|
| 300 | - */ |
|
| 301 | - public function show($id, $testOnly = true) { |
|
| 302 | - try { |
|
| 303 | - $storage = $this->service->getStorage($id); |
|
| 293 | + /** |
|
| 294 | + * Get an external storage entry. |
|
| 295 | + * |
|
| 296 | + * @param int $id storage id |
|
| 297 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
| 298 | + * |
|
| 299 | + * @return DataResponse |
|
| 300 | + */ |
|
| 301 | + public function show($id, $testOnly = true) { |
|
| 302 | + try { |
|
| 303 | + $storage = $this->service->getStorage($id); |
|
| 304 | 304 | |
| 305 | - $this->updateStorageStatus($storage, $testOnly); |
|
| 306 | - } catch (NotFoundException $e) { |
|
| 307 | - return new DataResponse( |
|
| 308 | - [ |
|
| 309 | - 'message' => (string)$this->l10n->t('Storage with id "%i" not found', array($id)) |
|
| 310 | - ], |
|
| 311 | - Http::STATUS_NOT_FOUND |
|
| 312 | - ); |
|
| 313 | - } |
|
| 305 | + $this->updateStorageStatus($storage, $testOnly); |
|
| 306 | + } catch (NotFoundException $e) { |
|
| 307 | + return new DataResponse( |
|
| 308 | + [ |
|
| 309 | + 'message' => (string)$this->l10n->t('Storage with id "%i" not found', array($id)) |
|
| 310 | + ], |
|
| 311 | + Http::STATUS_NOT_FOUND |
|
| 312 | + ); |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - return new DataResponse( |
|
| 316 | - $storage, |
|
| 317 | - Http::STATUS_OK |
|
| 318 | - ); |
|
| 319 | - } |
|
| 315 | + return new DataResponse( |
|
| 316 | + $storage, |
|
| 317 | + Http::STATUS_OK |
|
| 318 | + ); |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | - /** |
|
| 322 | - * Deletes the storage with the given id. |
|
| 323 | - * |
|
| 324 | - * @param int $id storage id |
|
| 325 | - * |
|
| 326 | - * @return DataResponse |
|
| 327 | - */ |
|
| 328 | - public function destroy($id) { |
|
| 329 | - try { |
|
| 330 | - $this->service->removeStorage($id); |
|
| 331 | - } catch (NotFoundException $e) { |
|
| 332 | - return new DataResponse( |
|
| 333 | - [ |
|
| 334 | - 'message' => (string)$this->l10n->t('Storage with id "%i" not found', array($id)) |
|
| 335 | - ], |
|
| 336 | - Http::STATUS_NOT_FOUND |
|
| 337 | - ); |
|
| 338 | - } |
|
| 321 | + /** |
|
| 322 | + * Deletes the storage with the given id. |
|
| 323 | + * |
|
| 324 | + * @param int $id storage id |
|
| 325 | + * |
|
| 326 | + * @return DataResponse |
|
| 327 | + */ |
|
| 328 | + public function destroy($id) { |
|
| 329 | + try { |
|
| 330 | + $this->service->removeStorage($id); |
|
| 331 | + } catch (NotFoundException $e) { |
|
| 332 | + return new DataResponse( |
|
| 333 | + [ |
|
| 334 | + 'message' => (string)$this->l10n->t('Storage with id "%i" not found', array($id)) |
|
| 335 | + ], |
|
| 336 | + Http::STATUS_NOT_FOUND |
|
| 337 | + ); |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - return new DataResponse([], Http::STATUS_NO_CONTENT); |
|
| 341 | - } |
|
| 340 | + return new DataResponse([], Http::STATUS_NO_CONTENT); |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | 343 | } |
| 344 | 344 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $this->logger->logException($e); |
| 128 | 128 | return new DataResponse( |
| 129 | 129 | [ |
| 130 | - 'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class') |
|
| 130 | + 'message' => (string) $this->l10n->t('Invalid backend or authentication mechanism class') |
|
| 131 | 131 | ], |
| 132 | 132 | Http::STATUS_UNPROCESSABLE_ENTITY |
| 133 | 133 | ); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | if ($mountPoint === '') { |
| 147 | 147 | return new DataResponse( |
| 148 | 148 | array( |
| 149 | - 'message' => (string)$this->l10n->t('Invalid mount point') |
|
| 149 | + 'message' => (string) $this->l10n->t('Invalid mount point') |
|
| 150 | 150 | ), |
| 151 | 151 | Http::STATUS_UNPROCESSABLE_ENTITY |
| 152 | 152 | ); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | // objectstore must not be sent from client side |
| 157 | 157 | return new DataResponse( |
| 158 | 158 | array( |
| 159 | - 'message' => (string)$this->l10n->t('Objectstore forbidden') |
|
| 159 | + 'message' => (string) $this->l10n->t('Objectstore forbidden') |
|
| 160 | 160 | ), |
| 161 | 161 | Http::STATUS_UNPROCESSABLE_ENTITY |
| 162 | 162 | ); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | // invalid backend |
| 171 | 171 | return new DataResponse( |
| 172 | 172 | array( |
| 173 | - 'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [ |
|
| 173 | + 'message' => (string) $this->l10n->t('Invalid storage backend "%s"', [ |
|
| 174 | 174 | $backend->getIdentifier() |
| 175 | 175 | ]) |
| 176 | 176 | ), |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | // not permitted to use backend |
| 183 | 183 | return new DataResponse( |
| 184 | 184 | array( |
| 185 | - 'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [ |
|
| 185 | + 'message' => (string) $this->l10n->t('Not permitted to use backend "%s"', [ |
|
| 186 | 186 | $backend->getIdentifier() |
| 187 | 187 | ]) |
| 188 | 188 | ), |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | // not permitted to use auth mechanism |
| 194 | 194 | return new DataResponse( |
| 195 | 195 | array( |
| 196 | - 'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [ |
|
| 196 | + 'message' => (string) $this->l10n->t('Not permitted to use authentication mechanism "%s"', [ |
|
| 197 | 197 | $authMechanism->getIdentifier() |
| 198 | 198 | ]) |
| 199 | 199 | ), |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | // unsatisfied parameters |
| 206 | 206 | return new DataResponse( |
| 207 | 207 | array( |
| 208 | - 'message' => (string)$this->l10n->t('Unsatisfied backend parameters') |
|
| 208 | + 'message' => (string) $this->l10n->t('Unsatisfied backend parameters') |
|
| 209 | 209 | ), |
| 210 | 210 | Http::STATUS_UNPROCESSABLE_ENTITY |
| 211 | 211 | ); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | // unsatisfied parameters |
| 215 | 215 | return new DataResponse( |
| 216 | 216 | [ |
| 217 | - 'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters') |
|
| 217 | + 'message' => (string) $this->l10n->t('Unsatisfied authentication mechanism parameters') |
|
| 218 | 218 | ], |
| 219 | 219 | Http::STATUS_UNPROCESSABLE_ENTITY |
| 220 | 220 | ); |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param StorageConfig $storage storage configuration |
| 242 | 242 | * @param bool $testOnly whether to storage should only test the connection or do more things |
| 243 | 243 | */ |
| 244 | - protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true) { |
|
| 244 | + protected function updateStorageStatus(StorageConfig & $storage, $testOnly = true) { |
|
| 245 | 245 | try { |
| 246 | 246 | $this->manipulateStorageConfig($storage); |
| 247 | 247 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | } catch (NotFoundException $e) { |
| 307 | 307 | return new DataResponse( |
| 308 | 308 | [ |
| 309 | - 'message' => (string)$this->l10n->t('Storage with id "%i" not found', array($id)) |
|
| 309 | + 'message' => (string) $this->l10n->t('Storage with id "%i" not found', array($id)) |
|
| 310 | 310 | ], |
| 311 | 311 | Http::STATUS_NOT_FOUND |
| 312 | 312 | ); |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | } catch (NotFoundException $e) { |
| 332 | 332 | return new DataResponse( |
| 333 | 333 | [ |
| 334 | - 'message' => (string)$this->l10n->t('Storage with id "%i" not found', array($id)) |
|
| 334 | + 'message' => (string) $this->l10n->t('Storage with id "%i" not found', array($id)) |
|
| 335 | 335 | ], |
| 336 | 336 | Http::STATUS_NOT_FOUND |
| 337 | 337 | ); |