* @throws OCSBadRequestException Invalid request or name conflict * @throws OCSForbiddenException Forbidden * @throws OCSNotFoundException Target or destination not found * * 200: Shortcut created * 400: Invalid request or name conflict * 403: Forbidden * 404: Target or destination not found */ #[NoAdminRequired] #[ApiRoute(verb: 'POST', url: '/api/v1/shortcuts')] public function create(int $fileId, string $destinationPath, ?string $name = null): DataResponse { $user = $this->userSession->getUser(); if ($user === null) { throw new OCSForbiddenException('Not logged in'); } try { return new DataResponse($this->shortcutService->create($user, $fileId, $destinationPath, $name)); } catch (ConflictException|InvalidPathException $e) { throw new OCSBadRequestException($e->getMessage()); } catch (ForbiddenException $e) { throw new OCSForbiddenException($e->getMessage()); } catch (NotFoundException $e) { throw new OCSNotFoundException($e->getMessage()); } } /** * Resolve a shortcut stub to its target * * @param int $fileId Shortcut stub file id * @return DataResponse * @throws OCSBadRequestException Invalid shortcut * @throws OCSForbiddenException Forbidden * @throws OCSNotFoundException Not found * * 200: Target resolved * 400: Invalid shortcut * 403: Forbidden * 404: Not found */ #[NoAdminRequired] #[ApiRoute(verb: 'GET', url: '/api/v1/shortcuts/resolve')] public function resolve(int $fileId): DataResponse { $user = $this->userSession->getUser(); if ($user === null) { throw new OCSForbiddenException('Not logged in'); } try { return new DataResponse($this->shortcutService->resolve($user, $fileId)); } catch (ForbiddenException $e) { throw new OCSForbiddenException($e->getMessage()); } catch (NotFoundException $e) { throw new OCSNotFoundException($e->getMessage()); } catch (InvalidPathException $e) { throw new OCSBadRequestException($e->getMessage()); } } }