@Override
  public void deleteSnapshot(String snapName) throws DatabaseException {

    try {

      // check if the snapshot exists; if not, throw an exception
      snapMan.getSnapshotDB(database.getName(), snapName);

      // delete the snapshot
      snapMan.deletePersistentSnapshot(database.getName(), snapName);

    } catch (BabuDBException exc) {
      throw new DatabaseException(exc);
    }
  }
 @Override
 public String[] getAllSnapshots() {
   return snapMan.getAllSnapshots(volume.getId());
 }
  @Override
  public void createSnapshot(String snapName, long parentId, String dirName, boolean recursive)
      throws DatabaseException {

    try {

      // determine the prefixes for the snapshot
      byte[][][] prefixes = null;

      FileMetadata snapDir = getMetadata(parentId, dirName);

      // for a full volume snapshot, simply use a 'null' prefix (full:
      // dirID == 1 && recursive)
      if (snapDir.getId() != 1 || !recursive) {

        // get the IDs of all files and directories contained in the
        // given directory; if recursive == true, include subdirectories
        List<FileMetadata> nestedFiles = new LinkedList<FileMetadata>();
        BabuDBStorageHelper.getNestedFiles(nestedFiles, database, snapDir.getId(), recursive);

        List<byte[]> dirEntryPrefixes = new ArrayList<byte[]>(nestedFiles.size());
        List<byte[]> filePrefixes = new ArrayList<byte[]>(nestedFiles.size());

        // include the extended attributes of the volume's root
        // directory if it's not the snapshot directory - they are
        // needed to access volume-wide parameters in the snapshot, such
        // as the access control policy
        if (snapDir.getId() != 1) filePrefixes.add(ByteBuffer.wrap(new byte[8]).putLong(1).array());

        // include all metadata of the snapshot (i.e. top level) dir
        byte[] idxKey = BabuDBStorageHelper.createFileKey(parentId, dirName, (byte) -1);
        byte[] fileKey = BabuDBStorageHelper.createFilePrefixKey(snapDir.getId());
        dirEntryPrefixes.add(idxKey);
        filePrefixes.add(fileKey);

        // include the snapshot directory content
        idxKey = BabuDBStorageHelper.createFilePrefixKey(snapDir.getId());
        dirEntryPrefixes.add(idxKey);

        // determine the key prefixes of all nested files to include and
        // exclude
        for (FileMetadata file : nestedFiles) {

          // create a prefix key for the nested file
          byte[] key = BabuDBStorageHelper.createFilePrefixKey(file.getId());

          // if the nested file is a directory, ...
          if (file.isDirectory()) {

            // include the directory in the file prefixes
            // and the directory prefix in the dir entry prefixes
            filePrefixes.add(key);
            dirEntryPrefixes.add(key);
          }

          // if the nested file is a file, ...
          else filePrefixes.add(key);
        }

        byte[][] dirEntryPrefixesA = dirEntryPrefixes.toArray(new byte[dirEntryPrefixes.size()][]);
        byte[][] filePrefixesA = filePrefixes.toArray(new byte[filePrefixes.size()][]);

        Arrays.sort(dirEntryPrefixesA, DefaultByteRangeComparator.getInstance());
        Arrays.sort(filePrefixesA, DefaultByteRangeComparator.getInstance());

        // FILE_INDEX, XATTRS_INDEX, ACL_INDEX, FILE_ID_INDEX,
        // VOLUME_INDEX
        prefixes =
            new byte[][][] {dirEntryPrefixesA, filePrefixesA, filePrefixesA, filePrefixesA, null};
      }

      // create the snapshot
      SnapshotConfig snap = new DefaultSnapshotConfig(snapName, ALL_INDICES, prefixes, null);
      snapMan.createPersistentSnapshot(database.getName(), snap);

    } catch (BabuDBException exc) {
      throw new DatabaseException(exc);
    }
  }