Skip to content

Commit cc47041

Browse files
committed
Code cleanup
- Remove trailing and leading space - Remove unneeded `use` statements - Sort `use` statements alphabetically
1 parent 2dad4fe commit cc47041

4 files changed

Lines changed: 50 additions & 60 deletions

File tree

solid/lib/Controller/AppController.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
namespace OCA\Solid\Controller;
33

44
use OCA\Solid\ServerConfig;
5-
use OCP\IRequest;
6-
use OCP\IUserManager;
7-
use OCP\Contacts\IManager;
8-
use OCP\IURLGenerator;
9-
use OCP\IConfig;
10-
use OCP\AppFramework\Http;
11-
use OCP\AppFramework\Http\TemplateResponse;
12-
use OCP\AppFramework\Http\DataResponse;
5+
136
use OCP\AppFramework\Controller;
14-
use OCP\AppFramework\Http\JSONResponse;
7+
use OCP\AppFramework\Http;
158
use OCP\AppFramework\Http\ContentSecurityPolicy;
9+
use OCP\AppFramework\Http\JSONResponse;
10+
use OCP\AppFramework\Http\TemplateResponse;
11+
use OCP\Contacts\IManager;
12+
use OCP\IConfig;
13+
use OCP\IRequest;
14+
use OCP\IURLGenerator;
15+
use OCP\IUserManager;
1616

1717
class AppController extends Controller {
1818
private $userId;
@@ -33,7 +33,7 @@ public function __construct($AppName, IRequest $request, IConfig $config, IUserM
3333
// $this->userDomains = $userDomains;
3434
}
3535

36-
private function getUserApps($userId) {
36+
private function getUserApps($userId) {
3737
$userApps = [];
3838
if ($this->userManager->userExists($userId)) {
3939
$allowedClients = $this->config->getAllowedClients($userId);
@@ -49,7 +49,7 @@ private function getAppsList() {
4949
$path = __DIR__ . "/../solid-app-list.json";
5050
$appsListJson = file_get_contents($path);
5151
$appsList = json_decode($appsListJson, true);
52-
52+
5353
$userApps = $this->getUserApps($this->userId);
5454

5555
foreach ($appsList as $key => $app) {

solid/lib/Controller/ProfileController.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ProfileController extends Controller {
2727

2828
/* @var ISession */
2929
private $session;
30-
30+
3131
public function __construct(
3232
$AppName,
3333
IRequest $request,
@@ -82,7 +82,7 @@ private function getFileSystem($userId) {
8282
$filesystem = new \League\Flysystem\Filesystem($rdfAdapter);
8383

8484
$filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats));
85-
85+
8686
$plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph);
8787
$filesystem->addPlugin($plugin);
8888

@@ -102,7 +102,7 @@ private function generateDefaultAcl($userId) {
102102
acl:accessTo <./>;
103103
acl:default <./>;
104104
acl:mode acl:Read.
105-
105+
106106
# The owner has full access to every resource in their pod.
107107
# Other agents have no access rights,
108108
# unless specifically authorized in other .acl resources.
@@ -165,11 +165,11 @@ public function handleRequest($userId, $path) {
165165

166166
$this->filesystem = $this->getFileSystem($userId);
167167

168-
$this->resourceServer = new ResourceServer($this->filesystem, $this->response);
168+
$this->resourceServer = new ResourceServer($this->filesystem, $this->response);
169169
$this->WAC = new WAC($this->filesystem);
170170

171171
$request = $this->rawRequest;
172-
$baseUrl = $this->getProfileUrl($userId);
172+
$baseUrl = $this->getProfileUrl($userId);
173173
$this->resourceServer->setBaseUrl($baseUrl);
174174
$this->WAC->setBaseUrl($baseUrl);
175175
$notifications = new SolidNotifications();
@@ -194,21 +194,21 @@ public function handleRequest($userId, $path) {
194194
return $this->respond($response);
195195
}
196196

197-
$response = $this->resourceServer->respondToRequest($request);
197+
$response = $this->resourceServer->respondToRequest($request);
198198
$response = $this->WAC->addWACHeaders($request, $response, $webId);
199199
return $this->respond($response);
200200
}
201-
201+
202202
/**
203203
* @PublicPage
204204
* @NoAdminRequired
205205
* @NoCSRFRequired
206206
*/
207-
public function handleGet($userId, $path) {
207+
public function handleGet($userId, $path) {
208208
//TODO: check that the $userId matches the userDomain, if enabled.
209209
return $this->handleRequest($userId, $path);
210210
}
211-
211+
212212
/**
213213
* @PublicPage
214214
* @NoAdminRequired
@@ -225,15 +225,15 @@ public function handlePost($userId, $path) {
225225
public function handlePut() { // $userId, $path) {
226226
// FIXME: Adding the correct variables in the function name will make nextcloud
227227
// throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
228-
228+
229229
// because we got here, the request uri should look like:
230230
// /index.php/apps/solid/@{userId}/storage{path}
231231
$pathInfo = explode("@", $_SERVER['REQUEST_URI']);
232232
$pathInfo = explode("/", $pathInfo[1], 2);
233233
$userId = $pathInfo[0];
234234
$path = $pathInfo[1];
235235
$path = preg_replace("/^profile/", "", $path);
236-
236+
237237
return $this->handleRequest($userId, $path);
238238
}
239239
/**
@@ -339,9 +339,9 @@ private function generateTurtleProfile($userId) {
339339
@prefix inbox: <<?php echo $profile['inbox']; ?>>.
340340
@prefix sp: <http://www.w3.org/ns/pim/space#>.
341341
@prefix ser: <<?php echo $profile['storage']; ?>>.
342-
342+
343343
pro:card a foaf:PersonalProfileDocument; foaf:maker :me; foaf:primaryTopic :me.
344-
344+
345345
:me
346346
a schem:Person, foaf:Person;
347347
ldp:inbox inbox:;

solid/lib/Controller/SolidWebhookController.php

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,22 @@
33
namespace OCA\Solid\Controller;
44

55
use Closure;
6-
use OCA\Solid\AppInfo\Application;
7-
use OCA\Solid\Service\SolidWebhookService;
8-
use OCA\Solid\ServerConfig;
9-
use OCA\Solid\PlainResponse;
10-
use OCA\Solid\Notifications\SolidNotifications;
6+
117
use OCA\Solid\DpopFactoryTrait;
8+
use OCA\Solid\PlainResponse;
9+
use OCA\Solid\Service\SolidWebhookService;
1210

1311
use OCP\AppFramework\Controller;
12+
use OCP\AppFramework\Http;
1413
use OCP\AppFramework\Http\DataResponse;
14+
use OCP\Files\IRootFolder;
15+
use OCP\IConfig;
16+
use OCP\IDBConnection;
1517
use OCP\IRequest;
16-
use OCP\IUserManager;
17-
use OCP\IURLGenerator;
1818
use OCP\ISession;
19-
use OCP\IDBConnection;
20-
use OCP\IConfig;
21-
use OCP\Files\IRootFolder;
22-
use OCP\Files\IHomeStorage;
23-
use OCP\Files\SimpleFS\ISimpleRoot;
24-
use OCP\AppFramework\Http;
25-
use OCP\AppFramework\Http\Response;
26-
use OCP\AppFramework\Http\JSONResponse;
27-
use OCP\AppFramework\Http\ContentSecurityPolicy;
19+
use OCP\IURLGenerator;
20+
use OCP\IUserManager;
2821

29-
use Pdsinterop\Solid\Resources\Server as ResourceServer;
30-
use Pdsinterop\Solid\Auth\Utils\DPop as DPop;
3122
use Pdsinterop\Solid\Auth\WAC as WAC;
3223

3324
class SolidWebhookController extends Controller {
@@ -38,7 +29,7 @@ class SolidWebhookController extends Controller {
3829

3930
/* @var ISession */
4031
private $session;
41-
32+
4233
/** @var SolidWebhookService */
4334
private $webhookService;
4435

@@ -139,7 +130,7 @@ private function getFileSystem() {
139130
$filesystem = new \League\Flysystem\Filesystem($rdfAdapter);
140131

141132
$filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats));
142-
133+
143134
$plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph);
144135
$filesystem->addPlugin($plugin);
145136

@@ -175,7 +166,7 @@ private function parseTopic($topic) {
175166
"path" => $storagePath
176167
);
177168
}
178-
169+
179170
private function createGetRequest($topic) {
180171
$serverParams = [];
181172
$fileParams = [];
@@ -192,15 +183,15 @@ private function createGetRequest($topic) {
192183
$headers
193184
);
194185
}
195-
186+
196187
private function checkReadAccess($topic) {
197188
// split out $topic into $userId and $path https://nextcloud.server/solid/@alice/storage/foo/bar
198189
// - userId in this case is the pod owner (not the one doing the request). (alice)
199190
// - path is the path within the storage pod (/foo/bar)
200191
$target = $this->parseTopic($topic);
201192
$userId = $target["userId"];
202193
$path = $target["path"];
203-
194+
204195
$this->initializeStorage($userId);
205196
$this->WAC = new WAC($this->filesystem);
206197

solid/lib/Controller/StorageController.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22
namespace OCA\Solid\Controller;
33

4-
use OCA\Solid\DpopFactoryTrait;
54
use OCA\Solid\BearerFactoryTrait;
6-
use OCA\Solid\PlainResponse;
5+
use OCA\Solid\DpopFactoryTrait;
76
use OCA\Solid\Notifications\SolidNotifications;
7+
use OCA\Solid\PlainResponse;
88

99
use OCP\AppFramework\Controller;
1010
use OCP\AppFramework\Http;
11+
use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
1112
use OCP\Files\IRootFolder;
1213
use OCP\IConfig;
1314
use OCP\IDBConnection;
@@ -16,8 +17,6 @@
1617
use OCP\IURLGenerator;
1718
use OCP\IUserManager;
1819

19-
use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
20-
2120
use Pdsinterop\Solid\Auth\WAC;
2221
use Pdsinterop\Solid\Resources\Server as ResourceServer;
2322

@@ -80,7 +79,7 @@ private function getFileSystem() {
8079
$filesystem = new \League\Flysystem\Filesystem($rdfAdapter);
8180

8281
$filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats));
83-
82+
8483
$plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph);
8584
$filesystem->addPlugin($plugin);
8685

@@ -307,7 +306,7 @@ public function handleRequest($userId, $path) {
307306
$this->WAC = new WAC($this->filesystem);
308307

309308
$request = $this->rawRequest;
310-
$baseUrl = $this->getStorageUrl($userId);
309+
$baseUrl = $this->getStorageUrl($userId);
311310
$this->resourceServer->setBaseUrl($baseUrl);
312311
$this->WAC->setBaseUrl($baseUrl);
313312

@@ -355,20 +354,20 @@ public function handleRequest($userId, $path) {
355354
->withStatus(403, "Access denied");
356355
return $this->respond($response);
357356
}
358-
$response = $this->resourceServer->respondToRequest($request);
357+
$response = $this->resourceServer->respondToRequest($request);
359358
$response = $this->WAC->addWACHeaders($request, $response, $webId);
360359
return $this->respond($response);
361360
}
362-
361+
363362
/**
364363
* @PublicPage
365364
* @NoAdminRequired
366365
* @NoCSRFRequired
367366
*/
368-
public function handleGet($userId, $path) {
367+
public function handleGet($userId, $path) {
369368
return $this->handleRequest($userId, $path);
370369
}
371-
370+
372371
/**
373372
* @PublicPage
374373
* @NoAdminRequired
@@ -385,15 +384,15 @@ public function handlePost($userId, $path) {
385384
public function handlePut() { // $userId, $path) {
386385
// FIXME: Adding the correct variables in the function name will make nextcloud
387386
// throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
388-
387+
389388
// because we got here, the request uri should look like:
390389
// /index.php/apps/solid/@{userId}/storage{path}
391390
$pathInfo = explode("@", $_SERVER['REQUEST_URI']);
392391
$pathInfo = explode("/", $pathInfo[1], 2);
393392
$userId = $pathInfo[0];
394393
$path = $pathInfo[1];
395394
$path = preg_replace("/^storage/", "", $path);
396-
395+
397396
return $this->handleRequest($userId, $path);
398397
}
399398
/**
@@ -438,7 +437,7 @@ private function respond($response) {
438437
// $result->addHeader('Access-Control-Allow-Credentials', 'true');
439438
// $result->addHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
440439
// $result->addHeader('Access-Control-Allow-Origin', $origin);
441-
440+
442441
$policy = new EmptyContentSecurityPolicy();
443442
$policy->addAllowedStyleDomain("*");
444443
$policy->addAllowedStyleDomain("data:");

0 commit comments

Comments
 (0)