| | |
| | | begin = suffix; |
| | | } |
| | | |
| | | ByteSequence startKey = begin; |
| | | |
| | | int lookthroughCount = 0; |
| | | int lookthroughLimit = searchOperation.getClientConnection().getLookthroughLimit(); |
| | | |
| | |
| | | try |
| | | { |
| | | // Initialize the cursor very close to the starting value. |
| | | boolean success = cursor.positionToKeyOrNext(startKey); |
| | | boolean success = cursor.positionToKeyOrNext(begin); |
| | | |
| | | // Step forward until we pass the ending value. |
| | | while (success) |
| | | while (success && cursor.getKey().compareTo(end) < 0) |
| | | { |
| | | if(lookthroughLimit > 0 && lookthroughCount > lookthroughLimit) |
| | | { |
| | | //Lookthrough limit exceeded |
| | | searchOperation.setResultCode(ResultCode.ADMIN_LIMIT_EXCEEDED); |
| | | searchOperation.appendErrorMessage( |
| | | NOTE_JEB_LOOKTHROUGH_LIMIT_EXCEEDED.get(lookthroughLimit)); |
| | | searchOperation.appendErrorMessage(NOTE_JEB_LOOKTHROUGH_LIMIT_EXCEEDED.get(lookthroughLimit)); |
| | | return; |
| | | } |
| | | int cmp = ByteSequence.COMPARATOR.compare(cursor.getKey(), end); |
| | | if (cmp >= 0) |
| | | { |
| | | // We have gone past the ending value. |
| | | break; |
| | | } |
| | | |
| | | // We have found a subordinate entry. |
| | | |
| | | EntryID entryID = new EntryID(cursor.getValue()); |
| | | |
| | | boolean isInScope = |
| | | searchScope != SearchScope.SINGLE_LEVEL |
| | | // Check if this entry is an immediate child. |
| | |
| | | |
| | | int subordinateEntriesDeleted = 0; |
| | | |
| | | ByteSequence startKey = suffix; |
| | | |
| | | Cursor cursor = dn2id.openCursor(txn); |
| | | try |
| | | { |
| | | // Initialize the cursor very close to the starting value. |
| | | boolean success = cursor.positionToKeyOrNext(startKey); |
| | | |
| | | // Step forward until the key is greater than the starting value. |
| | | while (success |
| | | && ByteSequence.COMPARATOR.compare(cursor.getKey(), suffix) <= 0) |
| | | { |
| | | success = cursor.next(); |
| | | } |
| | | |
| | | // Step forward until we pass the ending value. |
| | | while (success) |
| | | boolean success = cursor.positionToKeyOrNext(suffix); |
| | | while (success && cursor.getKey().compareTo(end) < 0) |
| | | { |
| | | int cmp = ByteSequence.COMPARATOR.compare(cursor.getKey(), end); |
| | | if (cmp >= 0) |
| | | { |
| | | // We have gone past the ending value. |
| | | break; |
| | | } |
| | | |
| | | // We have found a subordinate entry. |
| | | if (!isSubtreeDelete) |
| | | { |
| | |
| | | private Entry getEntry0(ReadableStorage txn, final DN entryDN) throws StorageRuntimeException, DirectoryException |
| | | { |
| | | final EntryCache<?> entryCache = DirectoryServer.getEntryCache(); |
| | | Entry entry = null; |
| | | |
| | | // Try the entry cache first. |
| | | if (entryCache != null) |
| | | { |
| | | entry = entryCache.getEntry(entryDN); |
| | | final Entry entry = entryCache.getEntry(entryDN); |
| | | if (entry != null) |
| | | { |
| | | return entry; |
| | | } |
| | | } |
| | | |
| | | if (entry == null) |
| | | { |
| | | try |
| | | { |
| | | // Read dn2id. |
| | |
| | | } |
| | | |
| | | // Read id2entry. |
| | | Entry entry2 = id2entry.get(txn, entryID, false); |
| | | if (entry2 == null) |
| | | final Entry entry = id2entry.get(txn, entryID, false); |
| | | if (entry == null) |
| | | { |
| | | // The entryID does not exist. |
| | | throw new DirectoryException(getServerErrorResultCode(), ERR_JEB_MISSING_ID2ENTRY_RECORD.get(entryID)); |
| | |
| | | // we read the cache. |
| | | if (entryCache != null) |
| | | { |
| | | entryCache.putEntryIfAbsent(entry2, backend, entryID.longValue()); |
| | | entryCache.putEntryIfAbsent(entry, backend, entryID.longValue()); |
| | | } |
| | | return entry2; |
| | | return entry; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // it is not very clean to specify twice the same exception but it saves me some code for now |
| | | throwAllowedExceptionTypes(e, DirectoryException.class, DirectoryException.class); |
| | | return null; // unreachable |
| | | } |
| | | } |
| | | |
| | | return entry; |
| | | } |
| | | |
| | | /** |
| | | * The simplest case of replacing an entry in which the entry DN has |
| | | * not changed. |
| | |
| | | suffix.append((byte) 0x00); |
| | | end.append((byte) 0x01); |
| | | |
| | | ByteSequence startKey = suffix; |
| | | |
| | | Cursor cursor = txn.openCursor(dn2id.getName()); |
| | | try |
| | | { |
| | | // Initialize the cursor very close to the starting value. |
| | | boolean success = cursor.positionToKeyOrNext(startKey); |
| | | |
| | | // Step forward until the key is greater than the starting value. |
| | | while (success && ByteSequence.COMPARATOR.compare(cursor.getKey(), suffix) <= 0) |
| | | { |
| | | success = cursor.next(); |
| | | } |
| | | |
| | | // Step forward until we pass the ending value. |
| | | while (success) |
| | | boolean success = cursor.positionToKeyOrNext(suffix); |
| | | while (success && cursor.getKey().compareTo(end) < 0) |
| | | { |
| | | int cmp = ByteSequence.COMPARATOR.compare(cursor.getKey(), end); |
| | | if (cmp >= 0) |
| | | { |
| | | // We have gone past the ending value. |
| | | break; |
| | | } |
| | | |
| | | // We have found a subordinate entry. |
| | | |
| | | EntryID oldID = new EntryID(cursor.getValue()); |
| | | Entry oldEntry = id2entry.get(txn, oldID, false); |
| | | |