Code Duplication    Length = 11-18 lines in 4 locations

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

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