Completed
Pull Request — master (#32303)
by Victor
10:52
created

OcmController::discovery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
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,
0 ignored issues
show
Unused Code introduced by
The parameter $shareWith is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
99
								$name,
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
100
								$description,
0 ignored issues
show
Unused Code introduced by
The parameter $description is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
101
								$providerId,
0 ignored issues
show
Unused Code introduced by
The parameter $providerId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
102
								$owner,
0 ignored issues
show
Unused Code introduced by
The parameter $owner is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
103
								$ownerDisplayName,
0 ignored issues
show
Unused Code introduced by
The parameter $ownerDisplayName is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
104
								$sender,
0 ignored issues
show
Unused Code introduced by
The parameter $sender is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
105
								$senderDisplayName,
0 ignored issues
show
Unused Code introduced by
The parameter $senderDisplayName is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
106
								$shareType,
0 ignored issues
show
Unused Code introduced by
The parameter $shareType is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
107
								$resourceType,
0 ignored issues
show
Unused Code introduced by
The parameter $resourceType is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
108
								$protocol
0 ignored issues
show
Unused Code introduced by
The parameter $protocol is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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,
0 ignored issues
show
Unused Code introduced by
The parameter $notificationType is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
125
										$resourceType,
0 ignored issues
show
Unused Code introduced by
The parameter $resourceType is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
126
										$providerId,
0 ignored issues
show
Unused Code introduced by
The parameter $providerId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
127
										$notification
0 ignored issues
show
Unused Code introduced by
The parameter $notification is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
128
	) {
129
		// TODO: implement
130
	}
131
132
	protected function getProtocols() {
133
		return [
134
			'webdav' => '/public.php/webdav/'
135
		];
136
	}
137
138
}
139