| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import com.sleepycat.je.*; |
| | | |
| | | import java.util.Arrays; |
| | | import static com.sleepycat.je.LockMode.*; |
| | | import static com.sleepycat.je.OperationStatus.*; |
| | | |
| | | /** |
| | | * This class is responsible for storing the configuration state of |
| | |
| | | { |
| | | String shortName = |
| | | index.getName().replace(entryContainer.getDatabasePrefix(), ""); |
| | | DatabaseEntry key = |
| | | new DatabaseEntry(StaticUtils.getBytes(shortName)); |
| | | return key; |
| | | return new DatabaseEntry(StaticUtils.getBytes(shortName)); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | DatabaseEntry key = keyForIndex(index); |
| | | |
| | | OperationStatus status = delete(txn, key); |
| | | if (status != OperationStatus.SUCCESS) |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | return delete(txn, key) == SUCCESS; |
| | | } |
| | | |
| | | /** |
| | |
| | | DatabaseEntry key = keyForIndex(index); |
| | | DatabaseEntry data = new DatabaseEntry(); |
| | | |
| | | OperationStatus status; |
| | | status = read(txn, key, data, LockMode.DEFAULT); |
| | | |
| | | if (status != OperationStatus.SUCCESS) |
| | | if (read(txn, key, data, DEFAULT) == SUCCESS) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | byte[] bytes = data.getData(); |
| | | return Arrays.equals(bytes, trueBytes); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Put index state to database. |
| | |
| | | DatabaseEntry key = keyForIndex(index); |
| | | DatabaseEntry data = new DatabaseEntry(); |
| | | |
| | | if(trusted) |
| | | data.setData(trueBytes); |
| | | else |
| | | data.setData(falseBytes); |
| | | data.setData(trusted ? trueBytes : falseBytes); |
| | | |
| | | OperationStatus status; |
| | | status = put(txn, key, data); |
| | | if (status != OperationStatus.SUCCESS) |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | return put(txn, key, data) == SUCCESS; |
| | | } |
| | | |
| | | } |