| | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.EntryCache; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginResult.SubordinateDelete; |
| | | import org.opends.server.api.plugin.PluginResult.SubordinateModifyDN; |
| | | import org.opends.server.backends.pluggable.SuffixContainer; |
| | | import org.opends.server.controls.*; |
| | | import org.opends.server.core.*; |
| | |
| | | import static com.sleepycat.je.LockMode.*; |
| | | |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.server.backends.jeb.JebFormat.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.opends.server.types.AdditionalLogItem.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | |
| | | EntryID entryID = dn2id.get(null, entryDN, LockMode.DEFAULT); |
| | | if (entryID != null) |
| | | { |
| | | DatabaseEntry key = |
| | | new DatabaseEntry(JebFormat.entryIDToDatabase(entryID.longValue())); |
| | | DatabaseEntry key = new DatabaseEntry(entryIDToDatabase(entryID.longValue())); |
| | | EntryIDSet entryIDSet; |
| | | if(!subtree) |
| | | if (subtree) |
| | | { |
| | | entryIDSet = id2children.readKey(key, null, LockMode.DEFAULT); |
| | | entryIDSet = id2subtree.readKey(key, null, LockMode.DEFAULT); |
| | | } |
| | | else |
| | | { |
| | | entryIDSet = id2subtree.readKey(key, null, LockMode.DEFAULT); |
| | | entryIDSet = id2children.readKey(key, null, LockMode.DEFAULT); |
| | | } |
| | | long count = entryIDSet.size(); |
| | | if(count != Long.MAX_VALUE) |
| | |
| | | rootContainer.getMonitorProvider().updateUnindexedSearchCount(); |
| | | } |
| | | |
| | | searchOperation.addAdditionalLogItem(AdditionalLogItem.keyOnly(getClass(), "unindexed")); |
| | | searchOperation.addAdditionalLogItem(keyOnly(getClass(), "unindexed")); |
| | | |
| | | // See if we could use a virtual attribute rule to process the search. |
| | | for (VirtualAttributeRule rule : DirectoryServer.getVirtualAttributes()) |
| | |
| | | * "cn=joe,ou=people,dc=example,dc=com" will appear after the entry |
| | | * "ou=people,dc=example,dc=com". |
| | | */ |
| | | byte[] baseDNKey = JebFormat.dnToDNKey(aBaseDN, |
| | | this.baseDN.size()); |
| | | byte[] baseDNKey = dnToDNKey(aBaseDN, this.baseDN.size()); |
| | | byte[] suffix = Arrays.copyOf(baseDNKey, baseDNKey.length+1); |
| | | suffix[suffix.length-1] = 0x00; |
| | | |
| | |
| | | boolean isInScope = |
| | | searchScope != SearchScope.SINGLE_LEVEL |
| | | // Check if this entry is an immediate child. |
| | | || JebFormat.findDNKeyParent(key.getData(), 0, key.getSize()) == baseDNKey.length; |
| | | || findDNKeyParent(key.getData(), 0, key.getSize()) == baseDNKey.length; |
| | | if (isInScope) |
| | | { |
| | | // Try the entry cache first. |
| | |
| | | * find subordinates of the target entry from the top of the tree |
| | | * downwards. |
| | | */ |
| | | byte[] entryDNKey = JebFormat.dnToDNKey(entryDN, |
| | | this.baseDN.size()); |
| | | byte[] entryDNKey = dnToDNKey(entryDN, this.baseDN.size()); |
| | | byte[] suffix = Arrays.copyOf(entryDNKey, entryDNKey.length+1); |
| | | suffix[suffix.length-1] = 0x00; |
| | | |
| | |
| | | if (deleteOperation != null |
| | | && !deleteOperation.isSynchronizationOperation()) |
| | | { |
| | | Entry subordinateEntry = id2entry.get( |
| | | txn, entryID, LockMode.DEFAULT); |
| | | PluginConfigManager pluginManager = |
| | | DirectoryServer.getPluginConfigManager(); |
| | | PluginResult.SubordinateDelete pluginResult = |
| | | pluginManager.invokeSubordinateDeletePlugins( |
| | | Entry subordinateEntry = id2entry.get(txn, entryID, LockMode.DEFAULT); |
| | | SubordinateDelete pluginResult = |
| | | getPluginConfigManager().invokeSubordinateDeletePlugins( |
| | | deleteOperation, subordinateEntry); |
| | | |
| | | if (!pluginResult.continueProcessing()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_JEB_DELETE_ABORTED_BY_SUBORDINATE_PLUGIN.get( |
| | | JebFormat.dnFromDNKey(key.getData(), 0, 0, getBaseDN()). |
| | | toString()); |
| | | dnFromDNKey(key.getData(), 0, 0, getBaseDN())); |
| | | throw new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), message); |
| | | } |
| | |
| | | |
| | | if(isSubtreeDelete) |
| | | { |
| | | deleteOperation.addAdditionalLogItem(AdditionalLogItem |
| | | .unquotedKeyValue(getClass(), "deletedEntries", |
| | | deleteOperation.addAdditionalLogItem( |
| | | unquotedKeyValue(getClass(), "deletedEntries", |
| | | subordinateEntriesDeleted + 1)); |
| | | } |
| | | } |
| | |
| | | // Read the entry ID from dn2id. |
| | | if(leafDNKey == null) |
| | | { |
| | | leafDNKey = new DatabaseEntry(JebFormat.dnToDNKey(targetDN, this.baseDN.size())); |
| | | leafDNKey = new DatabaseEntry(dnToDNKey(targetDN, baseDN.size())); |
| | | } |
| | | DatabaseEntry value = new DatabaseEntry(); |
| | | OperationStatus status = dn2id.read(txn, leafDNKey, value, LockMode.RMW); |
| | | if (status != OperationStatus.SUCCESS) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_JEB_DELETE_NO_SUCH_OBJECT.get(leafDNKey); |
| | | LocalizableMessage message = ERR_JEB_DELETE_NO_SUCH_OBJECT.get(leafDNKey); |
| | | DN matchedDN = getMatchedDN(baseDN); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, |
| | | message, matchedDN, null); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, matchedDN, null); |
| | | } |
| | | leafID = new EntryID(value); |
| | | } |
| | |
| | | // Do not expect to ever come through here. |
| | | LocalizableMessage message = ERR_JEB_DELETE_NO_SUCH_OBJECT.get(leafDNKey); |
| | | DN matchedDN = getMatchedDN(baseDN); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, |
| | | message, matchedDN, null); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, matchedDN, null); |
| | | } |
| | | |
| | | // Check that the entry exists in id2entry and read its contents. |
| | |
| | | public void replaceEntry(Entry oldEntry, Entry newEntry, |
| | | ModifyOperation modifyOperation) throws DatabaseException, |
| | | DirectoryException, CanceledOperationException |
| | | { |
| | | { |
| | | Transaction txn = beginTransaction(); |
| | | |
| | | try |
| | |
| | | * find subordinates of the target entry from the top of the tree |
| | | * downwards. |
| | | */ |
| | | byte[] currentDNKey = JebFormat.dnToDNKey(currentDN, |
| | | this.baseDN.size()); |
| | | byte[] currentDNKey = dnToDNKey(currentDN, this.baseDN.size()); |
| | | byte[] suffix = Arrays.copyOf(currentDNKey, currentDNKey.length+1); |
| | | suffix[suffix.length-1] = 0x00; |
| | | |
| | |
| | | // operations. |
| | | if (! modifyDNOperation.isSynchronizationOperation()) |
| | | { |
| | | PluginConfigManager pluginManager = |
| | | DirectoryServer.getPluginConfigManager(); |
| | | PluginResult.SubordinateModifyDN pluginResult = |
| | | pluginManager.invokeSubordinateModifyDNPlugins( |
| | | SubordinateModifyDN pluginResult = |
| | | getPluginConfigManager().invokeSubordinateModifyDNPlugins( |
| | | modifyDNOperation, oldEntry, newEntry, modifications); |
| | | |
| | | if (!pluginResult.continueProcessing()) |
| | |
| | | * @throws DatabaseException If an error occurs in the JE database. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | private void indexInsertEntry(IndexBuffer buffer, Entry entry, |
| | | EntryID entryID) |
| | | throws DatabaseException, DirectoryException |
| | | private void indexInsertEntry(IndexBuffer buffer, Entry entry, EntryID entryID) |
| | | throws DatabaseException, DirectoryException |
| | | { |
| | | for (AttributeIndex index : attrIndexMap.values()) |
| | | { |
| | |
| | | * @throws DatabaseException If an error occurs in the JE database. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | private void indexRemoveEntry(IndexBuffer buffer, Entry entry, |
| | | EntryID entryID) |
| | | throws DatabaseException, DirectoryException |
| | | private void indexRemoveEntry(IndexBuffer buffer, Entry entry, EntryID entryID) |
| | | throws DatabaseException, DirectoryException |
| | | { |
| | | for (AttributeIndex index : attrIndexMap.values()) |
| | | { |
| | |
| | | * @throws DatabaseException If an error occurs in the JE database. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | private void indexModifications(IndexBuffer buffer, Entry oldEntry, |
| | | Entry newEntry, |
| | | private void indexModifications(IndexBuffer buffer, Entry oldEntry, Entry newEntry, |
| | | EntryID entryID, List<Modification> mods) |
| | | throws DatabaseException, DirectoryException |
| | | { |
| | |
| | | EntryID entryID = dn2id.get(null, baseDN, LockMode.DEFAULT); |
| | | if (entryID != null) |
| | | { |
| | | DatabaseEntry key = new DatabaseEntry(JebFormat.entryIDToDatabase(entryID.longValue())); |
| | | DatabaseEntry key = new DatabaseEntry(entryIDToDatabase(entryID.longValue())); |
| | | EntryIDSet entryIDSet = id2subtree.readKey(key, null, LockMode.DEFAULT); |
| | | |
| | | long count = entryIDSet.size(); |