Browse Source

Migrate HintException to OCP

Signed-off-by: Gary Kim <gary@garykim.dev>
pull/26681/head
Gary Kim 4 years ago
parent
commit
b78f3a57d1
No known key found for this signature in database GPG Key ID: 9349B59FB54594AC
  1. 2
      apps/encryption/lib/Command/FixEncryptedVersion.php
  2. 2
      apps/federatedfilesharing/lib/AddressHandler.php
  3. 2
      apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
  4. 2
      apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
  5. 6
      apps/federatedfilesharing/lib/FederatedShareProvider.php
  6. 6
      apps/federatedfilesharing/lib/Notifications.php
  7. 2
      apps/federatedfilesharing/lib/Notifier.php
  8. 11
      apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
  9. 2
      apps/federatedfilesharing/tests/AddressHandlerTest.php
  10. 2
      apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
  11. 2
      apps/federation/lib/Controller/SettingsController.php
  12. 2
      apps/federation/lib/DbHandler.php
  13. 2
      apps/federation/lib/Middleware/AddServerMiddleware.php
  14. 2
      apps/federation/lib/TrustedServers.php
  15. 4
      apps/federation/tests/Controller/SettingsControllerTest.php
  16. 2
      apps/federation/tests/Middleware/AddServerMiddlewareTest.php
  17. 2
      apps/federation/tests/TrustedServersTest.php
  18. 4
      apps/files_sharing/lib/Controller/ShareController.php
  19. 6
      apps/provisioning_api/lib/Controller/UsersController.php
  20. 2
      apps/settings/lib/Controller/ChangePasswordController.php
  21. 2
      apps/sharebymail/lib/ShareByMailProvider.php
  22. 2
      apps/sharebymail/tests/ShareByMailProviderTest.php
  23. 2
      apps/user_ldap/lib/Access.php
  24. 4
      apps/user_ldap/lib/Controller/RenewPasswordController.php
  25. 2
      apps/user_ldap/tests/AccessTest.php
  26. 6
      apps/user_ldap/tests/User_LDAPTest.php
  27. 6
      core/Controller/LostController.php
  28. 2
      index.php
  29. 2
      lib/base.php
  30. 1
      lib/composer/composer/autoload_classmap.php
  31. 1
      lib/composer/composer/autoload_static.php
  32. 3
      lib/private/AppFramework/App.php
  33. 2
      lib/private/Config.php
  34. 2
      lib/private/DatabaseSetupException.php
  35. 71
      lib/private/HintException.php
  36. 1
      lib/private/Installer.php
  37. 2
      lib/private/Log/ExceptionSerializer.php
  38. 2
      lib/private/Log/Systemdlog.php
  39. 4
      lib/private/Memcache/Factory.php
  40. 2
      lib/private/Memcache/Memcached.php
  41. 2
      lib/private/Setup.php
  42. 2
      lib/private/Share20/Manager.php
  43. 1
      lib/private/Updater.php
  44. 2
      lib/private/User/Manager.php
  45. 4
      lib/private/legacy/OC_Hook.php
  46. 12
      lib/private/legacy/OC_Util.php
  47. 2
      lib/public/Encryption/Exceptions/GenericEncryptionException.php
  48. 2
      lib/public/Federation/Exceptions/ActionNotSupportedException.php
  49. 2
      lib/public/Federation/Exceptions/AuthenticationFailedException.php
  50. 2
      lib/public/Federation/Exceptions/BadRequestException.php
  51. 2
      lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php
  52. 2
      lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php
  53. 2
      lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php
  54. 2
      lib/public/Files/StorageNotAvailableException.php
  55. 82
      lib/public/HintException.php
  56. 2
      lib/public/Share/Exceptions/GenericShareException.php
  57. 2
      tests/Core/Controller/ChangePasswordControllerTest.php
  58. 2
      tests/lib/Memcache/FactoryTest.php
  59. 2
      tests/lib/Share20/ManagerTest.php
  60. 6
      tests/lib/User/DatabaseTest.php

2
apps/encryption/lib/Command/FixEncryptedVersion.php

@ -23,9 +23,9 @@
namespace OCA\Encryption\Command; namespace OCA\Encryption\Command;
use OC\Files\View; use OC\Files\View;
use OC\HintException;
use OCA\Encryption\Util; use OCA\Encryption\Util;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
use OCP\HintException;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use OCP\IUserManager; use OCP\IUserManager;

2
apps/federatedfilesharing/lib/AddressHandler.php

@ -25,8 +25,8 @@
*/ */
namespace OCA\FederatedFileSharing; namespace OCA\FederatedFileSharing;
use OC\HintException;
use OCP\Federation\ICloudIdManager; use OCP\Federation\ICloudIdManager;
use OCP\HintException;
use OCP\IL10N; use OCP\IL10N;
use OCP\IURLGenerator; use OCP\IURLGenerator;

2
apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php

@ -31,7 +31,6 @@
*/ */
namespace OCA\FederatedFileSharing\Controller; namespace OCA\FederatedFileSharing\Controller;
use OC\HintException;
use OCA\FederatedFileSharing\AddressHandler; use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
@ -39,6 +38,7 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCP\Constants; use OCP\Constants;
use OCP\Federation\ICloudIdManager; use OCP\Federation\ICloudIdManager;
use OCP\HintException;
use OCP\Http\Client\IClientService; use OCP\Http\Client\IClientService;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;

2
apps/federatedfilesharing/lib/Controller/RequestHandlerController.php

