示例#1
0
 /**
  * Check that a record entry exists in the entry tree.
  *
  * @param txn a non null transaction
  * @param entryID The entry ID which forms the key.
  * @return True if an entry with entryID exists
  * @throws StorageRuntimeException If an error occurs in the storage.
  */
 public boolean containsEntryID(ReadableTransaction txn, EntryID entryID) {
   checkNotNull(txn, "txn must not be null");
   checkNotNull(entryID, "entryID must not be null");
   try (final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName())) {
     return cursor.positionToKey(entryID.toByteString());
   }
 }
示例#2
0
 /**
  * Fetch a record from the entry tree.
  *
  * @param txn a non null transaction
  * @param entryID The desired entry ID which forms the key.
  * @return The requested entry, or null if there is no such record.
  * @throws DirectoryException If a problem occurs while getting the entry.
  * @throws StorageRuntimeException If an error occurs in the storage.
  */
 public Entry get(ReadableTransaction txn, EntryID entryID)
     throws DirectoryException, StorageRuntimeException {
   try {
     return get0(txn.read(getName(), entryID.toByteString()));
   } catch (Exception e) {
     throw new DirectoryException(
         DirectoryServer.getServerErrorResultCode(), ERR_ENTRY_DATABASE_CORRUPT.get(entryID));
   }
 }
示例#3
0
 @Override
 public ByteString generateKey(String data) {
   EntryID entryID = new EntryID(Long.parseLong(data));
   return entryID.toByteString();
 }
示例#4
0
 /**
  * Remove a record from the entry tree.
  *
  * @param txn a non null transaction
  * @param entryID The entry ID which forms the key.
  * @return true if the entry was removed, false if it was not.
  * @throws StorageRuntimeException If an error occurs in the storage.
  */
 boolean remove(WriteableTransaction txn, EntryID entryID) throws StorageRuntimeException {
   return txn.delete(getName(), entryID.toByteString());
 }
示例#5
0
 public void put(WriteableTransaction txn, EntryID entryID, ByteSequence encodedEntry)
     throws StorageRuntimeException, DirectoryException {
   Reject.ifNull(txn, "txn must not be null.");
   txn.put(getName(), entryID.toByteString(), encodedEntry);
 }