@@ -29,15 +29,15 @@ |
||
29 | 29 | * Authentication mechanism or backend has insufficient data |
30 | 30 | */ |
31 | 31 | class InsufficientDataForMeaningfulAnswerException extends StorageNotAvailableException { |
32 | - /** |
|
33 | - * StorageNotAvailableException constructor. |
|
34 | - * |
|
35 | - * @param string $message |
|
36 | - * @param int $code |
|
37 | - * @param \Exception|null $previous |
|
38 | - * @since 6.0.0 |
|
39 | - */ |
|
40 | - public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) { |
|
41 | - parent::__construct($message, $code, $previous); |
|
42 | - } |
|
32 | + /** |
|
33 | + * StorageNotAvailableException constructor. |
|
34 | + * |
|
35 | + * @param string $message |
|
36 | + * @param int $code |
|
37 | + * @param \Exception|null $previous |
|
38 | + * @since 6.0.0 |
|
39 | + */ |
|
40 | + public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) { |
|
41 | + parent::__construct($message, $code, $previous); |
|
42 | + } |
|
43 | 43 | } |
@@ -28,76 +28,76 @@ |
||
28 | 28 | */ |
29 | 29 | trait IdentifierTrait { |
30 | 30 | |
31 | - /** @var string */ |
|
32 | - protected $identifier; |
|
31 | + /** @var string */ |
|
32 | + protected $identifier; |
|
33 | 33 | |
34 | - /** @var string[] */ |
|
35 | - protected $identifierAliases = []; |
|
34 | + /** @var string[] */ |
|
35 | + protected $identifierAliases = []; |
|
36 | 36 | |
37 | - /** @var IdentifierTrait */ |
|
38 | - protected $deprecateTo = null; |
|
37 | + /** @var IdentifierTrait */ |
|
38 | + protected $deprecateTo = null; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function getIdentifier() { |
|
44 | - return $this->identifier; |
|
45 | - } |
|
40 | + /** |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function getIdentifier() { |
|
44 | + return $this->identifier; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string $identifier |
|
49 | - * @return $this |
|
50 | - */ |
|
51 | - public function setIdentifier($identifier) { |
|
52 | - $this->identifier = $identifier; |
|
53 | - $this->identifierAliases[] = $identifier; |
|
54 | - return $this; |
|
55 | - } |
|
47 | + /** |
|
48 | + * @param string $identifier |
|
49 | + * @return $this |
|
50 | + */ |
|
51 | + public function setIdentifier($identifier) { |
|
52 | + $this->identifier = $identifier; |
|
53 | + $this->identifierAliases[] = $identifier; |
|
54 | + return $this; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return string[] |
|
59 | - */ |
|
60 | - public function getIdentifierAliases() { |
|
61 | - return $this->identifierAliases; |
|
62 | - } |
|
57 | + /** |
|
58 | + * @return string[] |
|
59 | + */ |
|
60 | + public function getIdentifierAliases() { |
|
61 | + return $this->identifierAliases; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param string $alias |
|
66 | - * @return $this |
|
67 | - */ |
|
68 | - public function addIdentifierAlias($alias) { |
|
69 | - $this->identifierAliases[] = $alias; |
|
70 | - return $this; |
|
71 | - } |
|
64 | + /** |
|
65 | + * @param string $alias |
|
66 | + * @return $this |
|
67 | + */ |
|
68 | + public function addIdentifierAlias($alias) { |
|
69 | + $this->identifierAliases[] = $alias; |
|
70 | + return $this; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return object|null |
|
75 | - */ |
|
76 | - public function getDeprecateTo() { |
|
77 | - return $this->deprecateTo; |
|
78 | - } |
|
73 | + /** |
|
74 | + * @return object|null |
|
75 | + */ |
|
76 | + public function getDeprecateTo() { |
|
77 | + return $this->deprecateTo; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @param object $destinationObject |
|
82 | - * @return self |
|
83 | - */ |
|
84 | - public function deprecateTo($destinationObject) { |
|
85 | - $this->deprecateTo = $destinationObject; |
|
86 | - return $this; |
|
87 | - } |
|
80 | + /** |
|
81 | + * @param object $destinationObject |
|
82 | + * @return self |
|
83 | + */ |
|
84 | + public function deprecateTo($destinationObject) { |
|
85 | + $this->deprecateTo = $destinationObject; |
|
86 | + return $this; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - public function jsonSerializeIdentifier() { |
|
93 | - $data = [ |
|
94 | - 'identifier' => $this->identifier, |
|
95 | - 'identifierAliases' => $this->identifierAliases, |
|
96 | - ]; |
|
97 | - if ($this->deprecateTo) { |
|
98 | - $data['deprecateTo'] = $this->deprecateTo->getIdentifier(); |
|
99 | - } |
|
100 | - return $data; |
|
101 | - } |
|
89 | + /** |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + public function jsonSerializeIdentifier() { |
|
93 | + $data = [ |
|
94 | + 'identifier' => $this->identifier, |
|
95 | + 'identifierAliases' => $this->identifierAliases, |
|
96 | + ]; |
|
97 | + if ($this->deprecateTo) { |
|
98 | + $data['deprecateTo'] = $this->deprecateTo->getIdentifier(); |
|
99 | + } |
|
100 | + return $data; |
|
101 | + } |
|
102 | 102 | |
103 | 103 | } |
@@ -42,182 +42,182 @@ |
||
42 | 42 | use Symfony\Component\Console\Output\OutputInterface; |
43 | 43 | |
44 | 44 | class Create extends Base { |
45 | - /** |
|
46 | - * @var GlobalStoragesService |
|
47 | - */ |
|
48 | - private $globalService; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var UserStoragesService |
|
52 | - */ |
|
53 | - private $userService; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var IUserManager |
|
57 | - */ |
|
58 | - private $userManager; |
|
59 | - |
|
60 | - /** @var BackendService */ |
|
61 | - private $backendService; |
|
62 | - |
|
63 | - /** @var IUserSession */ |
|
64 | - private $userSession; |
|
65 | - |
|
66 | - function __construct(GlobalStoragesService $globalService, |
|
67 | - UserStoragesService $userService, |
|
68 | - IUserManager $userManager, |
|
69 | - IUserSession $userSession, |
|
70 | - BackendService $backendService |
|
71 | - ) { |
|
72 | - parent::__construct(); |
|
73 | - $this->globalService = $globalService; |
|
74 | - $this->userService = $userService; |
|
75 | - $this->userManager = $userManager; |
|
76 | - $this->userSession = $userSession; |
|
77 | - $this->backendService = $backendService; |
|
78 | - } |
|
79 | - |
|
80 | - protected function configure() { |
|
81 | - $this |
|
82 | - ->setName('files_external:create') |
|
83 | - ->setDescription('Create a new mount configuration') |
|
84 | - ->addOption( |
|
85 | - 'user', |
|
86 | - '', |
|
87 | - InputOption::VALUE_OPTIONAL, |
|
88 | - 'user to add the mount configuration for, if not set the mount will be added as system mount' |
|
89 | - ) |
|
90 | - ->addArgument( |
|
91 | - 'mount_point', |
|
92 | - InputArgument::REQUIRED, |
|
93 | - 'mount point for the new mount' |
|
94 | - ) |
|
95 | - ->addArgument( |
|
96 | - 'storage_backend', |
|
97 | - InputArgument::REQUIRED, |
|
98 | - 'storage backend identifier for the new mount, see `occ files_external:backends` for possible values' |
|
99 | - ) |
|
100 | - ->addArgument( |
|
101 | - 'authentication_backend', |
|
102 | - InputArgument::REQUIRED, |
|
103 | - 'authentication backend identifier for the new mount, see `occ files_external:backends` for possible values' |
|
104 | - ) |
|
105 | - ->addOption( |
|
106 | - 'config', |
|
107 | - 'c', |
|
108 | - InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
|
109 | - 'Mount configuration option in key=value format' |
|
110 | - ) |
|
111 | - ->addOption( |
|
112 | - 'dry', |
|
113 | - '', |
|
114 | - InputOption::VALUE_NONE, |
|
115 | - 'Don\'t save the created mount, only list the new mount' |
|
116 | - ); |
|
117 | - parent::configure(); |
|
118 | - } |
|
119 | - |
|
120 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
121 | - $user = $input->getOption('user'); |
|
122 | - $mountPoint = $input->getArgument('mount_point'); |
|
123 | - $storageIdentifier = $input->getArgument('storage_backend'); |
|
124 | - $authIdentifier = $input->getArgument('authentication_backend'); |
|
125 | - $configInput = $input->getOption('config'); |
|
126 | - |
|
127 | - $storageBackend = $this->backendService->getBackend($storageIdentifier); |
|
128 | - $authBackend = $this->backendService->getAuthMechanism($authIdentifier); |
|
129 | - |
|
130 | - if (!Filesystem::isValidPath($mountPoint)) { |
|
131 | - $output->writeln('<error>Invalid mountpoint "' . $mountPoint . '"</error>'); |
|
132 | - return 1; |
|
133 | - } |
|
134 | - if (is_null($storageBackend)) { |
|
135 | - $output->writeln('<error>Storage backend with identifier "' . $storageIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>'); |
|
136 | - return 404; |
|
137 | - } |
|
138 | - if (is_null($authBackend)) { |
|
139 | - $output->writeln('<error>Authentication backend with identifier "' . $authIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>'); |
|
140 | - return 404; |
|
141 | - } |
|
142 | - $supportedSchemes = array_keys($storageBackend->getAuthSchemes()); |
|
143 | - if (!in_array($authBackend->getScheme(), $supportedSchemes)) { |
|
144 | - $output->writeln('<error>Authentication backend "' . $authIdentifier . '" not valid for storage backend "' . $storageIdentifier . '" (see `occ files_external:backends storage ' . $storageIdentifier . '` for possible values)</error>'); |
|
145 | - return 1; |
|
146 | - } |
|
147 | - |
|
148 | - $config = []; |
|
149 | - foreach ($configInput as $configOption) { |
|
150 | - if (!strpos($configOption, '=')) { |
|
151 | - $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>'); |
|
152 | - return 1; |
|
153 | - } |
|
154 | - list($key, $value) = explode('=', $configOption, 2); |
|
155 | - if (!$this->validateParam($key, $value, $storageBackend, $authBackend)) { |
|
156 | - $output->writeln('<error>Unknown configuration for backends "' . $key . '"</error>'); |
|
157 | - return 1; |
|
158 | - } |
|
159 | - $config[$key] = $value; |
|
160 | - } |
|
161 | - |
|
162 | - $mount = new StorageConfig(); |
|
163 | - $mount->setMountPoint($mountPoint); |
|
164 | - $mount->setBackend($storageBackend); |
|
165 | - $mount->setAuthMechanism($authBackend); |
|
166 | - $mount->setBackendOptions($config); |
|
167 | - |
|
168 | - if ($user) { |
|
169 | - if (!$this->userManager->userExists($user)) { |
|
170 | - $output->writeln('<error>User "' . $user . '" not found</error>'); |
|
171 | - return 1; |
|
172 | - } |
|
173 | - $mount->setApplicableUsers([$user]); |
|
174 | - } |
|
175 | - |
|
176 | - if ($input->getOption('dry')) { |
|
177 | - $this->showMount($user, $mount, $input, $output); |
|
178 | - } else { |
|
179 | - $this->getStorageService($user)->addStorage($mount); |
|
180 | - if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
|
181 | - $output->writeln('<info>Storage created with id ' . $mount->getId() . '</info>'); |
|
182 | - } else { |
|
183 | - $output->writeln((string)$mount->getId()); |
|
184 | - } |
|
185 | - } |
|
186 | - return 0; |
|
187 | - } |
|
188 | - |
|
189 | - private function validateParam($key, &$value, Backend $storageBackend, AuthMechanism $authBackend) { |
|
190 | - $params = array_merge($storageBackend->getParameters(), $authBackend->getParameters()); |
|
191 | - foreach ($params as $param) { |
|
192 | - /** @var DefinitionParameter $param */ |
|
193 | - if ($param->getName() === $key) { |
|
194 | - if ($param->getType() === DefinitionParameter::VALUE_BOOLEAN) { |
|
195 | - $value = ($value === 'true'); |
|
196 | - } |
|
197 | - return true; |
|
198 | - } |
|
199 | - } |
|
200 | - return false; |
|
201 | - } |
|
202 | - |
|
203 | - private function showMount($user, StorageConfig $mount, InputInterface $input, OutputInterface $output) { |
|
204 | - $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
205 | - $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
206 | - $listInput->setOption('output', $input->getOption('output')); |
|
207 | - $listInput->setOption('show-password', true); |
|
208 | - $listCommand->listMounts($user, [$mount], $listInput, $output); |
|
209 | - } |
|
210 | - |
|
211 | - protected function getStorageService($userId) { |
|
212 | - if (!empty($userId)) { |
|
213 | - $user = $this->userManager->get($userId); |
|
214 | - if (is_null($user)) { |
|
215 | - throw new NoUserException("user $userId not found"); |
|
216 | - } |
|
217 | - $this->userSession->setUser($user); |
|
218 | - return $this->userService; |
|
219 | - } else { |
|
220 | - return $this->globalService; |
|
221 | - } |
|
222 | - } |
|
45 | + /** |
|
46 | + * @var GlobalStoragesService |
|
47 | + */ |
|
48 | + private $globalService; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var UserStoragesService |
|
52 | + */ |
|
53 | + private $userService; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var IUserManager |
|
57 | + */ |
|
58 | + private $userManager; |
|
59 | + |
|
60 | + /** @var BackendService */ |
|
61 | + private $backendService; |
|
62 | + |
|
63 | + /** @var IUserSession */ |
|
64 | + private $userSession; |
|
65 | + |
|
66 | + function __construct(GlobalStoragesService $globalService, |
|
67 | + UserStoragesService $userService, |
|
68 | + IUserManager $userManager, |
|
69 | + IUserSession $userSession, |
|
70 | + BackendService $backendService |
|
71 | + ) { |
|
72 | + parent::__construct(); |
|
73 | + $this->globalService = $globalService; |
|
74 | + $this->userService = $userService; |
|
75 | + $this->userManager = $userManager; |
|
76 | + $this->userSession = $userSession; |
|
77 | + $this->backendService = $backendService; |
|
78 | + } |
|
79 | + |
|
80 | + protected function configure() { |
|
81 | + $this |
|
82 | + ->setName('files_external:create') |
|
83 | + ->setDescription('Create a new mount configuration') |
|
84 | + ->addOption( |
|
85 | + 'user', |
|
86 | + '', |
|
87 | + InputOption::VALUE_OPTIONAL, |
|
88 | + 'user to add the mount configuration for, if not set the mount will be added as system mount' |
|
89 | + ) |
|
90 | + ->addArgument( |
|
91 | + 'mount_point', |
|
92 | + InputArgument::REQUIRED, |
|
93 | + 'mount point for the new mount' |
|
94 | + ) |
|
95 | + ->addArgument( |
|
96 | + 'storage_backend', |
|
97 | + InputArgument::REQUIRED, |
|
98 | + 'storage backend identifier for the new mount, see `occ files_external:backends` for possible values' |
|
99 | + ) |
|
100 | + ->addArgument( |
|
101 | + 'authentication_backend', |
|
102 | + InputArgument::REQUIRED, |
|
103 | + 'authentication backend identifier for the new mount, see `occ files_external:backends` for possible values' |
|
104 | + ) |
|
105 | + ->addOption( |
|
106 | + 'config', |
|
107 | + 'c', |
|
108 | + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
|
109 | + 'Mount configuration option in key=value format' |
|
110 | + ) |
|
111 | + ->addOption( |
|
112 | + 'dry', |
|
113 | + '', |
|
114 | + InputOption::VALUE_NONE, |
|
115 | + 'Don\'t save the created mount, only list the new mount' |
|
116 | + ); |
|
117 | + parent::configure(); |
|
118 | + } |
|
119 | + |
|
120 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
121 | + $user = $input->getOption('user'); |
|
122 | + $mountPoint = $input->getArgument('mount_point'); |
|
123 | + $storageIdentifier = $input->getArgument('storage_backend'); |
|
124 | + $authIdentifier = $input->getArgument('authentication_backend'); |
|
125 | + $configInput = $input->getOption('config'); |
|
126 | + |
|
127 | + $storageBackend = $this->backendService->getBackend($storageIdentifier); |
|
128 | + $authBackend = $this->backendService->getAuthMechanism($authIdentifier); |
|
129 | + |
|
130 | + if (!Filesystem::isValidPath($mountPoint)) { |
|
131 | + $output->writeln('<error>Invalid mountpoint "' . $mountPoint . '"</error>'); |
|
132 | + return 1; |
|
133 | + } |
|
134 | + if (is_null($storageBackend)) { |
|
135 | + $output->writeln('<error>Storage backend with identifier "' . $storageIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>'); |
|
136 | + return 404; |
|
137 | + } |
|
138 | + if (is_null($authBackend)) { |
|
139 | + $output->writeln('<error>Authentication backend with identifier "' . $authIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>'); |
|
140 | + return 404; |
|
141 | + } |
|
142 | + $supportedSchemes = array_keys($storageBackend->getAuthSchemes()); |
|
143 | + if (!in_array($authBackend->getScheme(), $supportedSchemes)) { |
|
144 | + $output->writeln('<error>Authentication backend "' . $authIdentifier . '" not valid for storage backend "' . $storageIdentifier . '" (see `occ files_external:backends storage ' . $storageIdentifier . '` for possible values)</error>'); |
|
145 | + return 1; |
|
146 | + } |
|
147 | + |
|
148 | + $config = []; |
|
149 | + foreach ($configInput as $configOption) { |
|
150 | + if (!strpos($configOption, '=')) { |
|
151 | + $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>'); |
|
152 | + return 1; |
|
153 | + } |
|
154 | + list($key, $value) = explode('=', $configOption, 2); |
|
155 | + if (!$this->validateParam($key, $value, $storageBackend, $authBackend)) { |
|
156 | + $output->writeln('<error>Unknown configuration for backends "' . $key . '"</error>'); |
|
157 | + return 1; |
|
158 | + } |
|
159 | + $config[$key] = $value; |
|
160 | + } |
|
161 | + |
|
162 | + $mount = new StorageConfig(); |
|
163 | + $mount->setMountPoint($mountPoint); |
|
164 | + $mount->setBackend($storageBackend); |
|
165 | + $mount->setAuthMechanism($authBackend); |
|
166 | + $mount->setBackendOptions($config); |
|
167 | + |
|
168 | + if ($user) { |
|
169 | + if (!$this->userManager->userExists($user)) { |
|
170 | + $output->writeln('<error>User "' . $user . '" not found</error>'); |
|
171 | + return 1; |
|
172 | + } |
|
173 | + $mount->setApplicableUsers([$user]); |
|
174 | + } |
|
175 | + |
|
176 | + if ($input->getOption('dry')) { |
|
177 | + $this->showMount($user, $mount, $input, $output); |
|
178 | + } else { |
|
179 | + $this->getStorageService($user)->addStorage($mount); |
|
180 | + if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
|
181 | + $output->writeln('<info>Storage created with id ' . $mount->getId() . '</info>'); |
|
182 | + } else { |
|
183 | + $output->writeln((string)$mount->getId()); |
|
184 | + } |
|
185 | + } |
|
186 | + return 0; |
|
187 | + } |
|
188 | + |
|
189 | + private function validateParam($key, &$value, Backend $storageBackend, AuthMechanism $authBackend) { |
|
190 | + $params = array_merge($storageBackend->getParameters(), $authBackend->getParameters()); |
|
191 | + foreach ($params as $param) { |
|
192 | + /** @var DefinitionParameter $param */ |
|
193 | + if ($param->getName() === $key) { |
|
194 | + if ($param->getType() === DefinitionParameter::VALUE_BOOLEAN) { |
|
195 | + $value = ($value === 'true'); |
|
196 | + } |
|
197 | + return true; |
|
198 | + } |
|
199 | + } |
|
200 | + return false; |
|
201 | + } |
|
202 | + |
|
203 | + private function showMount($user, StorageConfig $mount, InputInterface $input, OutputInterface $output) { |
|
204 | + $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
205 | + $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
206 | + $listInput->setOption('output', $input->getOption('output')); |
|
207 | + $listInput->setOption('show-password', true); |
|
208 | + $listCommand->listMounts($user, [$mount], $listInput, $output); |
|
209 | + } |
|
210 | + |
|
211 | + protected function getStorageService($userId) { |
|
212 | + if (!empty($userId)) { |
|
213 | + $user = $this->userManager->get($userId); |
|
214 | + if (is_null($user)) { |
|
215 | + throw new NoUserException("user $userId not found"); |
|
216 | + } |
|
217 | + $this->userSession->setUser($user); |
|
218 | + return $this->userService; |
|
219 | + } else { |
|
220 | + return $this->globalService; |
|
221 | + } |
|
222 | + } |
|
223 | 223 | } |
@@ -128,32 +128,32 @@ discard block |
||
128 | 128 | $authBackend = $this->backendService->getAuthMechanism($authIdentifier); |
129 | 129 | |
130 | 130 | if (!Filesystem::isValidPath($mountPoint)) { |
131 | - $output->writeln('<error>Invalid mountpoint "' . $mountPoint . '"</error>'); |
|
131 | + $output->writeln('<error>Invalid mountpoint "'.$mountPoint.'"</error>'); |
|
132 | 132 | return 1; |
133 | 133 | } |
134 | 134 | if (is_null($storageBackend)) { |
135 | - $output->writeln('<error>Storage backend with identifier "' . $storageIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>'); |
|
135 | + $output->writeln('<error>Storage backend with identifier "'.$storageIdentifier.'" not found (see `occ files_external:backends` for possible values)</error>'); |
|
136 | 136 | return 404; |
137 | 137 | } |
138 | 138 | if (is_null($authBackend)) { |
139 | - $output->writeln('<error>Authentication backend with identifier "' . $authIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>'); |
|
139 | + $output->writeln('<error>Authentication backend with identifier "'.$authIdentifier.'" not found (see `occ files_external:backends` for possible values)</error>'); |
|
140 | 140 | return 404; |
141 | 141 | } |
142 | 142 | $supportedSchemes = array_keys($storageBackend->getAuthSchemes()); |
143 | 143 | if (!in_array($authBackend->getScheme(), $supportedSchemes)) { |
144 | - $output->writeln('<error>Authentication backend "' . $authIdentifier . '" not valid for storage backend "' . $storageIdentifier . '" (see `occ files_external:backends storage ' . $storageIdentifier . '` for possible values)</error>'); |
|
144 | + $output->writeln('<error>Authentication backend "'.$authIdentifier.'" not valid for storage backend "'.$storageIdentifier.'" (see `occ files_external:backends storage '.$storageIdentifier.'` for possible values)</error>'); |
|
145 | 145 | return 1; |
146 | 146 | } |
147 | 147 | |
148 | 148 | $config = []; |
149 | 149 | foreach ($configInput as $configOption) { |
150 | 150 | if (!strpos($configOption, '=')) { |
151 | - $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>'); |
|
151 | + $output->writeln('<error>Invalid mount configuration option "'.$configOption.'"</error>'); |
|
152 | 152 | return 1; |
153 | 153 | } |
154 | 154 | list($key, $value) = explode('=', $configOption, 2); |
155 | 155 | if (!$this->validateParam($key, $value, $storageBackend, $authBackend)) { |
156 | - $output->writeln('<error>Unknown configuration for backends "' . $key . '"</error>'); |
|
156 | + $output->writeln('<error>Unknown configuration for backends "'.$key.'"</error>'); |
|
157 | 157 | return 1; |
158 | 158 | } |
159 | 159 | $config[$key] = $value; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | if ($user) { |
169 | 169 | if (!$this->userManager->userExists($user)) { |
170 | - $output->writeln('<error>User "' . $user . '" not found</error>'); |
|
170 | + $output->writeln('<error>User "'.$user.'" not found</error>'); |
|
171 | 171 | return 1; |
172 | 172 | } |
173 | 173 | $mount->setApplicableUsers([$user]); |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } else { |
179 | 179 | $this->getStorageService($user)->addStorage($mount); |
180 | 180 | if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
181 | - $output->writeln('<info>Storage created with id ' . $mount->getId() . '</info>'); |
|
181 | + $output->writeln('<info>Storage created with id '.$mount->getId().'</info>'); |
|
182 | 182 | } else { |
183 | - $output->writeln((string)$mount->getId()); |
|
183 | + $output->writeln((string) $mount->getId()); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | return 0; |
@@ -21,62 +21,62 @@ |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | return [ |
24 | - 'routes' => [ |
|
25 | - [ |
|
26 | - 'name' => 'RateLimitTest#userAndAnonProtected', |
|
27 | - 'url' => '/userAndAnonProtected', |
|
28 | - 'verb' => 'GET', |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'RateLimitTest#onlyAnonProtected', |
|
32 | - 'url' => '/anonProtected', |
|
33 | - 'verb' => 'GET', |
|
34 | - ], |
|
35 | - ], |
|
24 | + 'routes' => [ |
|
25 | + [ |
|
26 | + 'name' => 'RateLimitTest#userAndAnonProtected', |
|
27 | + 'url' => '/userAndAnonProtected', |
|
28 | + 'verb' => 'GET', |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'RateLimitTest#onlyAnonProtected', |
|
32 | + 'url' => '/anonProtected', |
|
33 | + 'verb' => 'GET', |
|
34 | + ], |
|
35 | + ], |
|
36 | 36 | |
37 | - 'ocs' => [ |
|
38 | - [ |
|
39 | - 'name' => 'Config#setAppValue', |
|
40 | - 'url' => '/api/v1/app/{appid}/{configkey}', |
|
41 | - 'verb' => 'POST', |
|
42 | - ], |
|
43 | - [ |
|
44 | - 'name' => 'Config#deleteAppValue', |
|
45 | - 'url' => '/api/v1/app/{appid}/{configkey}', |
|
46 | - 'verb' => 'DELETE', |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'Locking#isLockingEnabled', |
|
50 | - 'url' => '/api/v1/lockprovisioning', |
|
51 | - 'verb' => 'GET', |
|
52 | - ], |
|
53 | - [ |
|
54 | - 'name' => 'Locking#isLocked', |
|
55 | - 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
56 | - 'verb' => 'GET', |
|
57 | - ], |
|
58 | - [ |
|
59 | - 'name' => 'Locking#acquireLock', |
|
60 | - 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
61 | - 'verb' => 'POST', |
|
62 | - ], |
|
63 | - [ |
|
64 | - 'name' => 'Locking#changeLock', |
|
65 | - 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
66 | - 'verb' => 'PUT', |
|
67 | - ], |
|
68 | - [ |
|
69 | - 'name' => 'Locking#releaseLock', |
|
70 | - 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
71 | - 'verb' => 'DELETE', |
|
72 | - ], |
|
73 | - [ |
|
74 | - 'name' => 'Locking#releaseAll', |
|
75 | - 'url' => '/api/v1/lockprovisioning/{type}', |
|
76 | - 'verb' => 'DELETE', |
|
77 | - 'defaults' => [ |
|
78 | - 'type' => null |
|
79 | - ] |
|
80 | - ], |
|
81 | - ], |
|
37 | + 'ocs' => [ |
|
38 | + [ |
|
39 | + 'name' => 'Config#setAppValue', |
|
40 | + 'url' => '/api/v1/app/{appid}/{configkey}', |
|
41 | + 'verb' => 'POST', |
|
42 | + ], |
|
43 | + [ |
|
44 | + 'name' => 'Config#deleteAppValue', |
|
45 | + 'url' => '/api/v1/app/{appid}/{configkey}', |
|
46 | + 'verb' => 'DELETE', |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'Locking#isLockingEnabled', |
|
50 | + 'url' => '/api/v1/lockprovisioning', |
|
51 | + 'verb' => 'GET', |
|
52 | + ], |
|
53 | + [ |
|
54 | + 'name' => 'Locking#isLocked', |
|
55 | + 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
56 | + 'verb' => 'GET', |
|
57 | + ], |
|
58 | + [ |
|
59 | + 'name' => 'Locking#acquireLock', |
|
60 | + 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
61 | + 'verb' => 'POST', |
|
62 | + ], |
|
63 | + [ |
|
64 | + 'name' => 'Locking#changeLock', |
|
65 | + 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
66 | + 'verb' => 'PUT', |
|
67 | + ], |
|
68 | + [ |
|
69 | + 'name' => 'Locking#releaseLock', |
|
70 | + 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
71 | + 'verb' => 'DELETE', |
|
72 | + ], |
|
73 | + [ |
|
74 | + 'name' => 'Locking#releaseAll', |
|
75 | + 'url' => '/api/v1/lockprovisioning/{type}', |
|
76 | + 'verb' => 'DELETE', |
|
77 | + 'defaults' => [ |
|
78 | + 'type' => null |
|
79 | + ] |
|
80 | + ], |
|
81 | + ], |
|
82 | 82 | ]; |
@@ -32,14 +32,14 @@ |
||
32 | 32 | * @since 9.1.0 |
33 | 33 | */ |
34 | 34 | class OCSNotFoundException extends OCSException { |
35 | - /** |
|
36 | - * OCSNotFoundException constructor. |
|
37 | - * |
|
38 | - * @param string $message |
|
39 | - * @param Exception|null $previous |
|
40 | - * @since 9.1.0 |
|
41 | - */ |
|
42 | - public function __construct($message = '', Exception $previous = null) { |
|
43 | - parent::__construct($message, Http::STATUS_NOT_FOUND, $previous); |
|
44 | - } |
|
35 | + /** |
|
36 | + * OCSNotFoundException constructor. |
|
37 | + * |
|
38 | + * @param string $message |
|
39 | + * @param Exception|null $previous |
|
40 | + * @since 9.1.0 |
|
41 | + */ |
|
42 | + public function __construct($message = '', Exception $previous = null) { |
|
43 | + parent::__construct($message, Http::STATUS_NOT_FOUND, $previous); |
|
44 | + } |
|
45 | 45 | } |
@@ -32,14 +32,14 @@ |
||
32 | 32 | * @since 9.1.0 |
33 | 33 | */ |
34 | 34 | class OCSForbiddenException extends OCSException { |
35 | - /** |
|
36 | - * OCSForbiddenException constructor. |
|
37 | - * |
|
38 | - * @param string $message |
|
39 | - * @param Exception|null $previous |
|
40 | - * @since 9.1.0 |
|
41 | - */ |
|
42 | - public function __construct($message = '', Exception $previous = null) { |
|
43 | - parent::__construct($message, Http::STATUS_FORBIDDEN, $previous); |
|
44 | - } |
|
35 | + /** |
|
36 | + * OCSForbiddenException constructor. |
|
37 | + * |
|
38 | + * @param string $message |
|
39 | + * @param Exception|null $previous |
|
40 | + * @since 9.1.0 |
|
41 | + */ |
|
42 | + public function __construct($message = '', Exception $previous = null) { |
|
43 | + parent::__construct($message, Http::STATUS_FORBIDDEN, $previous); |
|
44 | + } |
|
45 | 45 | } |
@@ -32,14 +32,14 @@ |
||
32 | 32 | * @since 9.1.0 |
33 | 33 | */ |
34 | 34 | class OCSBadRequestException extends OCSException { |
35 | - /** |
|
36 | - * OCSBadRequestException constructor. |
|
37 | - * |
|
38 | - * @param string $message |
|
39 | - * @param Exception|null $previous |
|
40 | - * @since 9.1.0 |
|
41 | - */ |
|
42 | - public function __construct($message = '', Exception $previous = null) { |
|
43 | - parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous); |
|
44 | - } |
|
35 | + /** |
|
36 | + * OCSBadRequestException constructor. |
|
37 | + * |
|
38 | + * @param string $message |
|
39 | + * @param Exception|null $previous |
|
40 | + * @since 9.1.0 |
|
41 | + */ |
|
42 | + public function __construct($message = '', Exception $previous = null) { |
|
43 | + parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous); |
|
44 | + } |
|
45 | 45 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | public function __construct($arguments) { |
51 | 51 | $this->user = $arguments['user']; |
52 | 52 | $datadir = $this->user->getHome(); |
53 | - $this->id = 'home::' . $this->user->getUID(); |
|
53 | + $this->id = 'home::'.$this->user->getUID(); |
|
54 | 54 | |
55 | 55 | parent::__construct(['datadir' => $datadir]); |
56 | 56 | } |
@@ -33,80 +33,80 @@ |
||
33 | 33 | * Specialized version of Local storage for home directory usage |
34 | 34 | */ |
35 | 35 | class Home extends Local implements \OCP\Files\IHomeStorage { |
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - protected $id; |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + protected $id; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var \OC\User\User $user |
|
43 | - */ |
|
44 | - protected $user; |
|
41 | + /** |
|
42 | + * @var \OC\User\User $user |
|
43 | + */ |
|
44 | + protected $user; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Construct a Home storage instance |
|
48 | - * |
|
49 | - * @param array $arguments array with "user" containing the |
|
50 | - * storage owner |
|
51 | - */ |
|
52 | - public function __construct($arguments) { |
|
53 | - $this->user = $arguments['user']; |
|
54 | - $datadir = $this->user->getHome(); |
|
55 | - $this->id = 'home::' . $this->user->getUID(); |
|
46 | + /** |
|
47 | + * Construct a Home storage instance |
|
48 | + * |
|
49 | + * @param array $arguments array with "user" containing the |
|
50 | + * storage owner |
|
51 | + */ |
|
52 | + public function __construct($arguments) { |
|
53 | + $this->user = $arguments['user']; |
|
54 | + $datadir = $this->user->getHome(); |
|
55 | + $this->id = 'home::' . $this->user->getUID(); |
|
56 | 56 | |
57 | - parent::__construct(['datadir' => $datadir]); |
|
58 | - } |
|
57 | + parent::__construct(['datadir' => $datadir]); |
|
58 | + } |
|
59 | 59 | |
60 | - public function getId() { |
|
61 | - return $this->id; |
|
62 | - } |
|
60 | + public function getId() { |
|
61 | + return $this->id; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return \OC\Files\Cache\HomeCache |
|
66 | - */ |
|
67 | - public function getCache($path = '', $storage = null) { |
|
68 | - if (!$storage) { |
|
69 | - $storage = $this; |
|
70 | - } |
|
71 | - if (!isset($this->cache)) { |
|
72 | - $this->cache = new \OC\Files\Cache\HomeCache($storage); |
|
73 | - } |
|
74 | - return $this->cache; |
|
75 | - } |
|
64 | + /** |
|
65 | + * @return \OC\Files\Cache\HomeCache |
|
66 | + */ |
|
67 | + public function getCache($path = '', $storage = null) { |
|
68 | + if (!$storage) { |
|
69 | + $storage = $this; |
|
70 | + } |
|
71 | + if (!isset($this->cache)) { |
|
72 | + $this->cache = new \OC\Files\Cache\HomeCache($storage); |
|
73 | + } |
|
74 | + return $this->cache; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * get a propagator instance for the cache |
|
79 | - * |
|
80 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher |
|
81 | - * @return \OC\Files\Cache\Propagator |
|
82 | - */ |
|
83 | - public function getPropagator($storage = null) { |
|
84 | - if (!$storage) { |
|
85 | - $storage = $this; |
|
86 | - } |
|
87 | - if (!isset($this->propagator)) { |
|
88 | - $this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection()); |
|
89 | - } |
|
90 | - return $this->propagator; |
|
91 | - } |
|
77 | + /** |
|
78 | + * get a propagator instance for the cache |
|
79 | + * |
|
80 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher |
|
81 | + * @return \OC\Files\Cache\Propagator |
|
82 | + */ |
|
83 | + public function getPropagator($storage = null) { |
|
84 | + if (!$storage) { |
|
85 | + $storage = $this; |
|
86 | + } |
|
87 | + if (!isset($this->propagator)) { |
|
88 | + $this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection()); |
|
89 | + } |
|
90 | + return $this->propagator; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Returns the owner of this home storage |
|
96 | - * |
|
97 | - * @return \OC\User\User owner of this home storage |
|
98 | - */ |
|
99 | - public function getUser() { |
|
100 | - return $this->user; |
|
101 | - } |
|
94 | + /** |
|
95 | + * Returns the owner of this home storage |
|
96 | + * |
|
97 | + * @return \OC\User\User owner of this home storage |
|
98 | + */ |
|
99 | + public function getUser() { |
|
100 | + return $this->user; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * get the owner of a path |
|
105 | - * |
|
106 | - * @param string $path The path to get the owner |
|
107 | - * @return string uid or false |
|
108 | - */ |
|
109 | - public function getOwner($path) { |
|
110 | - return $this->user->getUID(); |
|
111 | - } |
|
103 | + /** |
|
104 | + * get the owner of a path |
|
105 | + * |
|
106 | + * @param string $path The path to get the owner |
|
107 | + * @return string uid or false |
|
108 | + */ |
|
109 | + public function getOwner($path) { |
|
110 | + return $this->user->getUID(); |
|
111 | + } |
|
112 | 112 | } |
@@ -31,33 +31,33 @@ |
||
31 | 31 | |
32 | 32 | class EMailProvider implements IProvider { |
33 | 33 | |
34 | - /** @var IActionFactory */ |
|
35 | - private $actionFactory; |
|
36 | - |
|
37 | - /** @var IURLGenerator */ |
|
38 | - private $urlGenerator; |
|
39 | - |
|
40 | - /** |
|
41 | - * @param IActionFactory $actionFactory |
|
42 | - * @param IURLGenerator $urlGenerator |
|
43 | - */ |
|
44 | - public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) { |
|
45 | - $this->actionFactory = $actionFactory; |
|
46 | - $this->urlGenerator = $urlGenerator; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @param IEntry $entry |
|
51 | - */ |
|
52 | - public function process(IEntry $entry) { |
|
53 | - $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); |
|
54 | - foreach ($entry->getEMailAddresses() as $address) { |
|
55 | - if (empty($address)) { |
|
56 | - // Skip |
|
57 | - continue; |
|
58 | - } |
|
59 | - $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address); |
|
60 | - $entry->addAction($action); |
|
61 | - } |
|
62 | - } |
|
34 | + /** @var IActionFactory */ |
|
35 | + private $actionFactory; |
|
36 | + |
|
37 | + /** @var IURLGenerator */ |
|
38 | + private $urlGenerator; |
|
39 | + |
|
40 | + /** |
|
41 | + * @param IActionFactory $actionFactory |
|
42 | + * @param IURLGenerator $urlGenerator |
|
43 | + */ |
|
44 | + public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) { |
|
45 | + $this->actionFactory = $actionFactory; |
|
46 | + $this->urlGenerator = $urlGenerator; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @param IEntry $entry |
|
51 | + */ |
|
52 | + public function process(IEntry $entry) { |
|
53 | + $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); |
|
54 | + foreach ($entry->getEMailAddresses() as $address) { |
|
55 | + if (empty($address)) { |
|
56 | + // Skip |
|
57 | + continue; |
|
58 | + } |
|
59 | + $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address); |
|
60 | + $entry->addAction($action); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | } |