Throw exception

This commit is contained in:
Roeland Jago Douma 2016-02-08 15:28:36 +01:00
parent ee65cd0bd8
commit 426a12baaa
3 changed files with 17 additions and 5 deletions

View file

@ -261,7 +261,14 @@ class Manager implements IManager {
}
// If expiredate is empty set a default one if there is a default
if ($share->getFullId() === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
$fullId = null;
try {
$fullId = $share->getFullId();
} catch (\UnexpectedValueException $e) {
// This is a new share
}
if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
$expirationDate = new \DateTime();
$expirationDate->setTime(0,0,0);
$expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
@ -360,8 +367,12 @@ class Manager implements IManager {
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP);
$existingShares = $provider->getSharesByPath($share->getNode());
foreach($existingShares as $existingShare) {
if ($existingShare->getFullId() === $share->getFullId()) {
continue;
try {
if ($existingShare->getFullId() === $share->getFullId()) {
continue;
}
} catch (\UnexpectedValueException $e) {
//It is a new share so just continue
}
if ($existingShare->getSharedWith() === $share->getSharedWith()) {

View file

@ -91,7 +91,7 @@ class Share implements \OCP\Share\IShare {
*/
public function getFullId() {
if ($this->providerId === null || $this->id === null) {
return null;
throw new \UnexpectedValueException;
}
return $this->providerId . ':' . $this->id;
}

View file

@ -46,8 +46,9 @@ interface IShare {
* Get the full share id. This is the <providerid>:<internalid>.
* The full id is unique in the system.
*
* @return string|null null is returned when the fullId can't be constructed
* @return string
* @since 9.0.0
* @throws \UnexpectedValueException If the fullId could not be constructed
*/
public function getFullId();