Code Duplication    Length = 6-6 lines in 4 locations

lib/private/Share/Share.php 4 locations

@@ 675-680 (lines=6) @@
672
				throw new \Exception($message_t);
673
			}
674
			// verify that the user has share permission
675
			if (!\OC\Files\Filesystem::isSharable($path) || \OCP\Util::isSharingDisabledForUser()) {
676
				$message = 'You are not allowed to share %s';
677
				$message_t = $l->t('You are not allowed to share %s', [$path]);
678
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $path), \OCP\Util::DEBUG);
679
				throw new \Exception($message_t);
680
			}
681
		}
682
683
		//verify that we don't share a folder which already contains a share mount point
@@ 726-731 (lines=6) @@
723
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG);
724
				throw new \Exception($message_t);
725
			}
726
			if (!\OC_User::userExists($shareWith)) {
727
				$message = 'Sharing %s failed, because the user %s does not exist';
728
				$message_t = $l->t('Sharing %s failed, because the user %s does not exist', [$itemSourceName, $shareWith]);
729
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
730
				throw new \Exception($message_t);
731
			}
732
			if ($shareWithinGroupOnly) {
733
				$inGroup = array_intersect(self::getGroupsForUser($uidOwner), self::getGroupsForUser($shareWith));
734
				if (empty($inGroup)) {
@@ 897-902 (lines=6) @@
894
			list($user, $remote) = Helper::splitUserRemote($shareWith);
895
			$currentServer = self::removeProtocolFromUrl(\OC::$server->getURLGenerator()->getAbsoluteURL('/'));
896
			$currentUser = \OC::$server->getUserSession()->getUser()->getUID();
897
			if (Helper::isSameUserOnSameServer($user, $remote, $currentUser, $currentServer)) {
898
				$message = 'Not allowed to create a federated share with the same user.';
899
				$message_t = $l->t('Not allowed to create a federated share with the same user');
900
				\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG);
901
				throw new \Exception($message_t);
902
			}
903
904
			$token = \OC::$server->getSecureRandom()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
905
				\OCP\Security\ISecureRandom::CHAR_DIGITS);
@@ 1560-1565 (lines=6) @@
1557
			$class = self::$backendTypes[$itemType]['class'];
1558
			if (class_exists($class)) {
1559
				self::$backends[$itemType] = new $class;
1560
				if (!(self::$backends[$itemType] instanceof \OCP\Share_Backend)) {
1561
					$message = 'Sharing backend %s must implement the interface OCP\Share_Backend';
1562
					$message_t = $l->t('Sharing backend %s must implement the interface OCP\Share_Backend', [$class]);
1563
					\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR);
1564
					throw new \Exception($message_t);
1565
				}
1566
				return self::$backends[$itemType];
1567
			} else {
1568
				$message = 'Sharing backend %s not found';