| | |
| | | import static org.opends.server.backends.pluggable.CursorTransformer.*; |
| | | import static org.opends.server.backends.pluggable.DnKeyFormat.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.NoSuchElementException; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.Functions; |
| | | import org.forgerock.util.Function; |
| | | import org.forgerock.util.Pair; |
| | | import org.forgerock.util.promise.NeverThrowsException; |
| | | import org.opends.server.backends.pluggable.OnDiskMergeImporter.SequentialCursorDecorator; |
| | | import org.opends.server.backends.pluggable.spi.Cursor; |
| | |
| | | import org.opends.server.backends.pluggable.spi.TreeName; |
| | | import org.opends.server.backends.pluggable.spi.UpdateFunction; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Operation; |
| | | |
| | | /** |
| | | * This class represents the dn2id index, which has one record |
| | |
| | | return transformKeysAndValues(new SubtreeCursor(openCursor0(txn, dn)), TO_VOID_KEY, TO_ENTRY_ID); |
| | | } |
| | | |
| | | List<Pair<Long, Long>> renameSubtree(WriteableTransaction txn, |
| | | DN oldName, |
| | | DN newName, |
| | | RootContainer rootContainer, |
| | | boolean renumberEntryIDs, |
| | | Operation operation) |
| | | throws CanceledOperationException |
| | | { |
| | | try (SequentialCursor<ByteString, ByteString> cursor = new SubtreeCursor(openCursor0(txn, oldName))) |
| | | { |
| | | List<Pair<Long, Long>> renamedEntryIDs = new ArrayList<>(); |
| | | int oldTargetDnKeyLength = toKey(oldName).length(); |
| | | ByteString newTargetDnKey = toKey(newName); |
| | | |
| | | do |
| | | { |
| | | ByteString currentDnKey = cursor.getKey(); |
| | | EntryID oldID = new EntryID(cursor.getValue()); |
| | | cursor.delete(); |
| | | |
| | | ByteString newDnKeySuffix = currentDnKey.subSequence(oldTargetDnKeyLength, currentDnKey.length()); |
| | | ByteSequence newDnKey = new ByteStringBuilder(newTargetDnKey).append(newDnKeySuffix); |
| | | EntryID newID = renumberEntryIDs ? rootContainer.getNextEntryID() : oldID; |
| | | txn.put(getName(), newDnKey, newID.toByteString()); |
| | | |
| | | renamedEntryIDs.add(Pair.of(oldID.longValue(), newID.longValue())); |
| | | |
| | | if (operation != null) |
| | | { |
| | | operation.checkIfCanceled(false); |
| | | } |
| | | } |
| | | while (cursor.next()); |
| | | |
| | | return renamedEntryIDs; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Check if two DN have a parent-child relationship. |
| | | * |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void delete() throws NoSuchElementException, UnsupportedOperationException |
| | | { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | @Override |
| | | public void close() |
| | | { |
| | | delegate.close(); |