| @@ 257-273 (lines=17) @@ | ||
| 254 | * |
|
| 255 | * @return Result |
|
| 256 | */ |
|
| 257 | public function acceptShare($id) { |
|
| 258 | try { |
|
| 259 | $this->ocmMiddleware->assertOutgoingSharingEnabled(); |
|
| 260 | $token = $this->request->getParam('token', null); |
|
| 261 | $share = $this->ocmMiddleware->getValidShare($id, $token); |
|
| 262 | $this->fedShareManager->acceptShare($share); |
|
| 263 | } catch (NotImplementedException $e) { |
|
| 264 | return new Result( |
|
| 265 | null, |
|
| 266 | Http::STATUS_SERVICE_UNAVAILABLE, |
|
| 267 | 'Server does not support federated cloud sharing' |
|
| 268 | ); |
|
| 269 | } catch (Share\Exceptions\ShareNotFound $e) { |
|
| 270 | // pass |
|
| 271 | } |
|
| 272 | return new Result(); |
|
| 273 | } |
|
| 274 | ||
| 275 | /** |
|
| 276 | * @NoCSRFRequired |
|
| @@ 285-302 (lines=18) @@ | ||
| 282 | * |
|
| 283 | * @return Result |
|
| 284 | */ |
|
| 285 | public function declineShare($id) { |
|
| 286 | try { |
|
| 287 | $token = $this->request->getParam('token', null); |
|
| 288 | $this->ocmMiddleware->assertOutgoingSharingEnabled(); |
|
| 289 | $share = $this->ocmMiddleware->getValidShare($id, $token); |
|
| 290 | $this->fedShareManager->declineShare($share); |
|
| 291 | } catch (NotImplementedException $e) { |
|
| 292 | return new Result( |
|
| 293 | null, |
|
| 294 | Http::STATUS_SERVICE_UNAVAILABLE, |
|
| 295 | 'Server does not support federated cloud sharing' |
|
| 296 | ); |
|
| 297 | } catch (Share\Exceptions\ShareNotFound $e) { |
|
| 298 | // pass |
|
| 299 | } |
|
| 300 | ||
| 301 | return new Result(); |
|
| 302 | } |
|
| 303 | ||
| 304 | /** |
|
| 305 | * @NoCSRFRequired |
|
| @@ 314-331 (lines=18) @@ | ||
| 311 | * |
|
| 312 | * @return Result |
|
| 313 | */ |
|
| 314 | public function unshare($id) { |
|
| 315 | try { |
|
| 316 | $this->ocmMiddleware->assertOutgoingSharingEnabled(); |
|
| 317 | $token = $this->request->getParam('token', null); |
|
| 318 | if ($token && $id) { |
|
| 319 | $this->fedShareManager->unshare($id, $token); |
|
| 320 | } |
|
| 321 | } catch (NotImplementedException $e) { |
|
| 322 | return new Result( |
|
| 323 | null, |
|
| 324 | Http::STATUS_SERVICE_UNAVAILABLE, |
|
| 325 | 'Server does not support federated cloud sharing' |
|
| 326 | ); |
|
| 327 | } catch (\Exception $e) { |
|
| 328 | // pass |
|
| 329 | } |
|
| 330 | return new Result(); |
|
| 331 | } |
|
| 332 | ||
| 333 | /** |
|
| 334 | * @NoCSRFRequired |
|
| @@ 343-353 (lines=11) @@ | ||
| 340 | * |
|
| 341 | * @return Result |
|
| 342 | */ |
|
| 343 | public function revoke($id) { |
|
| 344 | try { |
|
| 345 | $token = $this->request->getParam('token', null); |
|
| 346 | $share = $this->getValidShare($id, $token); |
|
| 347 | $this->fedShareManager->revoke($share); |
|
| 348 | } catch (\Exception $e) { |
|
| 349 | return new Result(null, Http::STATUS_BAD_REQUEST); |
|
| 350 | } |
|
| 351 | ||
| 352 | return new Result(); |
|
| 353 | } |
|
| 354 | ||
| 355 | /** |
|
| 356 | * @NoCSRFRequired |
|