public Iterable<ImportableData<ExportData>> serialize(BlobbyStorageContainerResource root)
      throws IOException {
    List<ImportableData<ExportData>> results = new ArrayList<>();

    String currentFolderPath = getFromStore(root.getId());
    if (currentFolderPath == null) {
      currentFolderPath = "/" + root.getName();
    }

    // Import the current folder
    results.add(
        new ImportableData<>(
            new GenericPayload<>(new FolderExportData(currentFolderPath), SCHEMA_SOURCE),
            root.getId(),
            currentFolderPath));

    // Import all sub folders, not recursively
    for (BlobbyStorageContainerResource childFolder : root.getFolders()) {
      String path = format("%s/%s", currentFolderPath, childFolder.getName());
      results.add(
          new ImportableData<>(
              new GenericPayload<>(new FolderExportData(path), SCHEMA_SOURCE),
              childFolder.getId(),
              path));
      addToJobStore(childFolder.getId(), path);
    }

    // Import all files in the current folder
    // Intentionally done after importing the current folder
    for (DigitalDocumentWrapper file : root.getFiles()) {
      results.add(
          new ImportableFileData<>(
              new CachedDownloadableItem(
                  file.getCachedContentId(), file.getDtpDigitalDocument().getName()),
              file.getDtpDigitalDocument().getEncodingFormat(),
              new GenericPayload<>(
                  FileExportData.fromDtpDigitalDocument(
                      currentFolderPath, file.getDtpDigitalDocument()),
                  SCHEMA_SOURCE),
              file.getCachedContentId(),
              file.getDtpDigitalDocument().getName()));
    }

    saveStateToStore();
    return results;
  }
Serializes a BlobbyStorageContainerResource into an iterable of ImportableData objects.

<p>This method only serializes the tree up to a single depth, assuming that the exporter will
send separate BlobbyStorageContainerResource objects for subfolders. It also stores an
ID-to-path mapping for folders, which can be used to establish parent-child relationships in
separate iterations.

@param root The BloppyStorageContainerResource to serialize.
@return An iterable of ImportableData objects representing the serialized data.
extensions/data-transfer/portability-data-transfer-generic/src/main/java/org/datatransferproject/datatransfer/generic/BlobbySerializer.java