Completed
Pull Request — master (#9345)
by Björn
22:56
created
apps/cloud_federation_api/lib/Controller/RequestHandlerController.php 2 patches
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -47,212 +47,212 @@
 block discarded – undo
47 47
  */
48 48
 class RequestHandlerController extends Controller {
49 49
 
50
-	/** @var ILogger */
51
-	private $logger;
52
-
53
-	/** @var IUserManager */
54
-	private $userManager;
55
-
56
-	/** @var IURLGenerator */
57
-	private $urlGenerator;
58
-
59
-	/** @var ICloudFederationProviderManager */
60
-	private $cloudFederationProviderManager;
61
-
62
-	/** @var Config */
63
-	private $config;
64
-
65
-	/** @var ICloudFederationFactory */
66
-	private $factory;
67
-
68
-	public function __construct($appName,
69
-								IRequest $request,
70
-								ILogger $logger,
71
-								IUserManager $userManager,
72
-								IURLGenerator $urlGenerator,
73
-								ICloudFederationProviderManager $cloudFederationProviderManager,
74
-								Config $config,
75
-								ICloudFederationFactory $factory
76
-	) {
77
-		parent::__construct($appName, $request);
78
-
79
-		$this->logger = $logger;
80
-		$this->userManager = $userManager;
81
-		$this->urlGenerator = $urlGenerator;
82
-		$this->cloudFederationProviderManager = $cloudFederationProviderManager;
83
-		$this->config = $config;
84
-		$this->factory = $factory;
85
-	}
86
-
87
-	/**
88
-	 * add share
89
-	 *
90
-	 * @NoCSRFRequired
91
-	 * @PublicPage
92
-	 * @BruteForceProtection(action=receiveFederatedShare)
93
-	 *
94
-	 * @param string $shareWith
95
-	 * @param string $name resource name (e.g. document.odt)
96
-	 * @param string $description share description (optional)
97
-	 * @param string $providerId resource UID on the provider side
98
-	 * @param string $owner provider specific UID of the user who owns the resource
99
-	 * @param string $ownerDisplayName display name of the user who shared the item
100
-	 * @param string $sharedBy provider specific UID of the user who shared the resource
101
-	 * @param $sharedByDisplayName display name of the user who shared the resource
102
-	 * @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
103
-	 * @param string $shareType ('group' or 'user' share)
104
-	 * @param $resourceType ('file', 'calendar',...)
105
-	 * @return Http\DataResponse|JSONResponse
106
-	 *
107
-	 * Example: curl -H "Content-Type: application/json" -X POST -d '{"shareWith":"admin1","name":"welcome server2.txt","description":"desc","providerId":"2","owner":"admin2@http://localhost/server2","ownerDisplayName":"admin2 display","shareType":"user","resourceType":"file","protocol":{"name":"webdav","options":{"access_token":"8Lrd1FVEREthux7","permissions":31}}}' http://localhost/server/index.php/ocm/shares
108
-	 */
109
-	public function addShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) {
110
-
111
-		if (!$this->config->incomingRequestsEnabled()) {
112
-			return new JSONResponse(
113
-				['message' => 'This server doesn\'t support outgoing federated shares'],
114
-			Http::STATUS_NOT_IMPLEMENTED
115
-			);
116
-		}
117
-
118
-		// check if all required parameters are set
119
-		if ($shareWith === null ||
120
-			$name === null ||
121
-			$providerId === null ||
122
-			$owner === null ||
123
-			$resourceType === null ||
124
-			$shareType === null ||
125
-			!is_array($protocol) ||
126
-			!isset($protocol['name']) ||
127
-			!isset ($protocol['options']) ||
128
-			!is_array($protocol['options'])
129
-		) {
130
-			return new JSONResponse(
131
-				['message' => 'Missing arguments'],
132
-				Http::STATUS_BAD_REQUEST
133
-			);
134
-		}
135
-
136
-		$shareWith = $this->mapUid($shareWith);
137
-
138
-		if (!$this->userManager->userExists($shareWith)) {
139
-			return new JSONResponse(
140
-				['message' => 'User "' . $shareWith . '" does not exists at ' . $this->urlGenerator->getBaseUrl()],
141
-				Http::STATUS_BAD_REQUEST
142
-			);
143
-		}
144
-
145
-		// if no explicit display name is given, we use the uid as display name
146
-		$ownerDisplayName = $ownerDisplayName === null ? $owner : $ownerDisplayName;
147
-		$sharedByDisplayName = $sharedByDisplayName === null ? $sharedBy : $sharedByDisplayName;
148
-
149
-		// sharedBy* parameter is optional, if nothing is set we assume that it is the same user as the owner
150
-		if ($sharedBy === null) {
151
-			$sharedBy = $owner;
152
-			$sharedByDisplayName = $ownerDisplayName;
153
-		}
154
-
155
-		try {
156
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType);
157
-			$share = $this->factory->getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType);
158
-			$id = $provider->shareReceived($share);
159
-		} catch (ProviderDoesNotExistsException $e) {
160
-			return new JSONResponse(
161
-				['message' => $e->getMessage()],
162
-				Http::STATUS_NOT_IMPLEMENTED
163
-			);
164
-		} catch (ProviderCouldNotAddShareException $e) {
165
-			return new JSONResponse(
166
-				['message' => $e->getMessage()],
167
-				$e->getCode()
168
-			);
169
-		} catch (\Exception $e) {
170
-			return new JSONResponse(
171
-				['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
172
-				Http::STATUS_BAD_REQUEST
173
-			);
174
-		}
175
-
176
-		return new JSONResponse(
177
-			['id' => $id, 'createdAt' => time()],
178
-			Http::STATUS_CREATED);
179
-
180
-	}
181
-
182
-	/**
183
-	 * receive notification about existing share
184
-	 *
185
-	 * @param string $version API version
186
-	 * @param string $name resource name (e.g "file", "calendar",...)
187
-	 * @param string $id unique id of the corresponding item on the receiving site
188
-	 * @param array $notification contain the actual notification, content is defined by cloud federation provider
189
-	 * @return JSONResponse
190
-	 */
191
-	public function receiveNotification($version, $name, $id, $notification) {
192
-		if (!$this->config->incomingRequestsEnabled()) {
193
-			return new JSONResponse(
194
-				['message' => 'This server doesn\'t support outgoing federated shares'],
195
-				Http::STATUS_NOT_IMPLEMENTED
196
-			);
197
-		}
198
-
199
-		// check if all required parameters are set
200
-		if ($name === null ||
201
-			$id === null ||
202
-			!is_array($notification)
203
-		) {
204
-			return new JSONResponse(
205
-				['message' => 'Missing arguments'],
206
-				Http::STATUS_BAD_REQUEST
207
-			);
208
-		}
209
-
210
-		try {
211
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider($name);
212
-			$provider->notificationReceived($id, $notification);
213
-		} catch (ProviderDoesNotExistsException $e) {
214
-			return new JSONResponse(
215
-				['message' => $e->getMessage()],
216
-				Http::STATUS_BAD_REQUEST
217
-			);
218
-		} catch (ShareNotFoundException $e) {
219
-			return new JSONResponse(
220
-				['message' => $e->getMessage()],
221
-				Http::STATUS_BAD_REQUEST
222
-			);
223
-		} catch (\Exception $e) {
224
-			return new JSONResponse(
225
-				['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
226
-				Http::STATUS_BAD_REQUEST
227
-			);
228
-		}
229
-
230
-
231
-		return new JSONResponse(
232
-			['id' => $id, 'createdAt' => date()],
233
-			Http::STATUS_CREATED);
234
-
235
-
236
-	}
237
-
238
-	/**
239
-	 * map login name to internal LDAP UID if a LDAP backend is in use
240
-	 *
241
-	 * @param string $uid
242
-	 * @return string mixed
243
-	 */
244
-	private function mapUid($uid) {
245
-		\OC::$server->getURLGenerator()->linkToDocs('key');
246
-		// FIXME this should be a method in the user management instead
247
-		$this->logger->debug('shareWith before, ' . $uid, ['app' => $this->appName]);
248
-		\OCP\Util::emitHook(
249
-			'\OCA\Files_Sharing\API\Server2Server',
250
-			'preLoginNameUsedAsUserName',
251
-			array('uid' => &$uid)
252
-		);
253
-		$this->logger->debug('shareWith after, ' . $uid, ['app' => $this->appName]);
254
-
255
-		return $uid;
256
-	}
50
+    /** @var ILogger */
51
+    private $logger;
52
+
53
+    /** @var IUserManager */
54
+    private $userManager;
55
+
56
+    /** @var IURLGenerator */
57
+    private $urlGenerator;
58
+
59
+    /** @var ICloudFederationProviderManager */
60
+    private $cloudFederationProviderManager;
61
+
62
+    /** @var Config */
63
+    private $config;
64
+
65
+    /** @var ICloudFederationFactory */
66
+    private $factory;
67
+
68
+    public function __construct($appName,
69
+                                IRequest $request,
70
+                                ILogger $logger,
71
+                                IUserManager $userManager,
72
+                                IURLGenerator $urlGenerator,
73
+                                ICloudFederationProviderManager $cloudFederationProviderManager,
74
+                                Config $config,
75
+                                ICloudFederationFactory $factory
76
+    ) {
77
+        parent::__construct($appName, $request);
78
+
79
+        $this->logger = $logger;
80
+        $this->userManager = $userManager;
81
+        $this->urlGenerator = $urlGenerator;
82
+        $this->cloudFederationProviderManager = $cloudFederationProviderManager;
83
+        $this->config = $config;
84
+        $this->factory = $factory;
85
+    }
86
+
87
+    /**
88
+     * add share
89
+     *
90
+     * @NoCSRFRequired
91
+     * @PublicPage
92
+     * @BruteForceProtection(action=receiveFederatedShare)
93
+     *
94
+     * @param string $shareWith
95
+     * @param string $name resource name (e.g. document.odt)
96
+     * @param string $description share description (optional)
97
+     * @param string $providerId resource UID on the provider side
98
+     * @param string $owner provider specific UID of the user who owns the resource
99
+     * @param string $ownerDisplayName display name of the user who shared the item
100
+     * @param string $sharedBy provider specific UID of the user who shared the resource
101
+     * @param $sharedByDisplayName display name of the user who shared the resource
102
+     * @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
103
+     * @param string $shareType ('group' or 'user' share)
104
+     * @param $resourceType ('file', 'calendar',...)
105
+     * @return Http\DataResponse|JSONResponse
106
+     *
107
+     * Example: curl -H "Content-Type: application/json" -X POST -d '{"shareWith":"admin1","name":"welcome server2.txt","description":"desc","providerId":"2","owner":"admin2@http://localhost/server2","ownerDisplayName":"admin2 display","shareType":"user","resourceType":"file","protocol":{"name":"webdav","options":{"access_token":"8Lrd1FVEREthux7","permissions":31}}}' http://localhost/server/index.php/ocm/shares
108
+     */
109
+    public function addShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) {
110
+
111
+        if (!$this->config->incomingRequestsEnabled()) {
112
+            return new JSONResponse(
113
+                ['message' => 'This server doesn\'t support outgoing federated shares'],
114
+            Http::STATUS_NOT_IMPLEMENTED
115
+            );
116
+        }
117
+
118
+        // check if all required parameters are set
119
+        if ($shareWith === null ||
120
+            $name === null ||
121
+            $providerId === null ||
122
+            $owner === null ||
123
+            $resourceType === null ||
124
+            $shareType === null ||
125
+            !is_array($protocol) ||
126
+            !isset($protocol['name']) ||
127
+            !isset ($protocol['options']) ||
128
+            !is_array($protocol['options'])
129
+        ) {
130
+            return new JSONResponse(
131
+                ['message' => 'Missing arguments'],
132
+                Http::STATUS_BAD_REQUEST
133
+            );
134
+        }
135
+
136
+        $shareWith = $this->mapUid($shareWith);
137
+
138
+        if (!$this->userManager->userExists($shareWith)) {
139
+            return new JSONResponse(
140
+                ['message' => 'User "' . $shareWith . '" does not exists at ' . $this->urlGenerator->getBaseUrl()],
141
+                Http::STATUS_BAD_REQUEST
142
+            );
143
+        }
144
+
145
+        // if no explicit display name is given, we use the uid as display name
146
+        $ownerDisplayName = $ownerDisplayName === null ? $owner : $ownerDisplayName;
147
+        $sharedByDisplayName = $sharedByDisplayName === null ? $sharedBy : $sharedByDisplayName;
148
+
149
+        // sharedBy* parameter is optional, if nothing is set we assume that it is the same user as the owner
150
+        if ($sharedBy === null) {
151
+            $sharedBy = $owner;
152
+            $sharedByDisplayName = $ownerDisplayName;
153
+        }
154
+
155
+        try {
156
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType);
157
+            $share = $this->factory->getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType);
158
+            $id = $provider->shareReceived($share);
159
+        } catch (ProviderDoesNotExistsException $e) {
160
+            return new JSONResponse(
161
+                ['message' => $e->getMessage()],
162
+                Http::STATUS_NOT_IMPLEMENTED
163
+            );
164
+        } catch (ProviderCouldNotAddShareException $e) {
165
+            return new JSONResponse(
166
+                ['message' => $e->getMessage()],
167
+                $e->getCode()
168
+            );
169
+        } catch (\Exception $e) {
170
+            return new JSONResponse(
171
+                ['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
172
+                Http::STATUS_BAD_REQUEST
173
+            );
174
+        }
175
+
176
+        return new JSONResponse(
177
+            ['id' => $id, 'createdAt' => time()],
178
+            Http::STATUS_CREATED);
179
+
180
+    }
181
+
182
+    /**
183
+     * receive notification about existing share
184
+     *
185
+     * @param string $version API version
186
+     * @param string $name resource name (e.g "file", "calendar",...)
187
+     * @param string $id unique id of the corresponding item on the receiving site
188
+     * @param array $notification contain the actual notification, content is defined by cloud federation provider
189
+     * @return JSONResponse
190
+     */
191
+    public function receiveNotification($version, $name, $id, $notification) {
192
+        if (!$this->config->incomingRequestsEnabled()) {
193
+            return new JSONResponse(
194
+                ['message' => 'This server doesn\'t support outgoing federated shares'],
195
+                Http::STATUS_NOT_IMPLEMENTED
196
+            );
197
+        }
198
+
199
+        // check if all required parameters are set
200
+        if ($name === null ||
201
+            $id === null ||
202
+            !is_array($notification)
203
+        ) {
204
+            return new JSONResponse(
205
+                ['message' => 'Missing arguments'],
206
+                Http::STATUS_BAD_REQUEST
207
+            );
208
+        }
209
+
210
+        try {
211
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($name);
212
+            $provider->notificationReceived($id, $notification);
213
+        } catch (ProviderDoesNotExistsException $e) {
214
+            return new JSONResponse(
215
+                ['message' => $e->getMessage()],
216
+                Http::STATUS_BAD_REQUEST
217
+            );
218
+        } catch (ShareNotFoundException $e) {
219
+            return new JSONResponse(
220
+                ['message' => $e->getMessage()],
221
+                Http::STATUS_BAD_REQUEST
222
+            );
223
+        } catch (\Exception $e) {
224
+            return new JSONResponse(
225
+                ['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
226
+                Http::STATUS_BAD_REQUEST
227
+            );
228
+        }
229
+
230
+
231
+        return new JSONResponse(
232
+            ['id' => $id, 'createdAt' => date()],
233
+            Http::STATUS_CREATED);
234
+
235
+
236
+    }
237
+
238
+    /**
239
+     * map login name to internal LDAP UID if a LDAP backend is in use
240
+     *
241
+     * @param string $uid
242
+     * @return string mixed
243
+     */
244
+    private function mapUid($uid) {
245
+        \OC::$server->getURLGenerator()->linkToDocs('key');
246
+        // FIXME this should be a method in the user management instead
247
+        $this->logger->debug('shareWith before, ' . $uid, ['app' => $this->appName]);
248
+        \OCP\Util::emitHook(
249
+            '\OCA\Files_Sharing\API\Server2Server',
250
+            'preLoginNameUsedAsUserName',
251
+            array('uid' => &$uid)
252
+        );
253
+        $this->logger->debug('shareWith after, ' . $uid, ['app' => $this->appName]);
254
+
255
+        return $uid;
256
+    }
257 257
 
258 258
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 
138 138
 		if (!$this->userManager->userExists($shareWith)) {
139 139
 			return new JSONResponse(
140
-				['message' => 'User "' . $shareWith . '" does not exists at ' . $this->urlGenerator->getBaseUrl()],
140
+				['message' => 'User "'.$shareWith.'" does not exists at '.$this->urlGenerator->getBaseUrl()],
141 141
 				Http::STATUS_BAD_REQUEST
142 142
 			);
143 143
 		}
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 			);
169 169
 		} catch (\Exception $e) {
170 170
 			return new JSONResponse(
171
-				['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
171
+				['message' => 'Internal error at '.$this->urlGenerator->getBaseUrl()],
172 172
 				Http::STATUS_BAD_REQUEST
173 173
 			);
174 174
 		}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 			);
