| | |
| | | public class MemoryBackend |
| | | extends Backend |
| | | { |
| | | |
| | | |
| | | |
| | | // The base DNs for this backend. |
| | | private DN[] baseDNs; |
| | | |
| | |
| | | { |
| | | super(); |
| | | |
| | | |
| | | |
| | | // Perform all initialization in initializeBackend. |
| | | } |
| | | |
| | |
| | | public synchronized void addEntry(Entry entry, AddOperation addOperation) |
| | | throws DirectoryException |
| | | { |
| | | Entry e = entry.duplicate(true); |
| | | |
| | | // See if the target entry already exists. If so, then fail. |
| | | DN entryDN = entry.getDN(); |
| | | DN entryDN = e.getDN(); |
| | | if (entryMap.containsKey(entryDN)) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ENTRY_ALREADY_EXISTS; |
| | |
| | | // If the entry is one of the base DNs, then add it. |
| | | if (baseDNSet.contains(entryDN)) |
| | | { |
| | | entryMap.put(entryDN, entry); |
| | | entryMap.put(entryDN, e); |
| | | return; |
| | | } |
| | | |
| | |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, msgID); |
| | | } |
| | | |
| | | entryMap.put(entryDN, entry); |
| | | entryMap.put(entryDN, e); |
| | | HashSet<DN> children = childDNs.get(parentDN); |
| | | if (children == null) |
| | | { |
| | |
| | | ModifyOperation modifyOperation) |
| | | throws DirectoryException |
| | | { |
| | | Entry e = entry.duplicate(true); |
| | | |
| | | // Make sure the entry exists. If not, then throw an exception. |
| | | DN entryDN = entry.getDN(); |
| | | DN entryDN = e.getDN(); |
| | | if (! entryMap.containsKey(entryDN)) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ENTRY_DOESNT_EXIST; |
| | |
| | | |
| | | |
| | | // Replace the old entry with the new one. |
| | | entryMap.put(entryDN, entry); |
| | | entryMap.put(entryDN, e); |
| | | } |
| | | |
| | | |
| | |
| | | ModifyDNOperation modifyDNOperation) |
| | | throws DirectoryException |
| | | { |
| | | Entry e = entry.duplicate(true); |
| | | |
| | | // Make sure that the target entry exists. |
| | | if (! entryMap.containsKey(currentDN)) |
| | | { |
| | |
| | | |
| | | |
| | | // Make sure that no entry exists with the new DN. |
| | | if (entryMap.containsKey(entry.getDN())) |
| | | if (entryMap.containsKey(e.getDN())) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ENTRY_ALREADY_EXISTS; |
| | | String message = getMessage(msgID, String.valueOf(entry.getDN())); |
| | | String message = getMessage(msgID, String.valueOf(e.getDN())); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, msgID); |
| | | } |
| | | |
| | |
| | | boolean matchFound = false; |
| | | for (DN dn : baseDNs) |
| | | { |
| | | if (dn.isAncestorOf(entry.getDN())) |
| | | if (dn.isAncestorOf(e.getDN())) |
| | | { |
| | | matchFound = true; |
| | | break; |
| | |
| | | |
| | | |
| | | // Make sure that the parent of the new entry exists. |
| | | DN parentDN = entry.getDN().getParentDNInSuffix(); |
| | | DN parentDN = e.getDN().getParentDNInSuffix(); |
| | | if ((parentDN == null) || (! entryMap.containsKey(parentDN))) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_RENAME_PARENT_DOESNT_EXIST; |
| | |
| | | |
| | | // Delete the current entry and add the new one. |
| | | deleteEntry(currentDN, null); |
| | | addEntry(entry, null); |
| | | addEntry(e, null); |
| | | } |
| | | |
| | | |