diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-15 03:41:49 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-15 03:41:49 +0200 |
commit | 407fbebc2da14520942e0a6a9220a5a3cfc4a7ad (patch) | |
tree | e313ddad41398382f82cd27b40f46e0b7394c393 | |
parent | 7d33bab5abd81871e4efcf995f8a715d45b9d590 (diff) |
rename businesslayer to service
42 files changed, 659 insertions, 1136 deletions
diff --git a/appinfo/application.php b/appinfo/application.php index d325adf00..c69c2ca5b 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -28,9 +28,9 @@ use \OCA\News\Controller\FolderApiController; use \OCA\News\Controller\FeedApiController; use \OCA\News\Controller\ItemApiController; -use \OCA\News\BusinessLayer\FolderBusinessLayer; -use \OCA\News\BusinessLayer\FeedBusinessLayer; -use \OCA\News\BusinessLayer\ItemBusinessLayer; +use \OCA\News\Service\FolderService; +use \OCA\News\Service\FeedService; +use \OCA\News\Service\ItemService; use \OCA\News\Db\FolderMapper; use \OCA\News\Db\FeedMapper; @@ -86,9 +86,9 @@ class Application extends App { return new FolderController( $c->query('AppName'), $c->query('Request'), - $c->query('FolderBusinessLayer'), - $c->query('FeedBusinessLayer'), - $c->query('ItemBusinessLayer'), + $c->query('FolderService'), + $c->query('FeedService'), + $c->query('ItemService'), $c->query('UserId') ); }); @@ -97,9 +97,9 @@ class Application extends App { return new FeedController( $c->query('AppName'), $c->query('Request'), - $c->query('FolderBusinessLayer'), - $c->query('FeedBusinessLayer'), - $c->query('ItemBusinessLayer'), + $c->query('FolderService'), + $c->query('FeedService'), + $c->query('ItemService'), $c->query('CoreConfig'), $c->query('UserId') ); @@ -109,8 +109,8 @@ class Application extends App { return new ItemController( $c->query('AppName'), $c->query('Request'), - $c->query('FeedBusinessLayer'), - $c->query('ItemBusinessLayer'), + $c->query('FeedService'), + $c->query('ItemService'), $c->query('CoreConfig'), $c->query('UserId') ); @@ -120,9 +120,9 @@ class Application extends App { return new ExportController( $c->query('AppName'), $c->query('Request'), - $c->query('FeedBusinessLayer'), - $c->query('FolderBusinessLayer'), - $c->query('ItemBusinessLayer'), + $c->query('FolderService'), + $c->query('FeedService'), + $c->query('ItemService'), $c->query('OPMLExporter'), $c->query('UserId') ); @@ -141,8 +141,8 @@ class Application extends App { return new FolderApiController( $c->query('AppName'), $c->query('Request'), - $c->query('FolderBusinessLayer'), - $c->query('ItemBusinessLayer'), + $c->query('FolderService'), + $c->query('ItemService'), $c->query('UserId') ); }); @@ -151,9 +151,8 @@ class Application extends App { return new FeedApiController( $c->query('AppName'), $c->query('Request'), - $c->query('FolderBusinessLayer'), - $c->query('FeedBusinessLayer'), - $c->query('ItemBusinessLayer'), + $c->query('FeedService'), + $c->query('ItemService'), $c->query('Logger'), $c->query('UserId'), $c->query('LoggerParameters') @@ -164,7 +163,7 @@ class Application extends App { return new ItemApiController( $c->query('AppName'), $c->query('Request'), - $c->query('ItemBusinessLayer'), + $c->query('ItemService'), $c->query('UserId') ); }); @@ -173,8 +172,8 @@ class Application extends App { /** * Business Layer */ - $container->registerService('FolderBusinessLayer', function($c) { - return new FolderBusinessLayer( + $container->registerService('FolderService', function($c) { + return new FolderService( $c->query('FolderMapper'), $c->query('L10N'), $c->query('TimeFactory'), @@ -182,8 +181,8 @@ class Application extends App { ); }); - $container->registerService('FeedBusinessLayer', function($c) { - return new FeedBusinessLayer( + $container->registerService('FeedService', function($c) { + return new FeedService( $c->query('FeedMapper'), $c->query('Fetcher'), $c->query('ItemMapper'), @@ -197,8 +196,8 @@ class Application extends App { ); }); - $container->registerService('ItemBusinessLayer', function($c) { - return new ItemBusinessLayer( + $container->registerService('ItemService', function($c) { + return new ItemService( $c->query('ItemMapper'), $c->query('StatusFlag'), $c->query('TimeFactory'), @@ -414,9 +413,9 @@ class Application extends App { $container->registerService('Updater', function($c) { return new Updater( - $c->query('FolderBusinessLayer'), - $c->query('FeedBusinessLayer'), - $c->query('ItemBusinessLayer') + $c->query('FolderService'), + $c->query('FeedService'), + $c->query('ItemService') ); }); 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){ |