Ejemplo n.º 1
0
  @Override
  public byte[] getXAttr(long fileId, String uid, String key) throws DatabaseException {

    ResultSet<byte[], byte[]> it = null;
    try {

      // peform a prefix lookup
      byte[] prefix = BabuDBStorageHelper.createXAttrPrefixKey(fileId, uid, key);
      it = database.prefixLookup(XATTRS_INDEX, prefix, null).get();

      // check whether the entry is the correct one
      while (it.hasNext()) {

        Entry<byte[], byte[]> curr = it.next();
        BufferBackedXAttr xattr = new BufferBackedXAttr(curr.getKey(), curr.getValue());
        if (uid.equals(xattr.getOwner()) && key.equals(xattr.getKey())) return xattr.getValue();
      }

      return null;

    } catch (BabuDBException exc) {
      throw new DatabaseException(exc);
    } finally {
      if (it != null) it.free();
    }
  }