Code Duplication    Length = 11-18 lines in 4 locations

apps/federatedfilesharing/lib/Controller/RequestHandlerController.php 4 locations

@@ 251-265 (lines=15) @@
248
	 *
249
	 * @return Result
250
	 */
251
	public function acceptShare($id) {
252
		try {
253
			$this->ocmMiddleware->assertOutgoingSharingEnabled();
254
			$token = $this->request->getParam('token', null);
255
			$share = $this->ocmMiddleware->getValidShare($id, $token);
256
			$this->fedShareManager->acceptShare($share);
257
		} catch (NotImplementedException $e) {
258
			return new Result(
259
				null,
260
				Http::STATUS_SERVICE_UNAVAILABLE,
261
				'Server does not support federated cloud sharing'
262
			);
263
		}
264
		return new Result();
265
	}
266
267
	/**
268
	 * @NoCSRFRequired
@@ 277-292 (lines=16) @@
274
	 *
275
	 * @return Result
276
	 */
277
	public function declineShare($id) {
278
		try {
279
			$token = $this->request->getParam('token', null);
280
			$this->ocmMiddleware->assertOutgoingSharingEnabled();
281
			$share = $this->ocmMiddleware->getValidShare($id, $token);
282
			$this->fedShareManager->declineShare($share);
283
		} catch (NotImplementedException $e) {
284
			return new Result(
285
				null,
286
				Http::STATUS_SERVICE_UNAVAILABLE,
287
				'Server does not support federated cloud sharing'
288
			);
289
		}
290
291
		return new Result();
292
	}
293
294
	/**
295
	 * @NoCSRFRequired
@@ 304-321 (lines=18) @@
301
	 *
302
	 * @return Result
303
	 */
304
	public function unshare($id) {
305
		try {
306
			$this->ocmMiddleware->assertOutgoingSharingEnabled();
307
			$token = $this->request->getParam('token', null);
308
			if ($token && $id) {
309
				$this->fedShareManager->unshare($id, $token);
310
			}
311
		} catch (NotImplementedException $e) {
312
			return new Result(
313
				null,
314
				Http::STATUS_SERVICE_UNAVAILABLE,
315
				'Server does not support federated cloud sharing'
316
			);
317
		} catch (\Exception $e) {
318
			// pass
319
		}
320
		return new Result();
321
	}
322
323
	/**
324
	 * @NoCSRFRequired
@@ 333-343 (lines=11) @@
330
	 *
331
	 * @return Result
332
	 */
333
	public function revoke($id) {
334
		try {
335
			$token = $this->request->getParam('token', null);
336
			$share = $this->getValidShare($id, $token);
337
			$this->fedShareManager->revoke($share);
338
		} catch (\Exception $e) {
339
			return new Result(null, Http::STATUS_BAD_REQUEST);
340
		}
341
342
		return new Result();
343
	}
344
345
	/**
346
	 * @NoCSRFRequired