From d8b2d32a5e3ddec7842f4e1007ff3233488f1f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 10 Mar 2022 11:35:07 +0100 Subject: [PATCH 1/6] Move UserMigrationException to OCP and add @throws documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/public/UserMigration/IMigrator.php | 2 ++ .../UserMigration/UserMigrationException.php | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 lib/public/UserMigration/UserMigrationException.php diff --git a/lib/public/UserMigration/IMigrator.php b/lib/public/UserMigration/IMigrator.php index 4ff09167f5e..c97fb3c0bca 100644 --- a/lib/public/UserMigration/IMigrator.php +++ b/lib/public/UserMigration/IMigrator.php @@ -38,6 +38,7 @@ interface IMigrator { /** * Export user data * + * @throws UserMigrationException * @since 24.0.0 */ public function export( @@ -49,6 +50,7 @@ interface IMigrator { /** * Import user data * + * @throws UserMigrationException * @since 24.0.0 */ public function import( diff --git a/lib/public/UserMigration/UserMigrationException.php b/lib/public/UserMigration/UserMigrationException.php new file mode 100644 index 00000000000..f3812bf42b1 --- /dev/null +++ b/lib/public/UserMigration/UserMigrationException.php @@ -0,0 +1,30 @@ + + * + * @author Côme Chilliet + * + * @license GNU AGPL version 3 or any later version + * + * 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, + * 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 + * along with this program. If not, see . + * + */ + +namespace OCP\UserMigration; + +class UserMigrationException extends \Exception { +} From 5534f70c5ddfd83cef78cb95d5b66ae078b472b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 10 Mar 2022 11:38:46 +0100 Subject: [PATCH 2/6] Add pathExists method to IImportSource to test if a path exists in the archive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/public/UserMigration/IImportSource.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/public/UserMigration/IImportSource.php b/lib/public/UserMigration/IImportSource.php index df91c0e71ab..17ad4c9f12f 100644 --- a/lib/public/UserMigration/IImportSource.php +++ b/lib/public/UserMigration/IImportSource.php @@ -63,6 +63,13 @@ interface IImportSource { */ public function getFolderListing(string $path): array; + /** + * Test if a path exists + * + * @since 24.0.0 + */ + public function pathExists(string $path): bool; + /** * Copy files from the export to a Folder * From b4b9e8adf7106dda846c21b62eba2ba24640e3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 10 Mar 2022 11:51:20 +0100 Subject: [PATCH 3/6] Add getOriginalUid in IImportSource to simplify code when importing under another uid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/public/UserMigration/IImportSource.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/public/UserMigration/IImportSource.php b/lib/public/UserMigration/IImportSource.php index 17ad4c9f12f..81fa1c0a3d1 100644 --- a/lib/public/UserMigration/IImportSource.php +++ b/lib/public/UserMigration/IImportSource.php @@ -32,6 +32,7 @@ use OCP\Files\Folder; * @since 24.0.0 */ interface IImportSource { + public const PATH_USER = 'user.json'; /** * Reads a file from the export @@ -96,6 +97,13 @@ interface IImportSource { */ public function getMigratorVersion(string $migrator): ?int; + /** + * Get original uid of the imported account + * + * @since 24.0.0 + */ + public function getOriginalUid(): string; + /** * Called after import is complete * From b63d22b6ea87d62ecfcea1e27692f99570ed1a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 10 Mar 2022 17:17:07 +0100 Subject: [PATCH 4/6] Improve wording of pathExists description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet Signed-off-by: Christopher Ng --- lib/public/UserMigration/IImportSource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/public/UserMigration/IImportSource.php b/lib/public/UserMigration/IImportSource.php index 81fa1c0a3d1..d34f2752549 100644 --- a/lib/public/UserMigration/IImportSource.php +++ b/lib/public/UserMigration/IImportSource.php @@ -65,7 +65,7 @@ interface IImportSource { public function getFolderListing(string $path): array; /** - * Test if a path exists + * Test if a path exists, which may be a file or a folder * * @since 24.0.0 */ From 1973b2fb758165a845580570d723e0beeafb9ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 14 Mar 2022 09:09:28 +0100 Subject: [PATCH 5/6] Fix autoloader and phpdoc for new class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + lib/public/UserMigration/TMigratorBasicVersionHandling.php | 1 + lib/public/UserMigration/UserMigrationException.php | 3 +++ 4 files changed, 6 insertions(+) diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 86efab3ad52..7ba3c7c0840 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -549,6 +549,7 @@ return array( 'OCP\\UserMigration\\IImportSource' => $baseDir . '/lib/public/UserMigration/IImportSource.php', 'OCP\\UserMigration\\IMigrator' => $baseDir . '/lib/public/UserMigration/IMigrator.php', 'OCP\\UserMigration\\TMigratorBasicVersionHandling' => $baseDir . '/lib/public/UserMigration/TMigratorBasicVersionHandling.php', + 'OCP\\UserMigration\\UserMigrationException' => $baseDir . '/lib/public/UserMigration/UserMigrationException.php', 'OCP\\UserStatus\\IManager' => $baseDir . '/lib/public/UserStatus/IManager.php', 'OCP\\UserStatus\\IProvider' => $baseDir . '/lib/public/UserStatus/IProvider.php', 'OCP\\UserStatus\\IUserStatus' => $baseDir . '/lib/public/UserStatus/IUserStatus.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index ea37771d63c..69ad8764822 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -578,6 +578,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\UserMigration\\IImportSource' => __DIR__ . '/../../..' . '/lib/public/UserMigration/IImportSource.php', 'OCP\\UserMigration\\IMigrator' => __DIR__ . '/../../..' . '/lib/public/UserMigration/IMigrator.php', 'OCP\\UserMigration\\TMigratorBasicVersionHandling' => __DIR__ . '/../../..' . '/lib/public/UserMigration/TMigratorBasicVersionHandling.php', + 'OCP\\UserMigration\\UserMigrationException' => __DIR__ . '/../../..' . '/lib/public/UserMigration/UserMigrationException.php', 'OCP\\UserStatus\\IManager' => __DIR__ . '/../../..' . '/lib/public/UserStatus/IManager.php', 'OCP\\UserStatus\\IProvider' => __DIR__ . '/../../..' . '/lib/public/UserStatus/IProvider.php', 'OCP\\UserStatus\\IUserStatus' => __DIR__ . '/../../..' . '/lib/public/UserStatus/IUserStatus.php', diff --git a/lib/public/UserMigration/TMigratorBasicVersionHandling.php b/lib/public/UserMigration/TMigratorBasicVersionHandling.php index 5554bb90a91..20a30a24307 100644 --- a/lib/public/UserMigration/TMigratorBasicVersionHandling.php +++ b/lib/public/UserMigration/TMigratorBasicVersionHandling.php @@ -28,6 +28,7 @@ namespace OCP\UserMigration; /** * Basic version handling: we can import older versions but not newer ones + * @since 24.0.0 */ trait TMigratorBasicVersionHandling { protected int $version = 1; diff --git a/lib/public/UserMigration/UserMigrationException.php b/lib/public/UserMigration/UserMigrationException.php index f3812bf42b1..ed8c28a6208 100644 --- a/lib/public/UserMigration/UserMigrationException.php +++ b/lib/public/UserMigration/UserMigrationException.php @@ -26,5 +26,8 @@ declare(strict_types=1); namespace OCP\UserMigration; +/** + * @since 24.0.0 + */ class UserMigrationException extends \Exception { } From 8f97f722ecb98dff6226d2b2572bfe1ae49869a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 14 Mar 2022 09:57:28 +0100 Subject: [PATCH 6/6] Extends UserMigrationException in CalendarMigratorException MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/dav/lib/UserMigration/CalendarMigratorException.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/UserMigration/CalendarMigratorException.php b/apps/dav/lib/UserMigration/CalendarMigratorException.php index 91bac58ffac..3b4f8f89232 100644 --- a/apps/dav/lib/UserMigration/CalendarMigratorException.php +++ b/apps/dav/lib/UserMigration/CalendarMigratorException.php @@ -26,7 +26,7 @@ declare(strict_types=1); namespace OCA\DAV\UserMigration; -use Exception; +use OCP\UserMigration\UserMigrationException; -class CalendarMigratorException extends Exception { +class CalendarMigratorException extends UserMigrationException { }