223 223
 		} catch (\Exception $e) {
224 224
 			return new JSONResponse(
225
-				['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
225
+				['message' => 'Internal error at '.$this->urlGenerator->getBaseUrl()],
226 226
 				Http::STATUS_BAD_REQUEST
227 227
 			);
228 228
 		}
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 	private function mapUid($uid) {
245 245
 		\OC::$server->getURLGenerator()->linkToDocs('key');
246 246
 		// FIXME this should be a method in the user management instead
247
-		$this->logger->debug('shareWith before, ' . $uid, ['app' => $this->appName]);
247
+		$this->logger->debug('shareWith before, '.$uid, ['app' => $this->appName]);
248 248
 		\OCP\Util::emitHook(
249 249
 			'\OCA\Files_Sharing\API\Server2Server',
250 250
 			'preLoginNameUsedAsUserName',
251 251
 			array('uid' => &$uid)
252 252
 		);
253
-		$this->logger->debug('shareWith after, ' . $uid, ['app' => $this->appName]);
253
+		$this->logger->debug('shareWith after, '.$uid, ['app' => $this->appName]);
254 254
 
255 255
 		return $uid;
256 256
 	}
Please login to merge, or discard this patch.
lib/public/Federation/ICloudFederationProvider.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -36,44 +36,44 @@
 block discarded – undo
36 36
 
37 37
 interface ICloudFederationProvider {
38 38
 
39
-	/**
40
-	 * get the name of the share type, handled by this provider
41
-	 *
42
-	 * @return string
43
-	 *
44
-	 * @since 14.0.0
45
-	 */
46
-	public function getShareType();
39
+    /**
40
+     * get the name of the share type, handled by this provider
41
+     *
42
+     * @return string
43
+     *
44
+     * @since 14.0.0
45
+     */
46
+    public function getShareType();
47 47
 
48
-	/**
49
-	 * send new share to another server
50
-	 *
51
-	 * @since 14.0.0
52
-	 */
53
-	public function sendShare();
48
+    /**
49
+     * send new share to another server
50
+     *
51
+     * @since 14.0.0
52
+     */
53
+    public function sendShare();
54 54
 
55
-	/**
56
-	 * share received from another server
57
-	 *
58
-	 * @param ICloudFederationShare $share
59
-	 * @return string provider specific unique ID of the share
60
-	 *
61
-	 * @throws ProviderCouldNotAddShareException
62
-	 *
63
-	 * @since 14.0.0
64
-	 */
65
-	public function shareReceived(ICloudFederationShare $share);
55
+    /**
56
+     * share received from another server
57
+     *
58
+     * @param ICloudFederationShare $share
59
+     * @return string provider specific unique ID of the share
60
+     *
61
+     * @throws ProviderCouldNotAddShareException
62
+     *
63
+     * @since 14.0.0
64
+     */
65
+    public function shareReceived(ICloudFederationShare $share);
66 66
 
67
-	/**
68
-	 * notification received from another server
69
-	 *
70
-	 * @param string $id unique ID of a already existing share
71
-	 * @param array $notification provider specific notification
72
-	 *
73
-	 * @throws ShareNotFoundException
74
-	 *
75
-	 * @since 14.0.0
76
-	 */
77
-	public function notificationReceived($id, $notification);
67
+    /**
68
+     * notification received from another server
69
+     *
70
+     * @param string $id unique ID of a already existing share
71
+     * @param array $notification provider specific notification
72
+     *
73
+     * @throws ShareNotFoundException
74
+     *
75
+     * @since 14.0.0
76
+     */
77
+    public function notificationReceived($id, $notification);
78 78
 
79 79
 }
Please login to merge, or discard this patch.
lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@
 block discarded – undo
26 26
 
27 27
 class ProviderCouldNotAddShareException extends HintException {
28 28
 
29
-	public function __construct($message, $hint = '', $code = Http::STATUS_BAD_REQUEST, \Exception $previous = null) {
30
-		parent::__construct($message, $hint, $code, $previous);
31
-	}
29
+    public function __construct($message, $hint = '', $code = Http::STATUS_BAD_REQUEST, \Exception $previous = null) {
30
+        parent::__construct($message, $hint, $code, $previous);
31
+    }
32 32
 
33 33
 
34 34
 }
Please login to merge, or discard this patch.
lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@
 block discarded – undo
25 25
 
26 26
 class ProviderDoesNotExistsException extends HintException {
27 27
 
28
-	/**
29
-	 * ProviderDoesNotExistsException constructor.
30
-	 *
31
-	 * @param string $providerId cloud federation provider ID
32
-	 */
33
-	public function __construct($providerId) {
34
-		$l = \OC::$server->getL10N('federation');
35
-		$message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.';
36
-		$hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]);
37
-		parent::__construct($message, $hint);
38
-	}
28
+    /**
29
+     * ProviderDoesNotExistsException constructor.
30
+     *
31
+     * @param string $providerId cloud federation provider ID
32
+     */
33
+    public function __construct($providerId) {
34
+        $l = \OC::$server->getL10N('federation');
35
+        $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.';
36
+        $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]);
37
+        parent::__construct($message, $hint);
38
+    }
39 39
 
