Interface LayerDatabase

All Known Implementing Classes:
LayerDatabaseImpl

public interface LayerDatabase
Provides access to the database that contains a record for every file and directory stored in the layered storage. Contains methods to add, delete and find information about these files and directories.
  • Method Details

    • saveRecords

      void saveRecords(ItemRecord... records)
      Save records to the database. The records may be new or existing. If a record already exists, it is updated.
      Parameters:
      records - the records to save
    • deleteRecordsById

      void deleteRecordsById(long... ids)
      Deletes the records with the given ids.
      Parameters:
      ids - the ids of the records to delete
    • getAllRecords

      Stream<ItemRecord> getAllRecords()
      Retrieves a stream of all the records in the database.
      Returns:
      a list of all the records in the database
    • listDirectory

      List<Item> listDirectory(String directoryPath) throws IOException
      Lists the items in directoryPath. It takes into account the complete stack of layers. If the directory does not exist in any of the layers, an IllegalArgumentException is thrown.
      Parameters:
      directoryPath - the directory path relative to the storage root
      Returns:
      the items in the directory
      Throws:
      IOException
    • listRecursive

      List<Item> listRecursive(String directoryPath) throws IOException
      Lists the items in directoryPath recursively. It takes into account the complete stack of layers.
      Parameters:
      directoryPath - the directory path relative to the storage root
      Returns:
      the items in the directory and its subdirectories
      Throws:
      IOException
    • addDirectory

      List<ItemRecord> addDirectory(long layerId, String path)
      Adds a directory to the database. Ancestor directories are added automatically, if they do not exist in the same layer yet.
      Parameters:
      path - the path of the directory relative to the storage root
      Returns:
      the records that were added to the database for directories that did not exist yet
      Throws:
      IllegalArgumentException - if the layerId is lower than the highest layerId in the database
    • findLayersContaining

      List<Long> findLayersContaining(String path)
      Finds all the layers that contain the given path.
      Parameters:
      path - path relative to the root of the storage
      Returns:
      the ids of the layers that contain the path
    • getRecordsByPath

      List<ItemRecord> getRecordsByPath(String path)
      Returns the records for the given path in any layer. The records are ordered by layer id, with the newest layer first.
      Parameters:
      path - path relative to the root of the storage
      Returns:
      the records for the given path
    • existsPathLike

      boolean existsPathLike(String pathPattern)
      Returns whether the path pattern matches any path in the database.
      Parameters:
      pathPattern - a path pattern that may contain wildcards
      Returns:
      true if the pattern matches any path in the database, false otherwise