@ -230,7 +230,7 @@ class RequestHandlerController extends OCSController {
* @return Http\DataResponse * @return Http\DataResponse
* @throws OCSException * @throws OCSException
* @throws ShareNotFound * @throws ShareNotFound
* @throws \OC\HintException
* @throws \OCP\HintException
*/ */
public function acceptShare($id) { public function acceptShare($id) {
$token = isset($_POST['token']) ? $_POST['token'] : null; $token = isset($_POST['token']) ? $_POST['token'] : null;

6
apps/federatedfilesharing/lib/FederatedShareProvider.php

@ -441,7 +441,7 @@ class FederatedShareProvider implements IShareProvider {
* *
* @param IShare $share * @param IShare $share
* @throws ShareNotFound * @throws ShareNotFound
* @throws \OC\HintException
* @throws \OCP\HintException
*/ */
protected function sendPermissionUpdate(IShare $share) { protected function sendPermissionUpdate(IShare $share) {
$remoteId = $this->getRemoteId($share); $remoteId = $this->getRemoteId($share);
@ -550,7 +550,7 @@ class FederatedShareProvider implements IShareProvider {
* *
* @param IShare $share * @param IShare $share
* @throws ShareNotFound * @throws ShareNotFound
* @throws \OC\HintException
* @throws \OCP\HintException
*/ */
public function delete(IShare $share) { public function delete(IShare $share) {
[, $remote] = $this->addressHandler->splitUserRemote($share->getSharedWith()); [, $remote] = $this->addressHandler->splitUserRemote($share->getSharedWith());
@ -577,7 +577,7 @@ class FederatedShareProvider implements IShareProvider {
* @param IShare $share * @param IShare $share
* @param bool $isOwner the user can either be the owner or the user who re-sahred it * @param bool $isOwner the user can either be the owner or the user who re-sahred it
* @throws ShareNotFound * @throws ShareNotFound
* @throws \OC\HintException
* @throws \OCP\HintException
*/ */
protected function revokeShare($share, $isOwner) { protected function revokeShare($share, $isOwner) {
if ($this->userManager->userExists($share->getShareOwner()) && $this->userManager->userExists($share->getSharedBy())) { if ($this->userManager->userExists($share->getShareOwner()) && $this->userManager->userExists($share->getSharedBy())) {

6
apps/federatedfilesharing/lib/Notifications.php

@ -34,8 +34,8 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\ICloudFederationProviderManager;
use OCP\Http\Client\IClientService; use OCP\Http\Client\IClientService;
use OCP\OCS\IDiscoveryService;
use OCP\ILogger; use OCP\ILogger;
use OCP\OCS\IDiscoveryService;
class Notifications { class Notifications {
public const RESPONSE_FORMAT = 'json'; // default response format for ocs calls public const RESPONSE_FORMAT = 'json'; // default response format for ocs calls
@ -97,7 +97,7 @@ class Notifications {
* @param string $sharedByFederatedId * @param string $sharedByFederatedId
* @param int $shareType (can be a remote user or group share) * @param int $shareType (can be a remote user or group share)
* @return bool * @return bool
* @throws \OC\HintException
* @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException * @throws \OC\ServerNotAvailableException
*/ */
public function sendRemoteShare($token, $shareWith, $name, $remoteId, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) { public function sendRemoteShare($token, $shareWith, $name, $remoteId, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) {
@ -156,7 +156,7 @@ class Notifications {
* @param int $permission * @param int $permission
* @param string $filename * @param string $filename
* @return array|false * @return array|false
* @throws \OC\HintException
* @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException * @throws \OC\ServerNotAvailableException
*/ */
public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename) { public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename) {

2
apps/federatedfilesharing/lib/Notifier.php

@ -27,10 +27,10 @@
*/ */
namespace OCA\FederatedFileSharing; namespace OCA\FederatedFileSharing;
use OC\HintException;
use OCP\Contacts\IManager; use OCP\Contacts\IManager;
use OCP\Federation\ICloudId; use OCP\Federation\ICloudId;
use OCP\Federation\ICloudIdManager; use OCP\Federation\ICloudIdManager;
use OCP\HintException;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\L10N\IFactory; use OCP\L10N\IFactory;
use OCP\Notification\INotification; use OCP\Notification\INotification;

11
apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php

@ -30,7 +30,6 @@ namespace OCA\FederatedFileSharing\OCM;
use OC\AppFramework\Http; use OC\AppFramework\Http;
use OC\Files\Filesystem; use OC\Files\Filesystem;
use OC\HintException;
use OCA\FederatedFileSharing\AddressHandler; use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Sharing\Activity\Providers\RemoteShares; use OCA\Files_Sharing\Activity\Providers\RemoteShares;
@ -48,6 +47,7 @@ use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudFederationShare; use OCP\Federation\ICloudFederationShare;
use OCP\Federation\ICloudIdManager; use OCP\Federation\ICloudIdManager;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\HintException;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\IGroupManager; use OCP\IGroupManager;
@ -55,7 +55,6 @@ use OCP\ILogger;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\Notification\IManager as INotificationManager; use OCP\Notification\IManager as INotificationManager;
use OCP\Share;
use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager; use OCP\Share\IManager;
use OCP\Share\IShare; use OCP\Share\IShare;
@ -176,7 +175,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* *
* @throws ProviderCouldNotAddShareException * @throws ProviderCouldNotAddShareException
* @throws \OCP\AppFramework\QueryException * @throws \OCP\AppFramework\QueryException
* @throws \OC\HintException
* @throws HintException
* @since 14.0.0 * @since 14.0.0
*/ */
public function shareReceived(ICloudFederationShare $share) { public function shareReceived(ICloudFederationShare $share) {
@ -305,7 +304,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @throws ActionNotSupportedException * @throws ActionNotSupportedException
* @throws AuthenticationFailedException * @throws AuthenticationFailedException
* @throws BadRequestException * @throws BadRequestException
* @throws \OC\HintException
* @throws HintException
* @since 14.0.0 * @since 14.0.0
*/ */
public function notificationReceived($notificationType, $providerId, array $notification) { public function notificationReceived($notificationType, $providerId, array $notification) {
@ -373,7 +372,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @throws ActionNotSupportedException * @throws ActionNotSupportedException
* @throws AuthenticationFailedException * @throws AuthenticationFailedException
* @throws BadRequestException * @throws BadRequestException
* @throws \OC\HintException
* @throws HintException
*/ */
private function shareAccepted($id, array $notification) { private function shareAccepted($id, array $notification) {
if (!$this->isS2SEnabled()) { if (!$this->isS2SEnabled()) {
@ -442,7 +441,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @throws AuthenticationFailedException * @throws AuthenticationFailedException
* @throws BadRequestException * @throws BadRequestException
* @throws ShareNotFound * @throws ShareNotFound
* @throws \OC\HintException
* @throws HintException
* *
*/ */
protected function shareDeclined($id, array $notification) { protected function shareDeclined($id, array $notification) {

2
apps/federatedfilesharing/tests/AddressHandlerTest.php

@ -136,7 +136,7 @@ class AddressHandlerTest extends \Test\TestCase {
* @param string $id * @param string $id
*/ */
public function testSplitUserRemoteError($id) { public function testSplitUserRemoteError($id) {
$this->expectException(\OC\HintException::class);
$this->expectException(\OCP\HintException::class);
$this->addressHandler->splitUserRemote($id); $this->addressHandler->splitUserRemote($id);
} }

2
apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php

@ -29,7 +29,6 @@
namespace OCA\FederatedFileSharing\Tests\Controller; namespace OCA\FederatedFileSharing\Tests\Controller;
use OC\Federation\CloudIdManager; use OC\Federation\CloudIdManager;
use OC\HintException;
use OCA\FederatedFileSharing\AddressHandler; use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\Controller\MountPublicLinkController; use OCA\FederatedFileSharing\Controller\MountPublicLinkController;
use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\FederatedShareProvider;
@ -37,6 +36,7 @@ use OCP\AppFramework\Http;
use OCP\Contacts\IManager as IContactsManager; use OCP\Contacts\IManager as IContactsManager;
use OCP\Federation\ICloudIdManager; use OCP\Federation\ICloudIdManager;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
use OCP\HintException;
use OCP\Http\Client\IClientService; use OCP\Http\Client\IClientService;
use OCP\IL10N; use OCP\IL10N;
use OCP\IRequest; use OCP\IRequest;

2
apps/federation/lib/Controller/SettingsController.php

@ -23,10 +23,10 @@
*/ */
namespace OCA\Federation\Controller; namespace OCA\Federation\Controller;
use OC\HintException;
use OCA\Federation\TrustedServers; use OCA\Federation\TrustedServers;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\HintException;
use OCP\IL10N; use OCP\IL10N;
use OCP\IRequest; use OCP\IRequest;

2
apps/federation/lib/DbHandler.php

@ -28,7 +28,7 @@
namespace OCA\Federation; namespace OCA\Federation;
use OC\Files\Filesystem; use OC\Files\Filesystem;
use OC\HintException;
use OCP\HintException;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\IL10N; use OCP\IL10N;

2
apps/federation/lib/Middleware/AddServerMiddleware.php

@ -28,12 +28,12 @@
*/ */
namespace OCA\Federation\Middleware; namespace OCA\Federation\Middleware;
use OC\HintException;
use OCA\Federation\Controller\SettingsController; use OCA\Federation\Controller\SettingsController;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Middleware; use OCP\AppFramework\Middleware;
use OCP\HintException;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;

2
apps/federation/lib/TrustedServers.php

@ -27,11 +27,11 @@
*/ */
namespace OCA\Federation; namespace OCA\Federation;
use OC\HintException;
use OCA\Federation\BackgroundJob\RequestSharedSecret; use OCA\Federation\BackgroundJob\RequestSharedSecret;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Utility\ITimeFactory; use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\IJobList;
use OCP\HintException;
use OCP\Http\Client\IClientService; use OCP\Http\Client\IClientService;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;

4
apps/federation/tests/Controller/SettingsControllerTest.php

@ -88,7 +88,7 @@ class SettingsControllerTest extends TestCase {
* @param bool $isOwnCloud * @param bool $isOwnCloud
*/ */
public function testAddServerFail($isTrustedServer, $isOwnCloud) { public function testAddServerFail($isTrustedServer, $isOwnCloud) {
$this->expectException(\OC\HintException::class);
$this->expectException(\OCP\HintException::class);
$this->trustedServers $this->trustedServers
->expects($this->any()) ->expects($this->any())
@ -136,7 +136,7 @@ class SettingsControllerTest extends TestCase {
* @param bool $isOwnCloud * @param bool $isOwnCloud
*/ */
public function testCheckServerFail($isTrustedServer, $isOwnCloud) { public function testCheckServerFail($isTrustedServer, $isOwnCloud) {
$this->expectException(\OC\HintException::class);
$this->expectException(\OCP\HintException::class);
$this->trustedServers $this->trustedServers
->expects($this->any()) ->expects($this->any())

2
apps/federation/tests/Middleware/AddServerMiddlewareTest.php

@ -26,10 +26,10 @@
*/ */
namespace OCA\Federation\Tests\Middleware; namespace OCA\Federation\Tests\Middleware;
use OC\HintException;
use OCA\Federation\Controller\SettingsController; use OCA\Federation\Controller\SettingsController;
use OCA\Federation\Middleware\AddServerMiddleware; use OCA\Federation\Middleware\AddServerMiddleware;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\HintException;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use Test\TestCase; use Test\TestCase;

2
apps/federation/tests/TrustedServersTest.php

@ -311,7 +311,7 @@ class TrustedServersTest extends TestCase {
* @dataProvider dataTestCheckOwnCloudVersionTooLow * @dataProvider dataTestCheckOwnCloudVersionTooLow
*/ */
public function testCheckOwnCloudVersionTooLow($status) { public function testCheckOwnCloudVersionTooLow($status) {
$this->expectException(\OC\HintException::class);
$this->expectException(\OCP\HintException::class);
$this->expectExceptionMessage('Remote server version is too low. 9.0 is required.'); $this->expectExceptionMessage('Remote server version is too low. 9.0 is required.');
$this->invokePrivate($this->trustedServers, 'checkOwnCloudVersion', [$status]); $this->invokePrivate($this->trustedServers, 'checkOwnCloudVersion', [$status]);

4
apps/files_sharing/lib/Controller/ShareController.php

@ -42,9 +42,9 @@
*/ */
namespace OCA\Files_Sharing\Controller; namespace OCA\Files_Sharing\Controller;
use OC\Security\CSP\ContentSecurityPolicy;
use OC_Files; use OC_Files;
use OC_Util; use OC_Util;
use OC\Security\CSP\ContentSecurityPolicy;
use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Sharing\Activity\Providers\Downloads; use OCA\Files_Sharing\Activity\Providers\Downloads;
use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
@ -242,7 +242,7 @@ class ShareController extends AuthPublicShareController {
* otherwise token * otherwise token
* @param int $errorCode * @param int $errorCode
* @param string $errorMessage * @param string $errorMessage
* @throws \OC\HintException
* @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException * @throws \OC\ServerNotAvailableException
*/ */
protected function emitAccessShareHook($share, $errorCode = 200, $errorMessage = '') { protected function emitAccessShareHook($share, $errorCode = 200, $errorMessage = '') {

6
apps/provisioning_api/lib/Controller/UsersController.php

@ -47,7 +47,6 @@ use libphonenumber\PhoneNumber;
use libphonenumber\PhoneNumberFormat; use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberUtil; use libphonenumber\PhoneNumberUtil;
use OC\Authentication\Token\RemoteWipe; use OC\Authentication\Token\RemoteWipe;
use OC\HintException;
use OC\KnownUser\KnownUserService; use OC\KnownUser\KnownUserService;
use OC\User\Backend; use OC\User\Backend;
use OCA\Settings\Mailer\NewUserMailHelper; use OCA\Settings\Mailer\NewUserMailHelper;
@ -59,6 +58,8 @@ use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCSController; use OCP\AppFramework\OCSController;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\HintException;
use OCP\IConfig; use OCP\IConfig;
use OCP\IGroup; use OCP\IGroup;
use OCP\IGroupManager; use OCP\IGroupManager;
@ -68,9 +69,8 @@ use OCP\IUser;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\L10N\IFactory; use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
use OCP\Security\Events\GenerateSecurePasswordEvent; use OCP\Security\Events\GenerateSecurePasswordEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Security\ISecureRandom;
use OCP\User\Backend\ISetDisplayNameBackend; use OCP\User\Backend\ISetDisplayNameBackend;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;

2
apps/settings/lib/Controller/ChangePasswordController.php

@ -36,11 +36,11 @@
namespace OCA\Settings\Controller; namespace OCA\Settings\Controller;
use OC\Group\Manager as GroupManager; use OC\Group\Manager as GroupManager;
use OC\HintException;
use OC\User\Session; use OC\User\Session;
use OCP\App\IAppManager; use OCP\App\IAppManager;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCP\HintException;
use OCP\IGroupManager; use OCP\IGroupManager;
use OCP\IL10N; use OCP\IL10N;
use OCP\IRequest; use OCP\IRequest;

2
apps/sharebymail/lib/ShareByMailProvider.php

@ -40,7 +40,6 @@
*/ */
namespace OCA\ShareByMail; namespace OCA\ShareByMail;
use OC\HintException;
use OC\Share20\Exception\InvalidShare; use OC\Share20\Exception\InvalidShare;
use OC\Share20\Share; use OC\Share20\Share;
use OC\User\NoUserException; use OC\User\NoUserException;
@ -52,6 +51,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Folder; use OCP\Files\Folder;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
use OCP\Files\Node; use OCP\Files\Node;
use OCP\HintException;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;

2
apps/sharebymail/tests/ShareByMailProviderTest.php

@ -479,7 +479,7 @@ class ShareByMailProviderTest extends TestCase {
public function testCreateMailShareFailed() { public function testCreateMailShareFailed() {
$this->expectException(\OC\HintException::class);
$this->expectException(\OCP\HintException::class);
$this->share->expects($this->any())->method('getToken')->willReturn('token'); $this->share->expects($this->any())->method('getToken')->willReturn('token');
$this->share->expects($this->once())->method('setToken')->with('token'); $this->share->expects($this->once())->method('setToken')->with('token');

2
apps/user_ldap/lib/Access.php

@ -47,7 +47,6 @@
namespace OCA\User_LDAP; namespace OCA\User_LDAP;
use DomainException; use DomainException;
use OC\HintException;
use OC\Hooks\PublicEmitter; use OC\Hooks\PublicEmitter;
use OC\ServerNotAvailableException; use OC\ServerNotAvailableException;
use OCA\User_LDAP\Exceptions\ConstraintViolationException; use OCA\User_LDAP\Exceptions\ConstraintViolationException;
@ -56,6 +55,7 @@ use OCA\User_LDAP\Mapping\AbstractMapping;
use OCA\User_LDAP\Mapping\UserMapping; use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\Manager; use OCA\User_LDAP\User\Manager;
use OCA\User_LDAP\User\OfflineUser; use OCA\User_LDAP\User\OfflineUser;
use OCP\HintException;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use OCP\IUserManager; use OCP\IUserManager;

4
apps/user_ldap/lib/Controller/RenewPasswordController.php

@ -23,10 +23,10 @@
*/ */
namespace OCA\User_LDAP\Controller; namespace OCA\User_LDAP\Controller;
use OC\HintException;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\HintException;
use OCP\IConfig; use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
use OCP\IRequest; use OCP\IRequest;
@ -139,7 +139,7 @@ class RenewPasswordController extends Controller {
]); ]);
return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args)); return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
} }
try { try {
if (!is_null($newPassword) && \OC_User::setPassword($user, $newPassword)) { if (!is_null($newPassword) && \OC_User::setPassword($user, $newPassword)) {
$this->session->set('loginMessages', [ $this->session->set('loginMessages', [

2
apps/user_ldap/tests/AccessTest.php

@ -482,7 +482,7 @@ class AccessTest extends TestCase {
public function testSetPasswordWithRejectedChange() { public function testSetPasswordWithRejectedChange() {
$this->expectException(\OC\HintException::class);
$this->expectException(\OCP\HintException::class);
$this->expectExceptionMessage('Password change rejected.'); $this->expectExceptionMessage('Password change rejected.');
$this->connection $this->connection

6
apps/user_ldap/tests/User_LDAPTest.php

@ -31,7 +31,6 @@
*/ */
namespace OCA\User_LDAP\Tests; namespace OCA\User_LDAP\Tests;
use OC\HintException;
use OC\User\Backend; use OC\User\Backend;
use OC\User\Session; use OC\User\Session;
use OCA\User_LDAP\Access; use OCA\User_LDAP\Access;
@ -44,6 +43,7 @@ use OCA\User_LDAP\User\User;
use OCA\User_LDAP\User_LDAP; use OCA\User_LDAP\User_LDAP;
use OCA\User_LDAP\User_LDAP as UserLDAP; use OCA\User_LDAP\User_LDAP as UserLDAP;
use OCA\User_LDAP\UserPluginManager; use OCA\User_LDAP\UserPluginManager;
use OCP\HintException;
use OCP\IConfig; use OCP\IConfig;
use OCP\IUser; use OCP\IUser;
use OCP\Notification\IManager as INotificationManager; use OCP\Notification\IManager as INotificationManager;
@ -1214,7 +1214,7 @@ class User_LDAPTest extends TestCase {
public function testSetPasswordInvalid() { public function testSetPasswordInvalid() {
$this->expectException(\OC\HintException::class);
$this->expectException(\OCP\HintException::class);
$this->expectExceptionMessage('Password fails quality checking policy'); $this->expectExceptionMessage('Password fails quality checking policy');
$this->prepareAccessForSetPassword($this->access); $this->prepareAccessForSetPassword($this->access);
@ -1359,7 +1359,7 @@ class User_LDAPTest extends TestCase {
public function testSetDisplayNameErrorWithPlugin() { public function testSetDisplayNameErrorWithPlugin() {
$this->expectException(\OC\HintException::class);
$this->expectException(\OCP\HintException::class);
$newDisplayName = 'J. Baker'; $newDisplayName = 'J. Baker';
$this->pluginManager->expects($this->once()) $this->pluginManager->expects($this->once())

6
core/Controller/LostController.php

@ -35,11 +35,8 @@
*/ */
namespace OC\Core\Controller; namespace OC\Core\Controller;
use function array_filter;
use function count;
use OC\Authentication\TwoFactorAuth\Manager; use OC\Authentication\TwoFactorAuth\Manager;
use OC\Core\Exception\ResetPasswordException; use OC\Core\Exception\ResetPasswordException;
use OC\HintException;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
@ -47,6 +44,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Defaults; use OCP\Defaults;
use OCP\Encryption\IEncryptionModule; use OCP\Encryption\IEncryptionModule;
use OCP\Encryption\IManager; use OCP\Encryption\IManager;
use OCP\HintException;
use OCP\IConfig; use OCP\IConfig;
use OCP\IInitialStateService; use OCP\IInitialStateService;
use OCP\IL10N; use OCP\IL10N;
@ -58,6 +56,8 @@ use OCP\IUserManager;
use OCP\Mail\IMailer; use OCP\Mail\IMailer;
use OCP\Security\ICrypto; use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;
use function array_filter;
use function count;
use function reset; use function reset;
/** /**

2
index.php

@ -39,7 +39,7 @@ try {
//show the user a detailed error page //show the user a detailed error page
OC_Template::printExceptionErrorPage($ex, 503); OC_Template::printExceptionErrorPage($ex, 503);
} catch (\OC\HintException $ex) {
} catch (\OCP\HintException $ex) {
try { try {
OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503); OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503);
} catch (Exception $ex2) { } catch (Exception $ex2) {

2
lib/base.php

@ -388,7 +388,7 @@ class OC {
if (!empty($incompatibleShippedApps)) { if (!empty($incompatibleShippedApps)) {
$l = \OC::$server->getL10N('core'); $l = \OC::$server->getL10N('core');
$hint = $l->t('The files of the app %1$s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]); $hint = $l->t('The files of the app %1$s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]);
throw new \OC\HintException('The files of the app ' . implode(', ', $incompatibleShippedApps) . ' were not replaced correctly. Make sure it is a version compatible with the server.', $hint);
throw new \OCP\HintException('The files of the app ' . implode(', ', $incompatibleShippedApps) . ' were not replaced correctly. Make sure it is a version compatible with the server.', $hint);
} }
$tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));

1
lib/composer/composer/autoload_classmap.php

@ -371,6 +371,7 @@ return array(
'OCP\\Group\\Events\\UserAddedEvent' => $baseDir . '/lib/public/Group/Events/UserAddedEvent.php', 'OCP\\Group\\Events\\UserAddedEvent' => $baseDir . '/lib/public/Group/Events/UserAddedEvent.php',
'OCP\\Group\\Events\\UserRemovedEvent' => $baseDir . '/lib/public/Group/Events/UserRemovedEvent.php', 'OCP\\Group\\Events\\UserRemovedEvent' => $baseDir . '/lib/public/Group/Events/UserRemovedEvent.php',
'OCP\\Group\\ISubAdmin' => $baseDir . '/lib/public/Group/ISubAdmin.php', 'OCP\\Group\\ISubAdmin' => $baseDir . '/lib/public/Group/ISubAdmin.php',
'OCP\\HintException' => $baseDir . '/lib/public/HintException.php',
'OCP\\Http\\Client\\IClient' => $baseDir . '/lib/public/Http/Client/IClient.php', 'OCP\\Http\\Client\\IClient' => $baseDir . '/lib/public/Http/Client/IClient.php',
'OCP\\Http\\Client\\IClientService' => $baseDir . '/lib/public/Http/Client/IClientService.php', 'OCP\\Http\\Client\\IClientService' => $baseDir . '/lib/public/Http/Client/IClientService.php',
'OCP\\Http\\Client\\IResponse' => $baseDir . '/lib/public/Http/Client/IResponse.php', 'OCP\\Http\\Client\\IResponse' => $baseDir . '/lib/public/Http/Client/IResponse.php',

1
lib/composer/composer/autoload_static.php

@ -400,6 +400,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Group\\Events\\UserAddedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/UserAddedEvent.php', 'OCP\\Group\\Events\\UserAddedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/UserAddedEvent.php',
'OCP\\Group\\Events\\UserRemovedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/UserRemovedEvent.php', 'OCP\\Group\\Events\\UserRemovedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/UserRemovedEvent.php',
'OCP\\Group\\ISubAdmin' => __DIR__ . '/../../..' . '/lib/public/Group/ISubAdmin.php', 'OCP\\Group\\ISubAdmin' => __DIR__ . '/../../..' . '/lib/public/Group/ISubAdmin.php',
'OCP\\HintException' => __DIR__ . '/../../..' . '/lib/public/HintException.php',
'OCP\\Http\\Client\\IClient' => __DIR__ . '/../../..' . '/lib/public/Http/Client/IClient.php', 'OCP\\Http\\Client\\IClient' => __DIR__ . '/../../..' . '/lib/public/Http/Client/IClient.php',
'OCP\\Http\\Client\\IClientService' => __DIR__ . '/../../..' . '/lib/public/Http/Client/IClientService.php', 'OCP\\Http\\Client\\IClientService' => __DIR__ . '/../../..' . '/lib/public/Http/Client/IClientService.php',
'OCP\\Http\\Client\\IResponse' => __DIR__ . '/../../..' . '/lib/public/Http/Client/IResponse.php', 'OCP\\Http\\Client\\IResponse' => __DIR__ . '/../../..' . '/lib/public/Http/Client/IResponse.php',

3
lib/private/AppFramework/App.php

@ -34,11 +34,11 @@ namespace OC\AppFramework;
use OC\AppFramework\DependencyInjection\DIContainer; use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Http\Dispatcher; use OC\AppFramework\Http\Dispatcher;
use OC\AppFramework\Http\Request; use OC\AppFramework\Http\Request;
use OC\HintException;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\ICallbackResponse; use OCP\AppFramework\Http\ICallbackResponse;
use OCP\AppFramework\Http\IOutput; use OCP\AppFramework\Http\IOutput;
use OCP\AppFramework\QueryException; use OCP\AppFramework\QueryException;
use OCP\HintException;
use OCP\IRequest; use OCP\IRequest;
/** /**
@ -105,6 +105,7 @@ class App {
/** /**
* Shortcut for calling a controller method and printing the result * Shortcut for calling a controller method and printing the result
*
* @param string $controllerName the name of the controller under which it is * @param string $controllerName the name of the controller under which it is
* stored in the DI container * stored in the DI container
* @param string $methodName the method that you want to call * @param string $methodName the method that you want to call

2
lib/private/Config.php

@ -38,6 +38,8 @@
*/ */
namespace OC; namespace OC;
use OCP\HintException;
/** /**
* This class is responsible for reading and writing config.php, the very basic * This class is responsible for reading and writing config.php, the very basic
* configuration file of Nextcloud. * configuration file of Nextcloud.

2
lib/private/DatabaseSetupException.php

@ -22,5 +22,7 @@
*/ */
namespace OC; namespace OC;
use OCP\HintException;
class DatabaseSetupException extends HintException { class DatabaseSetupException extends HintException {
} }

71
lib/private/HintException.php

@ -1,28 +1,28 @@
<?php <?php
declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @copyright Copyright (c) 2021 Gary Kim <gary@garykim.dev>
* *
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Michael Gapczynski <GapczynskiM@gmail.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Gary Kim <gary@garykim.dev>
* *
* @license AGPL-3.0
* @license GNU AGPL version 3 or any later version
* *
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
namespace OC; namespace OC;
/** /**
@ -31,48 +31,7 @@ namespace OC;
* An Exception class with the intention to be presented to the end user * An Exception class with the intention to be presented to the end user
* *
* @package OC * @package OC
* @depreacted 23.0.0 Use \OCP\HintException
*/ */
class HintException extends \Exception {
private $hint;
/**
* HintException constructor.
*
* @param string $message The error message. It will be not revealed to the
* the user (unless the hint is empty) and thus
* should be not translated.
* @param string $hint A useful message that is presented to the end
* user. It should be translated, but must not
* contain sensitive data.
* @param int $code
* @param \Exception|null $previous
*/
public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) {
$this->hint = $hint;
parent::__construct($message, $code, $previous);
}
/**
* Returns a string representation of this Exception that includes the error
* code, the message and the hint.
*
* @return string
*/
public function __toString() {
return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
}
/**
* Returns the hint with the intention to be presented to the end user. If
* an empty hint was specified upon instatiation, the message is returned
* instead.
*
* @return string
*/
public function getHint() {
if (empty($this->hint)) {
return $this->message;
}
return $this->hint;
}
class HintException extends \OCP\HintException {
} }

1
lib/private/Installer.php

@ -48,6 +48,7 @@ use OC\DB\Connection;
use OC\DB\MigrationService; use OC\DB\MigrationService;
use OC_App; use OC_App;
use OC_Helper; use OC_Helper;
use OCP\HintException;
use OCP\Http\Client\IClientService; use OCP\Http\Client\IClientService;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;

2
lib/private/Log/ExceptionSerializer.php

@ -29,10 +29,10 @@
namespace OC\Log; namespace OC\Log;
use OC\Core\Controller\SetupController; use OC\Core\Controller\SetupController;
use OC\HintException;
use OC\Security\IdentityProof\Key; use OC\Security\IdentityProof\Key;
use OC\Setup; use OC\Setup;
use OC\SystemConfig; use OC\SystemConfig;
use OCP\HintException;
class ExceptionSerializer { class ExceptionSerializer {
public const methodsWithSensitiveParameters = [ public const methodsWithSensitiveParameters = [

2
lib/private/Log/Systemdlog.php

@ -25,8 +25,8 @@
*/ */
namespace OC\Log; namespace OC\Log;
use OC\HintException;
use OC\SystemConfig; use OC\SystemConfig;
use OCP\HintException;
use OCP\ILogger; use OCP\ILogger;
use OCP\Log\IWriter; use OCP\Log\IWriter;

4
lib/private/Memcache/Factory.php

@ -86,12 +86,12 @@ class Factory implements ICacheFactory {
$missingCacheMessage = 'Memcache {class} not available for {use} cache'; $missingCacheMessage = 'Memcache {class} not available for {use} cache';
$missingCacheHint = 'Is the matching PHP module installed and enabled?'; $missingCacheHint = 'Is the matching PHP module installed and enabled?';
if (!class_exists($localCacheClass) || !$localCacheClass::isAvailable()) { if (!class_exists($localCacheClass) || !$localCacheClass::isAvailable()) {
throw new \OC\HintException(strtr($missingCacheMessage, [
throw new \OCP\HintException(strtr($missingCacheMessage, [
'{class}' => $localCacheClass, '{use}' => 'local' '{class}' => $localCacheClass, '{use}' => 'local'
]), $missingCacheHint); ]), $missingCacheHint);
} }
if (!class_exists($distributedCacheClass) || !$distributedCacheClass::isAvailable()) { if (!class_exists($distributedCacheClass) || !$distributedCacheClass::isAvailable()) {
throw new \OC\HintException(strtr($missingCacheMessage, [
throw new \OCP\HintException(strtr($missingCacheMessage, [
'{class}' => $distributedCacheClass, '{use}' => 'distributed' '{class}' => $distributedCacheClass, '{use}' => 'distributed'
]), $missingCacheHint); ]), $missingCacheHint);
} }

2
lib/private/Memcache/Memcached.php

@ -31,7 +31,7 @@
*/ */
namespace OC\Memcache; namespace OC\Memcache;
use OC\HintException;
use OCP\HintException;
use OCP\IMemcache; use OCP\IMemcache;
class Memcached extends Cache implements IMemcache { class Memcached extends Cache implements IMemcache {

2
lib/private/Setup.php

@ -224,7 +224,7 @@ class Setup {
try { try {
$util = new \OC_Util(); $util = new \OC_Util();
$htAccessWorking = $util->isHtaccessWorking(\OC::$server->getConfig()); $htAccessWorking = $util->isHtaccessWorking(\OC::$server->getConfig());
} catch (\OC\HintException $e) {
} catch (\OCP\HintException $e) {
$errors[] = [ $errors[] = [
'error' => $e->getMessage(), 'error' => $e->getMessage(),
'exception' => $e, 'exception' => $e,

2
lib/private/Share20/Manager.php

@ -43,7 +43,6 @@ namespace OC\Share20;
use OC\Cache\CappedMemoryCache; use OC\Cache\CappedMemoryCache;
use OC\Files\Mount\MoveableMount; use OC\Files\Mount\MoveableMount;
use OC\HintException;
use OC\Share20\Exception\ProviderException; use OC\Share20\Exception\ProviderException;
use OCA\Files_Sharing\ISharedStorage; use OCA\Files_Sharing\ISharedStorage;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
@ -52,6 +51,7 @@ use OCP\Files\Folder;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager; use OCP\Files\Mount\IMountManager;
use OCP\Files\Node; use OCP\Files\Node;
use OCP\HintException;
use OCP\IConfig; use OCP\IConfig;
use OCP\IGroupManager; use OCP\IGroupManager;
use OCP\IL10N; use OCP\IL10N;

1
lib/private/Updater.php

@ -45,6 +45,7 @@ use OC\DB\MigrationService;
use OC\Hooks\BasicEmitter; use OC\Hooks\BasicEmitter;
use OC\IntegrityCheck\Checker; use OC\IntegrityCheck\Checker;
use OC_App; use OC_App;
use OCP\HintException;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use OCP\Util; use OCP\Util;

2
lib/private/User/Manager.php

@ -33,10 +33,10 @@
*/ */
namespace OC\User; namespace OC\User;
use OC\HintException;
use OC\Hooks\PublicEmitter; use OC\Hooks\PublicEmitter;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\HintException;
use OCP\ICache; use OCP\ICache;
use OCP\ICacheFactory; use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;

4
lib/private/legacy/OC_Hook.php

@ -81,7 +81,7 @@ class OC_Hook {
* @param string $signalName name of signal * @param string $signalName name of signal
* @param mixed $params default: array() array with additional data * @param mixed $params default: array() array with additional data
* @return bool true if slots exists or false if not * @return bool true if slots exists or false if not
* @throws \OC\HintException
* @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException Emits a signal. To get data from the slot use references! * @throws \OC\ServerNotAvailableException Emits a signal. To get data from the slot use references!
* *
* TODO: write example * TODO: write example
@ -107,7 +107,7 @@ class OC_Hook {
} catch (Exception $e) { } catch (Exception $e) {
self::$thrownExceptions[] = $e; self::$thrownExceptions[] = $e;
\OC::$server->getLogger()->logException($e); \OC::$server->getLogger()->logException($e);
if ($e instanceof \OC\HintException) {
if ($e instanceof \OCP\HintException) {
throw $e; throw $e;
} }
if ($e instanceof \OC\ServerNotAvailableException) { if ($e instanceof \OC\ServerNotAvailableException) {

12
lib/private/legacy/OC_Util.php

@ -63,6 +63,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */
use bantu\IniGetWrapper\IniGetWrapper; use bantu\IniGetWrapper\IniGetWrapper;
use OC\AppFramework\Http\Request; use OC\AppFramework\Http\Request;
use OC\Files\Storage\LocalRootStorage; use OC\Files\Storage\LocalRootStorage;
@ -1214,7 +1215,7 @@ class OC_Util {
$fp = @fopen($testFile, 'w'); $fp = @fopen($testFile, 'w');
if (!$fp) { if (!$fp) {
throw new OC\HintException('Can\'t create test file to check for working .htaccess file.',
throw new \OCP\HintException('Can\'t create test file to check for working .htaccess file.',
'Make sure it is possible for the webserver to write to ' . $testFile); 'Make sure it is possible for the webserver to write to ' . $testFile);
} }
fwrite($fp, $testContent); fwrite($fp, $testContent);
@ -1225,10 +1226,11 @@ class OC_Util {
/** /**
* Check if the .htaccess file is working * Check if the .htaccess file is working
*
* @param \OCP\IConfig $config * @param \OCP\IConfig $config
* @return bool * @return bool
* @throws Exception * @throws Exception
* @throws \OC\HintException If the test file can't get written.
* @throws \OCP\HintException If the test file can't get written.
*/ */
public function isHtaccessWorking(\OCP\IConfig $config) { public function isHtaccessWorking(\OCP\IConfig $config) {
if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) { if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) {
@ -1422,7 +1424,7 @@ class OC_Util {
* *
* @param \OC\SystemConfig $config * @param \OC\SystemConfig $config
* @return bool whether the core or any app needs an upgrade * @return bool whether the core or any app needs an upgrade
* @throws \OC\HintException When the upgrade from the given version is not allowed
* @throws \OCP\HintException When the upgrade from the given version is not allowed
*/ */
public static function needUpgrade(\OC\SystemConfig $config) { public static function needUpgrade(\OC\SystemConfig $config) {
if ($config->getValue('installed', false)) { if ($config->getValue('installed', false)) {
@ -1442,11 +1444,11 @@ class OC_Util {
return true; return true;
} else { } else {
// downgrade attempt, throw exception // downgrade attempt, throw exception
throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
} }
} elseif ($versionDiff < 0) { } elseif ($versionDiff < 0) {
// downgrade attempt, throw exception // downgrade attempt, throw exception
throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
} }
// also check for upgrades for apps (independently from the user) // also check for upgrades for apps (independently from the user)

2
lib/public/Encryption/Exceptions/GenericEncryptionException.php

@ -26,7 +26,7 @@
*/ */
namespace OCP\Encryption\Exceptions; namespace OCP\Encryption\Exceptions;
use OC\HintException;
use OCP\HintException;
/** /**
* Class GenericEncryptionException * Class GenericEncryptionException

2
lib/public/Federation/Exceptions/ActionNotSupportedException.php

@ -22,7 +22,7 @@
*/ */
namespace OCP\Federation\Exceptions; namespace OCP\Federation\Exceptions;
use OC\HintException;
use OCP\HintException;
/** /**
* Class ActionNotSupportedException * Class ActionNotSupportedException

2
lib/public/Federation/Exceptions/AuthenticationFailedException.php

@ -22,7 +22,7 @@
*/ */
namespace OCP\Federation\Exceptions; namespace OCP\Federation\Exceptions;
use OC\HintException;
use OCP\HintException;
/** /**
* Class AuthenticationFailedException * Class AuthenticationFailedException

2
lib/public/Federation/Exceptions/BadRequestException.php

@ -23,7 +23,7 @@
*/ */
namespace OCP\Federation\Exceptions; namespace OCP\Federation\Exceptions;
use OC\HintException;
use OCP\HintException;
/** /**
* Class BadRequestException * Class BadRequestException

2
lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php

@ -24,7 +24,7 @@
*/ */
namespace OCP\Federation\Exceptions; namespace OCP\Federation\Exceptions;
use OC\HintException;
use OCP\HintException;
/** /**
* Class ProviderAlreadyExistsException * Class ProviderAlreadyExistsException

2
lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php

@ -22,8 +22,8 @@
*/ */
namespace OCP\Federation\Exceptions; namespace OCP\Federation\Exceptions;
use OC\HintException;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\HintException;
/** /**
* Class ProviderCouldNotAddShareException * Class ProviderCouldNotAddShareException

2
lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php

@ -22,7 +22,7 @@
*/ */
namespace OCP\Federation\Exceptions; namespace OCP\Federation\Exceptions;
use OC\HintException;
use OCP\HintException;
/** /**
* Class ProviderDoesNotExistsException * Class ProviderDoesNotExistsException

2
lib/public/Files/StorageNotAvailableException.php

@ -32,7 +32,7 @@
namespace OCP\Files; namespace OCP\Files;
use OC\HintException;
use OCP\HintException;
/** /**
* Storage is temporarily not available * Storage is temporarily not available

82
lib/public/HintException.php

@ -0,0 +1,82 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Michael Gapczynski <GapczynskiM@gmail.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP;
/**
* Class HintException
*
* An Exception class with the intention to be presented to the end user
*
* @package OCP
* @since 23.0.0
*/
class HintException extends \Exception {
private $hint;
/**
* HintException constructor.
*
* @since 23.0.0
* @param string $message The error message. It will be not revealed to the
* the user (unless the hint is empty) and thus
* should be not translated.
* @param string $hint A useful message that is presented to the end
* user. It should be translated, but must not
* contain sensitive data.
* @param int $code
* @param \Exception|null $previous
*/
public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) {
$this->hint = $hint;
parent::__construct($message, $code, $previous);
}
/**
* Returns a string representation of this Exception that includes the error
* code, the message and the hint.
*
* @since 23.0.0
* @return string
*/
public function __toString(): string {
return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
}
/**
* Returns the hint with the intention to be presented to the end user. If
* an empty hint was specified upon instatiation, the message is returned
* instead.
*
* @since 23.0.0
* @return string
*/
public function getHint(): string {
if (empty($this->hint)) {
return $this->message;
}
return $this->hint;
}
}

2
lib/public/Share/Exceptions/GenericShareException.php

@ -24,7 +24,7 @@
*/ */
namespace OCP\Share\Exceptions; namespace OCP\Share\Exceptions;
use OC\HintException;
use OCP\HintException;
/** /**
* Class GenericEncryptionException * Class GenericEncryptionException

2
tests/Core/Controller/ChangePasswordControllerTest.php

@ -22,11 +22,11 @@
namespace Tests\Core\Controller; namespace Tests\Core\Controller;
use OC\HintException;
use OC\User\Session; use OC\User\Session;
use OCA\Settings\Controller\ChangePasswordController; use OCA\Settings\Controller\ChangePasswordController;
use OCP\App\IAppManager; use OCP\App\IAppManager;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCP\HintException;
use OCP\IGroupManager; use OCP\IGroupManager;
use OCP\IL10N; use OCP\IL10N;
use OCP\IRequest; use OCP\IRequest;

2
tests/lib/Memcache/FactoryTest.php

@ -129,7 +129,7 @@ class FactoryTest extends \Test\TestCase {
* @dataProvider cacheUnavailableProvider * @dataProvider cacheUnavailableProvider
*/ */
public function testCacheNotAvailableException($localCache, $distributedCache) { public function testCacheNotAvailableException($localCache, $distributedCache) {
$this->expectException(\OC\HintException::class);
$this->expectException(\OCP\HintException::class);
$logger = $this->getMockBuilder(ILogger::class)->getMock(); $logger = $this->getMockBuilder(ILogger::class)->getMock();
new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache); new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache);

2
tests/lib/Share20/ManagerTest.php

@ -22,7 +22,6 @@
namespace Test\Share20; namespace Test\Share20;
use OC\Files\Mount\MoveableMount; use OC\Files\Mount\MoveableMount;
use OC\HintException;
use OC\Share20\DefaultShareProvider; use OC\Share20\DefaultShareProvider;
use OC\Share20\Exception; use OC\Share20\Exception;
use OC\Share20\Manager; use OC\Share20\Manager;
@ -36,6 +35,7 @@ use OCP\Files\Mount\IMountManager;
use OCP\Files\Mount\IMountPoint; use OCP\Files\Mount\IMountPoint;
use OCP\Files\Node; use OCP\Files\Node;
use OCP\Files\Storage; use OCP\Files\Storage;
use OCP\HintException;
use OCP\IConfig; use OCP\IConfig;
use OCP\IGroup; use OCP\IGroup;
use OCP\IGroupManager; use OCP\IGroupManager;

6
tests/lib/User/DatabaseTest.php

@ -22,10 +22,10 @@
namespace Test\User; namespace Test\User;
use OC\HintException;
use OC\User\User; use OC\User\User;
use OCP\EventDispatcher\Event; use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\HintException;
use OCP\Security\Events\ValidatePasswordPolicyEvent; use OCP\Security\Events\ValidatePasswordPolicyEvent;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -82,9 +82,9 @@ class DatabaseTest extends Backend {
$this->assertSame($user, $this->backend->checkPassword($user, 'newpass')); $this->assertSame($user, $this->backend->checkPassword($user, 'newpass'));
} }
public function testVerifyPasswordEventFail() { public function testVerifyPasswordEventFail() {
$this->expectException(\OC\HintException::class);
$this->expectException(\OCP\HintException::class);
$this->expectExceptionMessage('password change failed'); $this->expectExceptionMessage('password change failed');
$user = $this->getUser(); $user = $this->getUser();

Loading…
Cancel
Save