40 40
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 	 */
33 33
 	public function __construct($providerId) {
34 34
 		$l = \OC::$server->getL10N('federation');
35
-		$message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.';
35
+		$message = 'Cloud Federation Provider with ID: "'.$providerId.'" does not exist.';
36 36
 		$hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]);
37 37
 		parent::__construct($message, $hint);
38 38
 	}
Please login to merge, or discard this patch.
lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@
 block discarded – undo
25 25
 
26 26
 class ProviderAlreadyExistsException extends HintException {
27 27
 
28
-	/**
29
-	 * ProviderAlreadyExistsException constructor.
30
-	 *
31
-	 * @param string $newProviderId cloud federation provider ID of the new provider
32
-	 * @param string $existingProviderName name of cloud federation provider which already use the same ID
33
-	 */
34
-	public function __construct($newProviderId, $existingProviderName) {
35
-		$l = \OC::$server->getL10N('federation');
36
-		$message = 'Id "' . $newProviderId . '" already used by cloud federation provider "' . $existingProviderName . '"';
37
-		$hint = $l->t('Id "%s" already used by cloud federation provider "%s"', [$newProviderId, $existingProviderName]);
38
-		parent::__construct($message, $hint);
39
-	}
28
+    /**
29
+     * ProviderAlreadyExistsException constructor.
30
+     *
31
+     * @param string $newProviderId cloud federation provider ID of the new provider
32
+     * @param string $existingProviderName name of cloud federation provider which already use the same ID
33
+     */
34
+    public function __construct($newProviderId, $existingProviderName) {
35
+        $l = \OC::$server->getL10N('federation');
36
+        $message = 'Id "' . $newProviderId . '" already used by cloud federation provider "' . $existingProviderName . '"';
37
+        $hint = $l->t('Id "%s" already used by cloud federation provider "%s"', [$newProviderId, $existingProviderName]);
38
+        parent::__construct($message, $hint);
39
+    }
40 40
 
41 41
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 */
34 34
 	public function __construct($newProviderId, $existingProviderName) {
35 35
 		$l = \OC::$server->getL10N('federation');
36
-		$message = 'Id "' . $newProviderId . '" already used by cloud federation provider "' . $existingProviderName . '"';
36
+		$message = 'Id "'.$newProviderId.'" already used by cloud federation provider "'.$existingProviderName.'"';
37 37
 		$hint = $l->t('Id "%s" already used by cloud federation provider "%s"', [$newProviderId, $existingProviderName]);
38 38
 		parent::__construct($message, $hint);
39 39
 	}
Please login to merge, or discard this patch.
lib/public/Federation/ICloudFederationProviderManager.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -32,66 +32,66 @@
 block discarded – undo
32 32
  */
33 33
 interface ICloudFederationProviderManager {
34 34
 
35
-	/**
36
-	 * Registers an callback function which must return an cloud federation provider
37
-	 *
38
-	 * @param string $shareType which share type does the provider handles
39
-	 * @param string $displayName user facing name of the federated share provider
40
-	 * @param callable $callback
41
-	 * @throws Exceptions\ProviderAlreadyExistsException
42
-	 *
43
-	 * @since 14.0.0
44
-	 */
45
-	public function addCloudFederationProvider($shareType, $displayName, callable $callback);
35
+    /**
36
+     * Registers an callback function which must return an cloud federation provider
37
+     *
38
+     * @param string $shareType which share type does the provider handles
39
+     * @param string $displayName user facing name of the federated share provider
40
+     * @param callable $callback
41
+     * @throws Exceptions\ProviderAlreadyExistsException
42
+     *
43
+     * @since 14.0.0
44
+     */
45
+    public function addCloudFederationProvider($shareType, $displayName, callable $callback);
46 46
 
47
-	/**
48
-	 * remove cloud federation provider
49
-	 *
50
-	 * @param string $shareType
51
-	 *
52
-	 * @since 14.0.0
53
-	 */
54
-	public function removeCloudFederationProvider($shareType);
47
+    /**
48
+     * remove cloud federation provider
49
+     *
50
+     * @param string $shareType
51
+     *
52
+     * @since 14.0.0
53
+     */
54
+    public function removeCloudFederationProvider($shareType);
55 55
 
56
-	/**
57
-	 * get a list of all cloudFederationProviders
58
-	 *
59
-	 * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]]
60
-	 *
61
-	 * @since 14.0.0
62
-	 */
63
-	public function getAllCloudFederationProviders();
56
+    /**
57
+     * get a list of all cloudFederationProviders
58
+     *
59
+     * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]]
60
+     *
61
+     * @since 14.0.0
62
+     */
63
+    public function getAllCloudFederationProviders();
64 64
 
65
-	/**
66
-	 * get a specific cloud federation provider
67
-	 *
68
-	 * @param string $shareType
69
-	 * @return ICloudFederationProvider
70
-	 * @throws Exceptions\ProviderDoesNotExistsException;
71
-	 *
72
-	 * @since 14.0.0
73
-	 */
74
-	public function getCloudFederationProvider($shareType);
65
+    /**
66
+     * get a specific cloud federation provider
67
+     *
68
+     * @param string $shareType
69
+     * @return ICloudFederationProvider
70
+     * @throws Exceptions\ProviderDoesNotExistsException;
71
+     *
72
+     * @since 14.0.0
73
+     */
74
+    public function getCloudFederationProvider($shareType);
75 75
 
76
-	/**
77
-	 * send federated share
78
-	 *
79
-	 * @param ICloudFederationShare $share
80
-	 * @return mixed
81
-	 *
82
-	 * @since 14.0.0
83
-	 */
84
-	public function sendShare(ICloudFederationShare $share);
76
+    /**
77
+     * send federated share
78
+     *
79
+     * @param ICloudFederationShare $share
80
+     * @return mixed
81
+     *
82
+     * @since 14.0.0
83
+     */
84
+    public function sendShare(ICloudFederationShare $share);
85 85
 
86
-	/**
87
-	 * send notification about existing share
88
-	 *
89
-	 * @param ICloudFederationNotification $notification
90
-	 * @return mixed
91
-	 *
92
-	 * @since 14.0.0
93
-	 */
94
-	public function sendNotification(ICloudFederationNotification $notification);
86
+    /**
87
+     * send notification about existing share
88
+     *
89
+     * @param ICloudFederationNotification $notification
90
+     * @return mixed
91
+     *
92
+     * @since 14.0.0
93
+     */
94
+    public function sendNotification(ICloudFederationNotification $notification);
95 95
 
96 96
 
97 97
 }
Please login to merge, or discard this patch.
lib/public/Federation/ICloudFederationNotification.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -23,22 +23,22 @@
 block discarded – undo
23 23
 
24 24
 interface ICloudFederationNotification {
25 25
 
26
-	/**
27
-	 * add a message to the notification
28
-	 *
29
-	 * @param string $identifier
30
-	 * @param string $message
31
-	 *
32
-	 * @since 14.0.0
33
-	 */
34
-	public function setMessage($identifier, $message);
26
+    /**
27
+     * add a message to the notification
28
+     *
29
+     * @param string $identifier
30
+     * @param string $message
31
+     *
32
+     * @since 14.0.0
33
+     */
34
+    public function setMessage($identifier, $message);
35 35
 
36
-	/**
37
-	 * get JSON encoded Message, ready to send out
38
-	 *
39
-	 * @return string
40
-	 *
41
-	 * @since 14.0.0
42
-	 */
43
-	public function getMessage();
36
+    /**
37
+     * get JSON encoded Message, ready to send out
38
+     *
39
+     * @return string
40
+     *
41
+     * @since 14.0.0
42
+     */
43
+    public function getMessage();
44 44
 }
Please login to merge, or discard this patch.
lib/public/Federation/ICloudFederationFactory.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -23,33 +23,33 @@
 block discarded – undo
23 23
 
24 24
 interface ICloudFederationFactory {
25 25
 
26
-	/**
27
-	 * get a CloudFederationShare Object to prepare a share you want to send
28
-	 *
29
-	 * @param string $shareWith
30
-	 * @param string $name resource name (e.g. document.odt)
31
-	 * @param string $description share description (optional)
32
-	 * @param string $providerId resource UID on the provider side
33
-	 * @param string $owner provider specific UID of the user who owns the resource
34
-	 * @param string $ownerDisplayName display name of the user who shared the item
35
-	 * @param string $sharedBy provider specific UID of the user who shared the resource
36
-	 * @param $sharedByDisplayName display name of the user who shared the resource
37
-	 * @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
38
-	 * @param string $shareType ('group' or 'user' share)
39
-	 * @param $resourceType ('file', 'calendar',...)
40
-	 * @return ICloudFederationShare
41
-	 *
42
-	 * @since 14.0.0
43
-	 */
44
-	public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType);
26
+    /**
27
+     * get a CloudFederationShare Object to prepare a share you want to send
28
+     *
29
+     * @param string $shareWith
30
+     * @param string $name resource name (e.g. document.odt)
31
+     * @param string $description share description (optional)
32
+     * @param string $providerId resource UID on the provider side
33
+     * @param string $owner provider specific UID of the user who owns the resource
34
+     * @param string $ownerDisplayName display name of the user who shared the item
35
+     * @param string $sharedBy provider specific UID of the user who shared the resource
36
+     * @param $sharedByDisplayName display name of the user who shared the resource
37
+     * @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
38
+     * @param string $shareType ('group' or 'user' share)
39
+     * @param $resourceType ('file', 'calendar',...)
40
+     * @return ICloudFederationShare
41
+     *
42
+     * @since 14.0.0
43
+     */
44
+    public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType);
45 45
 
46
-	/**
47
-	 * get a Cloud FederationNotification object to prepare a notification you
48
-	 * want to send
49
-	 *
50
-	 * @return ICloudFederationNotification
51
-	 *
52
-	 * @since 14.0.0
53
-	 */
54
-	public function getCloudFederationNotification();
46
+    /**
47
+     * get a Cloud FederationNotification object to prepare a notification you
48
+     * want to send
49
+     *
50
+     * @return ICloudFederationNotification
51
+     *
52
+     * @since 14.0.0
53
+     */
54
+    public function getCloudFederationNotification();
55 55
 }
Please login to merge, or discard this patch.
lib/public/Federation/ICloudFederationShare.php 1 patch
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -23,211 +23,211 @@
 block discarded – undo
23 23
 
24 24
 interface ICloudFederationShare {
25 25
 
26
-	/**
27
-	 * set uid of the recipient
28
-	 *
29
-	 * @param string $user
30
-	 *
31
-	 * @since 14.0.0
32
-	 */
33
-	public function setShareWith($user);
34
-
35
-	/**
36
-	 * set resource name (e.g. file, calendar, contact,...)
37
-	 *
38
-	 * @param string $name
39
-	 *
40
-	 * @since 14.0.0
41
-	 */
42
-	public function setResourceName($name);
43
-
44
-	/**
45
-	 * set resource type (e.g. file, calendar, contact,...)
46
-	 *
47
-	 * @param string $resourceType
48
-	 *
49
-	 * @since 14.0.0
50
-	 */
51
-	public function setResourceType($resourceType);
52
-
53
-	/**
54
-	 * set resource description (optional)
55
-	 *
56
-	 * @param string $description
57
-	 *
58
-	 * @since 14.0.0
59
-	 */
60
-	public function setDescription($description);
61
-
62
-	/**
63
-	 * set provider ID (e.g. file ID)
64
-	 *
65
-	 * @param string $providerId
66
-	 *
67
-	 * @since 14.0.0
68
-	 */
69
-	public function setProviderId($providerId);
70
-
71
-	/**
72
-	 * set owner UID
73
-	 *
74
-	 * @param string $owner
75
-	 *
76
-	 * @since 14.0.0
77
-	 */
78
-	public function setOwner($owner);
79
-
80
-	/**
81
-	 * set owner display name
82
-	 *
83
-	 * @param string $ownerDisplayName
84
-	 *
85
-	 * @since 14.0.0
86
-	 */
87
-	public function setOwnerDisplayName($ownerDisplayName);
88
-
89
-	/**
90
-	 * set UID of the user who sends the share
91
-	 *
92
-	 * @param string $sharedBy
93
-	 *
94
-	 * @since 14.0.0
95
-	 */
96
-	public function setSharedBy($sharedBy);
97
-
98
-	/**
99
-	 * set display name of the user who sends the share
100
-	 *
101
-	 * @param $sharedByDisplayName
102
-	 *
103
-	 * @since 14.0.0
104
-	 */
105
-	public function setSharedByDisplayName($sharedByDisplayName);
106
-
107
-	/**
108
-	 * set protocol specification
109
-	 *
110
-	 * @param array $protocol
111
-	 *
112
-	 * @since 14.0.0
113
-	 */
114
-	public function setProtocol(array $protocol);
115
-
116
-	/**
117
-	 * share type (group or user)
118
-	 *
119
-	 * @param string $shareType
120
-	 *
121
-	 * @since 14.0.0
122
-	 */
123
-	public function setShareType($shareType);
124
-
125
-	/**
126
-	 * get JSON encoded share, ready to send out
127
-	 *
128
-	 * @return string
129
-	 *
130
-	 * @since 14.0.0
131
-	 */
132
-	public function getShare();
133
-
134
-	/**
135
-	 * get uid of the recipient
136
-	 *
137
-	 * @return string
138
-	 *
139
-	 * @since 14.0.0
140
-	 */
141
-	public function getShareWith();
142
-
143
-	/**
144
-	 * get resource name (e.g. file, calendar, contact,...)
145
-	 *
146
-	 * @return string
147
-	 *
148
-	 * @since 14.0.0
149
-	 */
150
-	public function getResourceName();
151
-
152
-	/**
153
-	 * get resource type (e.g. file, calendar, contact,...)
154
-	 *
155
-	 * @return string
156
-	 *
157
-	 * @since 14.0.0
158
-	 */
159
-	public function getResourceType();
160
-
161
-	/**
162
-	 * get resource description (optional)
163
-	 *
164
-	 * @return string
165
-	 *
166
-	 * @since 14.0.0
167
-	 */
168
-	public function getDescription();
169
-
170
-	/**
171
-	 * get provider ID (e.g. file ID)
172
-	 *
173
-	 * @return string
174
-	 *
175
-	 * @since 14.0.0
176
-	 */
177
-	public function getProviderId();
178
-
179
-	/**
180
-	 * get owner UID
181
-	 *
182
-	 * @return string
183
-	 *
184
-	 * @since 14.0.0
185
-	 */
186
-	public function getOwner();
187
-
188
-	/**
189
-	 * get owner display name
190
-	 *
191
-	 * @return string
192
-	 *
193
-	 * @since 14.0.0
194
-	 */
195
-	public function getOwnerDisplayName();
196
-
197
-	/**
198
-	 * get UID of the user who sends the share
199
-	 *
200
-	 * @return string
201
-	 *
202
-	 * @since 14.0.0
203
-	 */
204
-	public function getSharedBy();
205
-
206
-	/**
207
-	 * get display name of the user who sends the share
208
-	 *
209
-	 * @return string
210
-	 *
211
-	 * @since 14.0.0
212
-	 */
213
-	public function getSharedByDisplayName();
214
-
215
-	/**
216
-	 * get share type (group or user)
217
-	 *
218
-	 * @return string
219
-	 *
220
-	 * @since 14.0.0
221
-	 */
222
-	public function getShareType();
223
-
224
-	/**
225
-	 * get protocol specification
226
-	 *
227
-	 * @return array
228
-	 *
229
-	 * @since 14.0.0
230
-	 */
231
-	public function getProtocol();
26
+    /**
27
+     * set uid of the recipient
28
+     *
29
+     * @param string $user
30
+     *
31
+     * @since 14.0.0
32
+     */
33
+    public function setShareWith($user);
34
+
35
+    /**
36
+     * set resource name (e.g. file, calendar, contact,...)
37
+     *
38
+     * @param string $name
39
+     *
40
+     * @since 14.0.0
41
+     */
42
+    public function setResourceName($name);
43
+
44
+    /**
45
+     * set resource type (e.g. file, calendar, contact,...)
46
+     *
47
+     * @param string $resourceType
48
+     *
49
+     * @since 14.0.0
50
+     */
51
+    public function setResourceType($resourceType);
52
+
53
+    /**
54
+     * set resource description (optional)
55
+     *
56
+     * @param string $description
57
+     *
58
+     * @since 14.0.0
59
+     */
60
+    public function setDescription($description);
61
+
62
+    /**
63
+     * set provider ID (e.g. file ID)
64
+     *
65
+     * @param string $providerId
66
+     *
67
+     * @since 14.0.0
68
+     */
69
+    public function setProviderId($providerId);
70
+
71
+    /**
72
+     * set owner UID
73
+     *
74
+     * @param string $owner
75
+     *
76
+     * @since 14.0.0
77
+     */
78
+    public function setOwner($owner);
79
+
80
+    /**
81
+     * set owner display name
82
+     *
83
+     * @param string $ownerDisplayName
84
+     *
85
+     * @since 14.0.0
86
+     */
87
+    public function setOwnerDisplayName($ownerDisplayName);
88
+
89
+    /**
90
+     * set UID of the user who sends the share
91
+     *
92
+     * @param string $sharedBy
93
+     *
94
+     * @since 14.0.0
95
+     */
96
+    public function setSharedBy($sharedBy);
97
+
98
+    /**
99
+     * set display name of the user who sends the share
100
+     *
101
+     * @param $sharedByDisplayName
102
+     *
103
+     * @since 14.0.0
104
+     */
105
+    public function setSharedByDisplayName($sharedByDisplayName);
106
+
107
+    /**
108
+     * set protocol specification
109
+     *
110
+     * @param array $protocol
111
+     *
112
+     * @since 14.0.0
113
+     */
114
+    public function setProtocol(array $protocol);
115
+
116
+    /**
117
+     * share type (group or user)
118
+     *
119
+     * @param string $shareType
120
+     *
121
+     * @since 14.0.0
122
+     */
123
+    public function setShareType($shareType);
124
+
125
+    /**
126
+     * get JSON encoded share, ready to send out
127
+     *
128
+     * @return string
129
+     *
130
+     * @since 14.0.0
131
+     */
132
+    public function getShare();
133
+
134
+    /**
135
+     * get uid of the recipient
136
+     *
137
+     * @return string
138
+     *
139
+     * @since 14.0.0
140
+     */
141
+    public function getShareWith();
142
+
143
+    /**
144
+     * get resource name (e.g. file, calendar, contact,...)
145
+     *
146
+     * @return string
147
+     *
148
+     * @since 14.0.0
149
+     */
150
+    public function getResourceName();
151
+
152
+    /**
153
+     * get resource type (e.g. file, calendar, contact,...)
154
+     *
155
+     * @return string
156
+     *
157
+     * @since 14.0.0
158
+     */
159
+    public function getResourceType();
160
+
161
+    /**
162
+     * get resource description (optional)
163
+     *
164
+     * @return string
165
+     *
166
+     * @since 14.0.0
167
+     */
168
+    public function getDescription();
169
+
170
+    /**
171
+     * get provider ID (e.g. file ID)
172
+     *
173
+     * @return string
174
+     *
175
+     * @since 14.0.0
176
+     */
177
+    public function getProviderId();
178
+
179
+    /**
180
+     * get owner UID
181
+     *
182
+     * @return string
183
+     *
184
+     * @since 14.0.0
185
+     */
186
+    public function getOwner();
187
+
188
+    /**
189
+     * get owner display name
190
+     *
191
+     * @return string
192
+     *
193
+     * @since 14.0.0
194
+     */
195
+    public function getOwnerDisplayName();
196
+
197
+    /**
198
+     * get UID of the user who sends the share
199
+     *
200
+     * @return string
201
+     *
202
+     * @since 14.0.0
203
+     */
204
+    public function getSharedBy();
205
+
206
+    /**
207
+     * get display name of the user who sends the share
208
+     *
209
+     * @return string
210
+     *
211
+     * @since 14.0.0
212
+     */
213
+    public function getSharedByDisplayName();
214
+
215
+    /**
216
+     * get share type (group or user)
217
+     *
218
+     * @return string
219
+     *
220
+     * @since 14.0.0
221
+     */
222
+    public function getShareType();
223
+
224
+    /**
225
+     * get protocol specification
226
+     *
227
+     * @return array
228
+     *
229
+     * @since 14.0.0
230
+     */
231
+    public function getProtocol();
232 232
 
233 233
 }
Please login to merge, or discard this patch.