4545use OCP \IL10N ;
4646use OCP \IPreview ;
4747use OCP \IRequest ;
48+ use OCP \ITagManager ;
4849use OCP \IURLGenerator ;
4950use OCP \IUserManager ;
5051use OCP \Lock \ILockingProvider ;
@@ -280,7 +281,7 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
280281 /** @var array{share_with_displayname: string, share_with_link: string, share_with?: string, token?: string} $roomShare */
281282 $ roomShare = $ this ->getRoomShareHelper ()->formatShare ($ share );
282283 $ result = array_merge ($ result , $ roomShare );
283- } catch (QueryException $ e ) {
284+ } catch (ContainerExceptionInterface $ e ) {
284285 }
285286 } elseif ($ share ->getShareType () === IShare::TYPE_DECK ) {
286287 $ result ['share_with ' ] = $ share ->getSharedWith ();
@@ -290,7 +291,7 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
290291 /** @var array{share_with: string, share_with_displayname: string, share_with_link: string} $deckShare */
291292 $ deckShare = $ this ->getDeckShareHelper ()->formatShare ($ share );
292293 $ result = array_merge ($ result , $ deckShare );
293- } catch (QueryException $ e ) {
294+ } catch (ContainerExceptionInterface $ e ) {
294295 }
295296 } elseif ($ share ->getShareType () === IShare::TYPE_SCIENCEMESH ) {
296297 $ result ['share_with ' ] = $ share ->getSharedWith ();
@@ -300,7 +301,7 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
300301 /** @var array{share_with: string, share_with_displayname: string, token: string} $scienceMeshShare */
301302 $ scienceMeshShare = $ this ->getSciencemeshShareHelper ()->formatShare ($ share );
302303 $ result = array_merge ($ result , $ scienceMeshShare );
303- } catch (QueryException $ e ) {
304+ } catch (ContainerExceptionInterface $ e ) {
304305 }
305306 }
306307
@@ -470,7 +471,7 @@ public function getShare(string $id, bool $include_tags = false): DataResponse {
470471 $ share = $ this ->formatShare ($ share );
471472
472473 if ($ include_tags ) {
473- $ share = Helper::populateTags ([$ share ], \OC :: $ server -> getTagManager ( ));
474+ $ share = Helper::populateTags ([$ share ], \OCP \Server:: get (ITagManager::class ));
474475 } else {
475476 $ share = [$ share ];
476477 }
@@ -637,7 +638,9 @@ public function createShare(
637638 $ share = $ this ->setShareAttributes ($ share , $ attributes );
638639 }
639640
640- // Expire date
641+ // Expire date checks
642+ // Normally, null means no expiration date but we still set the default for backwards compatibility
643+ // If the client sends an empty string, we set noExpirationDate to true
641644 if ($ expireDate !== null ) {
642645 if ($ expireDate !== '' ) {
643646 try {
@@ -751,7 +754,7 @@ public function createShare(
751754 $ share ->setSharedWith ($ shareWith );
752755 $ share ->setPermissions ($ permissions );
753756 } elseif ($ shareType === IShare::TYPE_CIRCLE ) {
754- if (!\OC :: $ server -> getAppManager ( )->isEnabledForUser ('circles ' ) || !class_exists ('\OCA\Circles\ShareByCircleProvider ' )) {
757+ if (!\OCP \Server:: get (IAppManager::class )->isEnabledForUser ('circles ' ) || !class_exists ('\OCA\Circles\ShareByCircleProvider ' )) {
755758 throw new OCSNotFoundException ($ this ->l ->t ('You cannot share to a Team if the app is not enabled ' ));
756759 }
757760
@@ -766,19 +769,19 @@ public function createShare(
766769 } elseif ($ shareType === IShare::TYPE_ROOM ) {
767770 try {
768771 $ this ->getRoomShareHelper ()->createShare ($ share , $ shareWith , $ permissions , $ expireDate ?? '' );
769- } catch (QueryException $ e ) {
772+ } catch (ContainerExceptionInterface $ e ) {
770773 throw new OCSForbiddenException ($ this ->l ->t ('Sharing %s failed because the back end does not support room shares ' , [$ node ->getPath ()]));
771774 }
772775 } elseif ($ shareType === IShare::TYPE_DECK ) {
773776 try {
774777 $ this ->getDeckShareHelper ()->createShare ($ share , $ shareWith , $ permissions , $ expireDate ?? '' );
775- } catch (QueryException $ e ) {
778+ } catch (ContainerExceptionInterface $ e ) {
776779 throw new OCSForbiddenException ($ this ->l ->t ('Sharing %s failed because the back end does not support room shares ' , [$ node ->getPath ()]));
777780 }
778781 } elseif ($ shareType === IShare::TYPE_SCIENCEMESH ) {
779782 try {
780783 $ this ->getSciencemeshShareHelper ()->createShare ($ share , $ shareWith , $ permissions , $ expireDate ?? '' );
781- } catch (QueryException $ e ) {
784+ } catch (ContainerExceptionInterface $ e ) {
782785 throw new OCSForbiddenException ($ this ->l ->t ('Sharing %s failed because the back end does not support ScienceMesh shares ' , [$ node ->getPath ()]));
783786 }
784787 } else {
@@ -839,7 +842,7 @@ private function getSharedWithMe($node, bool $includeTags): array {
839842 }
840843
841844 if ($ includeTags ) {
842- $ formatted = Helper::populateTags ($ formatted , \OC :: $ server -> getTagManager ( ));
845+ $ formatted = Helper::populateTags ($ formatted , \OCP \Server:: get (ITagManager::class ));
843846 }
844847
845848 return $ formatted ;
@@ -1093,7 +1096,7 @@ private function getFormattedShares(
10931096
10941097 if ($ includeTags ) {
10951098 $ formatted =
1096- Helper::populateTags ($ formatted , \OC :: $ server -> getTagManager ( ));
1099+ Helper::populateTags ($ formatted , \OCP \Server:: get (ITagManager::class ));
10971100 }
10981101
10991102 return $ formatted ;
@@ -1522,23 +1525,23 @@ protected function canAccessShare(IShare $share, bool $checkGroups = true): bool
15221525 if ($ share ->getShareType () === IShare::TYPE_ROOM ) {
15231526 try {
15241527 return $ this ->getRoomShareHelper ()->canAccessShare ($ share , $ this ->userId );
1525- } catch (QueryException $ e ) {
1528+ } catch (ContainerExceptionInterface $ e ) {
15261529 return false ;
15271530 }
15281531 }
15291532
15301533 if ($ share ->getShareType () === IShare::TYPE_DECK ) {
15311534 try {
15321535 return $ this ->getDeckShareHelper ()->canAccessShare ($ share , $ this ->userId );
1533- } catch (QueryException $ e ) {
1536+ } catch (ContainerExceptionInterface $ e ) {
15341537 return false ;
15351538 }
15361539 }
15371540
15381541 if ($ share ->getShareType () === IShare::TYPE_SCIENCEMESH ) {
15391542 try {
15401543 return $ this ->getSciencemeshShareHelper ()->canAccessShare ($ share , $ this ->userId );
1541- } catch (QueryException $ e ) {
1544+ } catch (ContainerExceptionInterface $ e ) {
15421545 return false ;
15431546 }
15441547 }
@@ -1656,23 +1659,23 @@ protected function canDeleteShareFromSelf(IShare $share): bool {
16561659 if ($ share ->getShareType () === IShare::TYPE_ROOM ) {
16571660 try {
16581661 return $ this ->getRoomShareHelper ()->canAccessShare ($ share , $ this ->userId );
1659- } catch (QueryException $ e ) {
1662+ } catch (ContainerExceptionInterface $ e ) {
16601663 return false ;
16611664 }
16621665 }
16631666
16641667 if ($ share ->getShareType () === IShare::TYPE_DECK ) {
16651668 try {
16661669 return $ this ->getDeckShareHelper ()->canAccessShare ($ share , $ this ->userId );
1667- } catch (QueryException $ e ) {
1670+ } catch (ContainerExceptionInterface $ e ) {
16681671 return false ;
16691672 }
16701673 }
16711674
16721675 if ($ share ->getShareType () === IShare::TYPE_SCIENCEMESH ) {
16731676 try {
16741677 return $ this ->getSciencemeshShareHelper ()->canAccessShare ($ share , $ this ->userId );
1675- } catch (QueryException $ e ) {
1678+ } catch (ContainerExceptionInterface $ e ) {
16761679 return false ;
16771680 }
16781681 }
@@ -1798,10 +1801,10 @@ public function cleanup() {
17981801 * Returns the helper of ShareAPIController for room shares.
17991802 *
18001803 * If the Talk application is not enabled or the helper is not available
1801- * a QueryException is thrown instead.
1804+ * a ContainerExceptionInterface is thrown instead.
18021805 *
18031806 * @return \OCA\Talk\Share\Helper\ShareAPIController
1804- * @throws QueryException
1807+ * @throws ContainerExceptionInterface
18051808 */
18061809 private function getRoomShareHelper () {
18071810 if (!$ this ->appManager ->isEnabledForUser ('spreed ' )) {
@@ -1815,10 +1818,10 @@ private function getRoomShareHelper() {
18151818 * Returns the helper of ShareAPIHelper for deck shares.
18161819 *
18171820 * If the Deck application is not enabled or the helper is not available
1818- * a QueryException is thrown instead.
1821+ * a ContainerExceptionInterface is thrown instead.
18191822 *
18201823 * @return \OCA\Deck\Sharing\ShareAPIHelper
1821- * @throws QueryException
1824+ * @throws ContainerExceptionInterface
18221825 */
18231826 private function getDeckShareHelper () {
18241827 if (!$ this ->appManager ->isEnabledForUser ('deck ' )) {
@@ -1832,10 +1835,10 @@ private function getDeckShareHelper() {
18321835 * Returns the helper of ShareAPIHelper for sciencemesh shares.
18331836 *
18341837 * If the sciencemesh application is not enabled or the helper is not available
1835- * a QueryException is thrown instead.
1838+ * a ContainerExceptionInterface is thrown instead.
18361839 *
18371840 * @return \OCA\Deck\Sharing\ShareAPIHelper
1838- * @throws QueryException
1841+ * @throws ContainerExceptionInterface
18391842 */
18401843 private function getSciencemeshShareHelper () {
18411844 if (!$ this ->appManager ->isEnabledForUser ('sciencemesh ' )) {
@@ -1968,7 +1971,7 @@ private function shareProviderResharingRights(string $userId, IShare $share, $no
19681971 return true ;
19691972 }
19701973
1971- if ($ share ->getShareType () === IShare::TYPE_CIRCLE && \OC :: $ server -> getAppManager ( )->isEnabledForUser ('circles ' )
1974+ if ($ share ->getShareType () === IShare::TYPE_CIRCLE && \OCP \Server:: get (IAppManager::class )->isEnabledForUser ('circles ' )
19721975 && class_exists ('\OCA\Circles\Api\v1\Circles ' )) {
19731976 $ hasCircleId = (str_ends_with ($ share ->getSharedWith (), '] ' ));
19741977 $ shareWithStart = ($ hasCircleId ? strrpos ($ share ->getSharedWith (), '[ ' ) + 1 : 0 );
@@ -1984,7 +1987,7 @@ private function shareProviderResharingRights(string $userId, IShare $share, $no
19841987 return true ;
19851988 }
19861989 return false ;
1987- } catch (QueryException $ e ) {
1990+ } catch (ContainerExceptionInterface $ e ) {
19881991 return false ;
19891992 }
19901993 }
0 commit comments