From 407fbebc2da14520942e0a6a9220a5a3cfc4a7ad Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 15 May 2014 03:41:49 +0200 Subject: rename businesslayer to service --- controller/exportcontroller.php | 32 +++++++-------- controller/feedapicontroller.php | 62 ++++++++++++++--------------- controller/feedcontroller.php | 80 +++++++++++++++++++------------------- controller/folderapicontroller.php | 46 +++++++++++----------- controller/foldercontroller.php | 66 +++++++++++++++---------------- controller/itemapicontroller.php | 32 +++++++-------- controller/itemcontroller.php | 58 +++++++++++++-------------- 7 files changed, 186 insertions(+), 190 deletions(-) (limited to 'controller') 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\BusinessLayerException; -use \OCA\News\BusinessLayer\ItemBusinessLayer; -use \OCA\News\BusinessLayer\FeedBusinessLayer; +use \OCA\News\Service\ServiceException; +use \OCA\News\Service\ItemService; +use \OCA\News\Service\FeedService; class ItemController extends Controller { use JSONHttpError; - private $itemBusinessLayer; - private $feedBusinessLayer; + private $itemService; + private $feedService; private $userId; private $settings; public function __construct($appName, IRequest $request, - FeedBusinessLayer $feedBusinessLayer, - ItemBusinessLayer $itemBusinessLayer, + FeedService $feedService, + ItemService $itemService, IConfig $settings, $userId){ parent::__construct($appName, $request); - $this->itemBusinessLayer = $itemBusinessLayer; - $this->feedBusinessLayer = $feedBusinessLayer; + $this->itemService = $itemService; + $this->feedService = $feedService; $this->userId = $userId; $this->settings = $settings; } @@ -74,18 +74,18 @@ class ItemController extends Controller { // out of sync if($offset === 0) { $params['newestItemId'] = - $this->itemBusinessLayer->getNewestItemId($this->userId); - $params['feeds'] = $this->feedBusinessLayer->findAll($this->userId); - $params['starred'] = $this->itemBusinessLayer->starredCount($this->userId); + $this->itemService->getNewestItemId($this->userId); + $params['feeds'] = $this->feedService->findAll($this->userId); + $params['starred'] = $this->itemService->starredCount($this->userId); } - $params['items'] = $this->itemBusinessLayer->findAll( + $params['items'] = $this->itemService->findAll( $id, $type, $limit, $offset, $showAll, $this->userId, $oldestFirst ); // this gets thrown if there are no items // in that case just return an empty array - } catch(BusinessLayerException $ex) {} + } catch(ServiceException $ex) {} return $params; } @@ -105,15 +105,15 @@ class ItemController extends Controller { $params = []; try { - $params['newestItemId'] = $this->itemBusinessLayer->getNewestItemId($this->userId); - $params['feeds'] = $this->feedBusinessLayer->findAll($this->userId); - $params['starred'] = $this->itemBusinessLayer->starredCount($this->userId); - $params['items'] = $this->itemBusinessLayer->findAllNew($id, $type, + $params['newestItemId'] = $this->itemService->getNewestItemId($this->userId); + $params['feeds'] = $this->feedService->findAll($this->userId); + $params['starred'] = $this->itemService->starredCount($this->userId); + $params['items'] = $this->itemService->findAllNew($id, $type, $lastModified, $showAll, $this->userId); // this gets thrown if there are no items // in that case just return an empty array - } catch(BusinessLayerException $ex) {} + } catch(ServiceException $ex) {} return $params; } @@ -127,8 +127,8 @@ class ItemController extends Controller { */ public function star($feedId, $guidHash){ try { - $this->itemBusinessLayer->star($feedId, $guidHash, true, $this->userId); - } catch(BusinessLayerException $ex) { + $this->itemService->star($feedId, $guidHash, true, $this->userId); + } catch(ServiceException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -142,8 +142,8 @@ class ItemController extends Controller { */ public function unstar($feedId, $guidHash){ try { - $this->itemBusinessLayer->star($feedId, $guidHash, false, $this->userId); - } catch(BusinessLayerException $ex) { + $this->itemService->star($feedId, $guidHash, false, $this->userId); + } catch(ServiceException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -156,8 +156,8 @@ class ItemController extends Controller { */ public function read($itemId){ try { - $this->itemBusinessLayer->read($itemId, true, $this->userId); - } catch(BusinessLayerException $ex) { + $this->itemService->read($itemId, true, $this->userId); + } catch(ServiceException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -170,8 +170,8 @@ class ItemController extends Controller { */ public function unread($itemId){ try { - $this->itemBusinessLayer->read($itemId, false, $this->userId); - } catch(BusinessLayerException $ex) { + $this->itemService->read($itemId, false, $this->userId); + } catch(ServiceException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -183,8 +183,8 @@ class ItemController extends Controller { * @param int $highestItemId */ public function readAll($highestItemId){ - $this->itemBusinessLayer->readAll($highestItemId, $this->userId); - return ['feeds' => $this->feedBusinessLayer->findAll($this->userId)]; + $this->itemService->readAll($highestItemId, $this->userId); + return ['feeds' => $this->feedService->findAll($this->userId)]; } -- cgit v1.2.3