| | |
| | | public class DN2ID |
| | | { |
| | | /** |
| | | * The database container. |
| | | * The database entryContainer. |
| | | */ |
| | | private Container container; |
| | | private EntryContainer entryContainer; |
| | | |
| | | /** |
| | | * The JE database configuration. |
| | |
| | | private DatabaseConfig dbConfig; |
| | | |
| | | /** |
| | | * The name of the database within the container. |
| | | * The name of the database within the entryContainer. |
| | | */ |
| | | private String name; |
| | | |
| | |
| | | new ThreadLocal<Database>(); |
| | | |
| | | /** |
| | | * Create a DN2ID instance for the DN database in a given container. |
| | | * Create a DN2ID instance for the DN database in a given entryContainer. |
| | | * |
| | | * @param container The container of the DN database. |
| | | * @param entryContainer The entryContainer of the DN database. |
| | | * @param dbConfig The JE database configuration which will be used to |
| | | * open the database. |
| | | * @param name The name of the DN database ("dn2id"). |
| | | */ |
| | | public DN2ID(Container container, DatabaseConfig dbConfig, String name) |
| | | public DN2ID(EntryContainer entryContainer, DatabaseConfig dbConfig, |
| | | String name) |
| | | { |
| | | this.container = container; |
| | | this.entryContainer = entryContainer; |
| | | this.dbConfig = dbConfig; |
| | | this.name = name; |
| | | } |
| | |
| | | |
| | | /** |
| | | * Get a handle to the database. It returns a per-thread handle to avoid |
| | | * any thread contention on the database handle. The container is |
| | | * any thread contention on the database handle. The entryContainer is |
| | | * responsible for closing all handles. |
| | | * |
| | | * @return A database handle. |
| | |
| | | Database database = threadLocalDatabase.get(); |
| | | if (database == null) |
| | | { |
| | | database = container.openDatabase(dbConfig, name); |
| | | database = entryContainer.openDatabase(dbConfig, name); |
| | | threadLocalDatabase.set(database); |
| | | } |
| | | return database; |
| | |
| | | |
| | | OperationStatus status; |
| | | |
| | | status = Container.insert(getDatabase(), txn, key, data); |
| | | status = EntryContainer.insert(getDatabase(), txn, key, data); |
| | | if (status != OperationStatus.SUCCESS) |
| | | { |
| | | return false; |
| | |
| | | DatabaseEntry data = id.getDatabaseEntry(); |
| | | |
| | | OperationStatus status; |
| | | status = Container.put(getDatabase(), txn, key, data); |
| | | status = EntryContainer.put(getDatabase(), txn, key, data); |
| | | if (status != OperationStatus.SUCCESS) |
| | | { |
| | | return false; |
| | |
| | | throws DatabaseException |
| | | { |
| | | OperationStatus status; |
| | | status = Container.put(getDatabase(), txn, key, data); |
| | | status = EntryContainer.put(getDatabase(), txn, key, data); |
| | | if (status != OperationStatus.SUCCESS) |
| | | { |
| | | return false; |
| | |
| | | { |
| | | DatabaseEntry key = DNdata(dn); |
| | | |
| | | OperationStatus status = Container.delete(getDatabase(), txn, key); |
| | | OperationStatus status = EntryContainer.delete(getDatabase(), txn, key); |
| | | if (status != OperationStatus.SUCCESS) |
| | | { |
| | | return false; |
| | |
| | | DatabaseEntry data = new DatabaseEntry(); |
| | | |
| | | OperationStatus status; |
| | | status = Container.read(getDatabase(), txn, key, data, LockMode.DEFAULT); |
| | | status = EntryContainer.read(getDatabase(), txn, key, data, |
| | | LockMode.DEFAULT); |
| | | if (status != OperationStatus.SUCCESS) |
| | | { |
| | | return null; |