Interface ModuleFileProvider

All Known Implementing Classes:
DefaultModuleFileProvider

public interface ModuleFileProvider
Interface for providing file access operations specific to module parsing.

This interface encapsulates file access operations that are specific to parsing eLearning modules, such as getting manifest files, checking for xAPI files, etc. It separates file access concerns from parsing logic, making the parsers more focused on their primary responsibility.

Implementations of this interface should handle the details of accessing files from different storage mechanisms (e.g., ZIP files, local file system, S3, etc.) and provide a consistent interface for parsers to use.

  • Method Details

    • getFileContents

      InputStream getFileContents(String path) throws IOException
      Gets the contents of a file as an InputStream.
      Parameters:
      path - The path to the file.
      Returns:
      An InputStream containing the file contents.
      Throws:
      IOException - If an error occurs while reading the file.
      IllegalArgumentException - if path is null
    • fileExists

      boolean fileExists(String path)
      Checks if a file exists at the specified path.
      Parameters:
      path - The path to check.
      Returns:
      true if the file exists, false otherwise.
      Throws:
      IllegalArgumentException - if path is null
    • getRootPath

      String getRootPath()
      Gets the root path of the module.
      Returns:
      The root path of the module.
    • hasXapiSupport

      boolean hasXapiSupport()
      Checks if the module contains xAPI-related files.
      Returns:
      true if xAPI is enabled, false otherwise.
    • listFiles

      List<String> listFiles(String directory) throws IOException
      Lists all files in the specified directory.
      Parameters:
      directory - The directory to list files from.
      Returns:
      A list of file names in the directory.
      Throws:
      IOException - If an error occurs while listing the files.
      IllegalArgumentException - if directory is null
    • fileExistsBatch

      default Map<String,Boolean> fileExistsBatch(List<String> paths)
      Checks if multiple files exist in a batch operation.

      Default implementation calls fileExists() for each path individually. Implementations may override this to provide more efficient batch operations.

      Parameters:
      paths - List of file paths to check
      Returns:
      Map where keys are the file paths and values indicate whether the file exists
      Throws:
      IllegalArgumentException - if paths is null or contains null elements
    • prefetchCommonFiles

      default void prefetchCommonFiles()
      Prefetches common module files for faster subsequent access.

      Default implementation does nothing. Implementations that support caching (like S3) may override this to pre-load commonly accessed files.

    • getTotalSize

      default long getTotalSize() throws IOException
      Gets the total size of all files in the module.

      This method calculates the sum of all file sizes in the module. Implementations that maintain file size caches can provide efficient calculation of the total module size.

      Returns:
      Total size of all files in bytes, or -1 if not supported
      Throws:
      IOException - if there's an error accessing file sizes