@@ -27,69 +27,69 @@ |
||
27 | 27 | use OCP\IURLGenerator; |
28 | 28 | |
29 | 29 | class Filter implements IFilter { |
30 | - const TYPE_REMOTE_SHARE = 'remote_share'; |
|
31 | - const TYPE_SHARED = 'shared'; |
|
30 | + const TYPE_REMOTE_SHARE = 'remote_share'; |
|
31 | + const TYPE_SHARED = 'shared'; |
|
32 | 32 | |
33 | - /** @var IL10N */ |
|
34 | - protected $l; |
|
33 | + /** @var IL10N */ |
|
34 | + protected $l; |
|
35 | 35 | |
36 | - /** @var IURLGenerator */ |
|
37 | - protected $url; |
|
36 | + /** @var IURLGenerator */ |
|
37 | + protected $url; |
|
38 | 38 | |
39 | - public function __construct(IL10N $l, IURLGenerator $url) { |
|
40 | - $this->l = $l; |
|
41 | - $this->url = $url; |
|
42 | - } |
|
39 | + public function __construct(IL10N $l, IURLGenerator $url) { |
|
40 | + $this->l = $l; |
|
41 | + $this->url = $url; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @return string Lowercase a-z only identifier |
|
46 | - * @since 11.0.0 |
|
47 | - */ |
|
48 | - public function getIdentifier() { |
|
49 | - return 'files_sharing'; |
|
50 | - } |
|
44 | + /** |
|
45 | + * @return string Lowercase a-z only identifier |
|
46 | + * @since 11.0.0 |
|
47 | + */ |
|
48 | + public function getIdentifier() { |
|
49 | + return 'files_sharing'; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return string A translated string |
|
54 | - * @since 11.0.0 |
|
55 | - */ |
|
56 | - public function getName() { |
|
57 | - return $this->l->t('File shares'); |
|
58 | - } |
|
52 | + /** |
|
53 | + * @return string A translated string |
|
54 | + * @since 11.0.0 |
|
55 | + */ |
|
56 | + public function getName() { |
|
57 | + return $this->l->t('File shares'); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @return int |
|
62 | - * @since 11.0.0 |
|
63 | - */ |
|
64 | - public function getPriority() { |
|
65 | - return 31; |
|
66 | - } |
|
60 | + /** |
|
61 | + * @return int |
|
62 | + * @since 11.0.0 |
|
63 | + */ |
|
64 | + public function getPriority() { |
|
65 | + return 31; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return string Full URL to an icon, empty string when none is given |
|
70 | - * @since 11.0.0 |
|
71 | - */ |
|
72 | - public function getIcon() { |
|
73 | - return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @return string Full URL to an icon, empty string when none is given |
|
70 | + * @since 11.0.0 |
|
71 | + */ |
|
72 | + public function getIcon() { |
|
73 | + return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string[] $types |
|
78 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function filterTypes(array $types) { |
|
82 | - return array_intersect([ |
|
83 | - self::TYPE_SHARED, |
|
84 | - self::TYPE_REMOTE_SHARE |
|
85 | - ], $types); |
|
86 | - } |
|
76 | + /** |
|
77 | + * @param string[] $types |
|
78 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function filterTypes(array $types) { |
|
82 | + return array_intersect([ |
|
83 | + self::TYPE_SHARED, |
|
84 | + self::TYPE_REMOTE_SHARE |
|
85 | + ], $types); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
90 | - * @since 11.0.0 |
|
91 | - */ |
|
92 | - public function allowedApps() { |
|
93 | - return ['files_sharing']; |
|
94 | - } |
|
88 | + /** |
|
89 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
90 | + * @since 11.0.0 |
|
91 | + */ |
|
92 | + public function allowedApps() { |
|
93 | + return ['files_sharing']; |
|
94 | + } |
|
95 | 95 | } |
@@ -29,49 +29,49 @@ |
||
29 | 29 | */ |
30 | 30 | class ExpireSharesJob extends TimedJob { |
31 | 31 | |
32 | - /** |
|
33 | - * sets the correct interval for this timed job |
|
34 | - */ |
|
35 | - public function __construct() { |
|
36 | - // Run once a day |
|
37 | - $this->setInterval(24 * 60 * 60); |
|
38 | - } |
|
32 | + /** |
|
33 | + * sets the correct interval for this timed job |
|
34 | + */ |
|
35 | + public function __construct() { |
|
36 | + // Run once a day |
|
37 | + $this->setInterval(24 * 60 * 60); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Makes the background job do its work |
|
42 | - * |
|
43 | - * @param array $argument unused argument |
|
44 | - */ |
|
45 | - public function run($argument) { |
|
46 | - $connection = \OC::$server->getDatabaseConnection(); |
|
47 | - $logger = \OC::$server->getLogger(); |
|
40 | + /** |
|
41 | + * Makes the background job do its work |
|
42 | + * |
|
43 | + * @param array $argument unused argument |
|
44 | + */ |
|
45 | + public function run($argument) { |
|
46 | + $connection = \OC::$server->getDatabaseConnection(); |
|
47 | + $logger = \OC::$server->getLogger(); |
|
48 | 48 | |
49 | - //Current time |
|
50 | - $now = new \DateTime(); |
|
51 | - $now = $now->format('Y-m-d H:i:s'); |
|
49 | + //Current time |
|
50 | + $now = new \DateTime(); |
|
51 | + $now = $now->format('Y-m-d H:i:s'); |
|
52 | 52 | |
53 | - /* |
|
53 | + /* |
|
54 | 54 | * Expire file link shares only (for now) |
55 | 55 | */ |
56 | - $qb = $connection->getQueryBuilder(); |
|
57 | - $qb->select('id', 'file_source', 'uid_owner', 'item_type') |
|
58 | - ->from('share') |
|
59 | - ->where( |
|
60 | - $qb->expr()->andX( |
|
61 | - $qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)), |
|
62 | - $qb->expr()->lte('expiration', $qb->expr()->literal($now)), |
|
63 | - $qb->expr()->orX( |
|
64 | - $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
65 | - $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
66 | - ) |
|
67 | - ) |
|
68 | - ); |
|
56 | + $qb = $connection->getQueryBuilder(); |
|
57 | + $qb->select('id', 'file_source', 'uid_owner', 'item_type') |
|
58 | + ->from('share') |
|
59 | + ->where( |
|
60 | + $qb->expr()->andX( |
|
61 | + $qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)), |
|
62 | + $qb->expr()->lte('expiration', $qb->expr()->literal($now)), |
|
63 | + $qb->expr()->orX( |
|
64 | + $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
65 | + $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
66 | + ) |
|
67 | + ) |
|
68 | + ); |
|
69 | 69 | |
70 | - $shares = $qb->execute(); |
|
71 | - while($share = $shares->fetch()) { |
|
72 | - \OCP\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); |
|
73 | - } |
|
74 | - $shares->closeCursor(); |
|
75 | - } |
|
70 | + $shares = $qb->execute(); |
|
71 | + while($share = $shares->fetch()) { |
|
72 | + \OCP\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); |
|
73 | + } |
|
74 | + $shares->closeCursor(); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | ); |
69 | 69 | |
70 | 70 | $shares = $qb->execute(); |
71 | - while($share = $shares->fetch()) { |
|
71 | + while ($share = $shares->fetch()) { |
|
72 | 72 | \OCP\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); |
73 | 73 | } |
74 | 74 | $shares->closeCursor(); |
@@ -39,112 +39,112 @@ |
||
39 | 39 | */ |
40 | 40 | class ExternalSharesController extends Controller { |
41 | 41 | |
42 | - /** @var \OCA\Files_Sharing\External\Manager */ |
|
43 | - private $externalManager; |
|
44 | - /** @var IClientService */ |
|
45 | - private $clientService; |
|
42 | + /** @var \OCA\Files_Sharing\External\Manager */ |
|
43 | + private $externalManager; |
|
44 | + /** @var IClientService */ |
|
45 | + private $clientService; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string $appName |
|
49 | - * @param IRequest $request |
|
50 | - * @param \OCA\Files_Sharing\External\Manager $externalManager |
|
51 | - * @param IClientService $clientService |
|
52 | - */ |
|
53 | - public function __construct($appName, |
|
54 | - IRequest $request, |
|
55 | - \OCA\Files_Sharing\External\Manager $externalManager, |
|
56 | - IClientService $clientService) { |
|
57 | - parent::__construct($appName, $request); |
|
58 | - $this->externalManager = $externalManager; |
|
59 | - $this->clientService = $clientService; |
|
60 | - } |
|
47 | + /** |
|
48 | + * @param string $appName |
|
49 | + * @param IRequest $request |
|
50 | + * @param \OCA\Files_Sharing\External\Manager $externalManager |
|
51 | + * @param IClientService $clientService |
|
52 | + */ |
|
53 | + public function __construct($appName, |
|
54 | + IRequest $request, |
|
55 | + \OCA\Files_Sharing\External\Manager $externalManager, |
|
56 | + IClientService $clientService) { |
|
57 | + parent::__construct($appName, $request); |
|
58 | + $this->externalManager = $externalManager; |
|
59 | + $this->clientService = $clientService; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @NoAdminRequired |
|
64 | - * @NoOutgoingFederatedSharingRequired |
|
65 | - * |
|
66 | - * @return JSONResponse |
|
67 | - */ |
|
68 | - public function index() { |
|
69 | - return new JSONResponse($this->externalManager->getOpenShares()); |
|
70 | - } |
|
62 | + /** |
|
63 | + * @NoAdminRequired |
|
64 | + * @NoOutgoingFederatedSharingRequired |
|
65 | + * |
|
66 | + * @return JSONResponse |
|
67 | + */ |
|
68 | + public function index() { |
|
69 | + return new JSONResponse($this->externalManager->getOpenShares()); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @NoAdminRequired |
|
74 | - * @NoOutgoingFederatedSharingRequired |
|
75 | - * |
|
76 | - * @param int $id |
|
77 | - * @return JSONResponse |
|
78 | - */ |
|
79 | - public function create($id) { |
|
80 | - $this->externalManager->acceptShare($id); |
|
81 | - return new JSONResponse(); |
|
82 | - } |
|
72 | + /** |
|
73 | + * @NoAdminRequired |
|
74 | + * @NoOutgoingFederatedSharingRequired |
|
75 | + * |
|
76 | + * @param int $id |
|
77 | + * @return JSONResponse |
|
78 | + */ |
|
79 | + public function create($id) { |
|
80 | + $this->externalManager->acceptShare($id); |
|
81 | + return new JSONResponse(); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @NoAdminRequired |
|
86 | - * @NoOutgoingFederatedSharingRequired |
|
87 | - * |
|
88 | - * @param integer $id |
|
89 | - * @return JSONResponse |
|
90 | - */ |
|
91 | - public function destroy($id) { |
|
92 | - $this->externalManager->declineShare($id); |
|
93 | - return new JSONResponse(); |
|
94 | - } |
|
84 | + /** |
|
85 | + * @NoAdminRequired |
|
86 | + * @NoOutgoingFederatedSharingRequired |
|
87 | + * |
|
88 | + * @param integer $id |
|
89 | + * @return JSONResponse |
|
90 | + */ |
|
91 | + public function destroy($id) { |
|
92 | + $this->externalManager->declineShare($id); |
|
93 | + return new JSONResponse(); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Test whether the specified remote is accessible |
|
98 | - * |
|
99 | - * @param string $remote |
|
100 | - * @param bool $checkVersion |
|
101 | - * @return bool |
|
102 | - */ |
|
103 | - protected function testUrl($remote, $checkVersion = false) { |
|
104 | - try { |
|
105 | - $client = $this->clientService->newClient(); |
|
106 | - $response = json_decode($client->get( |
|
107 | - $remote, |
|
108 | - [ |
|
109 | - 'timeout' => 3, |
|
110 | - 'connect_timeout' => 3, |
|
111 | - ] |
|
112 | - )->getBody()); |
|
96 | + /** |
|
97 | + * Test whether the specified remote is accessible |
|
98 | + * |
|
99 | + * @param string $remote |
|
100 | + * @param bool $checkVersion |
|
101 | + * @return bool |
|
102 | + */ |
|
103 | + protected function testUrl($remote, $checkVersion = false) { |
|
104 | + try { |
|
105 | + $client = $this->clientService->newClient(); |
|
106 | + $response = json_decode($client->get( |
|
107 | + $remote, |
|
108 | + [ |
|
109 | + 'timeout' => 3, |
|
110 | + 'connect_timeout' => 3, |
|
111 | + ] |
|
112 | + )->getBody()); |
|
113 | 113 | |
114 | - if ($checkVersion) { |
|
115 | - return !empty($response->version) && version_compare($response->version, '7.0.0', '>='); |
|
116 | - } else { |
|
117 | - return is_object($response); |
|
118 | - } |
|
119 | - } catch (\Exception $e) { |
|
120 | - return false; |
|
121 | - } |
|
122 | - } |
|
114 | + if ($checkVersion) { |
|
115 | + return !empty($response->version) && version_compare($response->version, '7.0.0', '>='); |
|
116 | + } else { |
|
117 | + return is_object($response); |
|
118 | + } |
|
119 | + } catch (\Exception $e) { |
|
120 | + return false; |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * @PublicPage |
|
126 | - * @NoOutgoingFederatedSharingRequired |
|
127 | - * @NoIncomingFederatedSharingRequired |
|
128 | - * |
|
129 | - * @param string $remote |
|
130 | - * @return DataResponse |
|
131 | - */ |
|
132 | - public function testRemote($remote) { |
|
133 | - if ( |
|
134 | - $this->testUrl('https://' . $remote . '/ocs-provider/') || |
|
135 | - $this->testUrl('https://' . $remote . '/ocs-provider/index.php') || |
|
136 | - $this->testUrl('https://' . $remote . '/status.php', true) |
|
137 | - ) { |
|
138 | - return new DataResponse('https'); |
|
139 | - } elseif ( |
|
140 | - $this->testUrl('http://' . $remote . '/ocs-provider/') || |
|
141 | - $this->testUrl('http://' . $remote . '/ocs-provider/index.php') || |
|
142 | - $this->testUrl('http://' . $remote . '/status.php', true) |
|
143 | - ) { |
|
144 | - return new DataResponse('http'); |
|
145 | - } else { |
|
146 | - return new DataResponse(false); |
|
147 | - } |
|
148 | - } |
|
124 | + /** |
|
125 | + * @PublicPage |
|
126 | + * @NoOutgoingFederatedSharingRequired |
|
127 | + * @NoIncomingFederatedSharingRequired |
|
128 | + * |
|
129 | + * @param string $remote |
|
130 | + * @return DataResponse |
|
131 | + */ |
|
132 | + public function testRemote($remote) { |
|
133 | + if ( |
|
134 | + $this->testUrl('https://' . $remote . '/ocs-provider/') || |
|
135 | + $this->testUrl('https://' . $remote . '/ocs-provider/index.php') || |
|
136 | + $this->testUrl('https://' . $remote . '/status.php', true) |
|
137 | + ) { |
|
138 | + return new DataResponse('https'); |
|
139 | + } elseif ( |
|
140 | + $this->testUrl('http://' . $remote . '/ocs-provider/') || |
|
141 | + $this->testUrl('http://' . $remote . '/ocs-provider/index.php') || |
|
142 | + $this->testUrl('http://' . $remote . '/status.php', true) |
|
143 | + ) { |
|
144 | + return new DataResponse('http'); |
|
145 | + } else { |
|
146 | + return new DataResponse(false); |
|
147 | + } |
|
148 | + } |
|
149 | 149 | |
150 | 150 | } |
@@ -131,15 +131,15 @@ |
||
131 | 131 | */ |
132 | 132 | public function testRemote($remote) { |
133 | 133 | if ( |
134 | - $this->testUrl('https://' . $remote . '/ocs-provider/') || |
|
135 | - $this->testUrl('https://' . $remote . '/ocs-provider/index.php') || |
|
136 | - $this->testUrl('https://' . $remote . '/status.php', true) |
|
134 | + $this->testUrl('https://'.$remote.'/ocs-provider/') || |
|
135 | + $this->testUrl('https://'.$remote.'/ocs-provider/index.php') || |
|
136 | + $this->testUrl('https://'.$remote.'/status.php', true) |
|
137 | 137 | ) { |
138 | 138 | return new DataResponse('https'); |
139 | 139 | } elseif ( |
140 | - $this->testUrl('http://' . $remote . '/ocs-provider/') || |
|
141 | - $this->testUrl('http://' . $remote . '/ocs-provider/index.php') || |
|
142 | - $this->testUrl('http://' . $remote . '/status.php', true) |
|
140 | + $this->testUrl('http://'.$remote.'/ocs-provider/') || |
|
141 | + $this->testUrl('http://'.$remote.'/ocs-provider/index.php') || |
|
142 | + $this->testUrl('http://'.$remote.'/status.php', true) |
|
143 | 143 | ) { |
144 | 144 | return new DataResponse('http'); |
145 | 145 | } else { |
@@ -36,67 +36,67 @@ |
||
36 | 36 | |
37 | 37 | class PublicPreviewController extends Controller { |
38 | 38 | |
39 | - /** @var ShareManager */ |
|
40 | - private $shareManager; |
|
39 | + /** @var ShareManager */ |
|
40 | + private $shareManager; |
|
41 | 41 | |
42 | - /** @var IPreview */ |
|
43 | - private $previewManager; |
|
42 | + /** @var IPreview */ |
|
43 | + private $previewManager; |
|
44 | 44 | |
45 | - public function __construct($appName, |
|
46 | - IRequest $request, |
|
47 | - ShareManager $shareManger, |
|
48 | - IPreview $previewManager) { |
|
49 | - parent::__construct($appName, $request); |
|
45 | + public function __construct($appName, |
|
46 | + IRequest $request, |
|
47 | + ShareManager $shareManger, |
|
48 | + IPreview $previewManager) { |
|
49 | + parent::__construct($appName, $request); |
|
50 | 50 | |
51 | - $this->shareManager = $shareManger; |
|
52 | - $this->previewManager = $previewManager; |
|
53 | - } |
|
51 | + $this->shareManager = $shareManger; |
|
52 | + $this->previewManager = $previewManager; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @PublicPage |
|
57 | - * @NoCSRFRequired |
|
58 | - * |
|
59 | - * @param string $file |
|
60 | - * @param int $x |
|
61 | - * @param int $y |
|
62 | - * @param string $t |
|
63 | - * @param bool $a |
|
64 | - * @return DataResponse|FileDisplayResponse |
|
65 | - */ |
|
66 | - public function getPreview( |
|
67 | - $file = '', |
|
68 | - $x = 32, |
|
69 | - $y = 32, |
|
70 | - $t = '', |
|
71 | - $a = false |
|
72 | - ) { |
|
55 | + /** |
|
56 | + * @PublicPage |
|
57 | + * @NoCSRFRequired |
|
58 | + * |
|
59 | + * @param string $file |
|
60 | + * @param int $x |
|
61 | + * @param int $y |
|
62 | + * @param string $t |
|
63 | + * @param bool $a |
|
64 | + * @return DataResponse|FileDisplayResponse |
|
65 | + */ |
|
66 | + public function getPreview( |
|
67 | + $file = '', |
|
68 | + $x = 32, |
|
69 | + $y = 32, |
|
70 | + $t = '', |
|
71 | + $a = false |
|
72 | + ) { |
|
73 | 73 | |
74 | - if ($t === '' || $x === 0 || $y === 0) { |
|
75 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
76 | - } |
|
74 | + if ($t === '' || $x === 0 || $y === 0) { |
|
75 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
76 | + } |
|
77 | 77 | |
78 | - try { |
|
79 | - $share = $this->shareManager->getShareByToken($t); |
|
80 | - } catch (ShareNotFound $e) { |
|
81 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
82 | - } |
|
78 | + try { |
|
79 | + $share = $this->shareManager->getShareByToken($t); |
|
80 | + } catch (ShareNotFound $e) { |
|
81 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
82 | + } |
|
83 | 83 | |
84 | - if (($share->getPermissions() & Constants::PERMISSION_READ) === 0) { |
|
85 | - return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
86 | - } |
|
84 | + if (($share->getPermissions() & Constants::PERMISSION_READ) === 0) { |
|
85 | + return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
86 | + } |
|
87 | 87 | |
88 | - try { |
|
89 | - $node = $share->getNode(); |
|
90 | - if ($node instanceof Folder) { |
|
91 | - $file = $node->get($file); |
|
92 | - } else { |
|
93 | - $file = $node; |
|
94 | - } |
|
88 | + try { |
|
89 | + $node = $share->getNode(); |
|
90 | + if ($node instanceof Folder) { |
|
91 | + $file = $node->get($file); |
|
92 | + } else { |
|
93 | + $file = $node; |
|
94 | + } |
|
95 | 95 | |
96 | - $f = $this->previewManager->getPreview($file, $x, $y, !$a); |
|
97 | - return new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); |
|
98 | - } catch (NotFoundException $e) { |
|
99 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
100 | - } |
|
101 | - } |
|
96 | + $f = $this->previewManager->getPreview($file, $x, $y, !$a); |
|
97 | + return new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); |
|
98 | + } catch (NotFoundException $e) { |
|
99 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
100 | + } |
|
101 | + } |
|
102 | 102 | } |
@@ -33,151 +33,151 @@ |
||
33 | 33 | |
34 | 34 | class RemoteController extends OCSController { |
35 | 35 | |
36 | - /** @var Manager */ |
|
37 | - private $externalManager; |
|
38 | - |
|
39 | - /** |
|
40 | - * @NoAdminRequired |
|
41 | - * |
|
42 | - * Remote constructor. |
|
43 | - * |
|
44 | - * @param string $appName |
|
45 | - * @param IRequest $request |
|
46 | - * @param Manager $externalManager |
|
47 | - */ |
|
48 | - public function __construct($appName, |
|
49 | - IRequest $request, |
|
50 | - Manager $externalManager) { |
|
51 | - parent::__construct($appName, $request); |
|
52 | - |
|
53 | - $this->externalManager = $externalManager; |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @NoAdminRequired |
|
58 | - * |
|
59 | - * Get list of pending remote shares |
|
60 | - * |
|
61 | - * @return DataResponse |
|
62 | - */ |
|
63 | - public function getOpenShares() { |
|
64 | - return new DataResponse($this->externalManager->getOpenShares()); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * @NoAdminRequired |
|
69 | - * |
|
70 | - * Accept a remote share |
|
71 | - * |
|
72 | - * @param int $id |
|
73 | - * @return DataResponse |
|
74 | - * @throws OCSNotFoundException |
|
75 | - */ |
|
76 | - public function acceptShare($id) { |
|
77 | - if ($this->externalManager->acceptShare($id)) { |
|
78 | - return new DataResponse(); |
|
79 | - } |
|
80 | - |
|
81 | - // Make sure the user has no notification for something that does not exist anymore. |
|
82 | - $this->externalManager->processNotification($id); |
|
83 | - |
|
84 | - throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.'); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * @NoAdminRequired |
|
89 | - * |
|
90 | - * Decline a remote share |
|
91 | - * |
|
92 | - * @param int $id |
|
93 | - * @return DataResponse |
|
94 | - * @throws OCSNotFoundException |
|
95 | - */ |
|
96 | - public function declineShare($id) { |
|
97 | - if ($this->externalManager->declineShare($id)) { |
|
98 | - return new DataResponse(); |
|
99 | - } |
|
100 | - |
|
101 | - // Make sure the user has no notification for something that does not exist anymore. |
|
102 | - $this->externalManager->processNotification($id); |
|
103 | - |
|
104 | - throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.'); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param array $share Share with info from the share_external table |
|
109 | - * @return array enriched share info with data from the filecache |
|
110 | - */ |
|
111 | - private static function extendShareInfo($share) { |
|
112 | - $view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/'); |
|
113 | - $info = $view->getFileInfo($share['mountpoint']); |
|
114 | - |
|
115 | - $share['mimetype'] = $info->getMimetype(); |
|
116 | - $share['mtime'] = $info->getMTime(); |
|
117 | - $share['permissions'] = $info->getPermissions(); |
|
118 | - $share['type'] = $info->getType(); |
|
119 | - $share['file_id'] = $info->getId(); |
|
120 | - |
|
121 | - return $share; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @NoAdminRequired |
|
126 | - * |
|
127 | - * List accepted remote shares |
|
128 | - * |
|
129 | - * @return DataResponse |
|
130 | - */ |
|
131 | - public function getShares() { |
|
132 | - $shares = $this->externalManager->getAcceptedShares(); |
|
133 | - $shares = array_map('self::extendShareInfo', $shares); |
|
134 | - |
|
135 | - return new DataResponse($shares); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @NoAdminRequired |
|
140 | - * |
|
141 | - * Get info of a remote share |
|
142 | - * |
|
143 | - * @param int $id |
|
144 | - * @return DataResponse |
|
145 | - * @throws OCSNotFoundException |
|
146 | - */ |
|
147 | - public function getShare($id) { |
|
148 | - $shareInfo = $this->externalManager->getShare($id); |
|
149 | - |
|
150 | - if ($shareInfo === false) { |
|
151 | - throw new OCSNotFoundException('share does not exist'); |
|
152 | - } else { |
|
153 | - $shareInfo = self::extendShareInfo($shareInfo); |
|
154 | - return new DataResponse($shareInfo); |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @NoAdminRequired |
|
160 | - * |
|
161 | - * Unshare a remote share |
|
162 | - * |
|
163 | - * @param int $id |
|
164 | - * @return DataResponse |
|
165 | - * @throws OCSNotFoundException |
|
166 | - * @throws OCSForbiddenException |
|
167 | - */ |
|
168 | - public function unshare($id) { |
|
169 | - $shareInfo = $this->externalManager->getShare($id); |
|
170 | - |
|
171 | - if ($shareInfo === false) { |
|
172 | - throw new OCSNotFoundException('Share does not exist'); |
|
173 | - } |
|
174 | - |
|
175 | - $mountPoint = '/' . \OC_User::getUser() . '/files' . $shareInfo['mountpoint']; |
|
176 | - |
|
177 | - if ($this->externalManager->removeShare($mountPoint) === true) { |
|
178 | - return new DataResponse(); |
|
179 | - } else { |
|
180 | - throw new OCSForbiddenException('Could not unshare'); |
|
181 | - } |
|
182 | - } |
|
36 | + /** @var Manager */ |
|
37 | + private $externalManager; |
|
38 | + |
|
39 | + /** |
|
40 | + * @NoAdminRequired |
|
41 | + * |
|
42 | + * Remote constructor. |
|
43 | + * |
|
44 | + * @param string $appName |
|
45 | + * @param IRequest $request |
|
46 | + * @param Manager $externalManager |
|
47 | + */ |
|
48 | + public function __construct($appName, |
|
49 | + IRequest $request, |
|
50 | + Manager $externalManager) { |
|
51 | + parent::__construct($appName, $request); |
|
52 | + |
|
53 | + $this->externalManager = $externalManager; |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @NoAdminRequired |
|
58 | + * |
|
59 | + * Get list of pending remote shares |
|
60 | + * |
|
61 | + * @return DataResponse |
|
62 | + */ |
|
63 | + public function getOpenShares() { |
|
64 | + return new DataResponse($this->externalManager->getOpenShares()); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * @NoAdminRequired |
|
69 | + * |
|
70 | + * Accept a remote share |
|
71 | + * |
|
72 | + * @param int $id |
|
73 | + * @return DataResponse |
|
74 | + * @throws OCSNotFoundException |
|
75 | + */ |
|
76 | + public function acceptShare($id) { |
|
77 | + if ($this->externalManager->acceptShare($id)) { |
|
78 | + return new DataResponse(); |
|
79 | + } |
|
80 | + |
|
81 | + // Make sure the user has no notification for something that does not exist anymore. |
|
82 | + $this->externalManager->processNotification($id); |
|
83 | + |
|
84 | + throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.'); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * @NoAdminRequired |
|
89 | + * |
|
90 | + * Decline a remote share |
|
91 | + * |
|
92 | + * @param int $id |
|
93 | + * @return DataResponse |
|
94 | + * @throws OCSNotFoundException |
|
95 | + */ |
|
96 | + public function declineShare($id) { |
|
97 | + if ($this->externalManager->declineShare($id)) { |
|
98 | + return new DataResponse(); |
|
99 | + } |
|
100 | + |
|
101 | + // Make sure the user has no notification for something that does not exist anymore. |
|
102 | + $this->externalManager->processNotification($id); |
|
103 | + |
|
104 | + throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.'); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param array $share Share with info from the share_external table |
|
109 | + * @return array enriched share info with data from the filecache |
|
110 | + */ |
|
111 | + private static function extendShareInfo($share) { |
|
112 | + $view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/'); |
|
113 | + $info = $view->getFileInfo($share['mountpoint']); |
|
114 | + |
|
115 | + $share['mimetype'] = $info->getMimetype(); |
|
116 | + $share['mtime'] = $info->getMTime(); |
|
117 | + $share['permissions'] = $info->getPermissions(); |
|
118 | + $share['type'] = $info->getType(); |
|
119 | + $share['file_id'] = $info->getId(); |
|
120 | + |
|
121 | + return $share; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @NoAdminRequired |
|
126 | + * |
|
127 | + * List accepted remote shares |
|
128 | + * |
|
129 | + * @return DataResponse |
|
130 | + */ |
|
131 | + public function getShares() { |
|
132 | + $shares = $this->externalManager->getAcceptedShares(); |
|
133 | + $shares = array_map('self::extendShareInfo', $shares); |
|
134 | + |
|
135 | + return new DataResponse($shares); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @NoAdminRequired |
|
140 | + * |
|
141 | + * Get info of a remote share |
|
142 | + * |
|
143 | + * @param int $id |
|
144 | + * @return DataResponse |
|
145 | + * @throws OCSNotFoundException |
|
146 | + */ |
|
147 | + public function getShare($id) { |
|
148 | + $shareInfo = $this->externalManager->getShare($id); |
|
149 | + |
|
150 | + if ($shareInfo === false) { |
|
151 | + throw new OCSNotFoundException('share does not exist'); |
|
152 | + } else { |
|
153 | + $shareInfo = self::extendShareInfo($shareInfo); |
|
154 | + return new DataResponse($shareInfo); |
|
155 | + } |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @NoAdminRequired |
|
160 | + * |
|
161 | + * Unshare a remote share |
|
162 | + * |
|
163 | + * @param int $id |
|
164 | + * @return DataResponse |
|
165 | + * @throws OCSNotFoundException |
|
166 | + * @throws OCSForbiddenException |
|
167 | + */ |
|
168 | + public function unshare($id) { |
|
169 | + $shareInfo = $this->externalManager->getShare($id); |
|
170 | + |
|
171 | + if ($shareInfo === false) { |
|
172 | + throw new OCSNotFoundException('Share does not exist'); |
|
173 | + } |
|
174 | + |
|
175 | + $mountPoint = '/' . \OC_User::getUser() . '/files' . $shareInfo['mountpoint']; |
|
176 | + |
|
177 | + if ($this->externalManager->removeShare($mountPoint) === true) { |
|
178 | + return new DataResponse(); |
|
179 | + } else { |
|
180 | + throw new OCSForbiddenException('Could not unshare'); |
|
181 | + } |
|
182 | + } |
|
183 | 183 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return array enriched share info with data from the filecache |
110 | 110 | */ |
111 | 111 | private static function extendShareInfo($share) { |
112 | - $view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/'); |
|
112 | + $view = new \OC\Files\View('/'.\OC_User::getUser().'/files/'); |
|
113 | 113 | $info = $view->getFileInfo($share['mountpoint']); |
114 | 114 | |
115 | 115 | $share['mimetype'] = $info->getMimetype(); |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | throw new OCSNotFoundException('Share does not exist'); |
173 | 173 | } |
174 | 174 | |
175 | - $mountPoint = '/' . \OC_User::getUser() . '/files' . $shareInfo['mountpoint']; |
|
175 | + $mountPoint = '/'.\OC_User::getUser().'/files'.$shareInfo['mountpoint']; |
|
176 | 176 | |
177 | 177 | if ($this->externalManager->removeShare($mountPoint) === true) { |
178 | 178 | return new DataResponse(); |
@@ -23,6 +23,6 @@ |
||
23 | 23 | |
24 | 24 | namespace OCA\Files_Sharing; |
25 | 25 | |
26 | -interface ISharedStorage{ |
|
26 | +interface ISharedStorage { |
|
27 | 27 | |
28 | 28 | } |
@@ -27,7 +27,6 @@ |
||
27 | 27 | * Expected path with a different root |
28 | 28 | * Possible Error Codes: |
29 | 29 | * 10 - Path not relative to data/ and point to the users file directory |
30 | - |
|
31 | 30 | */ |
32 | 31 | class BrokenPath extends \Exception { |
33 | 32 | } |
@@ -40,131 +40,131 @@ |
||
40 | 40 | use OCP\IServerContainer; |
41 | 41 | |
42 | 42 | class Application extends App { |
43 | - public function __construct(array $urlParams = array()) { |
|
44 | - parent::__construct('files_sharing', $urlParams); |
|
43 | + public function __construct(array $urlParams = array()) { |
|
44 | + parent::__construct('files_sharing', $urlParams); |
|
45 | 45 | |
46 | - $container = $this->getContainer(); |
|
47 | - /** @var IServerContainer $server */ |
|
48 | - $server = $container->getServer(); |
|
46 | + $container = $this->getContainer(); |
|
47 | + /** @var IServerContainer $server */ |
|
48 | + $server = $container->getServer(); |
|
49 | 49 | |
50 | - /** |
|
51 | - * Controllers |
|
52 | - */ |
|
53 | - $container->registerService('ShareController', function (SimpleContainer $c) use ($server) { |
|
54 | - $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
|
55 | - return new ShareController( |
|
56 | - $c->query('AppName'), |
|
57 | - $c->query('Request'), |
|
58 | - $server->getConfig(), |
|
59 | - $server->getURLGenerator(), |
|
60 | - $server->getUserManager(), |
|
61 | - $server->getLogger(), |
|
62 | - $server->getActivityManager(), |
|
63 | - $server->getShareManager(), |
|
64 | - $server->getSession(), |
|
65 | - $server->getPreviewManager(), |
|
66 | - $server->getRootFolder(), |
|
67 | - $federatedSharingApp->getFederatedShareProvider(), |
|
68 | - $server->getEventDispatcher(), |
|
69 | - $server->getL10N($c->query('AppName')), |
|
70 | - $server->getThemingDefaults() |
|
71 | - ); |
|
72 | - }); |
|
73 | - $container->registerService('ExternalSharesController', function (SimpleContainer $c) { |
|
74 | - return new ExternalSharesController( |
|
75 | - $c->query('AppName'), |
|
76 | - $c->query('Request'), |
|
77 | - $c->query('ExternalManager'), |
|
78 | - $c->query('HttpClientService') |
|
79 | - ); |
|
80 | - }); |
|
50 | + /** |
|
51 | + * Controllers |
|
52 | + */ |
|
53 | + $container->registerService('ShareController', function (SimpleContainer $c) use ($server) { |
|
54 | + $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
|
55 | + return new ShareController( |
|
56 | + $c->query('AppName'), |
|
57 | + $c->query('Request'), |
|
58 | + $server->getConfig(), |
|
59 | + $server->getURLGenerator(), |
|
60 | + $server->getUserManager(), |
|
61 | + $server->getLogger(), |
|
62 | + $server->getActivityManager(), |
|
63 | + $server->getShareManager(), |
|
64 | + $server->getSession(), |
|
65 | + $server->getPreviewManager(), |
|
66 | + $server->getRootFolder(), |
|
67 | + $federatedSharingApp->getFederatedShareProvider(), |
|
68 | + $server->getEventDispatcher(), |
|
69 | + $server->getL10N($c->query('AppName')), |
|
70 | + $server->getThemingDefaults() |
|
71 | + ); |
|
72 | + }); |
|
73 | + $container->registerService('ExternalSharesController', function (SimpleContainer $c) { |
|
74 | + return new ExternalSharesController( |
|
75 | + $c->query('AppName'), |
|
76 | + $c->query('Request'), |
|
77 | + $c->query('ExternalManager'), |
|
78 | + $c->query('HttpClientService') |
|
79 | + ); |
|
80 | + }); |
|
81 | 81 | |
82 | - /** |
|
83 | - * Core class wrappers |
|
84 | - */ |
|
85 | - $container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) { |
|
86 | - return $server->getHTTPClientService(); |
|
87 | - }); |
|
88 | - $container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) { |
|
89 | - return $server->getCloudIdManager(); |
|
90 | - }); |
|
91 | - $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { |
|
92 | - $user = $server->getUserSession()->getUser(); |
|
93 | - $uid = $user ? $user->getUID() : null; |
|
94 | - $discoveryManager = new DiscoveryManager( |
|
95 | - \OC::$server->getMemCacheFactory(), |
|
96 | - \OC::$server->getHTTPClientService() |
|
97 | - ); |
|
98 | - return new \OCA\Files_Sharing\External\Manager( |
|
99 | - $server->getDatabaseConnection(), |
|
100 | - \OC\Files\Filesystem::getMountManager(), |
|
101 | - \OC\Files\Filesystem::getLoader(), |
|
102 | - $server->getHTTPClientService(), |
|
103 | - $server->getNotificationManager(), |
|
104 | - $discoveryManager, |
|
105 | - $uid |
|
106 | - ); |
|
107 | - }); |
|
108 | - $container->registerAlias('OCA\Files_Sharing\External\Manager', 'ExternalManager'); |
|
82 | + /** |
|
83 | + * Core class wrappers |
|
84 | + */ |
|
85 | + $container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) { |
|
86 | + return $server->getHTTPClientService(); |
|
87 | + }); |
|
88 | + $container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) { |
|
89 | + return $server->getCloudIdManager(); |
|
90 | + }); |
|
91 | + $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { |
|
92 | + $user = $server->getUserSession()->getUser(); |
|
93 | + $uid = $user ? $user->getUID() : null; |
|
94 | + $discoveryManager = new DiscoveryManager( |
|
95 | + \OC::$server->getMemCacheFactory(), |
|
96 | + \OC::$server->getHTTPClientService() |
|
97 | + ); |
|
98 | + return new \OCA\Files_Sharing\External\Manager( |
|
99 | + $server->getDatabaseConnection(), |
|
100 | + \OC\Files\Filesystem::getMountManager(), |
|
101 | + \OC\Files\Filesystem::getLoader(), |
|
102 | + $server->getHTTPClientService(), |
|
103 | + $server->getNotificationManager(), |
|
104 | + $discoveryManager, |
|
105 | + $uid |
|
106 | + ); |
|
107 | + }); |
|
108 | + $container->registerAlias('OCA\Files_Sharing\External\Manager', 'ExternalManager'); |
|
109 | 109 | |
110 | - /** |
|
111 | - * Middleware |
|
112 | - */ |
|
113 | - $container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) { |
|
114 | - return new SharingCheckMiddleware( |
|
115 | - $c->query('AppName'), |
|
116 | - $server->getConfig(), |
|
117 | - $server->getAppManager(), |
|
118 | - $c['ControllerMethodReflector'], |
|
119 | - $server->getShareManager(), |
|
120 | - $server->getRequest() |
|
121 | - ); |
|
122 | - }); |
|
110 | + /** |
|
111 | + * Middleware |
|
112 | + */ |
|
113 | + $container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) { |
|
114 | + return new SharingCheckMiddleware( |
|
115 | + $c->query('AppName'), |
|
116 | + $server->getConfig(), |
|
117 | + $server->getAppManager(), |
|
118 | + $c['ControllerMethodReflector'], |
|
119 | + $server->getShareManager(), |
|
120 | + $server->getRequest() |
|
121 | + ); |
|
122 | + }); |
|
123 | 123 | |
124 | - $container->registerService('OCSShareAPIMiddleware', function (SimpleContainer $c) use ($server) { |
|
125 | - return new OCSShareAPIMiddleware( |
|
126 | - $server->getShareManager(), |
|
127 | - $server->getL10N($c->query('AppName')) |
|
128 | - ); |
|
129 | - }); |
|
124 | + $container->registerService('OCSShareAPIMiddleware', function (SimpleContainer $c) use ($server) { |
|
125 | + return new OCSShareAPIMiddleware( |
|
126 | + $server->getShareManager(), |
|
127 | + $server->getL10N($c->query('AppName')) |
|
128 | + ); |
|
129 | + }); |
|
130 | 130 | |
131 | - // Execute middlewares |
|
132 | - $container->registerMiddleWare('SharingCheckMiddleware'); |
|
133 | - $container->registerMiddleWare('OCSShareAPIMiddleware'); |
|
131 | + // Execute middlewares |
|
132 | + $container->registerMiddleWare('SharingCheckMiddleware'); |
|
133 | + $container->registerMiddleWare('OCSShareAPIMiddleware'); |
|
134 | 134 | |
135 | - $container->registerService('MountProvider', function (IContainer $c) { |
|
136 | - /** @var \OCP\IServerContainer $server */ |
|
137 | - $server = $c->query('ServerContainer'); |
|
138 | - return new MountProvider( |
|
139 | - $server->getConfig(), |
|
140 | - $server->getShareManager(), |
|
141 | - $server->getLogger() |
|
142 | - ); |
|
143 | - }); |
|
135 | + $container->registerService('MountProvider', function (IContainer $c) { |
|
136 | + /** @var \OCP\IServerContainer $server */ |
|
137 | + $server = $c->query('ServerContainer'); |
|
138 | + return new MountProvider( |
|
139 | + $server->getConfig(), |
|
140 | + $server->getShareManager(), |
|
141 | + $server->getLogger() |
|
142 | + ); |
|
143 | + }); |
|
144 | 144 | |
145 | - $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
146 | - /** @var \OCP\IServerContainer $server */ |
|
147 | - $server = $c->query('ServerContainer'); |
|
148 | - return new \OCA\Files_Sharing\External\MountProvider( |
|
149 | - $server->getDatabaseConnection(), |
|
150 | - function() use ($c) { |
|
151 | - return $c->query('ExternalManager'); |
|
152 | - }, |
|
153 | - $server->getCloudIdManager() |
|
154 | - ); |
|
155 | - }); |
|
145 | + $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
146 | + /** @var \OCP\IServerContainer $server */ |
|
147 | + $server = $c->query('ServerContainer'); |
|
148 | + return new \OCA\Files_Sharing\External\MountProvider( |
|
149 | + $server->getDatabaseConnection(), |
|
150 | + function() use ($c) { |
|
151 | + return $c->query('ExternalManager'); |
|
152 | + }, |
|
153 | + $server->getCloudIdManager() |
|
154 | + ); |
|
155 | + }); |
|
156 | 156 | |
157 | - /* |
|
157 | + /* |
|
158 | 158 | * Register capabilities |
159 | 159 | */ |
160 | - $container->registerCapability('OCA\Files_Sharing\Capabilities'); |
|
161 | - } |
|
160 | + $container->registerCapability('OCA\Files_Sharing\Capabilities'); |
|
161 | + } |
|
162 | 162 | |
163 | - public function registerMountProviders() { |
|
164 | - /** @var \OCP\IServerContainer $server */ |
|
165 | - $server = $this->getContainer()->query('ServerContainer'); |
|
166 | - $mountProviderCollection = $server->getMountProviderCollection(); |
|
167 | - $mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider')); |
|
168 | - $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); |
|
169 | - } |
|
163 | + public function registerMountProviders() { |
|
164 | + /** @var \OCP\IServerContainer $server */ |
|
165 | + $server = $this->getContainer()->query('ServerContainer'); |
|
166 | + $mountProviderCollection = $server->getMountProviderCollection(); |
|
167 | + $mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider')); |
|
168 | + $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); |
|
169 | + } |
|
170 | 170 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Controllers |
52 | 52 | */ |
53 | - $container->registerService('ShareController', function (SimpleContainer $c) use ($server) { |
|
53 | + $container->registerService('ShareController', function(SimpleContainer $c) use ($server) { |
|
54 | 54 | $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
55 | 55 | return new ShareController( |
56 | 56 | $c->query('AppName'), |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $server->getThemingDefaults() |
71 | 71 | ); |
72 | 72 | }); |
73 | - $container->registerService('ExternalSharesController', function (SimpleContainer $c) { |
|
73 | + $container->registerService('ExternalSharesController', function(SimpleContainer $c) { |
|
74 | 74 | return new ExternalSharesController( |
75 | 75 | $c->query('AppName'), |
76 | 76 | $c->query('Request'), |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * Core class wrappers |
84 | 84 | */ |
85 | - $container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) { |
|
85 | + $container->registerService('HttpClientService', function(SimpleContainer $c) use ($server) { |
|
86 | 86 | return $server->getHTTPClientService(); |
87 | 87 | }); |
88 | - $container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) { |
|
88 | + $container->registerService(ICloudIdManager::class, function(SimpleContainer $c) use ($server) { |
|
89 | 89 | return $server->getCloudIdManager(); |
90 | 90 | }); |
91 | - $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { |
|
91 | + $container->registerService('ExternalManager', function(SimpleContainer $c) use ($server) { |
|
92 | 92 | $user = $server->getUserSession()->getUser(); |
93 | 93 | $uid = $user ? $user->getUID() : null; |
94 | 94 | $discoveryManager = new DiscoveryManager( |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | /** |
111 | 111 | * Middleware |
112 | 112 | */ |
113 | - $container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) { |
|
113 | + $container->registerService('SharingCheckMiddleware', function(SimpleContainer $c) use ($server) { |
|
114 | 114 | return new SharingCheckMiddleware( |
115 | 115 | $c->query('AppName'), |
116 | 116 | $server->getConfig(), |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | ); |
122 | 122 | }); |
123 | 123 | |
124 | - $container->registerService('OCSShareAPIMiddleware', function (SimpleContainer $c) use ($server) { |
|
124 | + $container->registerService('OCSShareAPIMiddleware', function(SimpleContainer $c) use ($server) { |
|
125 | 125 | return new OCSShareAPIMiddleware( |
126 | 126 | $server->getShareManager(), |
127 | 127 | $server->getL10N($c->query('AppName')) |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $container->registerMiddleWare('SharingCheckMiddleware'); |
133 | 133 | $container->registerMiddleWare('OCSShareAPIMiddleware'); |
134 | 134 | |
135 | - $container->registerService('MountProvider', function (IContainer $c) { |
|
135 | + $container->registerService('MountProvider', function(IContainer $c) { |
|
136 | 136 | /** @var \OCP\IServerContainer $server */ |
137 | 137 | $server = $c->query('ServerContainer'); |
138 | 138 | return new MountProvider( |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | ); |
143 | 143 | }); |
144 | 144 | |
145 | - $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
145 | + $container->registerService('ExternalMountProvider', function(IContainer $c) { |
|
146 | 146 | /** @var \OCP\IServerContainer $server */ |
147 | 147 | $server = $c->query('ServerContainer'); |
148 | 148 | return new \OCA\Files_Sharing\External\MountProvider( |
@@ -32,97 +32,97 @@ |
||
32 | 32 | use OCP\Files\StorageNotAvailableException; |
33 | 33 | |
34 | 34 | class Scanner extends \OC\Files\Cache\Scanner { |
35 | - /** @var \OCA\Files_Sharing\External\Storage */ |
|
36 | - protected $storage; |
|
35 | + /** @var \OCA\Files_Sharing\External\Storage */ |
|
36 | + protected $storage; |
|
37 | 37 | |
38 | - /** {@inheritDoc} */ |
|
39 | - public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { |
|
40 | - if(!$this->storage->remoteIsOwnCloud()) { |
|
41 | - return parent::scan($path, $recursive, $recursive, $lock); |
|
42 | - } |
|
38 | + /** {@inheritDoc} */ |
|
39 | + public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { |
|
40 | + if(!$this->storage->remoteIsOwnCloud()) { |
|
41 | + return parent::scan($path, $recursive, $recursive, $lock); |
|
42 | + } |
|
43 | 43 | |
44 | - $this->scanAll(); |
|
45 | - } |
|
44 | + $this->scanAll(); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Scan a single file and store it in the cache. |
|
49 | - * If an exception happened while accessing the external storage, |
|
50 | - * the storage will be checked for availability and removed |
|
51 | - * if it is not available any more. |
|
52 | - * |
|
53 | - * @param string $file file to scan |
|
54 | - * @param int $reuseExisting |
|
55 | - * @param int $parentId |
|
56 | - * @param array | null $cacheData existing data in the cache for the file to be scanned |
|
57 | - * @param bool $lock set to false to disable getting an additional read lock during scanning |
|
58 | - * @return array an array of metadata of the scanned file |
|
59 | - */ |
|
60 | - public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) { |
|
61 | - try { |
|
62 | - return parent::scanFile($file, $reuseExisting); |
|
63 | - } catch (ForbiddenException $e) { |
|
64 | - $this->storage->checkStorageAvailability(); |
|
65 | - } catch (NotFoundException $e) { |
|
66 | - // if the storage isn't found, the call to |
|
67 | - // checkStorageAvailable() will verify it and remove it |
|
68 | - // if appropriate |
|
69 | - $this->storage->checkStorageAvailability(); |
|
70 | - } catch (StorageInvalidException $e) { |
|
71 | - $this->storage->checkStorageAvailability(); |
|
72 | - } catch (StorageNotAvailableException $e) { |
|
73 | - $this->storage->checkStorageAvailability(); |
|
74 | - } |
|
75 | - } |
|
47 | + /** |
|
48 | + * Scan a single file and store it in the cache. |
|
49 | + * If an exception happened while accessing the external storage, |
|
50 | + * the storage will be checked for availability and removed |
|
51 | + * if it is not available any more. |
|
52 | + * |
|
53 | + * @param string $file file to scan |
|
54 | + * @param int $reuseExisting |
|
55 | + * @param int $parentId |
|
56 | + * @param array | null $cacheData existing data in the cache for the file to be scanned |
|
57 | + * @param bool $lock set to false to disable getting an additional read lock during scanning |
|
58 | + * @return array an array of metadata of the scanned file |
|
59 | + */ |
|
60 | + public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) { |
|
61 | + try { |
|
62 | + return parent::scanFile($file, $reuseExisting); |
|
63 | + } catch (ForbiddenException $e) { |
|
64 | + $this->storage->checkStorageAvailability(); |
|
65 | + } catch (NotFoundException $e) { |
|
66 | + // if the storage isn't found, the call to |
|
67 | + // checkStorageAvailable() will verify it and remove it |
|
68 | + // if appropriate |
|
69 | + $this->storage->checkStorageAvailability(); |
|
70 | + } catch (StorageInvalidException $e) { |
|
71 | + $this->storage->checkStorageAvailability(); |
|
72 | + } catch (StorageNotAvailableException $e) { |
|
73 | + $this->storage->checkStorageAvailability(); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Checks the remote share for changes. |
|
79 | - * If changes are available, scan them and update |
|
80 | - * the cache. |
|
81 | - * @throws NotFoundException |
|
82 | - * @throws StorageInvalidException |
|
83 | - * @throws \Exception |
|
84 | - */ |
|
85 | - public function scanAll() { |
|
86 | - try { |
|
87 | - $data = $this->storage->getShareInfo(); |
|
88 | - } catch (\Exception $e) { |
|
89 | - $this->storage->checkStorageAvailability(); |
|
90 | - throw new \Exception( |
|
91 | - 'Error while scanning remote share: "' . |
|
92 | - $this->storage->getRemote() . '" ' . |
|
93 | - $e->getMessage() |
|
94 | - ); |
|
95 | - } |
|
96 | - if ($data['status'] === 'success') { |
|
97 | - $this->addResult($data['data'], ''); |
|
98 | - } else { |
|
99 | - throw new \Exception( |
|
100 | - 'Error while scanning remote share: "' . |
|
101 | - $this->storage->getRemote() . '"' |
|
102 | - ); |
|
103 | - } |
|
104 | - } |
|
77 | + /** |
|
78 | + * Checks the remote share for changes. |
|
79 | + * If changes are available, scan them and update |
|
80 | + * the cache. |
|
81 | + * @throws NotFoundException |
|
82 | + * @throws StorageInvalidException |
|
83 | + * @throws \Exception |
|
84 | + */ |
|
85 | + public function scanAll() { |
|
86 | + try { |
|
87 | + $data = $this->storage->getShareInfo(); |
|
88 | + } catch (\Exception $e) { |
|
89 | + $this->storage->checkStorageAvailability(); |
|
90 | + throw new \Exception( |
|
91 | + 'Error while scanning remote share: "' . |
|
92 | + $this->storage->getRemote() . '" ' . |
|
93 | + $e->getMessage() |
|
94 | + ); |
|
95 | + } |
|
96 | + if ($data['status'] === 'success') { |
|
97 | + $this->addResult($data['data'], ''); |
|
98 | + } else { |
|
99 | + throw new \Exception( |
|
100 | + 'Error while scanning remote share: "' . |
|
101 | + $this->storage->getRemote() . '"' |
|
102 | + ); |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @param array $data |
|
108 | - * @param string $path |
|
109 | - */ |
|
110 | - private function addResult($data, $path) { |
|
111 | - $id = $this->cache->put($path, $data); |
|
112 | - if (isset($data['children'])) { |
|
113 | - $children = []; |
|
114 | - foreach ($data['children'] as $child) { |
|
115 | - $children[$child['name']] = true; |
|
116 | - $this->addResult($child, ltrim($path . '/' . $child['name'], '/')); |
|
117 | - } |
|
106 | + /** |
|
107 | + * @param array $data |
|
108 | + * @param string $path |
|
109 | + */ |
|
110 | + private function addResult($data, $path) { |
|
111 | + $id = $this->cache->put($path, $data); |
|
112 | + if (isset($data['children'])) { |
|
113 | + $children = []; |
|
114 | + foreach ($data['children'] as $child) { |
|
115 | + $children[$child['name']] = true; |
|
116 | + $this->addResult($child, ltrim($path . '/' . $child['name'], '/')); |
|
117 | + } |
|
118 | 118 | |
119 | - $existingCache = $this->cache->getFolderContentsById($id); |
|
120 | - foreach ($existingCache as $existingChild) { |
|
121 | - // if an existing child is not in the new data, remove it |
|
122 | - if (!isset($children[$existingChild['name']])) { |
|
123 | - $this->cache->remove(ltrim($path . '/' . $existingChild['name'], '/')); |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
127 | - } |
|
119 | + $existingCache = $this->cache->getFolderContentsById($id); |
|
120 | + foreach ($existingCache as $existingChild) { |
|
121 | + // if an existing child is not in the new data, remove it |
|
122 | + if (!isset($children[$existingChild['name']])) { |
|
123 | + $this->cache->remove(ltrim($path . '/' . $existingChild['name'], '/')); |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | + } |
|
128 | 128 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | /** {@inheritDoc} */ |
39 | 39 | public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { |
40 | - if(!$this->storage->remoteIsOwnCloud()) { |
|
40 | + if (!$this->storage->remoteIsOwnCloud()) { |
|
41 | 41 | return parent::scan($path, $recursive, $recursive, $lock); |
42 | 42 | } |
43 | 43 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | } catch (\Exception $e) { |
89 | 89 | $this->storage->checkStorageAvailability(); |
90 | 90 | throw new \Exception( |
91 | - 'Error while scanning remote share: "' . |
|
92 | - $this->storage->getRemote() . '" ' . |
|
91 | + 'Error while scanning remote share: "'. |
|
92 | + $this->storage->getRemote().'" '. |
|
93 | 93 | $e->getMessage() |
94 | 94 | ); |
95 | 95 | } |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | $this->addResult($data['data'], ''); |
98 | 98 | } else { |
99 | 99 | throw new \Exception( |
100 | - 'Error while scanning remote share: "' . |
|
101 | - $this->storage->getRemote() . '"' |
|
100 | + 'Error while scanning remote share: "'. |
|
101 | + $this->storage->getRemote().'"' |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | } |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | $children = []; |
114 | 114 | foreach ($data['children'] as $child) { |
115 | 115 | $children[$child['name']] = true; |
116 | - $this->addResult($child, ltrim($path . '/' . $child['name'], '/')); |
|
116 | + $this->addResult($child, ltrim($path.'/'.$child['name'], '/')); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | $existingCache = $this->cache->getFolderContentsById($id); |
120 | 120 | foreach ($existingCache as $existingChild) { |
121 | 121 | // if an existing child is not in the new data, remove it |
122 | 122 | if (!isset($children[$existingChild['name']])) { |
123 | - $this->cache->remove(ltrim($path . '/' . $existingChild['name'], '/')); |
|
123 | + $this->cache->remove(ltrim($path.'/'.$existingChild['name'], '/')); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |