aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Federation/Exceptions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Federation/Exceptions')
-rw-r--r--lib/public/Federation/Exceptions/ActionNotSupportedException.php30
-rw-r--r--lib/public/Federation/Exceptions/AuthenticationFailedException.php30
-rw-r--r--lib/public/Federation/Exceptions/BadRequestException.php62
-rw-r--r--lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php32
-rw-r--r--lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php32
-rw-r--r--lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php31
6 files changed, 217 insertions, 0 deletions
diff --git a/lib/public/Federation/Exceptions/ActionNotSupportedException.php b/lib/public/Federation/Exceptions/ActionNotSupportedException.php
new file mode 100644
index 00000000000..7f0e0f46907
--- /dev/null
+++ b/lib/public/Federation/Exceptions/ActionNotSupportedException.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Federation\Exceptions;
+
+use OCP\HintException;
+
+/**
+ * Class ActionNotSupportedException
+ *
+ *
+ * @since 14.0.0
+ */
+class ActionNotSupportedException extends HintException {
+ /**
+ * ActionNotSupportedException constructor.
+ *
+ * @since 14.0.0
+ *
+ */
+ public function __construct($action) {
+ $l = \OCP\Util::getL10N('federation');
+ $message = 'Action "' . $action . '" not supported or implemented.';
+ $hint = $l->t('Action "%s" not supported or implemented.', [$action]);
+ parent::__construct($message, $hint);
+ }
+}
diff --git a/lib/public/Federation/Exceptions/AuthenticationFailedException.php b/lib/public/Federation/Exceptions/AuthenticationFailedException.php
new file mode 100644
index 00000000000..6ce5314844e
--- /dev/null
+++ b/lib/public/Federation/Exceptions/AuthenticationFailedException.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Federation\Exceptions;
+
+use OCP\HintException;
+
+/**
+ * Class AuthenticationFailedException
+ *
+ *
+ * @since 14.0.0
+ */
+class AuthenticationFailedException extends HintException {
+ /**
+ * BadRequestException constructor.
+ *
+ * @since 14.0.0
+ *
+ */
+ public function __construct() {
+ $l = \OCP\Util::getL10N('federation');
+ $message = 'Authentication failed, wrong token or provider ID given';
+ $hint = $l->t('Authentication failed, wrong token or provider ID given');
+ parent::__construct($message, $hint);
+ }
+}
diff --git a/lib/public/Federation/Exceptions/BadRequestException.php b/lib/public/Federation/Exceptions/BadRequestException.php
new file mode 100644
index 00000000000..0210437a8d5
--- /dev/null
+++ b/lib/public/Federation/Exceptions/BadRequestException.php
@@ -0,0 +1,62 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Federation\Exceptions;
+
+use OCP\HintException;
+
+/**
+ * Class BadRequestException
+ *
+ *
+ * @since 14.0.0
+ */
+class BadRequestException extends HintException {
+ /**
+ * @var string[] $parameterList
+ */
+ private $parameterList;
+
+ /**
+ * BadRequestException constructor.
+ *
+ * @since 14.0.0
+ *
+ * @param array $missingParameters
+ */
+ public function __construct(array $missingParameters) {
+ $l = \OCP\Util::getL10N('federation');
+ $this->parameterList = $missingParameters;
+ $parameterList = implode(',', $missingParameters);
+ $message = 'Parameters missing in order to complete the request. Missing Parameters: ' . $parameterList;
+ $hint = $l->t('Parameters missing in order to complete the request. Missing Parameters: "%s"', [$parameterList]);
+ parent::__construct($message, $hint);
+ }
+
+ /**
+ * get array with the return message as defined in the OCM API
+ *
+ * @since 14.0.0
+ *
+ * @return array{message: string, validationErrors: array{message: string, name: string}[]}
+ */
+ public function getReturnMessage() {
+ $result = [
+ 'message' => 'RESOURCE_NOT_FOUND',
+ 'validationErrors' => [
+ ]
+ ];
+
+ foreach ($this->parameterList as $missingParameter) {
+ $result['validationErrors'][] = [
+ 'name' => $missingParameter,
+ 'message' => 'NOT_FOUND'
+ ];
+ }
+
+ return $result;
+ }
+}
diff --git a/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php b/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php
new file mode 100644
index 00000000000..f753f5f3326
--- /dev/null
+++ b/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Federation\Exceptions;
+
+use OCP\HintException;
+
+/**
+ * Class ProviderAlreadyExistsException
+ *
+ *
+ * @since 14.0.0
+ */
+class ProviderAlreadyExistsException extends HintException {
+ /**
+ * ProviderAlreadyExistsException constructor.
+ *
+ * @since 14.0.0
+ *
+ * @param string $newProviderId cloud federation provider ID of the new provider
+ * @param string $existingProviderName name of cloud federation provider which already use the same ID
+ */
+ public function __construct($newProviderId, $existingProviderName) {
+ $l = \OCP\Util::getL10N('federation');
+ $message = 'ID "' . $newProviderId . '" already used by cloud federation provider "' . $existingProviderName . '"';
+ $hint = $l->t('ID "%1$s" already used by cloud federation provider "%2$s"', [$newProviderId, $existingProviderName]);
+ parent::__construct($message, $hint);
+ }
+}
diff --git a/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php b/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php
new file mode 100644
index 00000000000..168eb2b8aeb
--- /dev/null
+++ b/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Federation\Exceptions;
+
+use OCP\AppFramework\Http;
+use OCP\HintException;
+
+/**
+ * Class ProviderCouldNotAddShareException
+ *
+ *
+ * @since 14.0.0
+ */
+class ProviderCouldNotAddShareException extends HintException {
+ /**
+ * ProviderCouldNotAddShareException constructor.
+ *
+ * @since 14.0.0
+ *
+ * @param string $message
+ * @param string $hint
+ * @param int $code
+ * @param \Exception|null $previous
+ */
+ public function __construct($message, $hint = '', $code = Http::STATUS_BAD_REQUEST, ?\Exception $previous = null) {
+ parent::__construct($message, $hint, $code, $previous);
+ }
+}
diff --git a/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php b/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php
new file mode 100644
index 00000000000..64dfcf0f856
--- /dev/null
+++ b/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php
@@ -0,0 +1,31 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Federation\Exceptions;
+
+use OCP\HintException;
+
+/**
+ * Class ProviderDoesNotExistsException
+ *
+ *
+ * @since 14.0.0
+ */
+class ProviderDoesNotExistsException extends HintException {
+ /**
+ * ProviderDoesNotExistsException constructor.
+ *
+ * @since 14.0.0
+ *
+ * @param string $providerId cloud federation provider ID
+ */
+ public function __construct($providerId) {
+ $l = \OCP\Util::getL10N('federation');
+ $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.';
+ $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]);
+ parent::__construct($message, $hint);
+ }
+}