Code Duplication    Length = 6-7 lines in 6 locations

lib/private/share/share.php 6 locations

@@ 566-571 (lines=6) @@
563
		if ($itemType === 'file' or $itemType === 'folder') {
564
			$path = \OC\Files\Filesystem::getPath($itemSource);
565
			// verify that the file exists before we try to share it
566
			if (!$path) {
567
				$message = 'Sharing %s failed, because the file does not exist';
568
				$message_t = $l->t('Sharing %s failed, because the file does not exist', array($itemSourceName));
569
				\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName), \OC_Log::ERROR);
570
				throw new \Exception($message_t);
571
			}
572
			// verify that the user has share permission
573
			if (!\OC\Files\Filesystem::isSharable($path)) {
574
				$message = 'You are not allowed to share %s';
@@ 765-771 (lines=7) @@
762
			}
763
764
			return $send;
765
		} else {
766
			// Future share types need to include their own conditions
767
			$message = 'Share type %s is not valid for %s';
768
			$message_t = $l->t('Share type %s is not valid for %s', array($shareType, $itemSource));
769
			\OC_Log::write('OCP\Share', sprintf($message, $shareType, $itemSource), \OC_Log::ERROR);
770
			throw new \Exception($message_t);
771
		}
772
773
		// Put the item into the database
774
		$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, null, $itemSourceName, $expirationDate);
@@ 1101-1106 (lines=6) @@
1098
			}
1099
		}
1100
1101
		if ($date < $today) {
1102
			$message = 'Cannot set expiration date. Expiration date is in the past';
1103
			$message_t = $l->t('Cannot set expiration date. Expiration date is in the past');
1104
			\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::WARN);
1105
			throw new \Exception($message_t);
1106
		}
1107
1108
		return $date;
1109
	}
@@ 1318-1323 (lines=6) @@
1315
					throw new \Exception($message_t);
1316
				}
1317
				return self::$backends[$itemType];
1318
			} else {
1319
				$message = 'Sharing backend %s not found';
1320
				$message_t = $l->t('Sharing backend %s not found', array($class));
1321
				\OC_Log::write('OCP\Share', sprintf($message, $class), \OC_Log::ERROR);
1322
				throw new \Exception($message_t);
1323
			}
1324
		}
1325
		$message = 'Sharing backend for %s not found';
1326
		$message_t = $l->t('Sharing backend for %s not found', array($itemType));
@@ 2118-2124 (lines=7) @@
2115
						$result['fileSource'] = ($backend instanceof \OCP\Share_Backend_File_Dependent) ? $itemSource : null;
2116
					}
2117
				}
2118
			} else {
2119
				$message = 'Sharing %s failed, because resharing is not allowed';
2120
				$message_t = $l->t('Sharing %s failed, because resharing is not allowed', array($itemSourceName));
2121
2122
				\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName), \OC_Log::ERROR);
2123
				throw new \Exception($message_t);
2124
			}
2125
		} else {
2126
			$result['parent'] = null;
2127
			$result['suggestedItemTarget'] = null;
@@ 2146-2152 (lines=7) @@
2143
					$meta = \OC\Files\Filesystem::getFileInfo($result['filePath']);
2144
					$result['fileSource'] = $meta['fileid'];
2145
				}
2146
				if ($result['fileSource'] == -1) {
2147
					$message = 'Sharing %s failed, because the file could not be found in the file cache';
2148
					$message_t = $l->t('Sharing %s failed, because the file could not be found in the file cache', array($itemSource));
2149
2150
					\OC_Log::write('OCP\Share', sprintf($message, $itemSource), \OC_Log::ERROR);
2151
					throw new \Exception($message_t);
2152
				}
2153
			} else {
2154
				$result['filePath'] = null;
2155
				$result['fileSource'] = null;