2022-02-04 15:49:11 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2022-02-04 15:49:11 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace OCP\UserMigration;
|
|
|
|
|
|
|
|
|
|
use OCP\Files\Folder;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
interface IImportSource {
|
2024-02-14 14:48:27 -05:00
|
|
|
/**
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
2022-03-10 05:51:20 -05:00
|
|
|
public const PATH_USER = 'user.json';
|
2022-02-04 15:49:11 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reads a file from the export
|
|
|
|
|
*
|
|
|
|
|
* @param string $path Full path to the file in the export archive.
|
|
|
|
|
* @return string The full content of the file.
|
2022-04-12 10:02:29 -04:00
|
|
|
* @throws UserMigrationException
|
2022-02-04 15:49:11 -05:00
|
|
|
*
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getFileContents(string $path): string;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reads a file from the export as a stream
|
|
|
|
|
*
|
|
|
|
|
* @param string $path Full path to the file in the export archive.
|
|
|
|
|
* @return resource A stream resource to read from to get the file content.
|
2022-04-12 10:02:29 -04:00
|
|
|
* @throws UserMigrationException
|
2022-02-04 15:49:11 -05:00
|
|
|
*
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getFileAsStream(string $path);
|
|
|
|
|
|
2022-02-23 00:43:29 -05:00
|
|
|
/**
|
|
|
|
|
* List the files of a folder
|
|
|
|
|
*
|
|
|
|
|
* @param string $path Full path to the folder in the export archive.
|
|
|
|
|
* @return array The list of files.
|
2022-04-12 10:02:29 -04:00
|
|
|
* @throws UserMigrationException
|
2022-02-23 00:43:29 -05:00
|
|
|
*
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getFolderListing(string $path): array;
|
|
|
|
|
|
2022-03-10 05:38:46 -05:00
|
|
|
/**
|
2022-03-10 11:17:07 -05:00
|
|
|
* Test if a path exists, which may be a file or a folder
|
2022-03-10 05:38:46 -05:00
|
|
|
*
|
2022-04-12 10:02:29 -04:00
|
|
|
* @throws UserMigrationException
|
|
|
|
|
*
|
2022-03-10 05:38:46 -05:00
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function pathExists(string $path): bool;
|
|
|
|
|
|
2022-02-04 15:49:11 -05:00
|
|
|
/**
|
|
|
|
|
* Copy files from the export to a Folder
|
|
|
|
|
*
|
|
|
|
|
* Folder $destination folder to copy into
|
|
|
|
|
* string $sourcePath path in the export archive
|
|
|
|
|
*
|
2022-04-12 10:02:29 -04:00
|
|
|
* @throws UserMigrationException
|
|
|
|
|
*
|
2022-02-04 15:49:11 -05:00
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
2022-04-12 10:02:29 -04:00
|
|
|
public function copyToFolder(Folder $destination, string $sourcePath): void;
|
2022-02-04 15:49:11 -05:00
|
|
|
|
2022-02-15 03:56:45 -05:00
|
|
|
/**
|
|
|
|
|
* @return array<string,int> Migrators and their versions from the export archive.
|
2022-04-12 10:02:29 -04:00
|
|
|
* @throws UserMigrationException
|
2022-02-15 03:56:45 -05:00
|
|
|
*
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getMigratorVersions(): array;
|
|
|
|
|
|
2022-02-17 12:09:14 -05:00
|
|
|
/**
|
|
|
|
|
* @return ?int Version for this migrator from the export archive. Null means migrator missing.
|
2022-04-12 10:02:29 -04:00
|
|
|
* @throws UserMigrationException
|
2022-04-11 04:53:51 -04:00
|
|
|
* @param string $migrator Migrator id (as returned by IMigrator::getId)
|
2022-02-17 12:09:14 -05:00
|
|
|
*
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getMigratorVersion(string $migrator): ?int;
|
|
|
|
|
|
2022-03-10 05:51:20 -05:00
|
|
|
/**
|
|
|
|
|
* Get original uid of the imported account
|
|
|
|
|
*
|
2022-04-12 10:02:29 -04:00
|
|
|
* @throws UserMigrationException
|
|
|
|
|
*
|
2022-03-10 05:51:20 -05:00
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getOriginalUid(): string;
|
|
|
|
|
|
2022-02-04 15:49:11 -05:00
|
|
|
/**
|
|
|
|
|
* Called after import is complete
|
|
|
|
|
*
|
2022-04-12 10:02:29 -04:00
|
|
|
* @throws UserMigrationException
|
|
|
|
|
*
|
2022-02-04 15:49:11 -05:00
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function close(): void;
|
|
|
|
|
}
|