diff options
Diffstat (limited to 'controller')
-rw-r--r-- | controller/exportcontroller.php | 32 | ||||
-rw-r--r-- | controller/feedapicontroller.php | 62 | ||||
-rw-r--r-- | controller/feedcontroller.php | 80 | ||||
-rw-r--r-- | controller/folderapicontroller.php | 46 | ||||
-rw-r--r-- | controller/foldercontroller.php | 66 | ||||
-rw-r--r-- | controller/itemapicontroller.php | 32 | ||||
-rw-r--r-- | controller/itemcontroller.php | 58 |
7 files changed, 186 insertions, 190 deletions
diff --git a/controller/exportcontroller.php b/controller/exportcontroller.php index 4652fa9a4..f5f97ee71 100644 --- a/controller/exportcontroller.php +++ b/controller/exportcontroller.php @@ -20,31 +20,31 @@ use \OCP\AppFramework\Http\JSONResponse; use \OCP\AppFramework\Http\Response; use \OCA\News\Http\TextDownloadResponse; -use \OCA\News\BusinessLayer\FeedBusinessLayer; -use \OCA\News\BusinessLayer\FolderBusinessLayer; -use \OCA\News\BusinessLayer\ItemBusinessLayer; +use \OCA\News\Service\FolderService; +use \OCA\News\Service\FeedService; +use \OCA\News\Service\ItemService; use \OCA\News\Utility\OPMLExporter; class ExportController extends Controller { private $opmlExporter; - private $folderBusinessLayer; - private $feedBusinessLayer; - private $itemBusinessLayer; + private $folderService; + private $feedService; + private $itemService; private $userId; public function __construct($appName, IRequest $request, - FeedBusinessLayer $feedBusinessLayer, - FolderBusinessLayer $folderBusinessLayer, - ItemBusinessLayer $itemBusinessLayer, + FolderService $folderService, + FeedService $feedService, + ItemService $itemService, OPMLExporter $opmlExporter, $userId){ parent::__construct($appName, $request); - $this->feedBusinessLayer = $feedBusinessLayer; - $this->folderBusinessLayer = $folderBusinessLayer; + $this->feedService = $feedService; + $this->folderService = $folderService; $this->opmlExporter = $opmlExporter; - $this->itemBusinessLayer = $itemBusinessLayer; + $this->itemService = $itemService; $this->userId = $userId; } @@ -54,8 +54,8 @@ class ExportController extends Controller { * @NoCSRFRequired */ public function opml(){ - $feeds = $this->feedBusinessLayer->findAll($this->userId); - $folders = $this->folderBusinessLayer->findAll($this->userId); + $feeds = $this->feedService->findAll($this->userId); + $folders = $this->folderService->findAll($this->userId); $opml = $this->opmlExporter->build($folders, $feeds)->saveXML(); return new TextDownloadResponse($opml, 'subscriptions.opml', 'text/xml'); } @@ -66,8 +66,8 @@ class ExportController extends Controller { * @NoCSRFRequired */ public function articles(){ - $feeds = $this->feedBusinessLayer->findAll($this->userId); - $items = $this->itemBusinessLayer->getUnreadOrStarred($this->userId); + $feeds = $this->feedService->findAll($this->userId); + $items = $this->itemService->getUnreadOrStarred($this->userId); // build assoc array for fast access $feedsDict = []; diff --git a/controller/feedapicontroller.php b/controller/feedapicontroller.php index 750d504af..c6b5b6866 100644 --- a/controller/feedapicontroller.php +++ b/controller/feedapicontroller.php @@ -18,36 +18,32 @@ use \OCP\ILogger; use \OCP\AppFramework\ApiController; use \OCP\AppFramework\Http; -use \OCA\News\BusinessLayer\FeedBusinessLayer; -use \OCA\News\BusinessLayer\FolderBusinessLayer; -use \OCA\News\BusinessLayer\ItemBusinessLayer; -use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerConflictException; +use \OCA\News\Service\FeedService; +use \OCA\News\Service\ItemService; +use \OCA\News\Service\ServiceNotFoundException; +use \OCA\News\Service\ServiceConflictException; class FeedApiController extends ApiController { use JSONHttpError; - private $itemBusinessLayer; - private $feedBusinessLayer; - private $folderBusinessLayer; + private $itemService; + private $feedService; private $userId; private $logger; private $loggerParams; public function __construct($appName, IRequest $request, - FolderBusinessLayer $folderBusinessLayer, - FeedBusinessLayer $feedBusinessLayer, - ItemBusinessLayer $itemBusinessLayer, + FeedService $feedService, + ItemService $itemService, ILogger $logger, $userId, $loggerParams){ parent::__construct($appName, $request); - $this->folderBusinessLayer = $folderBusinessLayer; - $this->feedBusinessLayer = $feedBusinessLayer; - $this->itemBusinessLayer = $itemBusinessLayer; + $this->feedService = $feedService; + $this->itemService = $itemService; $this->userId = $userId; $this->logger = $logger; $this->loggerParams = $loggerParams; @@ -64,16 +60,16 @@ class FeedApiController extends ApiController { $result = [ 'feeds' => [], - 'starredCount' => $this->itemBusinessLayer->starredCount($this->userId), - 'feeds' => $this->feedBusinessLayer->findAll($this->userId) + 'starredCount' => $this->itemService->starredCount($this->userId), + 'feeds' => $this->feedService->findAll($this->userId) ]; try { - $result['newestItemId'] = $this->itemBusinessLayer->getNewestItemId($this->userId); + $result['newestItemId'] = $this->itemService->getNewestItemId($this->userId); // in case there are no items, ignore - } catch(BusinessLayerException $ex) {} + } catch(ServiceNotFoundException $ex) {} return $result; } @@ -89,22 +85,22 @@ class FeedApiController extends ApiController { */ public function create($url, $folderId=0) { try { - $this->feedBusinessLayer->purgeDeleted($this->userId, false); + $this->feedService->purgeDeleted($this->userId, false); - $feed = $this->feedBusinessLayer->create($url, $folderId, $this->userId); + $feed = $this->feedService->create($url, $folderId, $this->userId); $result = ['feeds' => [$feed]]; try { - $result['newestItemId'] = $this->itemBusinessLayer->getNewestItemId($this->userId); + $result['newestItemId'] = $this->itemService->getNewestItemId($this->userId); // in case there are no items, ignore - } catch(BusinessLayerException $ex) {} + } catch(ServiceNotFoundException $ex) {} return $result; - } catch(BusinessLayerConflictException $ex) { + } catch(ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch(BusinessLayerException $ex) { + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -119,8 +115,8 @@ class FeedApiController extends ApiController { */ public function delete($feedId) { try { - $this->feedBusinessLayer->delete($feedId, $this->userId); - } catch(BusinessLayerException $ex) { + $this->feedService->delete($feedId, $this->userId); + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -135,7 +131,7 @@ class FeedApiController extends ApiController { * @param int $newestItemId */ public function read($feedId, $newestItemId) { - $this->itemBusinessLayer->readFeed($feedId, $newestItemId, $this->userId); + $this->itemService->readFeed($feedId, $newestItemId, $this->userId); } @@ -149,8 +145,8 @@ class FeedApiController extends ApiController { */ public function move($feedId, $folderId) { try { - $this->feedBusinessLayer->move($feedId, $folderId, $this->userId); - } catch(BusinessLayerException $ex) { + $this->feedService->move($feedId, $folderId, $this->userId); + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -166,8 +162,8 @@ class FeedApiController extends ApiController { */ public function rename($feedId, $feedTitle) { try { - $this->feedBusinessLayer->rename($feedId, $feedTitle, $this->userId); - } catch(BusinessLayerException $ex) { + $this->feedService->rename($feedId, $feedTitle, $this->userId); + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -178,7 +174,7 @@ class FeedApiController extends ApiController { * @CORS */ public function fromAllUsers() { - $feeds = $this->feedBusinessLayer->findAllFromAllUsers(); + $feeds = $this->feedService->findAllFromAllUsers(); $result = ['feeds' => []]; foreach ($feeds as $feed) { @@ -200,7 +196,7 @@ class FeedApiController extends ApiController { */ public function update($userId, $feedId) { try { - $this->feedBusinessLayer->update($feedId, $userId); + $this->feedService->update($feedId, $userId); // ignore update failure (feed could not be reachable etc, we dont care) } catch(\Exception $ex) { $this->logger->debug('Could not update feed ' . $ex->getMessage(), diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php index 9b5274fb5..c31d4d1d6 100644 --- a/controller/feedcontroller.php +++ b/controller/feedcontroller.php @@ -18,11 +18,11 @@ use \OCP\IConfig; use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http; -use \OCA\News\BusinessLayer\ItemBusinessLayer; -use \OCA\News\BusinessLayer\FeedBusinessLayer; -use \OCA\News\BusinessLayer\FolderBusinessLayer; -use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerConflictException; +use \OCA\News\Service\ItemService; +use \OCA\News\Service\FeedService; +use \OCA\News\Service\FolderService; +use \OCA\News\Service\ServiceNotFoundException; +use \OCA\News\Service\ServiceConflictException; use \OCA\News\Db\FeedType; @@ -30,23 +30,23 @@ class FeedController extends Controller { use JSONHttpError; - private $feedBusinessLayer; - private $folderBusinessLayer; - private $itemBusinessLayer; + private $feedService; + private $folderService; + private $itemService; private $userId; private $settings; public function __construct($appName, IRequest $request, - FolderBusinessLayer $folderBusinessLayer, - FeedBusinessLayer $feedBusinessLayer, - ItemBusinessLayer $itemBusinessLayer, + FolderService $folderService, + FeedService $feedService, + ItemService $itemService, IConfig $settings, $userId){ parent::__construct($appName, $request); - $this->feedBusinessLayer = $feedBusinessLayer; - $this->folderBusinessLayer = $folderBusinessLayer; - $this->itemBusinessLayer = $itemBusinessLayer; + $this->feedService = $feedService; + $this->folderService = $folderService; + $this->itemService = $itemService; $this->userId = $userId; $this->settings = $settings; } @@ -61,17 +61,17 @@ class FeedController extends Controller { // because of this we also pass the starred count and the newest // item id which will be used for marking feeds read $params = [ - 'feeds' => $this->feedBusinessLayer->findAll($this->userId), - 'starred' => $this->itemBusinessLayer->starredCount($this->userId) + 'feeds' => $this->feedService->findAll($this->userId), + 'starred' => $this->itemService->starredCount($this->userId) ]; try { $params['newestItemId'] = - $this->itemBusinessLayer->getNewestItemId($this->userId); + $this->itemService->getNewestItemId($this->userId); // An exception occurs if there is a newest item. If there is none, // simply ignore it and do not add the newestItemId - } catch (BusinessLayerException $ex) {} + } catch (ServiceNotFoundException $ex) {} return $params; } @@ -94,17 +94,17 @@ class FeedController extends Controller { // check if feed or folder exists try { if($feedType === FeedType::FOLDER){ - $this->folderBusinessLayer->find($feedId, $this->userId); + $this->folderService->find($feedId, $this->userId); } elseif ($feedType === FeedType::FEED){ - $this->feedBusinessLayer->find($feedId, $this->userId); + $this->feedService->find($feedId, $this->userId); // if its the first launch, those values will be null } elseif($feedType === null){ - throw new BusinessLayerException(''); + throw new ServiceNotFoundException(''); } - } catch (BusinessLayerException $ex){ + } catch (ServiceNotFoundException $ex){ $feedId = 0; $feedType = FeedType::SUBSCRIPTIONS; } @@ -128,24 +128,24 @@ class FeedController extends Controller { try { // we need to purge deleted feeds if a feed is created to // prevent already exists exceptions - $this->feedBusinessLayer->purgeDeleted($this->userId, false); + $this->feedService->purgeDeleted($this->userId, false); - $feed = $this->feedBusinessLayer->create($url, $parentFolderId, $this->userId); + $feed = $this->feedService->create($url, $parentFolderId, $this->userId); $params = ['feeds' => [$feed]]; try { $params['newestItemId'] = - $this->itemBusinessLayer->getNewestItemId($this->userId); + $this->itemService->getNewestItemId($this->userId); // An exception occurs if there is a newest item. If there is none, // simply ignore it and do not add the newestItemId - } catch (BusinessLayerException $ex) {} + } catch (ServiceNotFoundException $ex) {} return $params; - } catch(BusinessLayerConflictException $ex) { + } catch(ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch(BusinessLayerException $ex) { + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); } } @@ -158,8 +158,8 @@ class FeedController extends Controller { */ public function delete($feedId){ try { - $this->feedBusinessLayer->markDeleted($feedId, $this->userId); - } catch(BusinessLayerException $ex) { + $this->feedService->markDeleted($feedId, $this->userId); + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -172,7 +172,7 @@ class FeedController extends Controller { */ public function update($feedId){ try { - $feed = $this->feedBusinessLayer->update($feedId, $this->userId); + $feed = $this->feedService->update($feedId, $this->userId); return [ 'feeds' => [ @@ -185,7 +185,7 @@ class FeedController extends Controller { ] ]; - } catch(BusinessLayerException $ex) { + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -199,8 +199,8 @@ class FeedController extends Controller { */ public function move($feedId, $parentFolderId){ try { - $this->feedBusinessLayer->move($feedId, $parentFolderId, $this->userId); - } catch(BusinessLayerException $ex) { + $this->feedService->move($feedId, $parentFolderId, $this->userId); + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -213,8 +213,8 @@ class FeedController extends Controller { */ public function rename($feedId, $feedTitle) { try { - $this->feedBusinessLayer->rename($feedId, $feedTitle, $this->userId); - } catch(BusinessLayerException $ex) { + $this->feedService->rename($feedId, $feedTitle, $this->userId); + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -226,7 +226,7 @@ class FeedController extends Controller { * @param array $json */ public function import($json) { - $feed = $this->feedBusinessLayer->importArticles($json, $this->userId); + $feed = $this->feedService->importArticles($json, $this->userId); $params = []; @@ -245,7 +245,7 @@ class FeedController extends Controller { * @param int $highestItemId */ public function read($feedId, $highestItemId){ - $this->itemBusinessLayer->readFeed($feedId, $highestItemId, $this->userId); + $this->itemService->readFeed($feedId, $highestItemId, $this->userId); return [ 'feeds' => [ @@ -265,8 +265,8 @@ class FeedController extends Controller { */ public function restore($feedId){ try { - $this->feedBusinessLayer->unmarkDeleted($feedId, $this->userId); - } catch(BusinessLayerException $ex) { + $this->feedService->unmarkDeleted($feedId, $this->userId); + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } diff --git a/controller/folderapicontroller.php b/controller/folderapicontroller.php index feb901204..c5ed2b05a 100644 --- a/controller/folderapicontroller.php +++ b/controller/folderapicontroller.php @@ -17,29 +17,29 @@ use \OCP\IRequest; use \OCP\AppFramework\ApiController; use \OCP\AppFramework\Http; -use \OCA\News\BusinessLayer\FolderBusinessLayer; -use \OCA\News\BusinessLayer\ItemBusinessLayer; -use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerConflictException; -use \OCA\News\BusinessLayer\BusinessLayerValidationException; +use \OCA\News\Service\FolderService; +use \OCA\News\Service\ItemService; +use \OCA\News\Service\ServiceNotFoundException; +use \OCA\News\Service\ServiceConflictException; +use \OCA\News\Service\ServiceValidationException; class FolderApiController extends ApiController { use JSONHttpError; - private $folderBusinessLayer; - private $itemBusinessLayer; + private $folderService; + private $itemService; private $userId; public function __construct($appName, IRequest $request, - FolderBusinessLayer $folderBusinessLayer, - ItemBusinessLayer $itemBusinessLayer, + FolderService $folderService, + ItemService $itemService, $userId){ parent::__construct($appName, $request); - $this->folderBusinessLayer = $folderBusinessLayer; - $this->itemBusinessLayer = $itemBusinessLayer; + $this->folderService = $folderService; + $this->itemService = $itemService; $this->userId = $userId; $this->registerSerializer(new EntityApiSerializer('folders')); } @@ -51,7 +51,7 @@ class FolderApiController extends ApiController { * @CORS */ public function index() { - return $this->folderBusinessLayer->findAll($this->userId); + return $this->folderService->findAll($this->userId); } @@ -64,11 +64,11 @@ class FolderApiController extends ApiController { */ public function create($name) { try { - $this->folderBusinessLayer->purgeDeleted($this->userId, false); - return $this->folderBusinessLayer->create($name, $this->userId); - } catch(BusinessLayerValidationException $ex) { + $this->folderService->purgeDeleted($this->userId, false); + return $this->folderService->create($name, $this->userId); + } catch(ServiceValidationException $ex) { return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); - } catch(BusinessLayerConflictException $ex) { + } catch(ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); } } @@ -83,8 +83,8 @@ class FolderApiController extends ApiController { */ public function delete($folderId) { try { - $this->folderBusinessLayer->delete($folderId, $this->userId); - } catch(BusinessLayerException $ex) { + $this->folderService->delete($folderId, $this->userId); + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -99,13 +99,13 @@ class FolderApiController extends ApiController { */ public function update($folderId, $name) { try { - $this->folderBusinessLayer->rename($folderId, $name, $this->userId); + $this->folderService->rename($folderId, $name, $this->userId); - } catch(BusinessLayerValidationException $ex) { + } catch(ServiceValidationException $ex) { return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); - } catch(BusinessLayerConflictException $ex) { + } catch(ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch(BusinessLayerException $ex) { + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -120,7 +120,7 @@ class FolderApiController extends ApiController { * @param int $newestItemId */ public function read($folderId, $newestItemId) { - $this->itemBusinessLayer->readFolder($folderId, $newestItemId, $this->userId); + $this->itemService->readFolder($folderId, $newestItemId, $this->userId); } diff --git a/controller/foldercontroller.php b/controller/foldercontroller.php index 4cfc819b1..4a19ab513 100644 --- a/controller/foldercontroller.php +++ b/controller/foldercontroller.php @@ -17,33 +17,33 @@ use \OCP\IRequest; use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http; -use \OCA\News\BusinessLayer\FolderBusinessLayer; -use \OCA\News\BusinessLayer\FeedBusinessLayer; -use \OCA\News\BusinessLayer\ItemBusinessLayer; -use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerConflictException; -use \OCA\News\BusinessLayer\BusinessLayerValidationException; +use \OCA\News\Service\FolderService; +use \OCA\News\Service\FeedService; +use \OCA\News\Service\ItemService; +use \OCA\News\Service\ServiceNotFoundException; +use \OCA\News\Service\ServiceConflictException; +use \OCA\News\Service\ServiceValidationException; class FolderController extends Controller { use JSONHttpError; - private $folderBusinessLayer; - private $feedBusinessLayer; - private $itemBusinessLayer; + private $folderService; + private $feedService; + private $itemService; private $userId; public function __construct($appName, IRequest $request, - FolderBusinessLayer $folderBusinessLayer, - FeedBusinessLayer $feedBusinessLayer, - ItemBusinessLayer $itemBusinessLayer, + FolderService $folderService, + FeedService $feedService, + ItemService $itemService, $userId){ parent::__construct($appName, $request); - $this->folderBusinessLayer = $folderBusinessLayer; - $this->feedBusinessLayer = $feedBusinessLayer; - $this->itemBusinessLayer = $itemBusinessLayer; + $this->folderService = $folderService; + $this->feedService = $feedService; + $this->itemService = $itemService; $this->userId = $userId; } @@ -52,13 +52,13 @@ class FolderController extends Controller { * @NoAdminRequired */ public function index(){ - $folders = $this->folderBusinessLayer->findAll($this->userId); + $folders = $this->folderService->findAll($this->userId); return ['folders' => $folders]; } private function setOpened($isOpened, $folderId){ - $this->folderBusinessLayer->open($folderId, $isOpened, $this->userId); + $this->folderService->open($folderId, $isOpened, $this->userId); } @@ -70,7 +70,7 @@ class FolderController extends Controller { public function open($folderId){ try { $this->setOpened(true, $folderId); - } catch(BusinessLayerException $ex) { + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -84,7 +84,7 @@ class FolderController extends Controller { public function collapse($folderId){ try { $this->setOpened(false, $folderId); - } catch(BusinessLayerException $ex) { + } catch(ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -99,14 +99,14 @@ class FolderController extends Controller { try { // we need to purge deleted folders if a folder is created to // prevent already exists exceptions - $this->folderBusinessLayer->purgeDeleted($this->userId, false); - $folder = $this->folderBusinessLayer->create($folderName, $this->userId); + $this->folderService->purgeDeleted($this->userId, false); + $folder = $this->folderService->create($folderName, $this->userId); return ['folders' => [$folder]]; - } catch(BusinessLayerConflictException $ex) { + } catch(ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch(BusinessLayerValidationException $ex) { + } catch(ServiceValidationException $ex) { return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); } @@ -120,8 +120,8 @@ class FolderController extends Controller { */ public function delete($folderId){ try { - $this->folderBusinessLayer->markDeleted($folderId, $this->userId); - } catch (BusinessLayerException $ex){ + $this->folderService->markDeleted($folderId, $this->userId); + } catch (ServiceNotFoundException $ex){ return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -135,16 +135,16 @@ class FolderController extends Controller { */ public function rename($folderName, $folderId){ try { - $folder = $this->folderBusinessLayer->rename($folderId, $folderName, + $folder = $this->folderService->rename($folderId, $folderName, $this->userId); return ['folders' => [$folder]]; - } catch(BusinessLayerConflictException $ex) { + } catch(ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch(BusinessLayerValidationException $ex) { + } catch(ServiceValidationException $ex) { return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); - } catch (BusinessLayerException $ex){ + } catch (ServiceNotFoundException $ex){ return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -156,9 +156,9 @@ class FolderController extends Controller { * @param int $highestItemId */ public function read($folderId, $highestItemId){ - $this->itemBusinessLayer->readFolder($folderId, $highestItemId, $this->userId); + $this->itemService->readFolder($folderId, $highestItemId, $this->userId); - return ['feeds' => $this->feedBusinessLayer->findAll($this->userId)]; + return ['feeds' => $this->feedService->findAll($this->userId)]; } @@ -169,8 +169,8 @@ class FolderController extends Controller { */ public function restore($folderId){ try { - $this->folderBusinessLayer->unmarkDeleted($folderId, $this->userId); - } catch (BusinessLayerException $ex){ + $this->folderService->unmarkDeleted($folderId, $this->userId); + } catch (ServiceNotFoundException $ex){ return $this->error($ex, Http::STATUS_NOT_FOUND); } } diff --git a/controller/itemapicontroller.php b/controller/itemapicontroller.php index 8110c3ab0..da4596d1e 100644 --- a/controller/itemapicontroller.php +++ b/controller/itemapicontroller.php @@ -17,22 +17,22 @@ use \OCP\IRequest; use \OCP\AppFramework\ApiController; use \OCP\AppFramework\Http; -use \OCA\News\BusinessLayer\ItemBusinessLayer; -use \OCA\News\BusinessLayer\BusinessLayerException; +use \OCA\News\Service\ItemService; +use \OCA\News\Service\ServiceNotFoundException; class ItemApiController extends ApiController { use JSONHttpError; - private $itemBusinessLayer; + private $itemService; private $userId; public function __construct($appName, IRequest $request, - ItemBusinessLayer $itemBusinessLayer, + ItemService $itemService, $userId){ parent::__construct($appName, $request); - $this->itemBusinessLayer = $itemBusinessLayer; + $this->itemService = $itemService; $this->userId = $userId; $this->registerSerializer(new EntityApiSerializer('items')); } @@ -50,7 +50,7 @@ class ItemApiController extends ApiController { * @param int $offset */ public function index($type, $id, $getRead, $batchSize=20, $offset=0) { - return $this->itemBusinessLayer->findAll($id, $type, $batchSize, $offset, + return $this->itemService->findAll($id, $type, $batchSize, $offset, $getRead, $this->userId); } @@ -65,15 +65,15 @@ class ItemApiController extends ApiController { * @param int $lastModified */ public function updated($type, $id, $lastModified=0) { - return $this->itemBusinessLayer->findAllNew($id, $type, $lastModified, + return $this->itemService->findAllNew($id, $type, $lastModified, true, $this->userId); } private function setRead($isRead, $itemId) { try { - $this->itemBusinessLayer->read($itemId, $isRead, $this->userId); - } catch(BusinessLayerException $ex){ + $this->itemService->read($itemId, $isRead, $this->userId); + } catch(ServiceNotFoundException $ex){ return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -105,8 +105,8 @@ class ItemApiController extends ApiController { private function setStarred($isStarred, $feedId, $guidHash) { try { - $this->itemBusinessLayer->star($feedId, $guidHash, $isStarred, $this->userId); - } catch(BusinessLayerException $ex){ + $this->itemService->star($feedId, $guidHash, $isStarred, $this->userId); + } catch(ServiceNotFoundException $ex){ return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -146,15 +146,15 @@ class ItemApiController extends ApiController { * @param int $newestItemId */ public function readAll($newestItemId) { - $this->itemBusinessLayer->readAll($newestItemId, $this->userId); + $this->itemService->readAll($newestItemId, $this->userId); } private function setMultipleRead($isRead, $items) { foreach($items as $id) { try { - $this->itemBusinessLayer->read($id, $isRead, $this->userId); - } catch(BusinessLayerException $ex) { + $this->itemService->read($id, $isRead, $this->userId); + } catch(ServiceNotFoundException $ex) { continue; } } @@ -188,9 +188,9 @@ class ItemApiController extends ApiController { private function setMultipleStarred($isStarred, $items) { foreach($items as $item) { try { - $this->itemBusinessLayer->star($item['feedId'], $item['guidHash'], + $this->itemService->star($item['feedId'], $item['guidHash'], $isStarred, $this->userId); - } catch(BusinessLayerException $ex) { + } catch(ServiceNotFoundException $ex) { continue; } } diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php index 0f590950e..c27add3cb 100644 --- a/controller/itemcontroller.php +++ b/controller/itemcontroller.php @@ -18,29 +18,29 @@ use \OCP\IConfig; use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http; -use \OCA\News\BusinessLayer\Busines |