Class ObjectManager

java.lang.Object
io.bdeploy.bhive.objects.ObjectManager

public class ObjectManager extends Object
Provides higher level operations on the ObjectDatabase.
  • Constructor Details

  • Method Details

    • importTree

      public ObjectId importTree(Path location, boolean skipEmpty)
      Import a Path recursively into the underlying ObjectDatabase.
      Parameters:
      location - the location to import recursively
      skipEmpty - whether to skip empty directories
      Returns:
      the ObjectId of the resulting Tree.
    • exportTree

      public void exportTree(ObjectId tree, Path location, ReferenceHandler handler)
      Exports a given tree (by ObjectId) to the given location, which must not exist yet.
      Parameters:
      tree - the ObjectId of the Tree to write
      location - the target Path to create
      handler - a custom reference handler which takes care of references. If not set, the default will be used (inline export of manifest reference in place).
    • scan

      public TreeView scan(ObjectId tree, int maxDepth, boolean followReferences)
      Create a traversable snapshot of the given Tree state up to a given maximum depth.

      In case the root tree is damaged, it is wrapped in a dummy TreeView with a null ObjectId.

      Parameters:
      tree - the root tree to scan
      maxDepth - maximum scan depth. A depth of 1 will include only direct children at the root level, and so on.
    • getStreamForRelativePath

      public InputStream getStreamForRelativePath(ObjectId tree, String... path) throws IOException
      Parameters:
      tree - the root tree to resolve from
      path - the path in the tree to resolve
      Returns:
      an InputStream to the file denoted by the path.
      Throws:
      IOException
    • insertManifestReference

      public ObjectId insertManifestReference(Manifest.Key key)
      Inserts an object into the database which can be used to reference a Manifest in a Tree using Tree.EntryType.MANIFEST.
    • insertTree

      public ObjectId insertTree(Tree tree)
      Inserts a Tree object into the database and returns its ObjectId, which can be used to build further Tree or as root reference for a Manifest.
    • checkObject

      public boolean checkObject(ObjectId id, boolean remove)
      Checks whether a given ObjectIds backing file store is OK. In case it is not, the broken file is removed from the store!
      Parameters:
      id - the ObjectId to check
      remove - whether to remove broken objects
      Returns:
      whether the stored object in the database is OK.
    • db

      public <T> T db(ObjectManager.DbCallable<T> c)
      Perform an operation on the actual underlying object database.
    • invalidateCaches

      public void invalidateCaches()
      Invalidates all cached data.