1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Viktar Dubiniuk <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
6
|
|
|
* @license AGPL-3.0 |
7
|
|
|
* |
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
10
|
|
|
* as published by the Free Software Foundation. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace OCA\FederatedFileSharing\Controller; |
23
|
|
|
|
24
|
|
|
use OCP\AppFramework\Controller; |
25
|
|
|
use OCP\IRequest; |
26
|
|
|
use OCP\IURLGenerator; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Class OcmController |
30
|
|
|
* |
31
|
|
|
* @package OCA\FederatedFileSharing\Controller |
32
|
|
|
*/ |
33
|
|
|
class OcmController extends Controller { |
34
|
|
|
const API_VERSION = '1.0-proposal1'; |
35
|
|
|
|
36
|
|
|
protected $urlGenerator; |
37
|
|
|
|
38
|
|
|
public function __construct($appName, |
39
|
|
|
IRequest $request, |
40
|
|
|
IURLGenerator $urlGenerator) { |
41
|
|
|
parent::__construct($appName, $request); |
42
|
|
|
|
43
|
|
|
$this->urlGenerator = $urlGenerator; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @NoCSRFRequired |
48
|
|
|
* @PublicPage |
49
|
|
|
* |
50
|
|
|
* EndPoint discovery |
51
|
|
|
* Responds to /ocm-provider/ requests |
52
|
|
|
* |
53
|
|
|
* @return array |
54
|
|
|
*/ |
55
|
|
|
public function discovery() { |
56
|
|
|
return [ |
57
|
|
|
'enabled' => true, |
58
|
|
|
'apiVersion' => self::API_VERSION, |
59
|
|
|
'endPoint' => $this->urlGenerator->linkToRouteAbsolute( |
60
|
|
|
"{$this->appName}.ocm.index" |
61
|
|
|
), |
62
|
|
|
'shareTypes' => [ |
63
|
|
|
'name' => 'file', |
64
|
|
|
'protocols' => $this->getProtocols() |
65
|
|
|
] |
66
|
|
|
]; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @NoCSRFRequired |
71
|
|
|
* @PublicPage |
72
|
|
|
* |
73
|
|
|
* |
74
|
|
|
* |
75
|
|
|
* @param string $shareWith identifier of the user or group to share the resource with |
76
|
|
|
* @param string $name name of the shared resource |
77
|
|
|
* @param string $description share description (optional) |
78
|
|
|
* @param string $providerId Identifier of the resource at the provider side |
79
|
|
|
* @param string $owner identifier of the user that owns the resource |
80
|
|
|
* @param string $ownerDisplayName display name of the owner |
81
|
|
|
* @param string $sender Provider specific identifier of the user that wants to share the resource |
82
|
|
|
* @param string $senderDisplayName Display name of the user that wants to share the resource |
83
|
|
|
* @param string $shareType Share type (user or group share) |
84
|
|
|
* @param string $resourceType only 'file' is supported atm |
85
|
|
|
* @param array $protocol |
86
|
|
|
* [ |
87
|
|
|
* 'name' => (string) protocol name. Only 'webdav' is supported atm, |
88
|
|
|
* 'options' => [ |
89
|
|
|
* protocol specific options |
90
|
|
|
* only `webdav` options are supported atm |
91
|
|
|
* e.g. `uri`, `access_token`, `password`, `permissions` etc. |
92
|
|
|
* |
93
|
|
|
* For backward compatibility the webdav protocol will use |
94
|
|
|
* the 'sharedSecret" as username and password |
95
|
|
|
* ] |
96
|
|
|
* |
97
|
|
|
*/ |
98
|
|
|
public function createShare($shareWith, |
|
|
|
|
99
|
|
|
$name, |
|
|
|
|
100
|
|
|
$description, |
|
|
|
|
101
|
|
|
$providerId, |
|
|
|
|
102
|
|
|
$owner, |
|
|
|
|
103
|
|
|
$ownerDisplayName, |
|
|
|
|
104
|
|
|
$sender, |
|
|
|
|
105
|
|
|
$senderDisplayName, |
|
|
|
|
106
|
|
|
$shareType, |
|
|
|
|
107
|
|
|
$resourceType, |
|
|
|
|
108
|
|
|
$protocol |
|
|
|
|
109
|
|
|
|
110
|
|
|
) { |
111
|
|
|
// TODO: implement |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param string $notificationType notification type (SHARE_REMOVED, etc) |
116
|
|
|
* @param string $resourceType only 'file' is supported atm |
117
|
|
|
* @param string $providerId Identifier of the resource at the provider side |
118
|
|
|
* @param array $notification |
119
|
|
|
* [ |
120
|
|
|
* optional additional parameters, depending on the notification and the resource type |
121
|
|
|
* |
122
|
|
|
* ] |
123
|
|
|
*/ |
124
|
|
|
public function processNotification($notificationType, |
|
|
|
|
125
|
|
|
$resourceType, |
|
|
|
|
126
|
|
|
$providerId, |
|
|
|
|
127
|
|
|
$notification |
|
|
|
|
128
|
|
|
) { |
129
|
|
|
// TODO: implement |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
protected function getProtocols() { |
133
|
|
|
return [ |
134
|
|
|
'webdav' => '/public.php/webdav/' |
135
|
|
|
]; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
} |
139
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.