mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
refactor: Remove some deprecated containers and exceptions
Signed-off-by: nfebe <fenn25.fn@gmail.com>
This commit is contained in:
parent
7646b6b2b0
commit
ba2a1ec72f
1 changed files with 28 additions and 25 deletions
|
|
@ -45,6 +45,7 @@ use OCP\IGroupManager;
|
|||
use OCP\IL10N;
|
||||
use OCP\IPreview;
|
||||
use OCP\IRequest;
|
||||
use OCP\ITagManager;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Lock\ILockingProvider;
|
||||
|
|
@ -280,7 +281,7 @@ class ShareAPIController extends OCSController {
|
|||
/** @var array{share_with_displayname: string, share_with_link: string, share_with?: string, token?: string} $roomShare */
|
||||
$roomShare = $this->getRoomShareHelper()->formatShare($share);
|
||||
$result = array_merge($result, $roomShare);
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
}
|
||||
} elseif ($share->getShareType() === IShare::TYPE_DECK) {
|
||||
$result['share_with'] = $share->getSharedWith();
|
||||
|
|
@ -290,7 +291,7 @@ class ShareAPIController extends OCSController {
|
|||
/** @var array{share_with: string, share_with_displayname: string, share_with_link: string} $deckShare */
|
||||
$deckShare = $this->getDeckShareHelper()->formatShare($share);
|
||||
$result = array_merge($result, $deckShare);
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
}
|
||||
} elseif ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
|
||||
$result['share_with'] = $share->getSharedWith();
|
||||
|
|
@ -300,7 +301,7 @@ class ShareAPIController extends OCSController {
|
|||
/** @var array{share_with: string, share_with_displayname: string, token: string} $scienceMeshShare */
|
||||
$scienceMeshShare = $this->getSciencemeshShareHelper()->formatShare($share);
|
||||
$result = array_merge($result, $scienceMeshShare);
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -470,7 +471,7 @@ class ShareAPIController extends OCSController {
|
|||
$share = $this->formatShare($share);
|
||||
|
||||
if ($include_tags) {
|
||||
$share = Helper::populateTags([$share], \OC::$server->getTagManager());
|
||||
$share = Helper::populateTags([$share], \OCP\Server::get(ITagManager::class));
|
||||
} else {
|
||||
$share = [$share];
|
||||
}
|
||||
|
|
@ -637,7 +638,9 @@ class ShareAPIController extends OCSController {
|
|||
$share = $this->setShareAttributes($share, $attributes);
|
||||
}
|
||||
|
||||
// Expire date
|
||||
// Expire date checks
|
||||
// Normally, null means no expiration date but we still set the default for backwards compatibility
|
||||
// If the client sends an empty string, we set noExpirationDate to true
|
||||
if ($expireDate !== null) {
|
||||
if ($expireDate !== '') {
|
||||
try {
|
||||
|
|
@ -751,7 +754,7 @@ class ShareAPIController extends OCSController {
|
|||
$share->setSharedWith($shareWith);
|
||||
$share->setPermissions($permissions);
|
||||
} elseif ($shareType === IShare::TYPE_CIRCLE) {
|
||||
if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) {
|
||||
if (!\OCP\Server::get(IAppManager::class)->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) {
|
||||
throw new OCSNotFoundException($this->l->t('You cannot share to a Team if the app is not enabled'));
|
||||
}
|
||||
|
||||
|
|
@ -766,19 +769,19 @@ class ShareAPIController extends OCSController {
|
|||
} elseif ($shareType === IShare::TYPE_ROOM) {
|
||||
try {
|
||||
$this->getRoomShareHelper()->createShare($share, $shareWith, $permissions, $expireDate ?? '');
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$node->getPath()]));
|
||||
}
|
||||
} elseif ($shareType === IShare::TYPE_DECK) {
|
||||
try {
|
||||
$this->getDeckShareHelper()->createShare($share, $shareWith, $permissions, $expireDate ?? '');
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$node->getPath()]));
|
||||
}
|
||||
} elseif ($shareType === IShare::TYPE_SCIENCEMESH) {
|
||||
try {
|
||||
$this->getSciencemeshShareHelper()->createShare($share, $shareWith, $permissions, $expireDate ?? '');
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support ScienceMesh shares', [$node->getPath()]));
|
||||
}
|
||||
} else {
|
||||
|
|
@ -839,7 +842,7 @@ class ShareAPIController extends OCSController {
|
|||
}
|
||||
|
||||
if ($includeTags) {
|
||||
$formatted = Helper::populateTags($formatted, \OC::$server->getTagManager());
|
||||
$formatted = Helper::populateTags($formatted, \OCP\Server::get(ITagManager::class));
|
||||
}
|
||||
|
||||
return $formatted;
|
||||
|
|
@ -1093,7 +1096,7 @@ class ShareAPIController extends OCSController {
|
|||
|
||||
if ($includeTags) {
|
||||
$formatted =
|
||||
Helper::populateTags($formatted, \OC::$server->getTagManager());
|
||||
Helper::populateTags($formatted, \OCP\Server::get(ITagManager::class));
|
||||
}
|
||||
|
||||
return $formatted;
|
||||
|
|
@ -1522,7 +1525,7 @@ class ShareAPIController extends OCSController {
|
|||
if ($share->getShareType() === IShare::TYPE_ROOM) {
|
||||
try {
|
||||
return $this->getRoomShareHelper()->canAccessShare($share, $this->userId);
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1530,7 +1533,7 @@ class ShareAPIController extends OCSController {
|
|||
if ($share->getShareType() === IShare::TYPE_DECK) {
|
||||
try {
|
||||
return $this->getDeckShareHelper()->canAccessShare($share, $this->userId);
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1538,7 +1541,7 @@ class ShareAPIController extends OCSController {
|
|||
if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
|
||||
try {
|
||||
return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->userId);
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1656,7 +1659,7 @@ class ShareAPIController extends OCSController {
|
|||
if ($share->getShareType() === IShare::TYPE_ROOM) {
|
||||
try {
|
||||
return $this->getRoomShareHelper()->canAccessShare($share, $this->userId);
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1664,7 +1667,7 @@ class ShareAPIController extends OCSController {
|
|||
if ($share->getShareType() === IShare::TYPE_DECK) {
|
||||
try {
|
||||
return $this->getDeckShareHelper()->canAccessShare($share, $this->userId);
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1672,7 +1675,7 @@ class ShareAPIController extends OCSController {
|
|||
if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
|
||||
try {
|
||||
return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->userId);
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1798,10 +1801,10 @@ class ShareAPIController extends OCSController {
|
|||
* Returns the helper of ShareAPIController for room shares.
|
||||
*
|
||||
* If the Talk application is not enabled or the helper is not available
|
||||
* a QueryException is thrown instead.
|
||||
* a ContainerExceptionInterface is thrown instead.
|
||||
*
|
||||
* @return \OCA\Talk\Share\Helper\ShareAPIController
|
||||
* @throws QueryException
|
||||
* @throws ContainerExceptionInterface
|
||||
*/
|
||||
private function getRoomShareHelper() {
|
||||
if (!$this->appManager->isEnabledForUser('spreed')) {
|
||||
|
|
@ -1815,10 +1818,10 @@ class ShareAPIController extends OCSController {
|
|||
* Returns the helper of ShareAPIHelper for deck shares.
|
||||
*
|
||||
* If the Deck application is not enabled or the helper is not available
|
||||
* a QueryException is thrown instead.
|
||||
* a ContainerExceptionInterface is thrown instead.
|
||||
*
|
||||
* @return \OCA\Deck\Sharing\ShareAPIHelper
|
||||
* @throws QueryException
|
||||
* @throws ContainerExceptionInterface
|
||||
*/
|
||||
private function getDeckShareHelper() {
|
||||
if (!$this->appManager->isEnabledForUser('deck')) {
|
||||
|
|
@ -1832,10 +1835,10 @@ class ShareAPIController extends OCSController {
|
|||
* Returns the helper of ShareAPIHelper for sciencemesh shares.
|
||||
*
|
||||
* If the sciencemesh application is not enabled or the helper is not available
|
||||
* a QueryException is thrown instead.
|
||||
* a ContainerExceptionInterface is thrown instead.
|
||||
*
|
||||
* @return \OCA\Deck\Sharing\ShareAPIHelper
|
||||
* @throws QueryException
|
||||
* @throws ContainerExceptionInterface
|
||||
*/
|
||||
private function getSciencemeshShareHelper() {
|
||||
if (!$this->appManager->isEnabledForUser('sciencemesh')) {
|
||||
|
|
@ -1968,7 +1971,7 @@ class ShareAPIController extends OCSController {
|
|||
return true;
|
||||
}
|
||||
|
||||
if ($share->getShareType() === IShare::TYPE_CIRCLE && \OC::$server->getAppManager()->isEnabledForUser('circles')
|
||||
if ($share->getShareType() === IShare::TYPE_CIRCLE && \OCP\Server::get(IAppManager::class)->isEnabledForUser('circles')
|
||||
&& class_exists('\OCA\Circles\Api\v1\Circles')) {
|
||||
$hasCircleId = (str_ends_with($share->getSharedWith(), ']'));
|
||||
$shareWithStart = ($hasCircleId ? strrpos($share->getSharedWith(), '[') + 1 : 0);
|
||||
|
|
@ -1984,7 +1987,7 @@ class ShareAPIController extends OCSController {
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (QueryException $e) {
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue