Completed
Pull Request — master (#9895)
by Björn
43:43 queued 13:05
created
lib/public/IServerContainer.php 1 patch
Indentation   +506 added lines, -506 removed lines patch added patch discarded remove patch
@@ -60,510 +60,510 @@
 block discarded – undo
60 60
  */
61 61
 interface IServerContainer extends IContainer {
62 62
 
63
-	/**
64
-	 * The calendar manager will act as a broker between consumers for calendar information and
65
-	 * providers which actual deliver the calendar information.
66
-	 *
67
-	 * @return \OCP\Calendar\IManager
68
-	 * @since 13.0.0
69
-	 */
70
-	public function getCalendarManager();
71
-
72
-	/**
73
-	 * The contacts manager will act as a broker between consumers for contacts information and
74
-	 * providers which actual deliver the contact information.
75
-	 *
76
-	 * @return \OCP\Contacts\IManager
77
-	 * @since 6.0.0
78
-	 */
79
-	public function getContactsManager();
80
-
81
-	/**
82
-	 * The current request object holding all information about the request currently being processed
83
-	 * is returned from this method.
84
-	 * In case the current execution was not initiated by a web request null is returned
85
-	 *
86
-	 * @return \OCP\IRequest
87
-	 * @since 6.0.0
88
-	 */
89
-	public function getRequest();
90
-
91
-	/**
92
-	 * Returns the preview manager which can create preview images for a given file
93
-	 *
94
-	 * @return \OCP\IPreview
95
-	 * @since 6.0.0
96
-	 */
97
-	public function getPreviewManager();
98
-
99
-	/**
100
-	 * Returns the tag manager which can get and set tags for different object types
101
-	 *
102
-	 * @see \OCP\ITagManager::load()
103
-	 * @return \OCP\ITagManager
104
-	 * @since 6.0.0
105
-	 */
106
-	public function getTagManager();
107
-
108
-	/**
109
-	 * Returns the root folder of ownCloud's data directory
110
-	 *
111
-	 * @return \OCP\Files\IRootFolder
112
-	 * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder
113
-	 */
114
-	public function getRootFolder();
115
-
116
-	/**
117
-	 * Returns a view to ownCloud's files folder
118
-	 *
119
-	 * @param string $userId user ID
120
-	 * @return \OCP\Files\Folder
121
-	 * @since 6.0.0 - parameter $userId was added in 8.0.0
122
-	 * @see getUserFolder in \OCP\Files\IRootFolder
123
-	 */
124
-	public function getUserFolder($userId = null);
125
-
126
-	/**
127
-	 * Returns an app-specific view in ownClouds data directory
128
-	 *
129
-	 * @return \OCP\Files\Folder
130
-	 * @since 6.0.0
131
-	 * @deprecated 9.2.0 use IAppData
132
-	 */
133
-	public function getAppFolder();
134
-
135
-	/**
136
-	 * Returns a user manager
137
-	 *
138
-	 * @return \OCP\IUserManager
139
-	 * @since 8.0.0
140
-	 */
141
-	public function getUserManager();
142
-
143
-	/**
144
-	 * Returns a group manager
145
-	 *
146
-	 * @return \OCP\IGroupManager
147
-	 * @since 8.0.0
148
-	 */
149
-	public function getGroupManager();
150
-
151
-	/**
152
-	 * Returns the user session
153
-	 *
154
-	 * @return \OCP\IUserSession
155
-	 * @since 6.0.0
156
-	 */
157
-	public function getUserSession();
158
-
159
-	/**
160
-	 * Returns the navigation manager
161
-	 *
162
-	 * @return \OCP\INavigationManager
163
-	 * @since 6.0.0
164
-	 */
165
-	public function getNavigationManager();
166
-
167
-	/**
168
-	 * Returns the config manager
169
-	 *
170
-	 * @return \OCP\IConfig
171
-	 * @since 6.0.0
172
-	 */
173
-	public function getConfig();
174
-
175
-	/**
176
-	 * Returns a Crypto instance
177
-	 *
178
-	 * @return \OCP\Security\ICrypto
179
-	 * @since 8.0.0
180
-	 */
181
-	public function getCrypto();
182
-
183
-	/**
184
-	 * Returns a Hasher instance
185
-	 *
186
-	 * @return \OCP\Security\IHasher
187
-	 * @since 8.0.0
188
-	 */
189
-	public function getHasher();
190
-
191
-	/**
192
-	 * Returns a SecureRandom instance
193
-	 *
194
-	 * @return \OCP\Security\ISecureRandom
195
-	 * @since 8.1.0
196
-	 */
197
-	public function getSecureRandom();
198
-
199
-	/**
200
-	 * Returns a CredentialsManager instance
201
-	 *
202
-	 * @return \OCP\Security\ICredentialsManager
203
-	 * @since 9.0.0
204
-	 */
205
-	public function getCredentialsManager();
206
-
207
-	/**
208
-	 * Returns the app config manager
209
-	 *
210
-	 * @return \OCP\IAppConfig
211
-	 * @since 7.0.0
212
-	 */
213
-	public function getAppConfig();
214
-
215
-	/**
216
-	 * @return \OCP\L10N\IFactory
217
-	 * @since 8.2.0
218
-	 */
219
-	public function getL10NFactory();
220
-
221
-	/**
222
-	 * get an L10N instance
223
-	 * @param string $app appid
224
-	 * @param string $lang
225
-	 * @return \OCP\IL10N
226
-	 * @since 6.0.0 - parameter $lang was added in 8.0.0
227
-	 */
228
-	public function getL10N($app, $lang = null);
229
-
230
-	/**
231
-	 * @return \OC\Encryption\Manager
232
-	 * @since 8.1.0
233
-	 */
234
-	public function getEncryptionManager();
235
-
236
-	/**
237
-	 * @return \OC\Encryption\File
238
-	 * @since 8.1.0
239
-	 */
240
-	public function getEncryptionFilesHelper();
241
-
242
-	/**
243
-	 * @return \OCP\Encryption\Keys\IStorage
244
-	 * @since 8.1.0
245
-	 */
246
-	public function getEncryptionKeyStorage();
247
-
248
-	/**
249
-	 * Returns the URL generator
250
-	 *
251
-	 * @return \OCP\IURLGenerator
252
-	 * @since 6.0.0
253
-	 */
254
-	public function getURLGenerator();
255
-
256
-	/**
257
-	 * Returns an ICache instance
258
-	 *
259
-	 * @return \OCP\ICache
260
-	 * @since 6.0.0
261
-	 */
262
-	public function getCache();
263
-
264
-	/**
265
-	 * Returns an \OCP\CacheFactory instance
266
-	 *
267
-	 * @return \OCP\ICacheFactory
268
-	 * @since 7.0.0
269
-	 */
270
-	public function getMemCacheFactory();
271
-
272
-	/**
273
-	 * Returns the current session
274
-	 *
275
-	 * @return \OCP\ISession
276
-	 * @since 6.0.0
277
-	 */
278
-	public function getSession();
279
-
280
-	/**
281
-	 * Returns the activity manager
282
-	 *
283
-	 * @return \OCP\Activity\IManager
284
-	 * @since 6.0.0
285
-	 */
286
-	public function getActivityManager();
287
-
288
-	/**
289
-	 * Returns the current session
290
-	 *
291
-	 * @return \OCP\IDBConnection
292
-	 * @since 6.0.0
293
-	 */
294
-	public function getDatabaseConnection();
295
-
296
-	/**
297
-	 * Returns an avatar manager, used for avatar functionality
298
-	 *
299
-	 * @return \OCP\IAvatarManager
300
-	 * @since 6.0.0
301
-	 */
302
-	public function getAvatarManager();
303
-
304
-	/**
305
-	 * Returns an job list for controlling background jobs
306
-	 *
307
-	 * @return \OCP\BackgroundJob\IJobList
308
-	 * @since 7.0.0
309
-	 */
310
-	public function getJobList();
311
-
312
-	/**
313
-	 * Returns a logger instance
314
-	 *
315
-	 * @return \OCP\ILogger
316
-	 * @since 8.0.0
317
-	 */
318
-	public function getLogger();
319
-
320
-	/**
321
-	 * returns a log factory instance
322
-	 *
323
-	 * @return ILogFactory
324
-	 * @since 14.0.0
325
-	 */
326
-	public function getLogFactory();
327
-
328
-	/**
329
-	 * Returns a router for generating and matching urls
330
-	 *
331
-	 * @return \OCP\Route\IRouter
332
-	 * @since 7.0.0
333
-	 */
334
-	public function getRouter();
335
-
336
-	/**
337
-	 * Returns a search instance
338
-	 *
339
-	 * @return \OCP\ISearch
340
-	 * @since 7.0.0
341
-	 */
342
-	public function getSearch();
343
-
344
-	/**
345
-	 * Get the certificate manager for the user
346
-	 *
347
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
348
-	 * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in
349
-	 * @since 8.0.0
350
-	 */
351
-	public function getCertificateManager($userId = null);
352
-
353
-	/**
354
-	 * Create a new event source
355
-	 *
356
-	 * @return \OCP\IEventSource
357
-	 * @since 8.0.0
358
-	 */
359
-	public function createEventSource();
360
-
361
-	/**
362
-	 * Returns an instance of the HTTP client service
363
-	 *
364
-	 * @return \OCP\Http\Client\IClientService
365
-	 * @since 8.1.0
366
-	 */
367
-	public function getHTTPClientService();
368
-
369
-	/**
370
-	 * Get the active event logger
371
-	 *
372
-	 * @return \OCP\Diagnostics\IEventLogger
373
-	 * @since 8.0.0
374
-	 */
375
-	public function getEventLogger();
376
-
377
-	/**
378
-	 * Get the active query logger
379
-	 *
380
-	 * The returned logger only logs data when debug mode is enabled
381
-	 *
382
-	 * @return \OCP\Diagnostics\IQueryLogger
383
-	 * @since 8.0.0
384
-	 */
385
-	public function getQueryLogger();
386
-
387
-	/**
388
-	 * Get the manager for temporary files and folders
389
-	 *
390
-	 * @return \OCP\ITempManager
391
-	 * @since 8.0.0
392
-	 */
393
-	public function getTempManager();
394
-
395
-	/**
396
-	 * Get the app manager
397
-	 *
398
-	 * @return \OCP\App\IAppManager
399
-	 * @since 8.0.0
400
-	 */
401
-	public function getAppManager();
402
-
403
-	/**
404
-	 * Get the webroot
405
-	 *
406
-	 * @return string
407
-	 * @since 8.0.0
408
-	 */
409
-	public function getWebRoot();
410
-
411
-	/**
412
-	 * @return \OCP\Files\Config\IMountProviderCollection
413
-	 * @since 8.0.0
414
-	 */
415
-	public function getMountProviderCollection();
416
-
417
-	/**
418
-	 * Get the IniWrapper
419
-	 *
420
-	 * @return \bantu\IniGetWrapper\IniGetWrapper
421
-	 * @since 8.0.0
422
-	 */
423
-	public function getIniWrapper();
424
-	/**
425
-	 * @return \OCP\Command\IBus
426
-	 * @since 8.1.0
427
-	 */
428
-	public function getCommandBus();
429
-
430
-	/**
431
-	 * Creates a new mailer
432
-	 *
433
-	 * @return \OCP\Mail\IMailer
434
-	 * @since 8.1.0
435
-	 */
436
-	public function getMailer();
437
-
438
-	/**
439
-	 * Get the locking provider
440
-	 *
441
-	 * @return \OCP\Lock\ILockingProvider
442
-	 * @since 8.1.0
443
-	 */
444
-	public function getLockingProvider();
445
-
446
-	/**
447
-	 * @return \OCP\Files\Mount\IMountManager
448
-	 * @since 8.2.0
449
-	 */
450
-	public function getMountManager();
451
-
452
-	/**
453
-	 * Get the MimeTypeDetector
454
-	 *
455
-	 * @return \OCP\Files\IMimeTypeDetector
456
-	 * @since 8.2.0
457
-	 */
458
-	public function getMimeTypeDetector();
459
-
460
-	/**
461
-	 * Get the MimeTypeLoader
462
-	 *
463
-	 * @return \OCP\Files\IMimeTypeLoader
464
-	 * @since 8.2.0
465
-	 */
466
-	public function getMimeTypeLoader();
467
-
468
-	/**
469
-	 * Get the EventDispatcher
470
-	 *
471
-	 * @return EventDispatcherInterface
472
-	 * @since 8.2.0
473
-	 */
474
-	public function getEventDispatcher();
475
-
476
-	/**
477
-	 * Get the Notification Manager
478
-	 *
479
-	 * @return \OCP\Notification\IManager
480
-	 * @since 9.0.0
481
-	 */
482
-	public function getNotificationManager();
483
-
484
-	/**
485
-	 * @return \OCP\Comments\ICommentsManager
486
-	 * @since 9.0.0
487
-	 */
488
-	public function getCommentsManager();
489
-
490
-	/**
491
-	 * Returns the system-tag manager
492
-	 *
493
-	 * @return \OCP\SystemTag\ISystemTagManager
494
-	 *
495
-	 * @since 9.0.0
496
-	 */
497
-	public function getSystemTagManager();
498
-
499
-	/**
500
-	 * Returns the system-tag object mapper
501
-	 *
502
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
503
-	 *
504
-	 * @since 9.0.0
505
-	 */
506
-	public function getSystemTagObjectMapper();
507
-
508
-	/**
509
-	 * Returns the share manager
510
-	 *
511
-	 * @return \OCP\Share\IManager
512
-	 * @since 9.0.0
513
-	 */
514
-	public function getShareManager();
515
-
516
-	/**
517
-	 * @return IContentSecurityPolicyManager
518
-	 * @since 9.0.0
519
-	 */
520
-	public function getContentSecurityPolicyManager();
521
-
522
-	/**
523
-	 * @return \OCP\IDateTimeZone
524
-	 * @since 8.0.0
525
-	 */
526
-	public function getDateTimeZone();
527
-
528
-	/**
529
-	 * @return \OCP\IDateTimeFormatter
530
-	 * @since 8.0.0
531
-	 */
532
-	public function getDateTimeFormatter();
533
-
534
-	/**
535
-	 * @return \OCP\Federation\ICloudIdManager
536
-	 * @since 12.0.0
537
-	 */
538
-	public function getCloudIdManager();
539
-
540
-	/**
541
-	 * @return \OCP\GlobalScale\IConfig
542
-	 * @since 14.0.0
543
-	 */
544
-	public function getGlobalScaleConfig();
545
-
546
-	/**
547
-	 * @return ICloudFederationFactory
548
-	 * @since 14.0.0
549
-	 */
550
-	public function getCloudFederationFactory();
551
-
552
-	/**
553
-	 * @return ICloudFederationProviderManager
554
-	 * @since 14.0.0
555
-	 */
556
-	public function getCloudFederationProviderManager();
557
-
558
-	/**
559
-	 * @return \OCP\Remote\Api\IApiFactory
560
-	 * @since 13.0.0
561
-	 */
562
-	public function getRemoteApiFactory();
563
-
564
-	/**
565
-	 * @return \OCP\Remote\IInstanceFactory
566
-	 * @since 13.0.0
567
-	 */
568
-	public function getRemoteInstanceFactory();
63
+    /**
64
+     * The calendar manager will act as a broker between consumers for calendar information and
65
+     * providers which actual deliver the calendar information.
66
+     *
67
+     * @return \OCP\Calendar\IManager
68
+     * @since 13.0.0
69
+     */
70
+    public function getCalendarManager();
71
+
72
+    /**
73
+     * The contacts manager will act as a broker between consumers for contacts information and
74
+     * providers which actual deliver the contact information.
75
+     *
76
+     * @return \OCP\Contacts\IManager
77
+     * @since 6.0.0
78
+     */
79
+    public function getContactsManager();
80
+
81
+    /**
82
+     * The current request object holding all information about the request currently being processed
83
+     * is returned from this method.
84
+     * In case the current execution was not initiated by a web request null is returned
85
+     *
86
+     * @return \OCP\IRequest
87
+     * @since 6.0.0
88
+     */
89
+    public function getRequest();
90
+
91
+    /**
92
+     * Returns the preview manager which can create preview images for a given file
93
+     *
94
+     * @return \OCP\IPreview
95
+     * @since 6.0.0
96
+     */
97
+    public function getPreviewManager();
98
+
99
+    /**
100
+     * Returns the tag manager which can get and set tags for different object types
101
+     *
102
+     * @see \OCP\ITagManager::load()
103
+     * @return \OCP\ITagManager
104
+     * @since 6.0.0
105
+     */
106
+    public function getTagManager();
107
+
108
+    /**
109
+     * Returns the root folder of ownCloud's data directory
110
+     *
111
+     * @return \OCP\Files\IRootFolder
112
+     * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder
113
+     */
114
+    public function getRootFolder();
115
+
116
+    /**
117
+     * Returns a view to ownCloud's files folder
118
+     *
119
+     * @param string $userId user ID
120
+     * @return \OCP\Files\Folder
121
+     * @since 6.0.0 - parameter $userId was added in 8.0.0
122
+     * @see getUserFolder in \OCP\Files\IRootFolder
123
+     */
124
+    public function getUserFolder($userId = null);
125
+
126
+    /**
127
+     * Returns an app-specific view in ownClouds data directory
128
+     *
129
+     * @return \OCP\Files\Folder
130
+     * @since 6.0.0
131
+     * @deprecated 9.2.0 use IAppData
132
+     */
133
+    public function getAppFolder();
134
+
135
+    /**
136
+     * Returns a user manager
137
+     *
138
+     * @return \OCP\IUserManager
139
+     * @since 8.0.0
140
+     */
141
+    public function getUserManager();
142
+
143
+    /**
144
+     * Returns a group manager
145
+     *
146
+     * @return \OCP\IGroupManager
147
+     * @since 8.0.0
148
+     */
149
+    public function getGroupManager();
150
+
151
+    /**
152
+     * Returns the user session
153
+     *
154
+     * @return \OCP\IUserSession
155
+     * @since 6.0.0
156
+     */
157
+    public function getUserSession();
158
+
159
+    /**
160
+     * Returns the navigation manager
161
+     *
162
+     * @return \OCP\INavigationManager
163
+     * @since 6.0.0
164
+     */
165
+    public function getNavigationManager();
166
+
167
+    /**
168
+     * Returns the config manager
169
+     *
170
+     * @return \OCP\IConfig
171
+     * @since 6.0.0
172
+     */
173
+    public function getConfig();
174
+
175
+    /**
176
+     * Returns a Crypto instance
177
+     *
178
+     * @return \OCP\Security\ICrypto
179
+     * @since 8.0.0
180
+     */
181
+    public function getCrypto();
182
+
183
+    /**
184
+     * Returns a Hasher instance
185
+     *
186
+     * @return \OCP\Security\IHasher
187
+     * @since 8.0.0
188
+     */
189
+    public function getHasher();
190
+
191
+    /**
192
+     * Returns a SecureRandom instance
193
+     *
194
+     * @return \OCP\Security\ISecureRandom
195
+     * @since 8.1.0
196
+     */
197
+    public function getSecureRandom();
198
+
199
+    /**
200
+     * Returns a CredentialsManager instance
201
+     *
202
+     * @return \OCP\Security\ICredentialsManager
203
+     * @since 9.0.0
204
+     */
205
+    public function getCredentialsManager();
206
+
207
+    /**
208
+     * Returns the app config manager
209
+     *
210
+     * @return \OCP\IAppConfig
211
+     * @since 7.0.0
212
+     */
213
+    public function getAppConfig();
214
+
215
+    /**
216
+     * @return \OCP\L10N\IFactory
217
+     * @since 8.2.0
218
+     */
219
+    public function getL10NFactory();
220
+
221
+    /**
222
+     * get an L10N instance
223
+     * @param string $app appid
224
+     * @param string $lang
225
+     * @return \OCP\IL10N
226
+     * @since 6.0.0 - parameter $lang was added in 8.0.0
227
+     */
228
+    public function getL10N($app, $lang = null);
229
+
230
+    /**
231
+     * @return \OC\Encryption\Manager
232
+     * @since 8.1.0
233
+     */
234
+    public function getEncryptionManager();
235
+
236
+    /**
237
+     * @return \OC\Encryption\File
238
+     * @since 8.1.0
239
+     */
240
+    public function getEncryptionFilesHelper();
241
+
242
+    /**
243
+     * @return \OCP\Encryption\Keys\IStorage
244
+     * @since 8.1.0
245
+     */
246
+    public function getEncryptionKeyStorage();
247
+
248
+    /**
249
+     * Returns the URL generator
250
+     *
251
+     * @return \OCP\IURLGenerator
252
+     * @since 6.0.0
253
+     */
254
+    public function getURLGenerator();
255
+
256
+    /**
257
+     * Returns an ICache instance
258
+     *
259
+     * @return \OCP\ICache
260
+     * @since 6.0.0
261
+     */
262
+    public function getCache();
263
+
264
+    /**
265
+     * Returns an \OCP\CacheFactory instance
266
+     *
267
+     * @return \OCP\ICacheFactory
268
+     * @since 7.0.0
269
+     */
270
+    public function getMemCacheFactory();
271
+
272
+    /**
273
+     * Returns the current session
274
+     *
275
+     * @return \OCP\ISession
276
+     * @since 6.0.0
277
+     */
278
+    public function getSession();
279
+
280
+    /**
281
+     * Returns the activity manager
282
+     *
283
+     * @return \OCP\Activity\IManager
284
+     * @since 6.0.0
285
+     */
286
+    public function getActivityManager();
287
+
288
+    /**
289
+     * Returns the current session
290
+     *
291
+     * @return \OCP\IDBConnection
292
+     * @since 6.0.0
293
+     */
294
+    public function getDatabaseConnection();
295
+
296
+    /**
297
+     * Returns an avatar manager, used for avatar functionality
298
+     *
299
+     * @return \OCP\IAvatarManager
300
+     * @since 6.0.0
301
+     */
302
+    public function getAvatarManager();
303
+
304
+    /**
305
+     * Returns an job list for controlling background jobs
306
+     *
307
+     * @return \OCP\BackgroundJob\IJobList
308
+     * @since 7.0.0
309
+     */
310
+    public function getJobList();
311
+
312
+    /**
313
+     * Returns a logger instance
314
+     *
315
+     * @return \OCP\ILogger
316
+     * @since 8.0.0
317
+     */
318
+    public function getLogger();
319
+
320
+    /**
321
+     * returns a log factory instance
322
+     *
323
+     * @return ILogFactory
324
+     * @since 14.0.0
325
+     */
326
+    public function getLogFactory();
327
+
328
+    /**
329
+     * Returns a router for generating and matching urls
330
+     *
331
+     * @return \OCP\Route\IRouter
332
+     * @since 7.0.0
333
+     */
334
+    public function getRouter();
335
+
336
+    /**
337
+     * Returns a search instance
338
+     *
339
+     * @return \OCP\ISearch
340
+     * @since 7.0.0
341
+     */
342
+    public function getSearch();
343
+
344
+    /**
345
+     * Get the certificate manager for the user
346
+     *
347
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
348
+     * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in
349
+     * @since 8.0.0
350
+     */
351
+    public function getCertificateManager($userId = null);
352
+
353
+    /**
354
+     * Create a new event source
355
+     *
356
+     * @return \OCP\IEventSource
357
+     * @since 8.0.0
358
+     */
359
+    public function createEventSource();
360
+
361
+    /**
362
+     * Returns an instance of the HTTP client service
363
+     *
364
+     * @return \OCP\Http\Client\IClientService
365
+     * @since 8.1.0
366
+     */
367
+    public function getHTTPClientService();
368
+
369
+    /**
370
+     * Get the active event logger
371
+     *
372
+     * @return \OCP\Diagnostics\IEventLogger
373
+     * @since 8.0.0
374
+     */
375
+    public function getEventLogger();
376
+
377
+    /**
378
+     * Get the active query logger
379
+     *
380
+     * The returned logger only logs data when debug mode is enabled
381
+     *
382
+     * @return \OCP\Diagnostics\IQueryLogger
383
+     * @since 8.0.0
384
+     */
385
+    public function getQueryLogger();
386
+
387
+    /**
388
+     * Get the manager for temporary files and folders
389
+     *
390
+     * @return \OCP\ITempManager
391
+     * @since 8.0.0
392
+     */
393
+    public function getTempManager();
394
+
395
+    /**
396
+     * Get the app manager
397
+     *
398
+     * @return \OCP\App\IAppManager
399
+     * @since 8.0.0
400
+     */
401
+    public function getAppManager();
402
+
403
+    /**
404
+     * Get the webroot
405
+     *
406
+     * @return string
407
+     * @since 8.0.0
408
+     */
409
+    public function getWebRoot();
410
+
411
+    /**
412
+     * @return \OCP\Files\Config\IMountProviderCollection
413
+     * @since 8.0.0
414
+     */
415
+    public function getMountProviderCollection();
416
+
417
+    /**
418
+     * Get the IniWrapper
419
+     *
420
+     * @return \bantu\IniGetWrapper\IniGetWrapper
421
+     * @since 8.0.0
422
+     */
423
+    public function getIniWrapper();
424
+    /**
425
+     * @return \OCP\Command\IBus
426
+     * @since 8.1.0
427
+     */
428
+    public function getCommandBus();
429
+
430
+    /**
431
+     * Creates a new mailer
432
+     *
433
+     * @return \OCP\Mail\IMailer
434
+     * @since 8.1.0
435
+     */
436
+    public function getMailer();
437
+
438
+    /**
439
+     * Get the locking provider
440
+     *
441
+     * @return \OCP\Lock\ILockingProvider
442
+     * @since 8.1.0
443
+     */
444
+    public function getLockingProvider();
445
+
446
+    /**
447
+     * @return \OCP\Files\Mount\IMountManager
448
+     * @since 8.2.0
449
+     */
450
+    public function getMountManager();
451
+
452
+    /**
453
+     * Get the MimeTypeDetector
454
+     *
455
+     * @return \OCP\Files\IMimeTypeDetector
456
+     * @since 8.2.0
457
+     */
458
+    public function getMimeTypeDetector();
459
+
460
+    /**
461
+     * Get the MimeTypeLoader
462
+     *
463
+     * @return \OCP\Files\IMimeTypeLoader
464
+     * @since 8.2.0
465
+     */
466
+    public function getMimeTypeLoader();
467
+
468
+    /**
469
+     * Get the EventDispatcher
470
+     *
471
+     * @return EventDispatcherInterface
472
+     * @since 8.2.0
473
+     */
474
+    public function getEventDispatcher();
475
+
476
+    /**
477
+     * Get the Notification Manager
478
+     *
479
+     * @return \OCP\Notification\IManager
480
+     * @since 9.0.0
481
+     */
482
+    public function getNotificationManager();
483
+
484
+    /**
485
+     * @return \OCP\Comments\ICommentsManager
486
+     * @since 9.0.0
487
+     */
488
+    public function getCommentsManager();
489
+
490
+    /**
491
+     * Returns the system-tag manager
492
+     *
493
+     * @return \OCP\SystemTag\ISystemTagManager
494
+     *
495
+     * @since 9.0.0
496
+     */
497
+    public function getSystemTagManager();
498
+
499
+    /**
500
+     * Returns the system-tag object mapper
501
+     *
502
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
503
+     *
504
+     * @since 9.0.0
505
+     */
506
+    public function getSystemTagObjectMapper();
507
+
508
+    /**
509
+     * Returns the share manager
510
+     *
511
+     * @return \OCP\Share\IManager
512
+     * @since 9.0.0
513
+     */
514
+    public function getShareManager();
515
+
516
+    /**
517
+     * @return IContentSecurityPolicyManager
518
+     * @since 9.0.0
519
+     */
520
+    public function getContentSecurityPolicyManager();
521
+
522
+    /**
523
+     * @return \OCP\IDateTimeZone
524
+     * @since 8.0.0
525
+     */
526
+    public function getDateTimeZone();
527
+
528
+    /**
529
+     * @return \OCP\IDateTimeFormatter
530
+     * @since 8.0.0
531
+     */
532
+    public function getDateTimeFormatter();
533
+
534
+    /**
535
+     * @return \OCP\Federation\ICloudIdManager
536
+     * @since 12.0.0
537
+     */
538
+    public function getCloudIdManager();
539
+
540
+    /**
541
+     * @return \OCP\GlobalScale\IConfig
542
+     * @since 14.0.0
543
+     */
544
+    public function getGlobalScaleConfig();
545
+
546
+    /**
547
+     * @return ICloudFederationFactory
548
+     * @since 14.0.0
549
+     */
550
+    public function getCloudFederationFactory();
551
+
552
+    /**
553
+     * @return ICloudFederationProviderManager
554
+     * @since 14.0.0
555
+     */
556
+    public function getCloudFederationProviderManager();
557
+
558
+    /**
559
+     * @return \OCP\Remote\Api\IApiFactory
560
+     * @since 13.0.0
561
+     */
562
+    public function getRemoteApiFactory();
563
+
564
+    /**
565
+     * @return \OCP\Remote\IInstanceFactory
566
+     * @since 13.0.0
567
+     */
568
+    public function getRemoteInstanceFactory();
569 569
 }
Please login to merge, or discard this patch.
lib/public/Federation/Exceptions/AuthenticationFailedException.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,17 +32,17 @@
 block discarded – undo
32 32
  */
33 33
 class AuthenticationFailedException extends HintException {
34 34
 
35
-	/**
36
-	 * BadRequestException constructor.
37
-	 *
38
-	 * @since 14.0.0
39
-	 *
40
-	 */
41
-	public function __construct() {
42
-		$l = \OC::$server->getL10N('federation');
43
-		$message = 'Authentication failed, wrong token or provider ID given';
44
-		$hint = $l->t('Authentication failed, wrong token or provider ID given');
45
-		parent::__construct($message, $hint);
46
-	}
35
+    /**
36
+     * BadRequestException constructor.
37
+     *
38
+     * @since 14.0.0
39
+     *
40
+     */
41
+    public function __construct() {
42
+        $l = \OC::$server->getL10N('federation');
43
+        $message = 'Authentication failed, wrong token or provider ID given';
44
+        $hint = $l->t('Authentication failed, wrong token or provider ID given');
45
+        parent::__construct($message, $hint);
46
+    }
47 47
 
48 48
 }
Please login to merge, or discard this patch.
lib/public/Federation/ICloudFederationProvider.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -39,49 +39,49 @@
 block discarded – undo
39 39
 
40 40
 interface ICloudFederationProvider {
41 41
 
42
-	/**
43
-	 * get the name of the share type, handled by this provider
44
-	 *
45
-	 * @return string
46
-	 *
47
-	 * @since 14.0.0
48
-	 */
49
-	public function getShareType();
42
+    /**
43
+     * get the name of the share type, handled by this provider
44
+     *
45
+     * @return string
46
+     *
47
+     * @since 14.0.0
48
+     */
49
+    public function getShareType();
50 50
 
51
-	/**
52
-	 * share received from another server
53
-	 *
54
-	 * @param ICloudFederationShare $share
55
-	 * @return string provider specific unique ID of the share
56
-	 *
57
-	 * @throws ProviderCouldNotAddShareException
58
-	 *
59
-	 * @since 14.0.0
60
-	 */
61
-	public function shareReceived(ICloudFederationShare $share);
51
+    /**
52
+     * share received from another server
53
+     *
54
+     * @param ICloudFederationShare $share
55
+     * @return string provider specific unique ID of the share
56
+     *
57
+     * @throws ProviderCouldNotAddShareException
58
+     *
59
+     * @since 14.0.0
60
+     */
61
+    public function shareReceived(ICloudFederationShare $share);
62 62
 
63
-	/**
64
-	 * notification received from another server
65
-	 *
66
-	 * @param string $notificationType (e.g SHARE_ACCEPTED)
67
-	 * @param string $providerId share ID
68
-	 * @param array $notification provider specific notification
69
-	 * @return array $data send back to sender
70
-	 *
71
-	 * @throws ShareNotFound
72
-	 * @throws ActionNotSupportedException
73
-	 * @throws BadRequestException
74
-	 * @throws AuthenticationFailedException
75
-	 *
76
-	 * @since 14.0.0
77
-	 */
78
-	public function notificationReceived($notificationType, $providerId, array $notification);
63
+    /**
64
+     * notification received from another server
65
+     *
66
+     * @param string $notificationType (e.g SHARE_ACCEPTED)
67
+     * @param string $providerId share ID
68
+     * @param array $notification provider specific notification
69
+     * @return array $data send back to sender
70
+     *
71
+     * @throws ShareNotFound
72
+     * @throws ActionNotSupportedException
73
+     * @throws BadRequestException
74
+     * @throws AuthenticationFailedException
75
+     *
76
+     * @since 14.0.0
77
+     */
78
+    public function notificationReceived($notificationType, $providerId, array $notification);
79 79
 
80
-	/**
81
-	 * get the supported share types, e.g. "user", "group", etc.
82
-	 *
83
-	 * @return array
84
-	 */
85
-	public function getSupportedShareTypes();
80
+    /**
81
+     * get the supported share types, e.g. "user", "group", etc.
82
+     *
83
+     * @return array
84
+     */
85
+    public function getSupportedShareTypes();
86 86
 
87 87
 }
Please login to merge, or discard this patch.
lib/public/Federation/ICloudFederationProviderManager.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -32,76 +32,76 @@
 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 $resourceType which resource 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($resourceType, $displayName, callable $callback);
35
+    /**
36
+     * Registers an callback function which must return an cloud federation provider
37
+     *
38
+     * @param string $resourceType which resource 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($resourceType, $displayName, callable $callback);
46 46
 
47
-	/**
48
-	 * remove cloud federation provider
49
-	 *
50
-	 * @param string $resourceType
51
-	 *
52
-	 * @since 14.0.0
53
-	 */
54
-	public function removeCloudFederationProvider($resourceType);
47
+    /**
48
+     * remove cloud federation provider
49
+     *
50
+     * @param string $resourceType
51
+     *
52
+     * @since 14.0.0
53
+     */
54
+    public function removeCloudFederationProvider($resourceType);
55 55
 
56
-	/**
57
-	 * get a list of all cloudFederationProviders
58
-	 *
59
-	 * @return array [resourceType => ['resourceType' => $resourceType, '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 [resourceType => ['resourceType' => $resourceType, '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 $resourceType
69
-	 * @return ICloudFederationProvider
70
-	 * @throws Exceptions\ProviderDoesNotExistsException;
71
-	 *
72
-	 * @since 14.0.0
73
-	 */
74
-	public function getCloudFederationProvider($resourceType);
65
+    /**
66
+     * get a specific cloud federation provider
67
+     *
68
+     * @param string $resourceType
69
+     * @return ICloudFederationProvider
70
+     * @throws Exceptions\ProviderDoesNotExistsException;
71
+     *
72
+     * @since 14.0.0
73
+     */
74
+    public function getCloudFederationProvider($resourceType);
75 75
 
76
-	/**
77
-	 * send federated share
78
-	 *
79
-	 * @param ICloudFederationShare $share
80
-	 * @return bool
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 bool
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 string $url
90
-	 * @param ICloudFederationNotification $notification
91
-	 * @return mixed
92
-	 *
93
-	 * @since 14.0.0
94
-	 */
95
-	public function sendNotification($url, ICloudFederationNotification $notification);
86
+    /**
87
+     * send notification about existing share
88
+     *
89
+     * @param string $url
90
+     * @param ICloudFederationNotification $notification
91
+     * @return mixed
92
+     *
93
+     * @since 14.0.0
94
+     */
95
+    public function sendNotification($url, ICloudFederationNotification $notification);
96 96
 
97
-	/**
98
-	 * check if the new cloud federation API is ready to be used
99
-	 *
100
-	 * @return bool
101
-	 *
102
-	 * @since 14.0.0
103
-	 */
104
-	public function isReady();
97
+    /**
98
+     * check if the new cloud federation API is ready to be used
99
+     *
100
+     * @return bool
101
+     *
102
+     * @since 14.0.0
103
+     */
104
+    public function isReady();
105 105
 
106 106
 
107 107
 }
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php 3 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * share received from another server
151 151
 	 *
152 152
 	 * @param ICloudFederationShare $share
153
-	 * @return string provider specific unique ID of the share
153
+	 * @return integer provider specific unique ID of the share
154 154
 	 *
155 155
 	 * @throws ProviderCouldNotAddShareException
156 156
 	 * @throws \OCP\AppFramework\QueryException
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
 	 * notify user about new federated share
315 315
 	 *
316 316
 	 * @param $shareWith
317
-	 * @param $shareId
318
-	 * @param $ownerFederatedId
319
-	 * @param $sharedByFederatedId
320
-	 * @param $name
317
+	 * @param integer $shareId
318
+	 * @param string $ownerFederatedId
319
+	 * @param string $sharedByFederatedId
320
+	 * @param string $name
321 321
 	 */
322 322
 	private function notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name) {
323 323
 		$notification = $this->notificationManager->createNotification();
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 	/**
811 811
 	 * get the supported share types, e.g. "user", "group", etc.
812 812
 	 *
813
-	 * @return array
813
+	 * @return string[]
814 814
 	 */
815 815
 	public function getSupportedShareTypes() {
816 816
 		return ['user'];
Please login to merge, or discard this patch.
Indentation   +763 added lines, -763 removed lines patch added patch discarded remove patch
@@ -52,767 +52,767 @@
 block discarded – undo
52 52
 
53 53
 class CloudFederationProviderFiles implements ICloudFederationProvider {
54 54
 
55
-	/** @var IAppManager */
56
-	private $appManager;
57
-
58
-	/** @var FederatedShareProvider */
59
-	private $federatedShareProvider;
60
-
61
-	/** @var AddressHandler */
62
-	private $addressHandler;
63
-
64
-	/** @var ILogger */
65
-	private $logger;
66
-
67
-	/** @var IUserManager */
68
-	private $userManager;
69
-
70
-	/** @var ICloudIdManager */
71
-	private $cloudIdManager;
72
-
73
-	/** @var IActivityManager */
74
-	private $activityManager;
75
-
76
-	/** @var INotificationManager */
77
-	private $notificationManager;
78
-
79
-	/** @var IURLGenerator */
80
-	private $urlGenerator;
81
-
82
-	/** @var ICloudFederationFactory */
83
-	private $cloudFederationFactory;
84
-
85
-	/** @var ICloudFederationProviderManager */
86
-	private $cloudFederationProviderManager;
87
-
88
-	/** @var IDBConnection */
89
-	private $connection;
90
-
91
-	/** @var IGroupManager */
92
-	private $groupManager;
93
-
94
-	/**
95
-	 * CloudFederationProvider constructor.
96
-	 *
97
-	 * @param IAppManager $appManager
98
-	 * @param FederatedShareProvider $federatedShareProvider
99
-	 * @param AddressHandler $addressHandler
100
-	 * @param ILogger $logger
101
-	 * @param IUserManager $userManager
102
-	 * @param ICloudIdManager $cloudIdManager
103
-	 * @param IActivityManager $activityManager
104
-	 * @param INotificationManager $notificationManager
105
-	 * @param IURLGenerator $urlGenerator
106
-	 * @param ICloudFederationFactory $cloudFederationFactory
107
-	 * @param ICloudFederationProviderManager $cloudFederationProviderManager
108
-	 * @param IDBConnection $connection
109
-	 * @param IGroupManager $groupManager
110
-	 */
111
-	public function __construct(IAppManager $appManager,
112
-								FederatedShareProvider $federatedShareProvider,
113
-								AddressHandler $addressHandler,
114
-								ILogger $logger,
115
-								IUserManager $userManager,
116
-								ICloudIdManager $cloudIdManager,
117
-								IActivityManager $activityManager,
118
-								INotificationManager $notificationManager,
119
-								IURLGenerator $urlGenerator,
120
-								ICloudFederationFactory $cloudFederationFactory,
121
-								ICloudFederationProviderManager $cloudFederationProviderManager,
122
-								IDBConnection $connection,
123
-								IGroupManager $groupManager
124
-	) {
125
-		$this->appManager = $appManager;
126
-		$this->federatedShareProvider = $federatedShareProvider;
127
-		$this->addressHandler = $addressHandler;
128
-		$this->logger = $logger;
129
-		$this->userManager = $userManager;
130
-		$this->cloudIdManager = $cloudIdManager;
131
-		$this->activityManager = $activityManager;
132
-		$this->notificationManager = $notificationManager;
133
-		$this->urlGenerator = $urlGenerator;
134
-		$this->cloudFederationFactory = $cloudFederationFactory;
135
-		$this->cloudFederationProviderManager = $cloudFederationProviderManager;
136
-		$this->connection = $connection;
137
-		$this->groupManager = $groupManager;
138
-	}
139
-
140
-
141
-
142
-	/**
143
-	 * @return string
144
-	 */
145
-	public function getShareType() {
146
-		return 'file';
147
-	}
148
-
149
-	/**
150
-	 * share received from another server
151
-	 *
152
-	 * @param ICloudFederationShare $share
153
-	 * @return string provider specific unique ID of the share
154
-	 *
155
-	 * @throws ProviderCouldNotAddShareException
156
-	 * @throws \OCP\AppFramework\QueryException
157
-	 * @throws \OC\HintException
158
-	 * @since 14.0.0
159
-	 */
160
-	public function shareReceived(ICloudFederationShare $share) {
161
-
162
-		if (!$this->isS2SEnabled(true)) {
163
-			throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE);
164
-		}
165
-
166
-		$protocol = $share->getProtocol();
167
-		if ($protocol['name'] !== 'webdav') {
168
-			throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED);
169
-		}
170
-
171
-		list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner());
172
-		// for backward compatibility make sure that the remote url stored in the
173
-		// database ends with a trailing slash
174
-		if (substr($remote, -1) !== '/') {
175
-			$remote = $remote . '/';
176
-		}
177
-
178
-		$token = $share->getShareSecret();
179
-		$name = $share->getResourceName();
180
-		$owner = $share->getOwnerDisplayName();
181
-		$sharedBy = $share->getSharedByDisplayName();
182
-		$shareWith = $share->getShareWith();
183
-		$remoteId = $share->getProviderId();
184
-		$sharedByFederatedId = $share->getSharedBy();
185
-		$ownerFederatedId = $share->getOwner();
186
-		$shareType = $this->mapShareTypeToNextcloud($share->getShareType());
187
-
188
-		// if no explicit information about the person who created the share was send
189
-		// we assume that the share comes from the owner
190
-		if ($sharedByFederatedId === null) {
191
-			$sharedBy = $owner;
192
-			$sharedByFederatedId = $ownerFederatedId;
193
-		}
194
-
195
-		if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
196
-
197
-			if (!Util::isValidFileName($name)) {
198
-				throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST);
199
-			}
200
-
201
-			// FIXME this should be a method in the user management instead
202
-			$this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']);
203
-			Util::emitHook(
204
-				'\OCA\Files_Sharing\API\Server2Server',
205
-				'preLoginNameUsedAsUserName',
206
-				array('uid' => &$shareWith)
207
-			);
208
-			$this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']);
209
-
210
-			if (!$this->userManager->userExists($shareWith)) {
211
-				throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST);
212
-			}
213
-
214
-			\OC_Util::setupFS($shareWith);
215
-
216
-			$externalManager = new \OCA\Files_Sharing\External\Manager(
217
-				\OC::$server->getDatabaseConnection(),
218
-				Filesystem::getMountManager(),
219
-				Filesystem::getLoader(),
220
-				\OC::$server->getHTTPClientService(),
221
-				\OC::$server->getNotificationManager(),
222
-				\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
223
-				\OC::$server->getCloudFederationProviderManager(),
224
-				\OC::$server->getCloudFederationFactory(),
225
-				$shareWith
226
-			);
227
-
228
-			try {
229
-				$externalManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId);
230
-				$shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external');
231
-
232
-				$event = $this->activityManager->generateEvent();
233
-				$event->setApp('files_sharing')
234
-					->setType('remote_share')
235
-					->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')])
236
-					->setAffectedUser($shareWith)
237
-					->setObject('remote_share', (int)$shareId, $name);
238
-				\OC::$server->getActivityManager()->publish($event);
239
-
240
-				if ($shareType === Share::SHARE_TYPE_USER) {
241
-					$this->notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name);
242
-				} else {
243
-					$groupMembers = $this->groupManager->get($shareWith)->getUsers();
244
-					foreach ($groupMembers as $user) {
245
-						$this->notifyAboutNewShare($user, $shareId, $ownerFederatedId, $sharedByFederatedId, $name);
246
-					}
247
-				}
248
-				return $shareId;
249
-			} catch (\Exception $e) {
250
-				$this->logger->logException($e, [
251
-					'message' => 'Server can not add remote share.',
252
-					'level' => ILogger::ERROR,
253
-					'app' => 'files_sharing'
254
-				]);
255
-				throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR);
256
-			}
257
-		}
258
-
259
-		throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST);
260
-
261
-	}
262
-
263
-	/**
264
-	 * notification received from another server
265
-	 *
266
-	 * @param string $notificationType (e.g. SHARE_ACCEPTED)
267
-	 * @param string $providerId id of the share
268
-	 * @param array $notification payload of the notification
269
-	 * @return array data send back to the sender
270
-	 *
271
-	 * @throws ActionNotSupportedException
272
-	 * @throws AuthenticationFailedException
273
-	 * @throws BadRequestException
274
-	 * @throws \OC\HintException
275
-	 * @since 14.0.0
276
-	 */
277
-	public function notificationReceived($notificationType, $providerId, array $notification) {
278
-
279
-		switch ($notificationType) {
280
-			case 'SHARE_ACCEPTED':
281
-				return $this->shareAccepted($providerId, $notification);
282
-			case 'SHARE_DECLINED':
283
-				return $this->shareDeclined($providerId, $notification);
284
-			case 'SHARE_UNSHARED':
285
-				return $this->unshare($providerId, $notification);
286
-			case 'REQUEST_RESHARE':
287
-				return $this->reshareRequested($providerId, $notification);
288
-			case 'RESHARE_UNDO':
289
-				return $this->undoReshare($providerId, $notification);
290
-			case 'RESHARE_CHANGE_PERMISSION':
291
-				return $this->updateResharePermissions($providerId, $notification);
292
-		}
293
-
294
-
295
-		throw new BadRequestException([$notificationType]);
296
-	}
297
-
298
-	/**
299
-	 * map OCM share type (strings) to Nextcloud internal share types (integer)
300
-	 *
301
-	 * @param string $shareType
302
-	 * @return int
303
-	 */
304
-	private function mapShareTypeToNextcloud($shareType) {
305
-		$result = Share::SHARE_TYPE_USER;
306
-		if ($shareType === 'group') {
307
-			$result = Share::SHARE_TYPE_GROUP;
308
-		}
309
-
310
-		return $result;
311
-	}
312
-
313
-	/**
314
-	 * notify user about new federated share
315
-	 *
316
-	 * @param $shareWith
317
-	 * @param $shareId
318
-	 * @param $ownerFederatedId
319
-	 * @param $sharedByFederatedId
320
-	 * @param $name
321
-	 */
322
-	private function notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name) {
323
-		$notification = $this->notificationManager->createNotification();
324
-		$notification->setApp('files_sharing')
325
-			->setUser($shareWith)
326
-			->setDateTime(new \DateTime())
327
-			->setObject('remote_share', $shareId)
328
-			->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]);
329
-
330
-		$declineAction = $notification->createAction();
331
-		$declineAction->setLabel('decline')
332
-			->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE');
333
-		$notification->addAction($declineAction);
334
-
335
-		$acceptAction = $notification->createAction();
336
-		$acceptAction->setLabel('accept')
337
-			->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST');
338
-		$notification->addAction($acceptAction);
339
-
340
-		$this->notificationManager->notify($notification);
341
-	}
342
-
343
-	/**
344
-	 * process notification that the recipient accepted a share
345
-	 *
346
-	 * @param string $id
347
-	 * @param array $notification
348
-	 * @return array
349
-	 * @throws ActionNotSupportedException
350
-	 * @throws AuthenticationFailedException
351
-	 * @throws BadRequestException
352
-	 * @throws \OC\HintException
353
-	 */
354
-	private function shareAccepted($id, array $notification) {
355
-
356
-		if (!$this->isS2SEnabled()) {
357
-			throw new ActionNotSupportedException('Server does not support federated cloud sharing');
358
-		}
359
-
360
-		if (!isset($notification['sharedSecret'])) {
361
-			throw new BadRequestException(['sharedSecret']);
362
-		}
363
-
364
-		$token = $notification['sharedSecret'];
365
-
366
-		$share = $this->federatedShareProvider->getShareById($id);
367
-
368
-		$this->verifyShare($share, $token);
369
-		$this->executeAcceptShare($share);
370
-		if ($share->getShareOwner() !== $share->getSharedBy()) {
371
-			list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
372
-			$remoteId = $this->federatedShareProvider->getRemoteId($share);
373
-			$notification = $this->cloudFederationFactory->getCloudFederationNotification();
374
-			$notification->setMessage(
375
-				'SHARE_ACCEPTED',
376
-				'file',
377
-				$remoteId,
378
-				[
379
-					'sharedSecret' => $token,
380
-					'message' => 'Recipient accepted the re-share'
381
-				]
382
-
383
-			);
384
-			$this->cloudFederationProviderManager->sendNotification($remote, $notification);
385
-
386
-		}
387
-
388
-		return [];
389
-	}
390
-
391
-	/**
392
-	 * @param IShare $share
393
-	 * @throws ShareNotFound
394
-	 */
395
-	protected function executeAcceptShare(IShare $share) {
396
-		try {
397
-			$fileId = (int)$share->getNode()->getId();
398
-			list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
399
-		} catch (\Exception $e) {
400
-			throw new ShareNotFound();
401
-		}
402
-
403
-		$event = $this->activityManager->generateEvent();
404
-		$event->setApp('files_sharing')
405
-			->setType('remote_share')
406
-			->setAffectedUser($this->getCorrectUid($share))
407
-			->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]])
408
-			->setObject('files', $fileId, $file)
409
-			->setLink($link);
410
-		$this->activityManager->publish($event);
411
-	}
412
-
413
-	/**
414
-	 * process notification that the recipient declined a share
415
-	 *
416
-	 * @param string $id
417
-	 * @param array $notification
418
-	 * @return array
419
-	 * @throws ActionNotSupportedException
420
-	 * @throws AuthenticationFailedException
421
-	 * @throws BadRequestException
422
-	 * @throws ShareNotFound
423
-	 * @throws \OC\HintException
424
-	 *
425
-	 */
426
-	protected function shareDeclined($id, array $notification) {
427
-
428
-		if (!$this->isS2SEnabled()) {
429
-			throw new ActionNotSupportedException('Server does not support federated cloud sharing');
430
-		}
431
-
432
-		if (!isset($notification['sharedSecret'])) {
433
-			throw new BadRequestException(['sharedSecret']);
434
-		}
435
-
436
-		$token = $notification['sharedSecret'];
437
-
438
-		$share = $this->federatedShareProvider->getShareById($id);
439
-
440
-		$this->verifyShare($share, $token);
441
-
442
-		if ($share->getShareOwner() !== $share->getSharedBy()) {
443
-			list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
444
-			$remoteId = $this->federatedShareProvider->getRemoteId($share);
445
-			$notification = $this->cloudFederationFactory->getCloudFederationNotification();
446
-			$notification->setMessage(
447
-				'SHARE_DECLINED',
448
-				'file',
449
-				$remoteId,
450
-				[
451
-					'sharedSecret' => $token,
452
-					'message' => 'Recipient declined the re-share'
453
-				]
454
-
455
-			);
456
-			$this->cloudFederationProviderManager->sendNotification($remote, $notification);
457
-		}
458
-
459
-		$this->executeDeclineShare($share);
460
-
461
-		return [];
462
-
463
-	}
464
-
465
-	/**
466
-	 * delete declined share and create a activity
467
-	 *
468
-	 * @param IShare $share
469
-	 * @throws ShareNotFound
470
-	 */
471
-	protected function executeDeclineShare(IShare $share) {
472
-		$this->federatedShareProvider->removeShareFromTable($share);
473
-
474
-		try {
475
-			$fileId = (int)$share->getNode()->getId();
476
-			list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
477
-		} catch (\Exception $e) {
478
-			throw new ShareNotFound();
479
-		}
480
-
481
-		$event = $this->activityManager->generateEvent();
482
-		$event->setApp('files_sharing')
483
-			->setType('remote_share')
484
-			->setAffectedUser($this->getCorrectUid($share))
485
-			->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]])
486
-			->setObject('files', $fileId, $file)
487
-			->setLink($link);
488
-		$this->activityManager->publish($event);
489
-
490
-	}
491
-
492
-	/**
493
-	 * received the notification that the owner unshared a file from you
494
-	 *
495
-	 * @param string $id
496
-	 * @param array $notification
497
-	 * @return array
498
-	 * @throws AuthenticationFailedException
499
-	 * @throws BadRequestException
500
-	 */
501
-	private function undoReshare($id, array $notification) {
502
-		if (!isset($notification['sharedSecret'])) {
503
-			throw new BadRequestException(['sharedSecret']);
504
-		}
505
-		$token = $notification['sharedSecret'];
506
-
507
-		$share = $this->federatedShareProvider->getShareById($id);
508
-
509
-		$this->verifyShare($share, $token);
510
-		$this->federatedShareProvider->removeShareFromTable($share);
511
-		return [];
512
-	}
513
-
514
-	/**
515
-	 * unshare file from self
516
-	 *
517
-	 * @param string $id
518
-	 * @param array $notification
519
-	 * @return array
520
-	 * @throws ActionNotSupportedException
521
-	 * @throws BadRequestException
522
-	 */
523
-	private function unshare($id, array $notification) {
524
-
525
-		if (!$this->isS2SEnabled(true)) {
526
-			throw new ActionNotSupportedException("incoming shares disabled!");
527
-		}
528
-
529
-		if (!isset($notification['sharedSecret'])) {
530
-			throw new BadRequestException(['sharedSecret']);
531
-		}
532
-		$token = $notification['sharedSecret'];
533
-
534
-		$qb = $this->connection->getQueryBuilder();
535
-		$qb->select('*')
536
-			->from('share_external')
537
-			->where(
538
-				$qb->expr()->andX(
539
-					$qb->expr()->eq('remote_id', $qb->createNamedParameter($id)),
540
-					$qb->expr()->eq('share_token', $qb->createNamedParameter($token))
541
-				)
542
-			);
543
-
544
-		$result = $qb->execute();
545
-		$share = $result->fetch();
546
-		$result->closeCursor();
547
-
548
-		if ($token && $id && !empty($share)) {
549
-
550
-			$remote = $this->cleanupRemote($share['remote']);
551
-
552
-			$owner = $this->cloudIdManager->getCloudId($share['owner'], $remote);
553
-			$mountpoint = $share['mountpoint'];
554
-			$user = $share['user'];
555
-
556
-			$qb = $this->connection->getQueryBuilder();
557
-			$qb->delete('share_external')
558
-				->where(
559
-					$qb->expr()->andX(
560
-						$qb->expr()->eq('remote_id', $qb->createNamedParameter($id)),
561
-						$qb->expr()->eq('share_token', $qb->createNamedParameter($token))
562
-					)
563
-				);
564
-
565
-			$qb->execute();
566
-
567
-			if ($share['accepted']) {
568
-				$path = trim($mountpoint, '/');
569
-			} else {
570
-				$path = trim($share['name'], '/');
571
-			}
572
-
573
-			$notification = $this->notificationManager->createNotification();
574
-			$notification->setApp('files_sharing')
575
-				->setUser($share['user'])
576
-				->setObject('remote_share', (int)$share['id']);
577
-			$this->notificationManager->markProcessed($notification);
578
-
579
-			$event = $this->activityManager->generateEvent();
580
-			$event->setApp('files_sharing')
581
-				->setType('remote_share')
582
-				->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path])
583
-				->setAffectedUser($user)
584
-				->setObject('remote_share', (int)$share['id'], $path);
585
-			\OC::$server->getActivityManager()->publish($event);
586
-		}
587
-
588
-		return [];
589
-	}
590
-
591
-	private function cleanupRemote($remote) {
592
-		$remote = substr($remote, strpos($remote, '://') + 3);
593
-
594
-		return rtrim($remote, '/');
595
-	}
596
-
597
-	/**
598
-	 * recipient of a share request to re-share the file with another user
599
-	 *
600
-	 * @param string $id
601
-	 * @param array $notification
602
-	 * @return array
603
-	 * @throws AuthenticationFailedException
604
-	 * @throws BadRequestException
605
-	 * @throws ProviderCouldNotAddShareException
606
-	 * @throws ShareNotFound
607
-	 */
608
-	protected function reshareRequested($id, array $notification) {
609
-
610
-		if (!isset($notification['sharedSecret'])) {
611
-			throw new BadRequestException(['sharedSecret']);
612
-		}
613
-		$token = $notification['sharedSecret'];
614
-
615
-		if (!isset($notification['shareWith'])) {
616
-			throw new BadRequestException(['shareWith']);
617
-		}
618
-		$shareWith = $notification['shareWith'];
619
-
620
-		if (!isset($notification['senderId'])) {
621
-			throw new BadRequestException(['senderId']);
622
-		}
623
-		$senderId = $notification['senderId'];
624
-
625
-		$share = $this->federatedShareProvider->getShareById($id);
626
-		// don't allow to share a file back to the owner
627
-		try {
628
-			list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
629
-			$owner = $share->getShareOwner();
630
-			$currentServer = $this->addressHandler->generateRemoteURL();
631
-			if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) {
632
-				throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id);
633
-			}
634
-		} catch (\Exception $e) {
635
-			throw new ProviderCouldNotAddShareException($e->getMessage());
636
-		}
637
-
638
-		$this->verifyShare($share, $token);
639
-
640
-		// check if re-sharing is allowed
641
-		if ($share->getPermissions() & Constants::PERMISSION_SHARE) {
642
-			// the recipient of the initial share is now the initiator for the re-share
643
-			$share->setSharedBy($share->getSharedWith());
644
-			$share->setSharedWith($shareWith);
645
-			$result = $this->federatedShareProvider->create($share);
646
-			$this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId);
647
-			return ['token' => $result->getToken(), 'providerId' => $result->getId()];
648
-		} else {
649
-			throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id);
650
-		}
651
-
652
-	}
653
-
654
-	/**
655
-	 * update permission of a re-share so that the share dialog shows the right
656
-	 * permission if the owner or the sender changes the permission
657
-	 *
658
-	 * @param string $id
659
-	 * @param array $notification
660
-	 * @return array
661
-	 * @throws AuthenticationFailedException
662
-	 * @throws BadRequestException
663
-	 */
664
-	protected function updateResharePermissions($id, array $notification) {
665
-
666
-		if (!isset($notification['sharedSecret'])) {
667
-			throw new BadRequestException(['sharedSecret']);
668
-		}
669
-		$token = $notification['sharedSecret'];
670
-
671
-		if (!isset($notification['permission'])) {
672
-			throw new BadRequestException(['permission']);
673
-		}
674
-		$ocmPermissions = $notification['permission'];
675
-
676
-		$share = $this->federatedShareProvider->getShareById($id);
677
-
678
-		$ncPermission = $this->ocmPermissions2ncPermissions($ocmPermissions);
679
-
680
-		$this->verifyShare($share, $token);
681
-		$this->updatePermissionsInDatabase($share, $ncPermission);
682
-
683
-		return [];
684
-	}
685
-
686
-	/**
687
-	 * translate OCM Permissions to Nextcloud permissions
688
-	 *
689
-	 * @param array $ocmPermissions
690
-	 * @return int
691
-	 * @throws BadRequestException
692
-	 */
693
-	protected function ocmPermissions2ncPermissions(array $ocmPermissions) {
694
-		$ncPermissions = 0;
695
-		foreach($ocmPermissions as $permission) {
696
-			switch (strtolower($permission)) {
697
-				case 'read':
698
-					$ncPermissions += Constants::PERMISSION_READ;
699
-					break;
700
-				case 'write':
701
-					$ncPermissions += Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE;
702
-					break;
703
-				case 'share':
704
-					$ncPermissions += Constants::PERMISSION_SHARE;
705
-					break;
706
-				default:
707
-					throw new BadRequestException(['permission']);
708
-			}
709
-
710
-			error_log("new permissions: " . $ncPermissions);
711
-		}
712
-
713
-		return $ncPermissions;
714
-	}
715
-
716
-	/**
717
-	 * update permissions in database
718
-	 *
719
-	 * @param IShare $share
720
-	 * @param int $permissions
721
-	 */
722
-	protected function updatePermissionsInDatabase(IShare $share, $permissions) {
723
-		$query = $this->connection->getQueryBuilder();
724
-		$query->update('share')
725
-			->where($query->expr()->eq('id', $query->createNamedParameter($share->getId())))
726
-			->set('permissions', $query->createNamedParameter($permissions))
727
-			->execute();
728
-	}
729
-
730
-
731
-	/**
732
-	 * get file
733
-	 *
734
-	 * @param string $user
735
-	 * @param int $fileSource
736
-	 * @return array with internal path of the file and a absolute link to it
737
-	 */
738
-	private function getFile($user, $fileSource) {
739
-		\OC_Util::setupFS($user);
740
-
741
-		try {
742
-			$file = Filesystem::getPath($fileSource);
743
-		} catch (NotFoundException $e) {
744
-			$file = null;
745
-		}
746
-		$args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file);
747
-		$link = Util::linkToAbsolute('files', 'index.php', $args);
748
-
749
-		return [$file, $link];
750
-
751
-	}
752
-
753
-	/**
754
-	 * check if we are the initiator or the owner of a re-share and return the correct UID
755
-	 *
756
-	 * @param IShare $share
757
-	 * @return string
758
-	 */
759
-	protected function getCorrectUid(IShare $share) {
760
-		if ($this->userManager->userExists($share->getShareOwner())) {
761
-			return $share->getShareOwner();
762
-		}
763
-
764
-		return $share->getSharedBy();
765
-	}
766
-
767
-
768
-
769
-	/**
770
-	 * check if we got the right share
771
-	 *
772
-	 * @param IShare $share
773
-	 * @param string $token
774
-	 * @return bool
775
-	 * @throws AuthenticationFailedException
776
-	 */
777
-	protected function verifyShare(IShare $share, $token) {
778
-		if (
779
-			$share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE &&
780
-			$share->getToken() === $token
781
-		) {
782
-			return true;
783
-		}
784
-
785
-		throw new AuthenticationFailedException();
786
-	}
787
-
788
-
789
-
790
-	/**
791
-	 * check if server-to-server sharing is enabled
792
-	 *
793
-	 * @param bool $incoming
794
-	 * @return bool
795
-	 */
796
-	private function isS2SEnabled($incoming = false) {
797
-
798
-		$result = $this->appManager->isEnabledForUser('files_sharing');
799
-
800
-		if ($incoming) {
801
-			$result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();
802
-		} else {
803
-			$result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
804
-		}
805
-
806
-		return $result;
807
-	}
808
-
809
-
810
-	/**
811
-	 * get the supported share types, e.g. "user", "group", etc.
812
-	 *
813
-	 * @return array
814
-	 */
815
-	public function getSupportedShareTypes() {
816
-		return ['user'];
817
-	}
55
+    /** @var IAppManager */
56
+    private $appManager;
57
+
58
+    /** @var FederatedShareProvider */
59
+    private $federatedShareProvider;
60
+
61
+    /** @var AddressHandler */
62
+    private $addressHandler;
63
+
64
+    /** @var ILogger */
65
+    private $logger;
66
+
67
+    /** @var IUserManager */
68
+    private $userManager;
69
+
70
+    /** @var ICloudIdManager */
71
+    private $cloudIdManager;
72
+
73
+    /** @var IActivityManager */
74
+    private $activityManager;
75
+
76
+    /** @var INotificationManager */
77
+    private $notificationManager;
78
+
79
+    /** @var IURLGenerator */
80
+    private $urlGenerator;
81
+
82
+    /** @var ICloudFederationFactory */
83
+    private $cloudFederationFactory;
84
+
85
+    /** @var ICloudFederationProviderManager */
86
+    private $cloudFederationProviderManager;
87
+
88
+    /** @var IDBConnection */
89
+    private $connection;
90
+
91
+    /** @var IGroupManager */
92
+    private $groupManager;
93
+
94
+    /**
95
+     * CloudFederationProvider constructor.
96
+     *
97
+     * @param IAppManager $appManager
98
+     * @param FederatedShareProvider $federatedShareProvider
99
+     * @param AddressHandler $addressHandler
100
+     * @param ILogger $logger
101
+     * @param IUserManager $userManager
102
+     * @param ICloudIdManager $cloudIdManager
103
+     * @param IActivityManager $activityManager
104
+     * @param INotificationManager $notificationManager
105
+     * @param IURLGenerator $urlGenerator
106
+     * @param ICloudFederationFactory $cloudFederationFactory
107
+     * @param ICloudFederationProviderManager $cloudFederationProviderManager
108
+     * @param IDBConnection $connection
109
+     * @param IGroupManager $groupManager
110
+     */
111
+    public function __construct(IAppManager $appManager,
112
+                                FederatedShareProvider $federatedShareProvider,
113
+                                AddressHandler $addressHandler,
114
+                                ILogger $logger,
115
+                                IUserManager $userManager,
116
+                                ICloudIdManager $cloudIdManager,
117
+                                IActivityManager $activityManager,
118
+                                INotificationManager $notificationManager,
119
+                                IURLGenerator $urlGenerator,
120
+                                ICloudFederationFactory $cloudFederationFactory,
121
+                                ICloudFederationProviderManager $cloudFederationProviderManager,
122
+                                IDBConnection $connection,
123
+                                IGroupManager $groupManager
124
+    ) {
125
+        $this->appManager = $appManager;
126
+        $this->federatedShareProvider = $federatedShareProvider;
127
+        $this->addressHandler = $addressHandler;
128
+        $this->logger = $logger;
129
+        $this->userManager = $userManager;
130
+        $this->cloudIdManager = $cloudIdManager;
131
+        $this->activityManager = $activityManager;
132
+        $this->notificationManager = $notificationManager;
133
+        $this->urlGenerator = $urlGenerator;
134
+        $this->cloudFederationFactory = $cloudFederationFactory;
135
+        $this->cloudFederationProviderManager = $cloudFederationProviderManager;
136
+        $this->connection = $connection;
137
+        $this->groupManager = $groupManager;
138
+    }
139
+
140
+
141
+
142
+    /**
143
+     * @return string
144
+     */
145
+    public function getShareType() {
146
+        return 'file';
147
+    }
148
+
149
+    /**
150
+     * share received from another server
151
+     *
152
+     * @param ICloudFederationShare $share
153
+     * @return string provider specific unique ID of the share
154
+     *
155
+     * @throws ProviderCouldNotAddShareException
156
+     * @throws \OCP\AppFramework\QueryException
157
+     * @throws \OC\HintException
158
+     * @since 14.0.0
159
+     */
160
+    public function shareReceived(ICloudFederationShare $share) {
161
+
162
+        if (!$this->isS2SEnabled(true)) {
163
+            throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE);
164
+        }
165
+
166
+        $protocol = $share->getProtocol();
167
+        if ($protocol['name'] !== 'webdav') {
168
+            throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED);
169
+        }
170
+
171
+        list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner());
172
+        // for backward compatibility make sure that the remote url stored in the
173
+        // database ends with a trailing slash
174
+        if (substr($remote, -1) !== '/') {
175
+            $remote = $remote . '/';
176
+        }
177
+
178
+        $token = $share->getShareSecret();
179
+        $name = $share->getResourceName();
180
+        $owner = $share->getOwnerDisplayName();
181
+        $sharedBy = $share->getSharedByDisplayName();
182
+        $shareWith = $share->getShareWith();
183
+        $remoteId = $share->getProviderId();
184
+        $sharedByFederatedId = $share->getSharedBy();
185
+        $ownerFederatedId = $share->getOwner();
186
+        $shareType = $this->mapShareTypeToNextcloud($share->getShareType());
187
+
188
+        // if no explicit information about the person who created the share was send
189
+        // we assume that the share comes from the owner
190
+        if ($sharedByFederatedId === null) {
191
+            $sharedBy = $owner;
192
+            $sharedByFederatedId = $ownerFederatedId;
193
+        }
194
+
195
+        if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
196
+
197
+            if (!Util::isValidFileName($name)) {
198
+                throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST);
199
+            }
200
+
201
+            // FIXME this should be a method in the user management instead
202
+            $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']);
203
+            Util::emitHook(
204
+                '\OCA\Files_Sharing\API\Server2Server',
205
+                'preLoginNameUsedAsUserName',
206
+                array('uid' => &$shareWith)
207
+            );
208
+            $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']);
209
+
210
+            if (!$this->userManager->userExists($shareWith)) {
211
+                throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST);
212
+            }
213
+
214
+            \OC_Util::setupFS($shareWith);
215
+
216
+            $externalManager = new \OCA\Files_Sharing\External\Manager(
217
+                \OC::$server->getDatabaseConnection(),
218
+                Filesystem::getMountManager(),
219
+                Filesystem::getLoader(),
220
+                \OC::$server->getHTTPClientService(),
221
+                \OC::$server->getNotificationManager(),
222
+                \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
223
+                \OC::$server->getCloudFederationProviderManager(),
224
+                \OC::$server->getCloudFederationFactory(),
225
+                $shareWith
226
+            );
227
+
228
+            try {
229
+                $externalManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId);
230
+                $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external');
231
+
232
+                $event = $this->activityManager->generateEvent();
233
+                $event->setApp('files_sharing')
234
+                    ->setType('remote_share')
235
+                    ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')])
236
+                    ->setAffectedUser($shareWith)
237
+                    ->setObject('remote_share', (int)$shareId, $name);
238
+                \OC::$server->getActivityManager()->publish($event);
239
+
240
+                if ($shareType === Share::SHARE_TYPE_USER) {
241
+                    $this->notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name);
242
+                } else {
243
+                    $groupMembers = $this->groupManager->get($shareWith)->getUsers();
244
+                    foreach ($groupMembers as $user) {
245
+                        $this->notifyAboutNewShare($user, $shareId, $ownerFederatedId, $sharedByFederatedId, $name);
246
+                    }
247
+                }
248
+                return $shareId;
249
+            } catch (\Exception $e) {
250
+                $this->logger->logException($e, [
251
+                    'message' => 'Server can not add remote share.',
252
+                    'level' => ILogger::ERROR,
253
+                    'app' => 'files_sharing'
254
+                ]);
255
+                throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR);
256
+            }
257
+        }
258
+
259
+        throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST);
260
+
261
+    }
262
+
263
+    /**
264
+     * notification received from another server
265
+     *
266
+     * @param string $notificationType (e.g. SHARE_ACCEPTED)
267
+     * @param string $providerId id of the share
268
+     * @param array $notification payload of the notification
269
+     * @return array data send back to the sender
270
+     *
271
+     * @throws ActionNotSupportedException
272
+     * @throws AuthenticationFailedException
273
+     * @throws BadRequestException
274
+     * @throws \OC\HintException
275
+     * @since 14.0.0
276
+     */
277
+    public function notificationReceived($notificationType, $providerId, array $notification) {
278
+
279
+        switch ($notificationType) {
280
+            case 'SHARE_ACCEPTED':
281
+                return $this->shareAccepted($providerId, $notification);
282
+            case 'SHARE_DECLINED':
283
+                return $this->shareDeclined($providerId, $notification);
284
+            case 'SHARE_UNSHARED':
285
+                return $this->unshare($providerId, $notification);
286
+            case 'REQUEST_RESHARE':
287
+                return $this->reshareRequested($providerId, $notification);
288
+            case 'RESHARE_UNDO':
289
+                return $this->undoReshare($providerId, $notification);
290
+            case 'RESHARE_CHANGE_PERMISSION':
291
+                return $this->updateResharePermissions($providerId, $notification);
292
+        }
293
+
294
+
295
+        throw new BadRequestException([$notificationType]);
296
+    }
297
+
298
+    /**
299
+     * map OCM share type (strings) to Nextcloud internal share types (integer)
300
+     *
301
+     * @param string $shareType
302
+     * @return int
303
+     */
304
+    private function mapShareTypeToNextcloud($shareType) {
305
+        $result = Share::SHARE_TYPE_USER;
306
+        if ($shareType === 'group') {
307
+            $result = Share::SHARE_TYPE_GROUP;
308
+        }
309
+
310
+        return $result;
311
+    }
312
+
313
+    /**
314
+     * notify user about new federated share
315
+     *
316
+     * @param $shareWith
317
+     * @param $shareId
318
+     * @param $ownerFederatedId
319
+     * @param $sharedByFederatedId
320
+     * @param $name
321
+     */
322
+    private function notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name) {
323
+        $notification = $this->notificationManager->createNotification();
324
+        $notification->setApp('files_sharing')
325
+            ->setUser($shareWith)
326
+            ->setDateTime(new \DateTime())
327
+            ->setObject('remote_share', $shareId)
328
+            ->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]);
329
+
330
+        $declineAction = $notification->createAction();
331
+        $declineAction->setLabel('decline')
332
+            ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE');
333
+        $notification->addAction($declineAction);
334
+
335
+        $acceptAction = $notification->createAction();
336
+        $acceptAction->setLabel('accept')
337
+            ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST');
338
+        $notification->addAction($acceptAction);
339
+
340
+        $this->notificationManager->notify($notification);
341
+    }
342
+
343
+    /**
344
+     * process notification that the recipient accepted a share
345
+     *
346
+     * @param string $id
347
+     * @param array $notification
348
+     * @return array
349
+     * @throws ActionNotSupportedException
350
+     * @throws AuthenticationFailedException
351
+     * @throws BadRequestException
352
+     * @throws \OC\HintException
353
+     */
354
+    private function shareAccepted($id, array $notification) {
355
+
356
+        if (!$this->isS2SEnabled()) {
357
+            throw new ActionNotSupportedException('Server does not support federated cloud sharing');
358
+        }
359
+
360
+        if (!isset($notification['sharedSecret'])) {
361
+            throw new BadRequestException(['sharedSecret']);
362
+        }
363
+
364
+        $token = $notification['sharedSecret'];
365
+
366
+        $share = $this->federatedShareProvider->getShareById($id);
367
+
368
+        $this->verifyShare($share, $token);
369
+        $this->executeAcceptShare($share);
370
+        if ($share->getShareOwner() !== $share->getSharedBy()) {
371
+            list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
372
+            $remoteId = $this->federatedShareProvider->getRemoteId($share);
373
+            $notification = $this->cloudFederationFactory->getCloudFederationNotification();
374
+            $notification->setMessage(
375
+                'SHARE_ACCEPTED',
376
+                'file',
377
+                $remoteId,
378
+                [
379
+                    'sharedSecret' => $token,
380
+                    'message' => 'Recipient accepted the re-share'
381
+                ]
382
+
383
+            );
384
+            $this->cloudFederationProviderManager->sendNotification($remote, $notification);
385
+
386
+        }
387
+
388
+        return [];
389
+    }
390
+
391
+    /**
392
+     * @param IShare $share
393
+     * @throws ShareNotFound
394
+     */
395
+    protected function executeAcceptShare(IShare $share) {
396
+        try {
397
+            $fileId = (int)$share->getNode()->getId();
398
+            list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
399
+        } catch (\Exception $e) {
400
+            throw new ShareNotFound();
401
+        }
402
+
403
+        $event = $this->activityManager->generateEvent();
404
+        $event->setApp('files_sharing')
405
+            ->setType('remote_share')
406
+            ->setAffectedUser($this->getCorrectUid($share))
407
+            ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]])
408
+            ->setObject('files', $fileId, $file)
409
+            ->setLink($link);
410
+        $this->activityManager->publish($event);
411
+    }
412
+
413
+    /**
414
+     * process notification that the recipient declined a share
415
+     *
416
+     * @param string $id
417
+     * @param array $notification
418
+     * @return array
419
+     * @throws ActionNotSupportedException
420
+     * @throws AuthenticationFailedException
421
+     * @throws BadRequestException
422
+     * @throws ShareNotFound
423
+     * @throws \OC\HintException
424
+     *
425
+     */
426
+    protected function shareDeclined($id, array $notification) {
427
+
428
+        if (!$this->isS2SEnabled()) {
429
+            throw new ActionNotSupportedException('Server does not support federated cloud sharing');
430
+        }
431
+
432
+        if (!isset($notification['sharedSecret'])) {
433
+            throw new BadRequestException(['sharedSecret']);
434
+        }
435
+
436
+        $token = $notification['sharedSecret'];
437
+
438
+        $share = $this->federatedShareProvider->getShareById($id);
439
+
440
+        $this->verifyShare($share, $token);
441
+
442
+        if ($share->getShareOwner() !== $share->getSharedBy()) {
443
+            list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
444
+            $remoteId = $this->federatedShareProvider->getRemoteId($share);
445
+            $notification = $this->cloudFederationFactory->getCloudFederationNotification();
446
+            $notification->setMessage(
447
+                'SHARE_DECLINED',
448
+                'file',
449
+                $remoteId,
450
+                [
451
+                    'sharedSecret' => $token,
452
+                    'message' => 'Recipient declined the re-share'
453
+                ]
454
+
455
+            );
456
+            $this->cloudFederationProviderManager->sendNotification($remote, $notification);
457
+        }
458
+
459
+        $this->executeDeclineShare($share);
460
+
461
+        return [];
462
+
463
+    }
464
+
465
+    /**
466
+     * delete declined share and create a activity
467
+     *
468
+     * @param IShare $share
469
+     * @throws ShareNotFound
470
+     */
471
+    protected function executeDeclineShare(IShare $share) {
472
+        $this->federatedShareProvider->removeShareFromTable($share);
473
+
474
+        try {
475
+            $fileId = (int)$share->getNode()->getId();
476
+            list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
477
+        } catch (\Exception $e) {
478
+            throw new ShareNotFound();
479
+        }
480
+
481
+        $event = $this->activityManager->generateEvent();
482
+        $event->setApp('files_sharing')
483
+            ->setType('remote_share')
484
+            ->setAffectedUser($this->getCorrectUid($share))
485
+            ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]])
486
+            ->setObject('files', $fileId, $file)
487
+            ->setLink($link);
488
+        $this->activityManager->publish($event);
489
+
490
+    }
491
+
492
+    /**
493
+     * received the notification that the owner unshared a file from you
494
+     *
495
+     * @param string $id
496
+     * @param array $notification
497
+     * @return array
498
+     * @throws AuthenticationFailedException
499
+     * @throws BadRequestException
500
+     */
501
+    private function undoReshare($id, array $notification) {
502
+        if (!isset($notification['sharedSecret'])) {
503
+            throw new BadRequestException(['sharedSecret']);
504
+        }
505
+        $token = $notification['sharedSecret'];
506
+
507
+        $share = $this->federatedShareProvider->getShareById($id);
508
+
509
+        $this->verifyShare($share, $token);
510
+        $this->federatedShareProvider->removeShareFromTable($share);
511
+        return [];
512
+    }
513
+
514
+    /**
515
+     * unshare file from self
516
+     *
517
+     * @param string $id
518
+     * @param array $notification
519
+     * @return array
520
+     * @throws ActionNotSupportedException
521
+     * @throws BadRequestException
522
+     */
523
+    private function unshare($id, array $notification) {
524
+
525
+        if (!$this->isS2SEnabled(true)) {
526
+            throw new ActionNotSupportedException("incoming shares disabled!");
527
+        }
528
+
529
+        if (!isset($notification['sharedSecret'])) {
530
+            throw new BadRequestException(['sharedSecret']);
531
+        }
532
+        $token = $notification['sharedSecret'];
533
+
534
+        $qb = $this->connection->getQueryBuilder();
535
+        $qb->select('*')
536
+            ->from('share_external')
537
+            ->where(
538
+                $qb->expr()->andX(
539
+                    $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)),
540
+                    $qb->expr()->eq('share_token', $qb->createNamedParameter($token))
541
+                )
542
+            );
543
+
544
+        $result = $qb->execute();
545
+        $share = $result->fetch();
546
+        $result->closeCursor();
547
+
548
+        if ($token && $id && !empty($share)) {
549
+
550
+            $remote = $this->cleanupRemote($share['remote']);
551
+
552
+            $owner = $this->cloudIdManager->getCloudId($share['owner'], $remote);
553
+            $mountpoint = $share['mountpoint'];
554
+            $user = $share['user'];
555
+
556
+            $qb = $this->connection->getQueryBuilder();
557
+            $qb->delete('share_external')
558
+                ->where(
559
+                    $qb->expr()->andX(
560
+                        $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)),
561
+                        $qb->expr()->eq('share_token', $qb->createNamedParameter($token))
562
+                    )
563
+                );
564
+
565
+            $qb->execute();
566
+
567
+            if ($share['accepted']) {
568
+                $path = trim($mountpoint, '/');
569
+            } else {
570
+                $path = trim($share['name'], '/');
571
+            }
572
+
573
+            $notification = $this->notificationManager->createNotification();
574
+            $notification->setApp('files_sharing')
575
+                ->setUser($share['user'])
576
+                ->setObject('remote_share', (int)$share['id']);
577
+            $this->notificationManager->markProcessed($notification);
578
+
579
+            $event = $this->activityManager->generateEvent();
580
+            $event->setApp('files_sharing')
581
+                ->setType('remote_share')
582
+                ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path])
583
+                ->setAffectedUser($user)
584
+                ->setObject('remote_share', (int)$share['id'], $path);
585
+            \OC::$server->getActivityManager()->publish($event);
586
+        }
587
+
588
+        return [];
589
+    }
590
+
591
+    private function cleanupRemote($remote) {
592
+        $remote = substr($remote, strpos($remote, '://') + 3);
593
+
594
+        return rtrim($remote, '/');
595
+    }
596
+
597
+    /**
598
+     * recipient of a share request to re-share the file with another user
599
+     *
600
+     * @param string $id
601
+     * @param array $notification
602
+     * @return array
603
+     * @throws AuthenticationFailedException
604
+     * @throws BadRequestException
605
+     * @throws ProviderCouldNotAddShareException
606
+     * @throws ShareNotFound
607
+     */
608
+    protected function reshareRequested($id, array $notification) {
609
+
610
+        if (!isset($notification['sharedSecret'])) {
611
+            throw new BadRequestException(['sharedSecret']);
612
+        }
613
+        $token = $notification['sharedSecret'];
614
+
615
+        if (!isset($notification['shareWith'])) {
616
+            throw new BadRequestException(['shareWith']);
617
+        }
618
+        $shareWith = $notification['shareWith'];
619
+
620
+        if (!isset($notification['senderId'])) {
621
+            throw new BadRequestException(['senderId']);
622
+        }
623
+        $senderId = $notification['senderId'];
624
+
625
+        $share = $this->federatedShareProvider->getShareById($id);
626
+        // don't allow to share a file back to the owner
627
+        try {
628
+            list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
629
+            $owner = $share->getShareOwner();
630
+            $currentServer = $this->addressHandler->generateRemoteURL();
631
+            if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) {
632
+                throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id);
633
+            }
634
+        } catch (\Exception $e) {
635
+            throw new ProviderCouldNotAddShareException($e->getMessage());
636
+        }
637
+
638
+        $this->verifyShare($share, $token);
639
+
640
+        // check if re-sharing is allowed
641
+        if ($share->getPermissions() & Constants::PERMISSION_SHARE) {
642
+            // the recipient of the initial share is now the initiator for the re-share
643
+            $share->setSharedBy($share->getSharedWith());
644
+            $share->setSharedWith($shareWith);
645
+            $result = $this->federatedShareProvider->create($share);
646
+            $this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId);
647
+            return ['token' => $result->getToken(), 'providerId' => $result->getId()];
648
+        } else {
649
+            throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id);
650
+        }
651
+
652
+    }
653
+
654
+    /**
655
+     * update permission of a re-share so that the share dialog shows the right
656
+     * permission if the owner or the sender changes the permission
657
+     *
658
+     * @param string $id
659
+     * @param array $notification
660
+     * @return array
661
+     * @throws AuthenticationFailedException
662
+     * @throws BadRequestException
663
+     */
664
+    protected function updateResharePermissions($id, array $notification) {
665
+
666
+        if (!isset($notification['sharedSecret'])) {
667
+            throw new BadRequestException(['sharedSecret']);
668
+        }
669
+        $token = $notification['sharedSecret'];
670
+
671
+        if (!isset($notification['permission'])) {
672
+            throw new BadRequestException(['permission']);
673
+        }
674
+        $ocmPermissions = $notification['permission'];
675
+
676
+        $share = $this->federatedShareProvider->getShareById($id);
677
+
678
+        $ncPermission = $this->ocmPermissions2ncPermissions($ocmPermissions);
679
+
680
+        $this->verifyShare($share, $token);
681
+        $this->updatePermissionsInDatabase($share, $ncPermission);
682
+
683
+        return [];
684
+    }
685
+
686
+    /**
687
+     * translate OCM Permissions to Nextcloud permissions
688
+     *
689
+     * @param array $ocmPermissions
690
+     * @return int
691
+     * @throws BadRequestException
692
+     */
693
+    protected function ocmPermissions2ncPermissions(array $ocmPermissions) {
694
+        $ncPermissions = 0;
695
+        foreach($ocmPermissions as $permission) {
696
+            switch (strtolower($permission)) {
697
+                case 'read':
698
+                    $ncPermissions += Constants::PERMISSION_READ;
699
+                    break;
700
+                case 'write':
701
+                    $ncPermissions += Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE;
702
+                    break;
703
+                case 'share':
704
+                    $ncPermissions += Constants::PERMISSION_SHARE;
705
+                    break;
706
+                default:
707
+                    throw new BadRequestException(['permission']);
708
+            }
709
+
710
+            error_log("new permissions: " . $ncPermissions);
711
+        }
712
+
713
+        return $ncPermissions;
714
+    }
715
+
716
+    /**
717
+     * update permissions in database
718
+     *
719
+     * @param IShare $share
720
+     * @param int $permissions
721
+     */
722
+    protected function updatePermissionsInDatabase(IShare $share, $permissions) {
723
+        $query = $this->connection->getQueryBuilder();
724
+        $query->update('share')
725
+            ->where($query->expr()->eq('id', $query->createNamedParameter($share->getId())))
726
+            ->set('permissions', $query->createNamedParameter($permissions))
727
+            ->execute();
728
+    }
729
+
730
+
731
+    /**
732
+     * get file
733
+     *
734
+     * @param string $user
735
+     * @param int $fileSource
736
+     * @return array with internal path of the file and a absolute link to it
737
+     */
738
+    private function getFile($user, $fileSource) {
739
+        \OC_Util::setupFS($user);
740
+
741
+        try {
742
+            $file = Filesystem::getPath($fileSource);
743
+        } catch (NotFoundException $e) {
744
+            $file = null;
745
+        }
746
+        $args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file);
747
+        $link = Util::linkToAbsolute('files', 'index.php', $args);
748
+
749
+        return [$file, $link];
750
+
751
+    }
752
+
753
+    /**
754
+     * check if we are the initiator or the owner of a re-share and return the correct UID
755
+     *
756
+     * @param IShare $share
757
+     * @return string
758
+     */
759
+    protected function getCorrectUid(IShare $share) {
760
+        if ($this->userManager->userExists($share->getShareOwner())) {
761
+            return $share->getShareOwner();
762
+        }
763
+
764
+        return $share->getSharedBy();
765
+    }
766
+
767
+
768
+
769
+    /**
770
+     * check if we got the right share
771
+     *
772
+     * @param IShare $share
773
+     * @param string $token
774
+     * @return bool
775
+     * @throws AuthenticationFailedException
776
+     */
777
+    protected function verifyShare(IShare $share, $token) {
778
+        if (
779
+            $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE &&
780
+            $share->getToken() === $token
781
+        ) {
782
+            return true;
783
+        }
784
+
785
+        throw new AuthenticationFailedException();
786
+    }
787
+
788
+
789
+
790
+    /**
791
+     * check if server-to-server sharing is enabled
792
+     *
793
+     * @param bool $incoming
794
+     * @return bool
795
+     */
796
+    private function isS2SEnabled($incoming = false) {
797
+
798
+        $result = $this->appManager->isEnabledForUser('files_sharing');
799
+
800
+        if ($incoming) {
801
+            $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();
802
+        } else {
803
+            $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
804
+        }
805
+
806
+        return $result;
807
+    }
808
+
809
+
810
+    /**
811
+     * get the supported share types, e.g. "user", "group", etc.
812
+     *
813
+     * @return array
814
+     */
815
+    public function getSupportedShareTypes() {
816
+        return ['user'];
817
+    }
818 818
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		// for backward compatibility make sure that the remote url stored in the
173 173
 		// database ends with a trailing slash
174 174
 		if (substr($remote, -1) !== '/') {
175
-			$remote = $remote . '/';
175
+			$remote = $remote.'/';
176 176
 		}
177 177
 
178 178
 		$token = $share->getShareSecret();
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
 			}
200 200
 
201 201
 			// FIXME this should be a method in the user management instead
202
-			$this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']);
202
+			$this->logger->debug('shareWith before, '.$shareWith, ['app' => 'files_sharing']);
203 203
 			Util::emitHook(
204 204
 				'\OCA\Files_Sharing\API\Server2Server',
205 205
 				'preLoginNameUsedAsUserName',
206 206
 				array('uid' => &$shareWith)
207 207
 			);
208
-			$this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']);
208
+			$this->logger->debug('shareWith after, '.$shareWith, ['app' => 'files_sharing']);
209 209
 
210 210
 			if (!$this->userManager->userExists($shareWith)) {
211
-				throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST);
211
+				throw new ProviderCouldNotAddShareException('User does not exists', '', Http::STATUS_BAD_REQUEST);
212 212
 			}
213 213
 
214 214
 			\OC_Util::setupFS($shareWith);
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 			);
227 227
 
228 228
 			try {
229
-				$externalManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId);
229
+				$externalManager->addShare($remote, $token, '', $name, $owner, $shareType, false, $shareWith, $remoteId);
230 230
 				$shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external');
231 231
 
232 232
 				$event = $this->activityManager->generateEvent();
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 					->setType('remote_share')
235 235
 					->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')])
236 236
 					->setAffectedUser($shareWith)
237
-					->setObject('remote_share', (int)$shareId, $name);
237
+					->setObject('remote_share', (int) $shareId, $name);
238 238
 				\OC::$server->getActivityManager()->publish($event);
239 239
 
240 240
 				if ($shareType === Share::SHARE_TYPE_USER) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 					'level' => ILogger::ERROR,
253 253
 					'app' => 'files_sharing'
254 254
 				]);
255
-				throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR);
255
+				throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from '.$remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR);
256 256
 			}
257 257
 		}
258 258
 
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
 
330 330
 		$declineAction = $notification->createAction();
331 331
 		$declineAction->setLabel('decline')
332
-			->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE');
332
+			->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'DELETE');
333 333
 		$notification->addAction($declineAction);
334 334
 
335 335
 		$acceptAction = $notification->createAction();
336 336
 		$acceptAction->setLabel('accept')
337
-			->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST');
337
+			->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'POST');
338 338
 		$notification->addAction($acceptAction);
339 339
 
340 340
 		$this->notificationManager->notify($notification);
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	 */
395 395
 	protected function executeAcceptShare(IShare $share) {
396 396
 		try {
397
-			$fileId = (int)$share->getNode()->getId();
397
+			$fileId = (int) $share->getNode()->getId();
398 398
 			list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
399 399
 		} catch (\Exception $e) {
400 400
 			throw new ShareNotFound();
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 		$this->federatedShareProvider->removeShareFromTable($share);
473 473
 
474 474
 		try {
475
-			$fileId = (int)$share->getNode()->getId();
475
+			$fileId = (int) $share->getNode()->getId();
476 476
 			list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
477 477
 		} catch (\Exception $e) {
478 478
 			throw new ShareNotFound();
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 			$notification = $this->notificationManager->createNotification();
574 574
 			$notification->setApp('files_sharing')
575 575
 				->setUser($share['user'])
576
-				->setObject('remote_share', (int)$share['id']);
576
+				->setObject('remote_share', (int) $share['id']);
577 577
 			$this->notificationManager->markProcessed($notification);
578 578
 
579 579
 			$event = $this->activityManager->generateEvent();
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 				->setType('remote_share')
582 582
 				->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path])
583 583
 				->setAffectedUser($user)
584
-				->setObject('remote_share', (int)$share['id'], $path);
584
+				->setObject('remote_share', (int) $share['id'], $path);
585 585
 			\OC::$server->getActivityManager()->publish($event);
586 586
 		}
587 587
 
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			$owner = $share->getShareOwner();
630 630
 			$currentServer = $this->addressHandler->generateRemoteURL();
631 631
 			if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) {
632
-				throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id);
632
+				throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: '.$id);
633 633
 			}
634 634
 		} catch (\Exception $e) {
635 635
 			throw new ProviderCouldNotAddShareException($e->getMessage());
@@ -643,10 +643,10 @@  discard block
 block discarded – undo
643 643
 			$share->setSharedBy($share->getSharedWith());
644 644
 			$share->setSharedWith($shareWith);
645 645
 			$result = $this->federatedShareProvider->create($share);
646
-			$this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId);
646
+			$this->federatedShareProvider->storeRemoteId((int) $result->getId(), $senderId);
647 647
 			return ['token' => $result->getToken(), 'providerId' => $result->getId()];
648 648
 		} else {
649
-			throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id);
649
+			throw new ProviderCouldNotAddShareException('resharing not allowed for share: '.$id);
650 650
 		}
651 651
 
652 652
 	}
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	 */
693 693
 	protected function ocmPermissions2ncPermissions(array $ocmPermissions) {
694 694
 		$ncPermissions = 0;
695
-		foreach($ocmPermissions as $permission) {
695
+		foreach ($ocmPermissions as $permission) {
696 696
 			switch (strtolower($permission)) {
697 697
 				case 'read':
698 698
 					$ncPermissions += Constants::PERMISSION_READ;
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 					throw new BadRequestException(['permission']);
708 708
 			}
709 709
 
710
-			error_log("new permissions: " . $ncPermissions);
710
+			error_log("new permissions: ".$ncPermissions);
711 711
 		}
712 712
 
713 713
 		return $ncPermissions;
Please login to merge, or discard this patch.
lib/private/Share/Constants.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -29,27 +29,27 @@
 block discarded – undo
29 29
 
30 30
 class Constants {
31 31
 
32
-	const SHARE_TYPE_USER = 0;
33
-	const SHARE_TYPE_GROUP = 1;
34
-	const SHARE_TYPE_LINK = 3;
35
-	const SHARE_TYPE_EMAIL = 4;
36
-	const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it
37
-	const SHARE_TYPE_REMOTE = 6;
38
-	const SHARE_TYPE_CIRCLE = 7;
39
-	const SHARE_TYPE_GUEST = 8;
40
-	const SHARE_TYPE_REMOTE_GROUP = 9;
32
+    const SHARE_TYPE_USER = 0;
33
+    const SHARE_TYPE_GROUP = 1;
34
+    const SHARE_TYPE_LINK = 3;
35
+    const SHARE_TYPE_EMAIL = 4;
36
+    const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it
37
+    const SHARE_TYPE_REMOTE = 6;
38
+    const SHARE_TYPE_CIRCLE = 7;
39
+    const SHARE_TYPE_GUEST = 8;
40
+    const SHARE_TYPE_REMOTE_GROUP = 9;
41 41
 
42
-	const FORMAT_NONE = -1;
43
-	const FORMAT_STATUSES = -2;
44
-	const FORMAT_SOURCES = -3;  // ToDo Check if it is still in use otherwise remove it
42
+    const FORMAT_NONE = -1;
43
+    const FORMAT_STATUSES = -2;
44
+    const FORMAT_SOURCES = -3;  // ToDo Check if it is still in use otherwise remove it
45 45
 
46
-	const RESPONSE_FORMAT = 'json'; // default resonse format for ocs calls
46
+    const RESPONSE_FORMAT = 'json'; // default resonse format for ocs calls
47 47
 
48
-	const TOKEN_LENGTH = 15; // old (oc7) length is 32, keep token length in db at least that for compatibility
48
+    const TOKEN_LENGTH = 15; // old (oc7) length is 32, keep token length in db at least that for compatibility
49 49
 
50
-	protected static $shareTypeUserAndGroups = -1;
51
-	protected static $shareTypeGroupUserUnique = 2;
52
-	protected static $backends = array();
53
-	protected static $backendTypes = array();
54
-	protected static $isResharingAllowed;
50
+    protected static $shareTypeUserAndGroups = -1;
51
+    protected static $shareTypeGroupUserUnique = 2;
52
+    protected static $backends = array();
53
+    protected static $backendTypes = array();
54
+    protected static $isResharingAllowed;
55 55
 }
Please login to merge, or discard this patch.
apps/cloud_federation_api/lib/Config.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -35,26 +35,26 @@
 block discarded – undo
35 35
  */
36 36
 class Config {
37 37
 
38
-	/** @var ICloudFederationProviderManager */
39
-	private $cloudFederationProviderManager;
40
-
41
-	public function __construct(ICloudFederationProviderManager $cloudFederationProviderManager) {
42
-		$this->cloudFederationProviderManager = $cloudFederationProviderManager;
43
-	}
44
-
45
-	/**
46
-	 * get a list of supported share types
47
-	 *
48
-	 * @param string $resourceType
49
-	 * @return array
50
-	 */
51
-	public function getSupportedShareTypes($resourceType) {
52
-		try {
53
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType);
54
-			return $provider->getSupportedShareTypes();
55
-		} catch (\Exception $e) {
56
-			return [];
57
-		}
58
-	}
38
+    /** @var ICloudFederationProviderManager */
39
+    private $cloudFederationProviderManager;
40
+
41
+    public function __construct(ICloudFederationProviderManager $cloudFederationProviderManager) {
42
+        $this->cloudFederationProviderManager = $cloudFederationProviderManager;
43
+    }
44
+
45
+    /**
46
+     * get a list of supported share types
47
+     *
48
+     * @param string $resourceType
49
+     * @return array
50
+     */
51
+    public function getSupportedShareTypes($resourceType) {
52
+        try {
53
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType);
54
+            return $provider->getSupportedShareTypes();
55
+        } catch (\Exception $e) {
56
+            return [];
57
+        }
58
+    }
59 59
 
60 60
 }
Please login to merge, or discard this patch.