@@ -23,25 +23,25 @@ |
||
23 | 23 | |
24 | 24 | interface ICloudFederationNotification { |
25 | 25 | |
26 | - /** |
|
27 | - * add a message to the notification |
|
28 | - * |
|
29 | - * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
30 | - * @param string $resourceType (e.g. file, calendar, contact,...) |
|
31 | - * @param $providerId id of the share |
|
32 | - * @param array $notification , payload of the notification |
|
33 | - * |
|
34 | - * @return |
|
35 | - * @since 14.0.0 |
|
36 | - */ |
|
37 | - public function setMessage($notificationType, $resourceType, $providerId, array $notification); |
|
26 | + /** |
|
27 | + * add a message to the notification |
|
28 | + * |
|
29 | + * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
30 | + * @param string $resourceType (e.g. file, calendar, contact,...) |
|
31 | + * @param $providerId id of the share |
|
32 | + * @param array $notification , payload of the notification |
|
33 | + * |
|
34 | + * @return |
|
35 | + * @since 14.0.0 |
|
36 | + */ |
|
37 | + public function setMessage($notificationType, $resourceType, $providerId, array $notification); |
|
38 | 38 | |
39 | - /** |
|
40 | - * get message, ready to send out |
|
41 | - * |
|
42 | - * @return string |
|
43 | - * |
|
44 | - * @since 14.0.0 |
|
45 | - */ |
|
46 | - public function getMessage(); |
|
39 | + /** |
|
40 | + * get message, ready to send out |
|
41 | + * |
|
42 | + * @return string |
|
43 | + * |
|
44 | + * @since 14.0.0 |
|
45 | + */ |
|
46 | + public function getMessage(); |
|
47 | 47 | } |
@@ -25,328 +25,328 @@ |
||
25 | 25 | |
26 | 26 | class CloudFederationShare implements ICloudFederationShare { |
27 | 27 | |
28 | - private $share = [ |
|
29 | - 'shareWith' => '', |
|
30 | - 'shareType' => '', |
|
31 | - 'name' => '', |
|
32 | - 'resourceType' => '', |
|
33 | - 'description' => '', |
|
34 | - 'providerId' => '', |
|
35 | - 'owner' => '', |
|
36 | - 'ownerDisplayName' => '', |
|
37 | - 'sharedBy' => '', |
|
38 | - 'sharedByDisplayName' => '', |
|
39 | - 'protocol' => [] |
|
40 | - ]; |
|
28 | + private $share = [ |
|
29 | + 'shareWith' => '', |
|
30 | + 'shareType' => '', |
|
31 | + 'name' => '', |
|
32 | + 'resourceType' => '', |
|
33 | + 'description' => '', |
|
34 | + 'providerId' => '', |
|
35 | + 'owner' => '', |
|
36 | + 'ownerDisplayName' => '', |
|
37 | + 'sharedBy' => '', |
|
38 | + 'sharedByDisplayName' => '', |
|
39 | + 'protocol' => [] |
|
40 | + ]; |
|
41 | 41 | |
42 | - /** |
|
43 | - * get a CloudFederationShare Object to prepare a share you want to send |
|
44 | - * |
|
45 | - * @param string $shareWith |
|
46 | - * @param string $name resource name (e.g. document.odt) |
|
47 | - * @param string $description share description (optional) |
|
48 | - * @param string $providerId resource UID on the provider side |
|
49 | - * @param string $owner provider specific UID of the user who owns the resource |
|
50 | - * @param string $ownerDisplayName display name of the user who shared the item |
|
51 | - * @param string $sharedBy provider specific UID of the user who shared the resource |
|
52 | - * @param string $sharedByDisplayName display name of the user who shared the resource |
|
53 | - * @param string $shareType ('group' or 'user' share) |
|
54 | - * @param string $resourceType ('file', 'calendar',...) |
|
55 | - * @param string $sharedSecret |
|
56 | - */ |
|
57 | - public function __construct($shareWith = '', |
|
58 | - $name = '', |
|
59 | - $description = '', |
|
60 | - $providerId = '', |
|
61 | - $owner = '', |
|
62 | - $ownerDisplayName = '', |
|
63 | - $sharedBy = '', |
|
64 | - $sharedByDisplayName = '', |
|
65 | - $shareType = '', |
|
66 | - $resourceType = '', |
|
67 | - $sharedSecret = '' |
|
68 | - ) { |
|
69 | - $this->setShareWith($shareWith); |
|
70 | - $this->setResourceName($name); |
|
71 | - $this->setDescription($description); |
|
72 | - $this->setProviderId($providerId); |
|
73 | - $this->setOwner($owner); |
|
74 | - $this->setOwnerDisplayName($ownerDisplayName); |
|
75 | - $this->setSharedBy($sharedBy); |
|
76 | - $this->setSharedByDisplayName($sharedByDisplayName); |
|
77 | - $this->setProtocol([ |
|
78 | - 'name' => 'webdav', |
|
79 | - 'options' => [ |
|
80 | - 'sharedSecret' => $sharedSecret, |
|
81 | - 'permissions' => '{http://open-collaboration-services.org/ns}share-permissions' |
|
82 | - ] |
|
83 | - ]); |
|
84 | - $this->setShareType($shareType); |
|
85 | - $this->setResourceType($resourceType); |
|
42 | + /** |
|
43 | + * get a CloudFederationShare Object to prepare a share you want to send |
|
44 | + * |
|
45 | + * @param string $shareWith |
|
46 | + * @param string $name resource name (e.g. document.odt) |
|
47 | + * @param string $description share description (optional) |
|
48 | + * @param string $providerId resource UID on the provider side |
|
49 | + * @param string $owner provider specific UID of the user who owns the resource |
|
50 | + * @param string $ownerDisplayName display name of the user who shared the item |
|
51 | + * @param string $sharedBy provider specific UID of the user who shared the resource |
|
52 | + * @param string $sharedByDisplayName display name of the user who shared the resource |
|
53 | + * @param string $shareType ('group' or 'user' share) |
|
54 | + * @param string $resourceType ('file', 'calendar',...) |
|
55 | + * @param string $sharedSecret |
|
56 | + */ |
|
57 | + public function __construct($shareWith = '', |
|
58 | + $name = '', |
|
59 | + $description = '', |
|
60 | + $providerId = '', |
|
61 | + $owner = '', |
|
62 | + $ownerDisplayName = '', |
|
63 | + $sharedBy = '', |
|
64 | + $sharedByDisplayName = '', |
|
65 | + $shareType = '', |
|
66 | + $resourceType = '', |
|
67 | + $sharedSecret = '' |
|
68 | + ) { |
|
69 | + $this->setShareWith($shareWith); |
|
70 | + $this->setResourceName($name); |
|
71 | + $this->setDescription($description); |
|
72 | + $this->setProviderId($providerId); |
|
73 | + $this->setOwner($owner); |
|
74 | + $this->setOwnerDisplayName($ownerDisplayName); |
|
75 | + $this->setSharedBy($sharedBy); |
|
76 | + $this->setSharedByDisplayName($sharedByDisplayName); |
|
77 | + $this->setProtocol([ |
|
78 | + 'name' => 'webdav', |
|
79 | + 'options' => [ |
|
80 | + 'sharedSecret' => $sharedSecret, |
|
81 | + 'permissions' => '{http://open-collaboration-services.org/ns}share-permissions' |
|
82 | + ] |
|
83 | + ]); |
|
84 | + $this->setShareType($shareType); |
|
85 | + $this->setResourceType($resourceType); |
|
86 | 86 | |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * set uid of the recipient |
|
91 | - * |
|
92 | - * @param string $user |
|
93 | - * |
|
94 | - * @since 14.0.0 |
|
95 | - */ |
|
96 | - public function setShareWith($user) { |
|
97 | - $this->share['shareWith'] = $user; |
|
98 | - } |
|
89 | + /** |
|
90 | + * set uid of the recipient |
|
91 | + * |
|
92 | + * @param string $user |
|
93 | + * |
|
94 | + * @since 14.0.0 |
|
95 | + */ |
|
96 | + public function setShareWith($user) { |
|
97 | + $this->share['shareWith'] = $user; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * set resource name (e.g. document.odt) |
|
102 | - * |
|
103 | - * @param string $name |
|
104 | - * |
|
105 | - * @since 14.0.0 |
|
106 | - */ |
|
107 | - public function setResourceName($name) { |
|
108 | - $this->share['name'] = $name; |
|
109 | - } |
|
100 | + /** |
|
101 | + * set resource name (e.g. document.odt) |
|
102 | + * |
|
103 | + * @param string $name |
|
104 | + * |
|
105 | + * @since 14.0.0 |
|
106 | + */ |
|
107 | + public function setResourceName($name) { |
|
108 | + $this->share['name'] = $name; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * set resource type (e.g. file, calendar, contact,...) |
|
113 | - * |
|
114 | - * @param string $resourceType |
|
115 | - * |
|
116 | - * @since 14.0.0 |
|
117 | - */ |
|
118 | - public function setResourceType($resourceType) { |
|
119 | - $this->share['resourceType'] = $resourceType; |
|
120 | - } |
|
111 | + /** |
|
112 | + * set resource type (e.g. file, calendar, contact,...) |
|
113 | + * |
|
114 | + * @param string $resourceType |
|
115 | + * |
|
116 | + * @since 14.0.0 |
|
117 | + */ |
|
118 | + public function setResourceType($resourceType) { |
|
119 | + $this->share['resourceType'] = $resourceType; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * set resource description (optional) |
|
124 | - * |
|
125 | - * @param string $description |
|
126 | - * |
|
127 | - * @since 14.0.0 |
|
128 | - */ |
|
129 | - public function setDescription($description) { |
|
130 | - $this->share['description'] = $description; |
|
131 | - } |
|
122 | + /** |
|
123 | + * set resource description (optional) |
|
124 | + * |
|
125 | + * @param string $description |
|
126 | + * |
|
127 | + * @since 14.0.0 |
|
128 | + */ |
|
129 | + public function setDescription($description) { |
|
130 | + $this->share['description'] = $description; |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * set provider ID (e.g. file ID) |
|
135 | - * |
|
136 | - * @param string $providerId |
|
137 | - * |
|
138 | - * @since 14.0.0 |
|
139 | - */ |
|
140 | - public function setProviderId($providerId) { |
|
141 | - $this->share['providerId'] = $providerId; |
|
142 | - } |
|
133 | + /** |
|
134 | + * set provider ID (e.g. file ID) |
|
135 | + * |
|
136 | + * @param string $providerId |
|
137 | + * |
|
138 | + * @since 14.0.0 |
|
139 | + */ |
|
140 | + public function setProviderId($providerId) { |
|
141 | + $this->share['providerId'] = $providerId; |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * set owner UID |
|
146 | - * |
|
147 | - * @param string $owner |
|
148 | - * |
|
149 | - * @since 14.0.0 |
|
150 | - */ |
|
151 | - public function setOwner($owner) { |
|
152 | - $this->share['owner'] = $owner; |
|
153 | - } |
|
144 | + /** |
|
145 | + * set owner UID |
|
146 | + * |
|
147 | + * @param string $owner |
|
148 | + * |
|
149 | + * @since 14.0.0 |
|
150 | + */ |
|
151 | + public function setOwner($owner) { |
|
152 | + $this->share['owner'] = $owner; |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * set owner display name |
|
157 | - * |
|
158 | - * @param string $ownerDisplayName |
|
159 | - * |
|
160 | - * @since 14.0.0 |
|
161 | - */ |
|
162 | - public function setOwnerDisplayName($ownerDisplayName) { |
|
163 | - $this->share['ownerDisplayName'] = $ownerDisplayName; |
|
164 | - } |
|
155 | + /** |
|
156 | + * set owner display name |
|
157 | + * |
|
158 | + * @param string $ownerDisplayName |
|
159 | + * |
|
160 | + * @since 14.0.0 |
|
161 | + */ |
|
162 | + public function setOwnerDisplayName($ownerDisplayName) { |
|
163 | + $this->share['ownerDisplayName'] = $ownerDisplayName; |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * set UID of the user who sends the share |
|
168 | - * |
|
169 | - * @param string $sharedBy |
|
170 | - * |
|
171 | - * @since 14.0.0 |
|
172 | - */ |
|
173 | - public function setSharedBy($sharedBy) { |
|
174 | - $this->share['sharedBy'] = $sharedBy; |
|
175 | - } |
|
166 | + /** |
|
167 | + * set UID of the user who sends the share |
|
168 | + * |
|
169 | + * @param string $sharedBy |
|
170 | + * |
|
171 | + * @since 14.0.0 |
|
172 | + */ |
|
173 | + public function setSharedBy($sharedBy) { |
|
174 | + $this->share['sharedBy'] = $sharedBy; |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * set display name of the user who sends the share |
|
179 | - * |
|
180 | - * @param $sharedByDisplayName |
|
181 | - * |
|
182 | - * @since 14.0.0 |
|
183 | - */ |
|
184 | - public function setSharedByDisplayName($sharedByDisplayName) { |
|
185 | - $this->share['sharedByDisplayName'] = $sharedByDisplayName; |
|
186 | - } |
|
177 | + /** |
|
178 | + * set display name of the user who sends the share |
|
179 | + * |
|
180 | + * @param $sharedByDisplayName |
|
181 | + * |
|
182 | + * @since 14.0.0 |
|
183 | + */ |
|
184 | + public function setSharedByDisplayName($sharedByDisplayName) { |
|
185 | + $this->share['sharedByDisplayName'] = $sharedByDisplayName; |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * set protocol specification |
|
190 | - * |
|
191 | - * @param array $protocol |
|
192 | - * |
|
193 | - * @since 14.0.0 |
|
194 | - */ |
|
195 | - public function setProtocol(array $protocol) { |
|
196 | - $this->share['protocol'] = $protocol; |
|
197 | - } |
|
188 | + /** |
|
189 | + * set protocol specification |
|
190 | + * |
|
191 | + * @param array $protocol |
|
192 | + * |
|
193 | + * @since 14.0.0 |
|
194 | + */ |
|
195 | + public function setProtocol(array $protocol) { |
|
196 | + $this->share['protocol'] = $protocol; |
|
197 | + } |
|
198 | 198 | |
199 | - /** |
|
200 | - * share type (group or user) |
|
201 | - * |
|
202 | - * @param string $shareType |
|
203 | - * |
|
204 | - * @since 14.0.0 |
|
205 | - */ |
|
206 | - public function setShareType($shareType) { |
|
207 | - $this->share['shareType'] = $shareType; |
|
208 | - } |
|
199 | + /** |
|
200 | + * share type (group or user) |
|
201 | + * |
|
202 | + * @param string $shareType |
|
203 | + * |
|
204 | + * @since 14.0.0 |
|
205 | + */ |
|
206 | + public function setShareType($shareType) { |
|
207 | + $this->share['shareType'] = $shareType; |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * get the whole share, ready to send out |
|
212 | - * |
|
213 | - * @return array |
|
214 | - * |
|
215 | - * @since 14.0.0 |
|
216 | - */ |
|
217 | - public function getShare() { |
|
218 | - return $this->share; |
|
219 | - } |
|
210 | + /** |
|
211 | + * get the whole share, ready to send out |
|
212 | + * |
|
213 | + * @return array |
|
214 | + * |
|
215 | + * @since 14.0.0 |
|
216 | + */ |
|
217 | + public function getShare() { |
|
218 | + return $this->share; |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * get uid of the recipient |
|
223 | - * |
|
224 | - * @return string |
|
225 | - * |
|
226 | - * @since 14.0.0 |
|
227 | - */ |
|
228 | - public function getShareWith() { |
|
229 | - return $this->share['shareWith']; |
|
230 | - } |
|
221 | + /** |
|
222 | + * get uid of the recipient |
|
223 | + * |
|
224 | + * @return string |
|
225 | + * |
|
226 | + * @since 14.0.0 |
|
227 | + */ |
|
228 | + public function getShareWith() { |
|
229 | + return $this->share['shareWith']; |
|
230 | + } |
|
231 | 231 | |
232 | - /** |
|
233 | - * get resource name (e.g. file, calendar, contact,...) |
|
234 | - * |
|
235 | - * @return string |
|
236 | - * |
|
237 | - * @since 14.0.0 |
|
238 | - */ |
|
239 | - public function getResourceName() { |
|
240 | - return $this->share['name']; |
|
241 | - } |
|
232 | + /** |
|
233 | + * get resource name (e.g. file, calendar, contact,...) |
|
234 | + * |
|
235 | + * @return string |
|
236 | + * |
|
237 | + * @since 14.0.0 |
|
238 | + */ |
|
239 | + public function getResourceName() { |
|
240 | + return $this->share['name']; |
|
241 | + } |
|
242 | 242 | |
243 | - /** |
|
244 | - * get resource type (e.g. file, calendar, contact,...) |
|
245 | - * |
|
246 | - * @return string |
|
247 | - * |
|
248 | - * @since 14.0.0 |
|
249 | - */ |
|
250 | - public function getResourceType() { |
|
251 | - return $this->share['resourceType']; |
|
252 | - } |
|
243 | + /** |
|
244 | + * get resource type (e.g. file, calendar, contact,...) |
|
245 | + * |
|
246 | + * @return string |
|
247 | + * |
|
248 | + * @since 14.0.0 |
|
249 | + */ |
|
250 | + public function getResourceType() { |
|
251 | + return $this->share['resourceType']; |
|
252 | + } |
|
253 | 253 | |
254 | - /** |
|
255 | - * get resource description (optional) |
|
256 | - * |
|
257 | - * @return string |
|
258 | - * |
|
259 | - * @since 14.0.0 |
|
260 | - */ |
|
261 | - public function getDescription() { |
|
262 | - return $this->share['description']; |
|
263 | - } |
|
254 | + /** |
|
255 | + * get resource description (optional) |
|
256 | + * |
|
257 | + * @return string |
|
258 | + * |
|
259 | + * @since 14.0.0 |
|
260 | + */ |
|
261 | + public function getDescription() { |
|
262 | + return $this->share['description']; |
|
263 | + } |
|
264 | 264 | |
265 | - /** |
|
266 | - * get provider ID (e.g. file ID) |
|
267 | - * |
|
268 | - * @return string |
|
269 | - * |
|
270 | - * @since 14.0.0 |
|
271 | - */ |
|
272 | - public function getProviderId() { |
|
273 | - return $this->share['providerId']; |
|
274 | - } |
|
265 | + /** |
|
266 | + * get provider ID (e.g. file ID) |
|
267 | + * |
|
268 | + * @return string |
|
269 | + * |
|
270 | + * @since 14.0.0 |
|
271 | + */ |
|
272 | + public function getProviderId() { |
|
273 | + return $this->share['providerId']; |
|
274 | + } |
|
275 | 275 | |
276 | - /** |
|
277 | - * get owner UID |
|
278 | - * |
|
279 | - * @return string |
|
280 | - * |
|
281 | - * @since 14.0.0 |
|
282 | - */ |
|
283 | - public function getOwner() { |
|
284 | - return $this->share['owner']; |
|
285 | - } |
|
276 | + /** |
|
277 | + * get owner UID |
|
278 | + * |
|
279 | + * @return string |
|
280 | + * |
|
281 | + * @since 14.0.0 |
|
282 | + */ |
|
283 | + public function getOwner() { |
|
284 | + return $this->share['owner']; |
|
285 | + } |
|
286 | 286 | |
287 | - /** |
|
288 | - * get owner display name |
|
289 | - * |
|
290 | - * @return string |
|
291 | - * |
|
292 | - * @since 14.0.0 |
|
293 | - */ |
|
294 | - public function getOwnerDisplayName() { |
|
295 | - return $this->share['ownerDisplayName']; |
|
296 | - } |
|
287 | + /** |
|
288 | + * get owner display name |
|
289 | + * |
|
290 | + * @return string |
|
291 | + * |
|
292 | + * @since 14.0.0 |
|
293 | + */ |
|
294 | + public function getOwnerDisplayName() { |
|
295 | + return $this->share['ownerDisplayName']; |
|
296 | + } |
|
297 | 297 | |
298 | - /** |
|
299 | - * get UID of the user who sends the share |
|
300 | - * |
|
301 | - * @return string |
|
302 | - * |
|
303 | - * @since 14.0.0 |
|
304 | - */ |
|
305 | - public function getSharedBy() { |
|
306 | - return $this->share['sharedBy']; |
|
307 | - } |
|
298 | + /** |
|
299 | + * get UID of the user who sends the share |
|
300 | + * |
|
301 | + * @return string |
|
302 | + * |
|
303 | + * @since 14.0.0 |
|
304 | + */ |
|
305 | + public function getSharedBy() { |
|
306 | + return $this->share['sharedBy']; |
|
307 | + } |
|
308 | 308 | |
309 | - /** |
|
310 | - * get display name of the user who sends the share |
|
311 | - * |
|
312 | - * @return string |
|
313 | - * |
|
314 | - * @since 14.0.0 |
|
315 | - */ |
|
316 | - public function getSharedByDisplayName() { |
|
317 | - return $this->share['sharedByDisplayName']; |
|
318 | - } |
|
309 | + /** |
|
310 | + * get display name of the user who sends the share |
|
311 | + * |
|
312 | + * @return string |
|
313 | + * |
|
314 | + * @since 14.0.0 |
|
315 | + */ |
|
316 | + public function getSharedByDisplayName() { |
|
317 | + return $this->share['sharedByDisplayName']; |
|
318 | + } |
|
319 | 319 | |
320 | - /** |
|
321 | - * get share type (group or user) |
|
322 | - * |
|
323 | - * @return string |
|
324 | - * |
|
325 | - * @since 14.0.0 |
|
326 | - */ |
|
327 | - public function getShareType() { |
|
328 | - return $this->share['shareType']; |
|
329 | - } |
|
320 | + /** |
|
321 | + * get share type (group or user) |
|
322 | + * |
|
323 | + * @return string |
|
324 | + * |
|
325 | + * @since 14.0.0 |
|
326 | + */ |
|
327 | + public function getShareType() { |
|
328 | + return $this->share['shareType']; |
|
329 | + } |
|
330 | 330 | |
331 | - /** |
|
332 | - * get share Secret |
|
333 | - * |
|
334 | - * @return string |
|
335 | - * |
|
336 | - * @since 14.0.0 |
|
337 | - */ |
|
338 | - public function getShareSecret() { |
|
339 | - return $this->share['protocol']['options']['sharedSecret']; |
|
340 | - } |
|
331 | + /** |
|
332 | + * get share Secret |
|
333 | + * |
|
334 | + * @return string |
|
335 | + * |
|
336 | + * @since 14.0.0 |
|
337 | + */ |
|
338 | + public function getShareSecret() { |
|
339 | + return $this->share['protocol']['options']['sharedSecret']; |
|
340 | + } |
|
341 | 341 | |
342 | - /** |
|
343 | - * get protocol specification |
|
344 | - * |
|
345 | - * @return array |
|
346 | - * |
|
347 | - * @since 14.0.0 |
|
348 | - */ |
|
349 | - public function getProtocol() { |
|
350 | - return $this->share['protocol']; |
|
351 | - } |
|
342 | + /** |
|
343 | + * get protocol specification |
|
344 | + * |
|
345 | + * @return array |
|
346 | + * |
|
347 | + * @since 14.0.0 |
|
348 | + */ |
|
349 | + public function getProtocol() { |
|
350 | + return $this->share['protocol']; |
|
351 | + } |
|
352 | 352 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | IClientService $httpClientService, |
72 | 72 | ICloudIdManager $cloudIdManager, |
73 | 73 | ILogger $logger) { |
74 | - $this->cloudFederationProvider= []; |
|
74 | + $this->cloudFederationProvider = []; |
|
75 | 75 | $this->appManager = $appManager; |
76 | 76 | $this->httpClientService = $httpClientService; |
77 | 77 | $this->cloudIdManager = $cloudIdManager; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | $client = $this->httpClientService->newClient(); |
142 | 142 | try { |
143 | - $response = $client->post($ocmEndPoint . '/shares', [ |
|
143 | + $response = $client->post($ocmEndPoint.'/shares', [ |
|
144 | 144 | 'body' => $share->getShare(), |
145 | 145 | 'timeout' => 10, |
146 | 146 | 'connect_timeout' => 10, |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $client = $this->httpClientService->newClient(); |
179 | 179 | try { |
180 | - $response = $client->post($ocmEndPoint . '/notifications', [ |
|
180 | + $response = $client->post($ocmEndPoint.'/notifications', [ |
|
181 | 181 | 'body' => $notification->getMessage(), |
182 | 182 | 'timeout' => 10, |
183 | 183 | 'connect_timeout' => 10, |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | } catch (\Exception $e) { |
189 | 189 | // log the error and return false |
190 | - $this->logger->error('error while sending notification for federated share: ' . $e->getMessage()); |
|
190 | + $this->logger->error('error while sending notification for federated share: '.$e->getMessage()); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | return false; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | protected function getOCMEndPoint($url) { |
211 | 211 | $client = $this->httpClientService->newClient(); |
212 | 212 | try { |
213 | - $response = $client->get($url . '/ocm-provider/', ['timeout' => 10, 'connect_timeout' => 10]); |
|
213 | + $response = $client->get($url.'/ocm-provider/', ['timeout' => 10, 'connect_timeout' => 10]); |
|
214 | 214 | } catch (\Exception $e) { |
215 | 215 | return ''; |
216 | 216 | } |
@@ -42,191 +42,191 @@ |
||
42 | 42 | */ |
43 | 43 | class CloudFederationProviderManager implements ICloudFederationProviderManager { |
44 | 44 | |
45 | - /** @var array list of available cloud federation providers */ |
|
46 | - private $cloudFederationProvider; |
|
47 | - |
|
48 | - /** @var IAppManager */ |
|
49 | - private $appManager; |
|
50 | - |
|
51 | - /** @var IClientService */ |
|
52 | - private $httpClientService; |
|
53 | - |
|
54 | - /** @var ICloudIdManager */ |
|
55 | - private $cloudIdManager; |
|
56 | - |
|
57 | - /** @var ILogger */ |
|
58 | - private $logger; |
|
59 | - |
|
60 | - private $supportedAPIVersion = '1.0-proposal1'; |
|
61 | - |
|
62 | - /** |
|
63 | - * CloudFederationProviderManager constructor. |
|
64 | - * |
|
65 | - * @param IAppManager $appManager |
|
66 | - * @param IClientService $httpClientService |
|
67 | - * @param ICloudIdManager $cloudIdManager |
|
68 | - * @param ILogger $logger |
|
69 | - */ |
|
70 | - public function __construct(IAppManager $appManager, |
|
71 | - IClientService $httpClientService, |
|
72 | - ICloudIdManager $cloudIdManager, |
|
73 | - ILogger $logger) { |
|
74 | - $this->cloudFederationProvider= []; |
|
75 | - $this->appManager = $appManager; |
|
76 | - $this->httpClientService = $httpClientService; |
|
77 | - $this->cloudIdManager = $cloudIdManager; |
|
78 | - $this->logger = $logger; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * Registers an callback function which must return an cloud federation provider |
|
84 | - * |
|
85 | - * @param string $shareType which share type does the provider handles |
|
86 | - * @param string $displayName user facing name of the federated share provider |
|
87 | - * @param callable $callback |
|
88 | - */ |
|
89 | - public function addCloudFederationProvider($shareType, $displayName, callable $callback) { |
|
90 | - \OC::$server->getRemoteApiFactory(); |
|
91 | - |
|
92 | - $this->cloudFederationProvider[$shareType] = [ |
|
93 | - 'shareType' => $shareType, |
|
94 | - 'displayName' => $displayName, |
|
95 | - 'callback' => $callback, |
|
96 | - ]; |
|
97 | - |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * remove cloud federation provider |
|
102 | - * |
|
103 | - * @param string $providerId |
|
104 | - */ |
|
105 | - public function removeCloudFederationProvider($providerId) { |
|
106 | - unset($this->cloudFederationProvider[$providerId]); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * get a list of all cloudFederationProviders |
|
111 | - * |
|
112 | - * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
113 | - */ |
|
114 | - public function getAllCloudFederationProviders() { |
|
115 | - return $this->cloudFederationProvider; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * get a specific cloud federation provider |
|
120 | - * |
|
121 | - * @param string $shareType |
|
122 | - * @return ICloudFederationProvider |
|
123 | - * @throws ProviderDoesNotExistsException |
|
124 | - */ |
|
125 | - public function getCloudFederationProvider($shareType) { |
|
126 | - if (isset($this->cloudFederationProvider[$shareType])) { |
|
127 | - return call_user_func($this->cloudFederationProvider[$shareType]['callback']); |
|
128 | - } else { |
|
129 | - throw new ProviderDoesNotExistsException($shareType); |
|
130 | - } |
|
131 | - } |
|
132 | - |
|
133 | - public function sendShare(ICloudFederationShare $share) { |
|
134 | - $cloudID = $this->cloudIdManager->resolveCloudId($share->getShareWith()); |
|
135 | - $ocmEndPoint = $this->getOCMEndPoint($cloudID->getRemote()); |
|
136 | - |
|
137 | - if (empty($ocmEndPoint)) { |
|
138 | - return false; |
|
139 | - } |
|
140 | - |
|
141 | - $client = $this->httpClientService->newClient(); |
|
142 | - try { |
|
143 | - $response = $client->post($ocmEndPoint . '/shares', [ |
|
144 | - 'body' => $share->getShare(), |
|
145 | - 'timeout' => 10, |
|
146 | - 'connect_timeout' => 10, |
|
147 | - ]); |
|
148 | - |
|
149 | - if ($response->getStatusCode() === Http::STATUS_CREATED) { |
|
150 | - return true; |
|
151 | - } |
|
152 | - |
|
153 | - } catch (\Exception $e) { |
|
154 | - // if flat re-sharing is not supported by the remote server |
|
155 | - // we re-throw the exception and fall back to the old behaviour. |
|
156 | - // (flat re-shares has been introduced in Nextcloud 9.1) |
|
157 | - if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) { |
|
158 | - throw $e; |
|
159 | - } |
|
160 | - } |
|
161 | - |
|
162 | - return false; |
|
163 | - |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * @param string $url |
|
168 | - * @param ICloudFederationNotification $notification |
|
169 | - * @return mixed |
|
170 | - */ |
|
171 | - public function sendNotification($url, ICloudFederationNotification $notification) { |
|
172 | - $ocmEndPoint = $this->getOCMEndPoint($url); |
|
173 | - |
|
174 | - if (empty($ocmEndPoint)) { |
|
175 | - return false; |
|
176 | - } |
|
177 | - |
|
178 | - $client = $this->httpClientService->newClient(); |
|
179 | - try { |
|
180 | - $response = $client->post($ocmEndPoint . '/notifications', [ |
|
181 | - 'body' => $notification->getMessage(), |
|
182 | - 'timeout' => 10, |
|
183 | - 'connect_timeout' => 10, |
|
184 | - ]); |
|
185 | - if ($response->getStatusCode() === Http::STATUS_CREATED) { |
|
186 | - $result = json_decode($response->getBody(), true); |
|
187 | - return (is_array($result)) ? $result : []; |
|
188 | - } |
|
189 | - } catch (\Exception $e) { |
|
190 | - // log the error and return false |
|
191 | - $this->logger->error('error while sending notification for federated share: ' . $e->getMessage()); |
|
192 | - } |
|
193 | - |
|
194 | - return false; |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * check if the new cloud federation API is ready to be used |
|
199 | - * |
|
200 | - * @return bool |
|
201 | - */ |
|
202 | - public function isReady() { |
|
203 | - return $this->appManager->isEnabledForUser('cloud_federation_api', false); |
|
204 | - } |
|
205 | - /** |
|
206 | - * check if server supports the new OCM api and ask for the correct end-point |
|
207 | - * |
|
208 | - * @param string $url full base URL of the cloud server |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - protected function getOCMEndPoint($url) { |
|
212 | - $client = $this->httpClientService->newClient(); |
|
213 | - try { |
|
214 | - $response = $client->get($url . '/ocm-provider/', ['timeout' => 10, 'connect_timeout' => 10]); |
|
215 | - } catch (\Exception $e) { |
|
216 | - return ''; |
|
217 | - } |
|
218 | - |
|
219 | - $result = $response->getBody(); |
|
220 | - $result = json_decode($result, true); |
|
221 | - |
|
222 | - $supportedVersion = isset($result['apiVersion']) && $result['apiVersion'] === $this->supportedAPIVersion; |
|
223 | - |
|
224 | - if (isset($result['endPoint']) && $supportedVersion) { |
|
225 | - return $result['endPoint']; |
|
226 | - } |
|
227 | - |
|
228 | - return ''; |
|
229 | - } |
|
45 | + /** @var array list of available cloud federation providers */ |
|
46 | + private $cloudFederationProvider; |
|
47 | + |
|
48 | + /** @var IAppManager */ |
|
49 | + private $appManager; |
|
50 | + |
|
51 | + /** @var IClientService */ |
|
52 | + private $httpClientService; |
|
53 | + |
|
54 | + /** @var ICloudIdManager */ |
|
55 | + private $cloudIdManager; |
|
56 | + |
|
57 | + /** @var ILogger */ |
|
58 | + private $logger; |
|
59 | + |
|
60 | + private $supportedAPIVersion = '1.0-proposal1'; |
|
61 | + |
|
62 | + /** |
|
63 | + * CloudFederationProviderManager constructor. |
|
64 | + * |
|
65 | + * @param IAppManager $appManager |
|
66 | + * @param IClientService $httpClientService |
|
67 | + * @param ICloudIdManager $cloudIdManager |
|
68 | + * @param ILogger $logger |
|
69 | + */ |
|
70 | + public function __construct(IAppManager $appManager, |
|
71 | + IClientService $httpClientService, |
|
72 | + ICloudIdManager $cloudIdManager, |
|
73 | + ILogger $logger) { |
|
74 | + $this->cloudFederationProvider= []; |
|
75 | + $this->appManager = $appManager; |
|
76 | + $this->httpClientService = $httpClientService; |
|
77 | + $this->cloudIdManager = $cloudIdManager; |
|
78 | + $this->logger = $logger; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * Registers an callback function which must return an cloud federation provider |
|
84 | + * |
|
85 | + * @param string $shareType which share type does the provider handles |
|
86 | + * @param string $displayName user facing name of the federated share provider |
|
87 | + * @param callable $callback |
|
88 | + */ |
|
89 | + public function addCloudFederationProvider($shareType, $displayName, callable $callback) { |
|
90 | + \OC::$server->getRemoteApiFactory(); |
|
91 | + |
|
92 | + $this->cloudFederationProvider[$shareType] = [ |
|
93 | + 'shareType' => $shareType, |
|
94 | + 'displayName' => $displayName, |
|
95 | + 'callback' => $callback, |
|
96 | + ]; |
|
97 | + |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * remove cloud federation provider |
|
102 | + * |
|
103 | + * @param string $providerId |
|
104 | + */ |
|
105 | + public function removeCloudFederationProvider($providerId) { |
|
106 | + unset($this->cloudFederationProvider[$providerId]); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * get a list of all cloudFederationProviders |
|
111 | + * |
|
112 | + * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
113 | + */ |
|
114 | + public function getAllCloudFederationProviders() { |
|
115 | + return $this->cloudFederationProvider; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * get a specific cloud federation provider |
|
120 | + * |
|
121 | + * @param string $shareType |
|
122 | + * @return ICloudFederationProvider |
|
123 | + * @throws ProviderDoesNotExistsException |
|
124 | + */ |
|
125 | + public function getCloudFederationProvider($shareType) { |
|
126 | + if (isset($this->cloudFederationProvider[$shareType])) { |
|
127 | + return call_user_func($this->cloudFederationProvider[$shareType]['callback']); |
|
128 | + } else { |
|
129 | + throw new ProviderDoesNotExistsException($shareType); |
|
130 | + } |
|
131 | + } |
|
132 | + |
|
133 | + public function sendShare(ICloudFederationShare $share) { |
|
134 | + $cloudID = $this->cloudIdManager->resolveCloudId($share->getShareWith()); |
|
135 | + $ocmEndPoint = $this->getOCMEndPoint($cloudID->getRemote()); |
|
136 | + |
|
137 | + if (empty($ocmEndPoint)) { |
|
138 | + return false; |
|
139 | + } |
|
140 | + |
|
141 | + $client = $this->httpClientService->newClient(); |
|
142 | + try { |
|
143 | + $response = $client->post($ocmEndPoint . '/shares', [ |
|
144 | + 'body' => $share->getShare(), |
|
145 | + 'timeout' => 10, |
|
146 | + 'connect_timeout' => 10, |
|
147 | + ]); |
|
148 | + |
|
149 | + if ($response->getStatusCode() === Http::STATUS_CREATED) { |
|
150 | + return true; |
|
151 | + } |
|
152 | + |
|
153 | + } catch (\Exception $e) { |
|
154 | + // if flat re-sharing is not supported by the remote server |
|
155 | + // we re-throw the exception and fall back to the old behaviour. |
|
156 | + // (flat re-shares has been introduced in Nextcloud 9.1) |
|
157 | + if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) { |
|
158 | + throw $e; |
|
159 | + } |
|
160 | + } |
|
161 | + |
|
162 | + return false; |
|
163 | + |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * @param string $url |
|
168 | + * @param ICloudFederationNotification $notification |
|
169 | + * @return mixed |
|
170 | + */ |
|
171 | + public function sendNotification($url, ICloudFederationNotification $notification) { |
|
172 | + $ocmEndPoint = $this->getOCMEndPoint($url); |
|
173 | + |
|
174 | + if (empty($ocmEndPoint)) { |
|
175 | + return false; |
|
176 | + } |
|
177 | + |
|
178 | + $client = $this->httpClientService->newClient(); |
|
179 | + try { |
|
180 | + $response = $client->post($ocmEndPoint . '/notifications', [ |
|
181 | + 'body' => $notification->getMessage(), |
|
182 | + 'timeout' => 10, |
|
183 | + 'connect_timeout' => 10, |
|
184 | + ]); |
|
185 | + if ($response->getStatusCode() === Http::STATUS_CREATED) { |
|
186 | + $result = json_decode($response->getBody(), true); |
|
187 | + return (is_array($result)) ? $result : []; |
|
188 | + } |
|
189 | + } catch (\Exception $e) { |
|
190 | + // log the error and return false |
|
191 | + $this->logger->error('error while sending notification for federated share: ' . $e->getMessage()); |
|
192 | + } |
|
193 | + |
|
194 | + return false; |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * check if the new cloud federation API is ready to be used |
|
199 | + * |
|
200 | + * @return bool |
|
201 | + */ |
|
202 | + public function isReady() { |
|
203 | + return $this->appManager->isEnabledForUser('cloud_federation_api', false); |
|
204 | + } |
|
205 | + /** |
|
206 | + * check if server supports the new OCM api and ask for the correct end-point |
|
207 | + * |
|
208 | + * @param string $url full base URL of the cloud server |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + protected function getOCMEndPoint($url) { |
|
212 | + $client = $this->httpClientService->newClient(); |
|
213 | + try { |
|
214 | + $response = $client->get($url . '/ocm-provider/', ['timeout' => 10, 'connect_timeout' => 10]); |
|
215 | + } catch (\Exception $e) { |
|
216 | + return ''; |
|
217 | + } |
|
218 | + |
|
219 | + $result = $response->getBody(); |
|
220 | + $result = json_decode($result, true); |
|
221 | + |
|
222 | + $supportedVersion = isset($result['apiVersion']) && $result['apiVersion'] === $this->supportedAPIVersion; |
|
223 | + |
|
224 | + if (isset($result['endPoint']) && $supportedVersion) { |
|
225 | + return $result['endPoint']; |
|
226 | + } |
|
227 | + |
|
228 | + return ''; |
|
229 | + } |
|
230 | 230 | |
231 | 231 | |
232 | 232 | } |
@@ -25,36 +25,36 @@ |
||
25 | 25 | |
26 | 26 | class CloudFederationNotification implements ICloudFederationNotification { |
27 | 27 | |
28 | - private $message = []; |
|
28 | + private $message = []; |
|
29 | 29 | |
30 | - /** |
|
31 | - * add a message to the notification |
|
32 | - * |
|
33 | - * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
34 | - * @param string $resourceType (e.g. file, calendar, contact,...) |
|
35 | - * @param string $providerId id of the share |
|
36 | - * @param array $notification payload of the notification |
|
37 | - * |
|
38 | - * @since 14.0.0 |
|
39 | - */ |
|
40 | - public function setMessage($notificationType, $resourceType, $providerId, array $notification) { |
|
41 | - $this->message = [ |
|
42 | - 'notificationType' => $notificationType, |
|
43 | - 'resourceType' => $resourceType, |
|
44 | - 'providerId' => $providerId, |
|
45 | - 'notification' => $notification, |
|
46 | - ]; |
|
30 | + /** |
|
31 | + * add a message to the notification |
|
32 | + * |
|
33 | + * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
34 | + * @param string $resourceType (e.g. file, calendar, contact,...) |
|
35 | + * @param string $providerId id of the share |
|
36 | + * @param array $notification payload of the notification |
|
37 | + * |
|
38 | + * @since 14.0.0 |
|
39 | + */ |
|
40 | + public function setMessage($notificationType, $resourceType, $providerId, array $notification) { |
|
41 | + $this->message = [ |
|
42 | + 'notificationType' => $notificationType, |
|
43 | + 'resourceType' => $resourceType, |
|
44 | + 'providerId' => $providerId, |
|
45 | + 'notification' => $notification, |
|
46 | + ]; |
|
47 | 47 | |
48 | - } |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * get message, ready to send out |
|
52 | - * |
|
53 | - * @return array |
|
54 | - * |
|
55 | - * @since 14.0.0 |
|
56 | - */ |
|
57 | - public function getMessage() { |
|
58 | - return $this->message; |
|
59 | - } |
|
50 | + /** |
|
51 | + * get message, ready to send out |
|
52 | + * |
|
53 | + * @return array |
|
54 | + * |
|
55 | + * @since 14.0.0 |
|
56 | + */ |
|
57 | + public function getMessage() { |
|
58 | + return $this->message; |
|
59 | + } |
|
60 | 60 | } |
@@ -27,37 +27,37 @@ |
||
27 | 27 | |
28 | 28 | class CloudFederationFactory implements ICloudFederationFactory { |
29 | 29 | |
30 | - /** |
|
31 | - * get a CloudFederationShare Object to prepare a share you want to send |
|
32 | - * |
|
33 | - * @param string $shareWith |
|
34 | - * @param string $name resource name (e.g. document.odt) |
|
35 | - * @param string $description share description (optional) |
|
36 | - * @param string $providerId resource UID on the provider side |
|
37 | - * @param string $owner provider specific UID of the user who owns the resource |
|
38 | - * @param string $ownerDisplayName display name of the user who shared the item |
|
39 | - * @param string $sharedBy provider specific UID of the user who shared the resource |
|
40 | - * @param string $sharedByDisplayName display name of the user who shared the resource |
|
41 | - * @param string $sharedSecret used to authenticate requests across servers |
|
42 | - * @param string $shareType ('group' or 'user' share) |
|
43 | - * @param $resourceType ('file', 'calendar',...) |
|
44 | - * @return ICloudFederationShare |
|
45 | - * |
|
46 | - * @since 14.0.0 |
|
47 | - */ |
|
48 | - public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType) { |
|
49 | - return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $shareType, $resourceType, $sharedSecret); |
|
50 | - } |
|
30 | + /** |
|
31 | + * get a CloudFederationShare Object to prepare a share you want to send |
|
32 | + * |
|
33 | + * @param string $shareWith |
|
34 | + * @param string $name resource name (e.g. document.odt) |
|
35 | + * @param string $description share description (optional) |
|
36 | + * @param string $providerId resource UID on the provider side |
|
37 | + * @param string $owner provider specific UID of the user who owns the resource |
|
38 | + * @param string $ownerDisplayName display name of the user who shared the item |
|
39 | + * @param string $sharedBy provider specific UID of the user who shared the resource |
|
40 | + * @param string $sharedByDisplayName display name of the user who shared the resource |
|
41 | + * @param string $sharedSecret used to authenticate requests across servers |
|
42 | + * @param string $shareType ('group' or 'user' share) |
|
43 | + * @param $resourceType ('file', 'calendar',...) |
|
44 | + * @return ICloudFederationShare |
|
45 | + * |
|
46 | + * @since 14.0.0 |
|
47 | + */ |
|
48 | + public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType) { |
|
49 | + return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $shareType, $resourceType, $sharedSecret); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * get a Cloud FederationNotification object to prepare a notification you |
|
54 | - * want to send |
|
55 | - * |
|
56 | - * @return ICloudFederationNotification |
|
57 | - * |
|
58 | - * @since 14.0.0 |
|
59 | - */ |
|
60 | - public function getCloudFederationNotification() { |
|
61 | - return new CloudFederationNotification(); |
|
62 | - } |
|
52 | + /** |
|
53 | + * get a Cloud FederationNotification object to prepare a notification you |
|
54 | + * want to send |
|
55 | + * |
|
56 | + * @return ICloudFederationNotification |
|
57 | + * |
|
58 | + * @since 14.0.0 |
|
59 | + */ |
|
60 | + public function getCloudFederationNotification() { |
|
61 | + return new CloudFederationNotification(); |
|
62 | + } |
|
63 | 63 | } |
@@ -28,7 +28,6 @@ |
||
28 | 28 | /** |
29 | 29 | * BadRequestException constructor. |
30 | 30 | * |
31 | - * @param array $missingParameters |
|
32 | 31 | */ |
33 | 32 | public function __construct() { |
34 | 33 | $l = \OC::$server->getL10N('federation'); |
@@ -25,16 +25,16 @@ |
||
25 | 25 | |
26 | 26 | class AuthenticationFailedException extends HintException { |
27 | 27 | |
28 | - /** |
|
29 | - * BadRequestException constructor. |
|
30 | - * |
|
31 | - * @param array $missingParameters |
|
32 | - */ |
|
33 | - public function __construct() { |
|
34 | - $l = \OC::$server->getL10N('federation'); |
|
35 | - $message = 'Authentication failed, wrong token or provider ID given'; |
|
36 | - $hint = $l->t('Authentication failed, wrong token or provider ID given'); |
|
37 | - parent::__construct($message, $hint); |
|
38 | - } |
|
28 | + /** |
|
29 | + * BadRequestException constructor. |
|
30 | + * |
|
31 | + * @param array $missingParameters |
|
32 | + */ |
|
33 | + public function __construct() { |
|
34 | + $l = \OC::$server->getL10N('federation'); |
|
35 | + $message = 'Authentication failed, wrong token or provider ID given'; |
|
36 | + $hint = $l->t('Authentication failed, wrong token or provider ID given'); |
|
37 | + parent::__construct($message, $hint); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
@@ -25,42 +25,42 @@ |
||
25 | 25 | |
26 | 26 | class BadRequestException extends HintException { |
27 | 27 | |
28 | - private $parameterList; |
|
28 | + private $parameterList; |
|
29 | 29 | |
30 | - /** |
|
31 | - * BadRequestException constructor. |
|
32 | - * |
|
33 | - * @param array $missingParameters |
|
34 | - */ |
|
35 | - public function __construct(array $missingParameters) { |
|
36 | - $l = \OC::$server->getL10N('federation'); |
|
37 | - $this->parameterList = $missingParameters; |
|
38 | - $parameterList = implode(',', $missingParameters); |
|
39 | - $message = 'Parameters missing in order to complete the request. Missing Parameters: ' . $parameterList; |
|
40 | - $hint = $l->t('Parameters missing in order to complete the request. Missing Parameters: "%s"', [$parameterList]); |
|
41 | - parent::__construct($message, $hint); |
|
42 | - } |
|
30 | + /** |
|
31 | + * BadRequestException constructor. |
|
32 | + * |
|
33 | + * @param array $missingParameters |
|
34 | + */ |
|
35 | + public function __construct(array $missingParameters) { |
|
36 | + $l = \OC::$server->getL10N('federation'); |
|
37 | + $this->parameterList = $missingParameters; |
|
38 | + $parameterList = implode(',', $missingParameters); |
|
39 | + $message = 'Parameters missing in order to complete the request. Missing Parameters: ' . $parameterList; |
|
40 | + $hint = $l->t('Parameters missing in order to complete the request. Missing Parameters: "%s"', [$parameterList]); |
|
41 | + parent::__construct($message, $hint); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * get array with the return message as defined in the OCM API |
|
46 | - * |
|
47 | - * @return array |
|
48 | - */ |
|
49 | - public function getReturnMessage() { |
|
50 | - $result = [ |
|
51 | - 'message' => 'RESOURCE_NOT_FOUND', |
|
52 | - 'validationErrors' =>[ |
|
53 | - ] |
|
54 | - ]; |
|
44 | + /** |
|
45 | + * get array with the return message as defined in the OCM API |
|
46 | + * |
|
47 | + * @return array |
|
48 | + */ |
|
49 | + public function getReturnMessage() { |
|
50 | + $result = [ |
|
51 | + 'message' => 'RESOURCE_NOT_FOUND', |
|
52 | + 'validationErrors' =>[ |
|
53 | + ] |
|
54 | + ]; |
|
55 | 55 | |
56 | - foreach ($this->parameterList as $missingParameter) { |
|
57 | - $result['validationErrors'] = [ |
|
58 | - 'name' => $missingParameter, |
|
59 | - 'message' => 'NOT_FOUND' |
|
60 | - ]; |
|
61 | - } |
|
56 | + foreach ($this->parameterList as $missingParameter) { |
|
57 | + $result['validationErrors'] = [ |
|
58 | + 'name' => $missingParameter, |
|
59 | + 'message' => 'NOT_FOUND' |
|
60 | + ]; |
|
61 | + } |
|
62 | 62 | |
63 | - return $result; |
|
64 | - } |
|
63 | + return $result; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $l = \OC::$server->getL10N('federation'); |
37 | 37 | $this->parameterList = $missingParameters; |
38 | 38 | $parameterList = implode(',', $missingParameters); |
39 | - $message = 'Parameters missing in order to complete the request. Missing Parameters: ' . $parameterList; |
|
39 | + $message = 'Parameters missing in order to complete the request. Missing Parameters: '.$parameterList; |
|
40 | 40 | $hint = $l->t('Parameters missing in order to complete the request. Missing Parameters: "%s"', [$parameterList]); |
41 | 41 | parent::__construct($message, $hint); |
42 | 42 | } |
@@ -36,172 +36,172 @@ |
||
36 | 36 | */ |
37 | 37 | interface IShareProvider { |
38 | 38 | |
39 | - /** |
|
40 | - * Return the identifier of this provider. |
|
41 | - * |
|
42 | - * @return string Containing only [a-zA-Z0-9] |
|
43 | - * @since 9.0.0 |
|
44 | - */ |
|
45 | - public function identifier(); |
|
46 | - |
|
47 | - /** |
|
48 | - * Create a share |
|
49 | - * |
|
50 | - * @param \OCP\Share\IShare $share |
|
51 | - * @return \OCP\Share\IShare The share object |
|
52 | - * @since 9.0.0 |
|
53 | - */ |
|
54 | - public function create(\OCP\Share\IShare $share); |
|
55 | - |
|
56 | - /** |
|
57 | - * Update a share |
|
58 | - * |
|
59 | - * @param \OCP\Share\IShare $share |
|
60 | - * @return \OCP\Share\IShare The share object |
|
61 | - * @since 9.0.0 |
|
62 | - */ |
|
63 | - public function update(\OCP\Share\IShare $share); |
|
64 | - |
|
65 | - /** |
|
66 | - * Delete a share |
|
67 | - * |
|
68 | - * @param \OCP\Share\IShare $share |
|
69 | - * @since 9.0.0 |
|
70 | - */ |
|
71 | - public function delete(\OCP\Share\IShare $share); |
|
72 | - |
|
73 | - /** |
|
74 | - * Unshare a file from self as recipient. |
|
75 | - * This may require special handling. If a user unshares a group |
|
76 | - * share from their self then the original group share should still exist. |
|
77 | - * |
|
78 | - * @param \OCP\Share\IShare $share |
|
79 | - * @param string $recipient UserId of the recipient |
|
80 | - * @since 9.0.0 |
|
81 | - */ |
|
82 | - public function deleteFromSelf(\OCP\Share\IShare $share, $recipient); |
|
83 | - |
|
84 | - /** |
|
85 | - * Move a share as a recipient. |
|
86 | - * This is updating the share target. Thus the mount point of the recipient. |
|
87 | - * This may require special handling. If a user moves a group share |
|
88 | - * the target should only be changed for them. |
|
89 | - * |
|
90 | - * @param \OCP\Share\IShare $share |
|
91 | - * @param string $recipient userId of recipient |
|
92 | - * @return \OCP\Share\IShare |
|
93 | - * @since 9.0.0 |
|
94 | - */ |
|
95 | - public function move(\OCP\Share\IShare $share, $recipient); |
|
96 | - |
|
97 | - /** |
|
98 | - * Get all shares by the given user in a folder |
|
99 | - * |
|
100 | - * @param string $userId |
|
101 | - * @param Folder $node |
|
102 | - * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator |
|
103 | - * @return \OCP\Share\IShare[] |
|
104 | - * @since 11.0.0 |
|
105 | - */ |
|
106 | - public function getSharesInFolder($userId, Folder $node, $reshares); |
|
107 | - |
|
108 | - /** |
|
109 | - * Get all shares by the given user |
|
110 | - * |
|
111 | - * @param string $userId |
|
112 | - * @param int $shareType |
|
113 | - * @param Node|null $node |
|
114 | - * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator |
|
115 | - * @param int $limit The maximum number of shares to be returned, -1 for all shares |
|
116 | - * @param int $offset |
|
117 | - * @return \OCP\Share\IShare[] |
|
118 | - * @since 9.0.0 |
|
119 | - */ |
|
120 | - public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset); |
|
121 | - |
|
122 | - /** |
|
123 | - * Get share by id |
|
124 | - * |
|
125 | - * @param int $id |
|
126 | - * @param string|null $recipientId |
|
127 | - * @return \OCP\Share\IShare |
|
128 | - * @throws ShareNotFoundException |
|
129 | - * @since 9.0.0 |
|
130 | - */ |
|
131 | - public function getShareById($id, $recipientId = null); |
|
132 | - |
|
133 | - /** |
|
134 | - * Get shares for a given path |
|
135 | - * |
|
136 | - * @param Node $path |
|
137 | - * @return \OCP\Share\IShare[] |
|
138 | - * @since 9.0.0 |
|
139 | - */ |
|
140 | - public function getSharesByPath(Node $path); |
|
141 | - |
|
142 | - /** |
|
143 | - * Get shared with the given user |
|
144 | - * |
|
145 | - * @param string $userId get shares where this user is the recipient |
|
146 | - * @param int $shareType |
|
147 | - * @param Node|null $node |
|
148 | - * @param int $limit The max number of entries returned, -1 for all |
|
149 | - * @param int $offset |
|
150 | - * @return \OCP\Share\IShare[] |
|
151 | - * @since 9.0.0 |
|
152 | - */ |
|
153 | - public function getSharedWith($userId, $shareType, $node, $limit, $offset); |
|
154 | - |
|
155 | - /** |
|
156 | - * Get a share by token |
|
157 | - * |
|
158 | - * @param string $token |
|
159 | - * @return \OCP\Share\IShare |
|
160 | - * @throws ShareNotFound |
|
161 | - * @since 9.0.0 |
|
162 | - */ |
|
163 | - public function getShareByToken($token); |
|
164 | - |
|
165 | - /** |
|
166 | - * A user is deleted from the system |
|
167 | - * So clean up the relevant shares. |
|
168 | - * |
|
169 | - * @param string $uid |
|
170 | - * @param int $shareType |
|
171 | - * @since 9.1.0 |
|
172 | - */ |
|
173 | - public function userDeleted($uid, $shareType); |
|
174 | - |
|
175 | - /** |
|
176 | - * A group is deleted from the system. |
|
177 | - * We have to clean up all shares to this group. |
|
178 | - * Providers not handling group shares should just return |
|
179 | - * |
|
180 | - * @param string $gid |
|
181 | - * @since 9.1.0 |
|
182 | - */ |
|
183 | - public function groupDeleted($gid); |
|
184 | - |
|
185 | - /** |
|
186 | - * A user is deleted from a group |
|
187 | - * We have to clean up all the related user specific group shares |
|
188 | - * Providers not handling group shares should just return |
|
189 | - * |
|
190 | - * @param string $uid |
|
191 | - * @param string $gid |
|
192 | - * @since 9.1.0 |
|
193 | - */ |
|
194 | - public function userDeletedFromGroup($uid, $gid); |
|
195 | - |
|
196 | - /** |
|
197 | - * Get the access list to the array of provided nodes. |
|
198 | - * |
|
199 | - * @see IManager::getAccessList() for sample docs |
|
200 | - * |
|
201 | - * @param Node[] $nodes The list of nodes to get access for |
|
202 | - * @param bool $currentAccess If current access is required (like for removed shares that might get revived later) |
|
203 | - * @return array |
|
204 | - * @since 12 |
|
205 | - */ |
|
206 | - public function getAccessList($nodes, $currentAccess); |
|
39 | + /** |
|
40 | + * Return the identifier of this provider. |
|
41 | + * |
|
42 | + * @return string Containing only [a-zA-Z0-9] |
|
43 | + * @since 9.0.0 |
|
44 | + */ |
|
45 | + public function identifier(); |
|
46 | + |
|
47 | + /** |
|
48 | + * Create a share |
|
49 | + * |
|
50 | + * @param \OCP\Share\IShare $share |
|
51 | + * @return \OCP\Share\IShare The share object |
|
52 | + * @since 9.0.0 |
|
53 | + */ |
|
54 | + public function create(\OCP\Share\IShare $share); |
|
55 | + |
|
56 | + /** |
|
57 | + * Update a share |
|
58 | + * |
|
59 | + * @param \OCP\Share\IShare $share |
|
60 | + * @return \OCP\Share\IShare The share object |
|
61 | + * @since 9.0.0 |
|
62 | + */ |
|
63 | + public function update(\OCP\Share\IShare $share); |
|
64 | + |
|
65 | + /** |
|
66 | + * Delete a share |
|
67 | + * |
|
68 | + * @param \OCP\Share\IShare $share |
|
69 | + * @since 9.0.0 |
|
70 | + */ |
|
71 | + public function delete(\OCP\Share\IShare $share); |
|
72 | + |
|
73 | + /** |
|
74 | + * Unshare a file from self as recipient. |
|
75 | + * This may require special handling. If a user unshares a group |
|
76 | + * share from their self then the original group share should still exist. |
|
77 | + * |
|
78 | + * @param \OCP\Share\IShare $share |
|
79 | + * @param string $recipient UserId of the recipient |
|
80 | + * @since 9.0.0 |
|
81 | + */ |
|
82 | + public function deleteFromSelf(\OCP\Share\IShare $share, $recipient); |
|
83 | + |
|
84 | + /** |
|
85 | + * Move a share as a recipient. |
|
86 | + * This is updating the share target. Thus the mount point of the recipient. |
|
87 | + * This may require special handling. If a user moves a group share |
|
88 | + * the target should only be changed for them. |
|
89 | + * |
|
90 | + * @param \OCP\Share\IShare $share |
|
91 | + * @param string $recipient userId of recipient |
|
92 | + * @return \OCP\Share\IShare |
|
93 | + * @since 9.0.0 |
|
94 | + */ |
|
95 | + public function move(\OCP\Share\IShare $share, $recipient); |
|
96 | + |
|
97 | + /** |
|
98 | + * Get all shares by the given user in a folder |
|
99 | + * |
|
100 | + * @param string $userId |
|
101 | + * @param Folder $node |
|
102 | + * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator |
|
103 | + * @return \OCP\Share\IShare[] |
|
104 | + * @since 11.0.0 |
|
105 | + */ |
|
106 | + public function getSharesInFolder($userId, Folder $node, $reshares); |
|
107 | + |
|
108 | + /** |
|
109 | + * Get all shares by the given user |
|
110 | + * |
|
111 | + * @param string $userId |
|
112 | + * @param int $shareType |
|
113 | + * @param Node|null $node |
|
114 | + * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator |
|
115 | + * @param int $limit The maximum number of shares to be returned, -1 for all shares |
|
116 | + * @param int $offset |
|
117 | + * @return \OCP\Share\IShare[] |
|
118 | + * @since 9.0.0 |
|
119 | + */ |
|
120 | + public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset); |
|
121 | + |
|
122 | + /** |
|
123 | + * Get share by id |
|
124 | + * |
|
125 | + * @param int $id |
|
126 | + * @param string|null $recipientId |
|
127 | + * @return \OCP\Share\IShare |
|
128 | + * @throws ShareNotFoundException |
|
129 | + * @since 9.0.0 |
|
130 | + */ |
|
131 | + public function getShareById($id, $recipientId = null); |
|
132 | + |
|
133 | + /** |
|
134 | + * Get shares for a given path |
|
135 | + * |
|
136 | + * @param Node $path |
|
137 | + * @return \OCP\Share\IShare[] |
|
138 | + * @since 9.0.0 |
|
139 | + */ |
|
140 | + public function getSharesByPath(Node $path); |
|
141 | + |
|
142 | + /** |
|
143 | + * Get shared with the given user |
|
144 | + * |
|
145 | + * @param string $userId get shares where this user is the recipient |
|
146 | + * @param int $shareType |
|
147 | + * @param Node|null $node |
|
148 | + * @param int $limit The max number of entries returned, -1 for all |
|
149 | + * @param int $offset |
|
150 | + * @return \OCP\Share\IShare[] |
|
151 | + * @since 9.0.0 |
|
152 | + */ |
|
153 | + public function getSharedWith($userId, $shareType, $node, $limit, $offset); |
|
154 | + |
|
155 | + /** |
|
156 | + * Get a share by token |
|
157 | + * |
|
158 | + * @param string $token |
|
159 | + * @return \OCP\Share\IShare |
|
160 | + * @throws ShareNotFound |
|
161 | + * @since 9.0.0 |
|
162 | + */ |
|
163 | + public function getShareByToken($token); |
|
164 | + |
|
165 | + /** |
|
166 | + * A user is deleted from the system |
|
167 | + * So clean up the relevant shares. |
|
168 | + * |
|
169 | + * @param string $uid |
|
170 | + * @param int $shareType |
|
171 | + * @since 9.1.0 |
|
172 | + */ |
|
173 | + public function userDeleted($uid, $shareType); |
|
174 | + |
|
175 | + /** |
|
176 | + * A group is deleted from the system. |
|
177 | + * We have to clean up all shares to this group. |
|
178 | + * Providers not handling group shares should just return |
|
179 | + * |
|
180 | + * @param string $gid |
|
181 | + * @since 9.1.0 |
|
182 | + */ |
|
183 | + public function groupDeleted($gid); |
|
184 | + |
|
185 | + /** |
|
186 | + * A user is deleted from a group |
|
187 | + * We have to clean up all the related user specific group shares |
|
188 | + * Providers not handling group shares should just return |
|
189 | + * |
|
190 | + * @param string $uid |
|
191 | + * @param string $gid |
|
192 | + * @since 9.1.0 |
|
193 | + */ |
|
194 | + public function userDeletedFromGroup($uid, $gid); |
|
195 | + |
|
196 | + /** |
|
197 | + * Get the access list to the array of provided nodes. |
|
198 | + * |
|
199 | + * @see IManager::getAccessList() for sample docs |
|
200 | + * |
|
201 | + * @param Node[] $nodes The list of nodes to get access for |
|
202 | + * @param bool $currentAccess If current access is required (like for removed shares that might get revived later) |
|
203 | + * @return array |
|
204 | + * @since 12 |
|
205 | + */ |
|
206 | + public function getAccessList($nodes, $currentAccess); |
|
207 | 207 | } |
@@ -28,37 +28,37 @@ |
||
28 | 28 | |
29 | 29 | class Capabilities implements ICapability { |
30 | 30 | |
31 | - /** @var IURLGenerator */ |
|
32 | - private $urlGenerator; |
|
31 | + /** @var IURLGenerator */ |
|
32 | + private $urlGenerator; |
|
33 | 33 | |
34 | - public function __construct(IURLGenerator $urlGenerator) { |
|
35 | - $this->urlGenerator = $urlGenerator; |
|
36 | - } |
|
34 | + public function __construct(IURLGenerator $urlGenerator) { |
|
35 | + $this->urlGenerator = $urlGenerator; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Function an app uses to return the capabilities |
|
40 | - * |
|
41 | - * @return array Array containing the apps capabilities |
|
42 | - * @since 8.2.0 |
|
43 | - */ |
|
44 | - public function getCapabilities() { |
|
45 | - $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare'); |
|
46 | - $capabilities = ['ocm' => |
|
47 | - [ |
|
48 | - 'enabled' => true, |
|
49 | - 'apiVersion' => '1.0-proposal1', |
|
50 | - 'endPoint' => substr($url, 0, strrpos($url, '/')), |
|
51 | - 'shareTypes' => [ |
|
52 | - [ |
|
53 | - 'name' => 'file', |
|
54 | - 'protocols' => [ |
|
55 | - 'webdav' => '/public.php/webdav/', |
|
56 | - ] |
|
57 | - ], |
|
58 | - ] |
|
59 | - ] |
|
60 | - ]; |
|
38 | + /** |
|
39 | + * Function an app uses to return the capabilities |
|
40 | + * |
|
41 | + * @return array Array containing the apps capabilities |
|
42 | + * @since 8.2.0 |
|
43 | + */ |
|
44 | + public function getCapabilities() { |
|
45 | + $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare'); |
|
46 | + $capabilities = ['ocm' => |
|
47 | + [ |
|
48 | + 'enabled' => true, |
|
49 | + 'apiVersion' => '1.0-proposal1', |
|
50 | + 'endPoint' => substr($url, 0, strrpos($url, '/')), |
|
51 | + 'shareTypes' => [ |
|
52 | + [ |
|
53 | + 'name' => 'file', |
|
54 | + 'protocols' => [ |
|
55 | + 'webdav' => '/public.php/webdav/', |
|
56 | + ] |
|
57 | + ], |
|
58 | + ] |
|
59 | + ] |
|
60 | + ]; |
|
61 | 61 | |
62 | - return $capabilities; |
|
63 | - } |
|
62 | + return $capabilities; |
|
63 | + } |
|
64 | 64 | } |