Class LayerDatabaseImpl

java.lang.Object
nl.knaw.dans.layerstore.LayerDatabaseImpl
All Implemented Interfaces:
LayerDatabase

public class LayerDatabaseImpl extends Object implements LayerDatabase
  • Constructor Details

    • LayerDatabaseImpl

      public LayerDatabaseImpl(nl.knaw.dans.lib.util.PersistenceProvider<ItemRecord> persistenceProvider)
  • Method Details

    • saveRecords

      public void saveRecords(ItemRecord... records)
      Description copied from interface: LayerDatabase
      Save records to the database. The records may be new or existing. If a record already exists, it is updated.
      Specified by:
      saveRecords in interface LayerDatabase
      Parameters:
      records - the records to save
    • deleteRecordsById

      public void deleteRecordsById(long... id)
      Description copied from interface: LayerDatabase
      Deletes the records with the given ids.
      Specified by:
      deleteRecordsById in interface LayerDatabase
      Parameters:
      id - the ids of the records to delete
    • listDirectory

      public List<Item> listDirectory(String directoryPath) throws IOException
      Description copied from interface: LayerDatabase
      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.
      Specified by:
      listDirectory in interface LayerDatabase
      Parameters:
      directoryPath - the directory path relative to the storage root
      Returns:
      the items in the directory
      Throws:
      IOException
    • listRecursive

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

      public List<ItemRecord> addDirectory(long layerId, String path)
      Description copied from interface: LayerDatabase
      Adds a directory to the database. Ancestor directories are added automatically, if they do not exist in the same layer yet.
      Specified by:
      addDirectory in interface LayerDatabase
      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
    • findLayersContaining

      public List<Long> findLayersContaining(String path)
      Description copied from interface: LayerDatabase
      Finds all the layers that contain the given path.
      Specified by:
      findLayersContaining in interface LayerDatabase
      Parameters:
      path - path relative to the root of the storage
      Returns:
      the ids of the layers that contain the path
    • getRecordsByPath

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

      public Stream<ItemRecord> getAllRecords()
      Description copied from interface: LayerDatabase
      Retrieves a stream of all the records in the database.
      Specified by:
      getAllRecords in interface LayerDatabase
      Returns:
      a list of all the records in the database
    • existsPathLike

      public boolean existsPathLike(String pathPattern)
      Description copied from interface: LayerDatabase
      Returns whether the path pattern matches any path in the database.
      Specified by:
      existsPathLike in interface LayerDatabase
      Parameters:
      pathPattern - a path pattern that may contain wildcards
      Returns:
      true if the pattern matches any path in the database, false otherwise