IImportSource.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\UserMigration;
  8. use OCP\Files\Folder;
  9. /**
  10. * @since 24.0.0
  11. */
  12. interface IImportSource {
  13. /**
  14. * @since 24.0.0
  15. */
  16. public const PATH_USER = 'user.json';
  17. /**
  18. * Reads a file from the export
  19. *
  20. * @param string $path Full path to the file in the export archive.
  21. * @return string The full content of the file.
  22. * @throws UserMigrationException
  23. *
  24. * @since 24.0.0
  25. */
  26. public function getFileContents(string $path): string;
  27. /**
  28. * Reads a file from the export as a stream
  29. *
  30. * @param string $path Full path to the file in the export archive.
  31. * @return resource A stream resource to read from to get the file content.
  32. * @throws UserMigrationException
  33. *
  34. * @since 24.0.0
  35. */
  36. public function getFileAsStream(string $path);
  37. /**
  38. * List the files of a folder
  39. *
  40. * @param string $path Full path to the folder in the export archive.
  41. * @return array The list of files.
  42. * @throws UserMigrationException
  43. *
  44. * @since 24.0.0
  45. */
  46. public function getFolderListing(string $path): array;
  47. /**
  48. * Test if a path exists, which may be a file or a folder
  49. *
  50. * @throws UserMigrationException
  51. *
  52. * @since 24.0.0
  53. */
  54. public function pathExists(string $path): bool;
  55. /**
  56. * Copy files from the export to a Folder
  57. *
  58. * Folder $destination folder to copy into
  59. * string $sourcePath path in the export archive
  60. *
  61. * @throws UserMigrationException
  62. *
  63. * @since 24.0.0
  64. */
  65. public function copyToFolder(Folder $destination, string $sourcePath): void;
  66. /**
  67. * @return array<string,int> Migrators and their versions from the export archive.
  68. * @throws UserMigrationException
  69. *
  70. * @since 24.0.0
  71. */
  72. public function getMigratorVersions(): array;
  73. /**
  74. * @return ?int Version for this migrator from the export archive. Null means migrator missing.
  75. * @throws UserMigrationException
  76. * @param string $migrator Migrator id (as returned by IMigrator::getId)
  77. *
  78. * @since 24.0.0
  79. */
  80. public function getMigratorVersion(string $migrator): ?int;
  81. /**
  82. * Get original uid of the imported account
  83. *
  84. * @throws UserMigrationException
  85. *
  86. * @since 24.0.0
  87. */
  88. public function getOriginalUid(): string;
  89. /**
  90. * Called after import is complete
  91. *
  92. * @throws UserMigrationException
  93. *
  94. * @since 24.0.0
  95. */
  96. public function close(): void;
  97. }