| | |
| | | @Override |
| | | public Long run(ReadableStorage txn) throws Exception |
| | | { |
| | | EntryID entryID = dn2id.get(txn, entryDN, false); |
| | | EntryID entryID = dn2id.get(txn, entryDN); |
| | | if (entryID != null) |
| | | { |
| | | ByteString key = entryID.toByteString(); |
| | |
| | | if (entryIDList.size() > IndexFilter.FILTER_CANDIDATE_THRESHOLD) |
| | | { |
| | | // Read the ID from dn2id. |
| | | EntryID baseID = dn2id.get(txn, aBaseDN, false); |
| | | EntryID baseID = dn2id.get(txn, aBaseDN); |
| | | if (baseID == null) |
| | | { |
| | | LocalizableMessage message = ERR_JEB_SEARCH_NO_SUCH_OBJECT.get(aBaseDN); |
| | |
| | | return cacheEntry; |
| | | } |
| | | |
| | | final Entry entry = id2entry.get(txn, entryID, false); |
| | | final Entry entry = id2entry.get(txn, entryID); |
| | | if (entry != null) |
| | | { |
| | | // Put the entry in the cache making sure not to overwrite a newer copy |
| | |
| | | try |
| | | { |
| | | // Check whether the entry already exists. |
| | | if (dn2id.get(txn, entry.getName(), false) != null) |
| | | if (dn2id.get(txn, entry.getName()) != null) |
| | | { |
| | | throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS, ERR_JEB_ADD_ENTRY_ALREADY_EXISTS.get(entry |
| | | .getName())); |
| | |
| | | dn2uri.targetEntryReferrals(txn, entry.getName(), null); |
| | | |
| | | // Read the parent ID from dn2id. |
| | | parentID = dn2id.get(txn, parentDN, false); |
| | | parentID = dn2id.get(txn, parentDN); |
| | | if (parentID == null) |
| | | { |
| | | LocalizableMessage message = ERR_JEB_ADD_NO_SUCH_OBJECT.get(entry.getName()); |
| | |
| | | for (DN dn = getParentWithinBase(parentDN); dn != null; dn = getParentWithinBase(dn)) |
| | | { |
| | | // Read the ID from dn2id. |
| | | EntryID nodeID = dn2id.get(txn, dn, false); |
| | | EntryID nodeID = dn2id.get(txn, dn); |
| | | if (nodeID == null) |
| | | { |
| | | throw new StorageRuntimeException(ERR_JEB_MISSING_DN2ID_RECORD.get(dn).toString()); |
| | |
| | | |
| | | int subordinateEntriesDeleted = 0; |
| | | |
| | | Cursor cursor = dn2id.openCursor(txn); |
| | | Cursor cursor = txn.openCursor(dn2id.getName()); |
| | | try |
| | | { |
| | | // Step forward until we pass the ending value. |
| | |
| | | // Invoke any subordinate delete plugins on the entry. |
| | | if (deleteOperation != null && !deleteOperation.isSynchronizationOperation()) |
| | | { |
| | | Entry subordinateEntry = id2entry.get(txn, entryID, false); |
| | | Entry subordinateEntry = id2entry.get(txn, entryID); |
| | | SubordinateDelete pluginResult = |
| | | getPluginConfigManager().invokeSubordinateDeletePlugins(deleteOperation, subordinateEntry); |
| | | |
| | |
| | | { |
| | | leafDNKey = dnToDNKey(targetDN, baseDN.size()); |
| | | } |
| | | ByteString value = dn2id.read(txn, leafDNKey, true); |
| | | ByteString value = txn.getRMW(dn2id.getName(), leafDNKey); |
| | | if (value == null) |
| | | { |
| | | LocalizableMessage message = ERR_JEB_DELETE_NO_SUCH_OBJECT.get(targetDN); |
| | |
| | | } |
| | | |
| | | // Remove from dn2id. |
| | | if (!dn2id.delete(txn, leafDNKey)) |
| | | if (!txn.delete(dn2id.getName(), leafDNKey)) |
| | | { |
| | | // Do not expect to ever come through here. |
| | | LocalizableMessage message = ERR_JEB_DELETE_NO_SUCH_OBJECT.get(leafDNKey); |
| | |
| | | } |
| | | |
| | | // Check that the entry exists in id2entry and read its contents. |
| | | Entry entry = id2entry.get(txn, leafID, true); |
| | | Entry entry = id2entry.getRMW(txn, leafID); |
| | | if (entry == null) |
| | | { |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | |
| | | parentDN = getParentWithinBase(parentDN)) |
| | | { |
| | | // Read the ID from dn2id. |
| | | EntryID parentID = dn2id.get(txn, parentDN, false); |
| | | EntryID parentID = dn2id.get(txn, parentDN); |
| | | if (parentID == null) |
| | | { |
| | | throw new StorageRuntimeException(ERR_JEB_MISSING_DN2ID_RECORD.get(parentDN).toString()); |
| | |
| | | @Override |
| | | public Boolean run(ReadableStorage txn) throws Exception |
| | | { |
| | | EntryID id = dn2id.get(null, entryDN, false); |
| | | EntryID id = dn2id.get(null, entryDN); |
| | | return id != null; |
| | | } |
| | | }); |
| | |
| | | try |
| | | { |
| | | // Read dn2id. |
| | | EntryID entryID = dn2id.get(txn, entryDN, false); |
| | | EntryID entryID = dn2id.get(txn, entryDN); |
| | | if (entryID == null) |
| | | { |
| | | // The entryDN does not exist. |
| | |
| | | } |
| | | |
| | | // Read id2entry. |
| | | final Entry entry = id2entry.get(txn, entryID, false); |
| | | final Entry entry = id2entry.get(txn, entryID); |
| | | if (entry == null) |
| | | { |
| | | // The entryID does not exist. |
| | |
| | | try |
| | | { |
| | | // Read dn2id. |
| | | EntryID entryID = dn2id.get(txn, newEntry.getName(), true); |
| | | EntryID entryID = dn2id.getRMW(txn, newEntry.getName()); |
| | | if (entryID == null) |
| | | { |
| | | // The entry does not exist. |
| | |
| | | try |
| | | { |
| | | // Check whether the renamed entry already exists. |
| | | if (!currentDN.equals(entry.getName()) && dn2id.get(txn, entry.getName(), false) != null) |
| | | if (!currentDN.equals(entry.getName()) && dn2id.get(txn, entry.getName()) != null) |
| | | { |
| | | LocalizableMessage message = ERR_JEB_MODIFYDN_ALREADY_EXISTS.get(entry.getName()); |
| | | throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS, message); |
| | | } |
| | | |
| | | EntryID oldApexID = dn2id.get(txn, currentDN, false); |
| | | EntryID oldApexID = dn2id.get(txn, currentDN); |
| | | if (oldApexID == null) |
| | | { |
| | | // Check for referral entries above the target entry. |
| | |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, matchedDN, null); |
| | | } |
| | | |
| | | Entry oldApexEntry = id2entry.get(txn, oldApexID, false); |
| | | Entry oldApexEntry = id2entry.get(txn, oldApexID); |
| | | if (oldApexEntry == null) |
| | | { |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), ERR_JEB_MISSING_ID2ENTRY_RECORD |
| | |
| | | * greater than its parent, since search results are returned in |
| | | * ID order. |
| | | */ |
| | | EntryID newSuperiorID = dn2id.get(txn, newSuperiorDN, false); |
| | | EntryID newSuperiorID = dn2id.get(txn, newSuperiorDN); |
| | | if (newSuperiorID == null) |
| | | { |
| | | LocalizableMessage msg = ERR_JEB_NEW_SUPERIOR_NO_SUCH_OBJECT.get(newSuperiorDN); |
| | |
| | | { |
| | | // We have found a subordinate entry. |
| | | EntryID oldID = new EntryID(cursor.getValue()); |
| | | Entry oldEntry = id2entry.get(txn, oldID, false); |
| | | Entry oldEntry = id2entry.get(txn, oldID); |
| | | |
| | | // Construct the new DN of the entry. |
| | | DN newDN = modDN(oldEntry.getName(), currentDN.size(), entry.getName()); |
| | |
| | | for (DN dn = getParentWithinBase(newEntry.getName()); dn != null; |
| | | dn = getParentWithinBase(dn)) |
| | | { |
| | | EntryID parentID = dn2id.get(txn, dn, false); |
| | | EntryID parentID = dn2id.get(txn, dn); |
| | | ByteString parentIDKeyBytes = parentID.toByteString(); |
| | | if(isParent) |
| | | { |
| | |
| | | boolean isParent = true; |
| | | for (DN dn = oldSuperiorDN; dn != null; dn = getParentWithinBase(dn)) |
| | | { |
| | | EntryID parentID = dn2id.get(txn, dn, false); |
| | | EntryID parentID = dn2id.get(txn, dn); |
| | | ByteString parentIDKeyBytes = parentID.toByteString(); |
| | | if(isParent) |
| | | { |
| | |
| | | // Remove the old ID from id2subtree of old apex superior entries. |
| | | for (DN dn = oldSuperiorDN; dn != null; dn = getParentWithinBase(dn)) |
| | | { |
| | | EntryID parentID = dn2id.get(txn, dn, false); |
| | | EntryID parentID = dn2id.get(txn, dn); |
| | | ByteString parentIDKeyBytes = parentID.toByteString(); |
| | | id2subtree.removeID(buffer, parentIDKeyBytes, oldID); |
| | | } |
| | |
| | | */ |
| | | long getEntryCount(ReadableStorage txn) throws StorageRuntimeException |
| | | { |
| | | final EntryID entryID = dn2id.get(txn, baseDN, false); |
| | | final EntryID entryID = dn2id.get(txn, baseDN); |
| | | if (entryID != null) |
| | | { |
| | | final EntryIDSet entryIDSet = id2subtree.readKey(entryID.toByteString(), txn); |
| | |
| | | |
| | | try |
| | | { |
| | | // Rename in transaction. |
| | | storage.write(new WriteOperation() |
| | | { |
| | | @Override |
| | |
| | | } |
| | | } |
| | | }); |
| | | storage.write(new WriteOperation() |
| | | // Only rename the containers if the txn succeeded. |
| | | for (DatabaseContainer db : databases) |
| | | { |
| | | @Override |
| | | public void run(WriteableStorage txn) throws Exception |
| | | { |
| | | for (DatabaseContainer db : databases) |
| | | { |
| | | TreeName oldName = db.getName(); |
| | | TreeName newName = oldName.replaceBaseDN(newBaseDN); |
| | | db.setName(newName); |
| | | } |
| | | } |
| | | }); |
| | | TreeName oldName = db.getName(); |
| | | TreeName newName = oldName.replaceBaseDN(newBaseDN); |
| | | db.setName(newName); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |