You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.8 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Jesús Macias <jmacias@solidgear.es>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin Appelman <robin@icewind.nl>
  11. * @author Robin McCorkell <robin@mccorkell.me.uk>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author Vincent Petry <pvince81@owncloud.com>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. /**
  31. * Public interface of ownCloud for apps to use.
  32. * Files/AlreadyExistsException class
  33. */
  34. // use OCP namespace for all classes that are considered public.
  35. // This means that they should be used by apps instead of the internal ownCloud classes
  36. namespace OCP\Files;
  37. use OC\HintException;
  38. /**
  39. * Storage is temporarily not available
  40. * @since 6.0.0 - since 8.2.1 based on HintException
  41. */
  42. class StorageNotAvailableException extends HintException {
  43. public const STATUS_SUCCESS = 0;
  44. public const STATUS_ERROR = 1;
  45. public const STATUS_INDETERMINATE = 2;
  46. public const STATUS_INCOMPLETE_CONF = 3;
  47. public const STATUS_UNAUTHORIZED = 4;
  48. public const STATUS_TIMEOUT = 5;
  49. public const STATUS_NETWORK_ERROR = 6;
  50. /**
  51. * StorageNotAvailableException constructor.
  52. *
  53. * @param string $message
  54. * @param int $code
  55. * @param \Exception|null $previous
  56. * @since 6.0.0
  57. */
  58. public function __construct($message = '', $code = self::STATUS_ERROR, \Exception $previous = null) {
  59. $l = \OC::$server->getL10N('core');
  60. parent::__construct($message, $l->t('Storage is temporarily not available'), $code, $previous);
  61. }
  62. /**
  63. * Get the name for a status code
  64. *
  65. * @param int $code
  66. * @return string
  67. * @since 9.0.0
  68. */
  69. public static function getStateCodeName($code) {
  70. switch ($code) {
  71. case self::STATUS_SUCCESS:
  72. return 'ok';
  73. case self::STATUS_ERROR:
  74. return 'error';
  75. case self::STATUS_INDETERMINATE:
  76. return 'indeterminate';
  77. case self::STATUS_UNAUTHORIZED:
  78. return 'unauthorized';
  79. case self::STATUS_TIMEOUT:
  80. return 'timeout';
  81. case self::STATUS_NETWORK_ERROR:
  82. return 'network error';
  83. default:
  84. return 'unknown';
  85. }
  86. }
  87. }