| | |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.backends; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.BackendMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | |
| | | // map. |
| | | if ((baseDNs == null) || (baseDNs.length != 1)) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_REQUIRE_EXACTLY_ONE_BASE; |
| | | String message = getMessage(msgID); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_MEMORYBACKEND_REQUIRE_EXACTLY_ONE_BASE.get(); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | baseDNSet = new HashSet<DN>(); |
| | |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_BACKEND_CANNOT_REGISTER_BASEDN; |
| | | String message = getMessage(msgID, dn.toString(), |
| | | getExceptionMessage(e)); |
| | | throw new InitializationException(msgID, message, e); |
| | | Message message = ERR_BACKEND_CANNOT_REGISTER_BASEDN.get( |
| | | dn.toString(), getExceptionMessage(e)); |
| | | throw new InitializationException(message, e); |
| | | } |
| | | } |
| | | } |
| | |
| | | DN entryDN = e.getDN(); |
| | | if (entryMap.containsKey(entryDN)) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ENTRY_ALREADY_EXISTS; |
| | | String message = getMessage(msgID, String.valueOf(entryDN)); |
| | | throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS, message, |
| | | msgID); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_ENTRY_ALREADY_EXISTS.get(String.valueOf(entryDN)); |
| | | throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS, message); |
| | | } |
| | | |
| | | |
| | |
| | | DN parentDN = entryDN.getParentDNInSuffix(); |
| | | if (parentDN == null) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ENTRY_DOESNT_BELONG; |
| | | String message = getMessage(msgID, String.valueOf(entryDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, msgID); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_ENTRY_DOESNT_BELONG.get(String.valueOf(entryDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message); |
| | | } |
| | | else if (! entryMap.containsKey(parentDN)) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_PARENT_DOESNT_EXIST; |
| | | String message = getMessage(msgID, String.valueOf(entryDN), |
| | | String.valueOf(parentDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, msgID); |
| | | Message message = ERR_MEMORYBACKEND_PARENT_DOESNT_EXIST.get( |
| | | String.valueOf(entryDN), String.valueOf(parentDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message); |
| | | } |
| | | |
| | | entryMap.put(entryDN, e); |
| | |
| | | // Make sure the entry exists. If not, then throw an exception. |
| | | if (! entryMap.containsKey(entryDN)) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ENTRY_DOESNT_EXIST; |
| | | String message = getMessage(msgID, String.valueOf(entryDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, msgID); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_ENTRY_DOESNT_EXIST.get(String.valueOf(entryDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message); |
| | | } |
| | | |
| | | |
| | |
| | | // an exception. |
| | | if ((children != null) && (! children.isEmpty())) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_CANNOT_DELETE_ENTRY_WITH_CHILDREN; |
| | | String message = getMessage(msgID, String.valueOf(entryDN)); |
| | | throw new DirectoryException(ResultCode.NOT_ALLOWED_ON_NONLEAF, message, |
| | | msgID); |
| | | Message message = ERR_MEMORYBACKEND_CANNOT_DELETE_ENTRY_WITH_CHILDREN. |
| | | get(String.valueOf(entryDN)); |
| | | throw new DirectoryException( |
| | | ResultCode.NOT_ALLOWED_ON_NONLEAF, message); |
| | | } |
| | | } |
| | | |
| | |
| | | DN entryDN = e.getDN(); |
| | | if (! entryMap.containsKey(entryDN)) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ENTRY_DOESNT_EXIST; |
| | | String message = getMessage(msgID, String.valueOf(entryDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, msgID); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_ENTRY_DOESNT_EXIST.get(String.valueOf(entryDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message); |
| | | } |
| | | |
| | | |
| | |
| | | // Make sure that the target entry exists. |
| | | if (! entryMap.containsKey(currentDN)) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ENTRY_DOESNT_EXIST; |
| | | String message = getMessage(msgID, String.valueOf(currentDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, msgID); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_ENTRY_DOESNT_EXIST.get(String.valueOf(currentDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_CANNOT_RENAME_ENRY_WITH_CHILDREN; |
| | | String message = getMessage(msgID, String.valueOf(currentDN)); |
| | | throw new DirectoryException(ResultCode.NOT_ALLOWED_ON_NONLEAF, message, |
| | | msgID); |
| | | Message message = ERR_MEMORYBACKEND_CANNOT_RENAME_ENRY_WITH_CHILDREN. |
| | | get(String.valueOf(currentDN)); |
| | | throw new DirectoryException( |
| | | ResultCode.NOT_ALLOWED_ON_NONLEAF, message); |
| | | } |
| | | } |
| | | |
| | |
| | | // Make sure that no entry exists with the new DN. |
| | | if (entryMap.containsKey(e.getDN())) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ENTRY_ALREADY_EXISTS; |
| | | String message = getMessage(msgID, String.valueOf(e.getDN())); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, msgID); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_ENTRY_ALREADY_EXISTS.get(String.valueOf(e.getDN())); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | if (! matchFound) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_CANNOT_RENAME_TO_ANOTHER_BACKEND; |
| | | String message = getMessage(msgID, String.valueOf(currentDN)); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message, |
| | | msgID); |
| | | Message message = ERR_MEMORYBACKEND_CANNOT_RENAME_TO_ANOTHER_BACKEND.get( |
| | | String.valueOf(currentDN)); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | | |
| | |
| | | DN parentDN = e.getDN().getParentDNInSuffix(); |
| | | if ((parentDN == null) || (! entryMap.containsKey(parentDN))) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_RENAME_PARENT_DOESNT_EXIST; |
| | | String message = getMessage(msgID, String.valueOf(currentDN), |
| | | String.valueOf(parentDN)); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message, |
| | | msgID); |
| | | Message message = ERR_MEMORYBACKEND_RENAME_PARENT_DOESNT_EXIST.get( |
| | | String.valueOf(currentDN), String.valueOf(parentDN)); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | | |
| | |
| | | matchedDN = matchedDN.getParentDNInSuffix(); |
| | | } |
| | | |
| | | int msgID = MSGID_MEMORYBACKEND_ENTRY_DOESNT_EXIST; |
| | | String message = getMessage(msgID, String.valueOf(baseDN)); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, msgID, |
| | | matchedDN, null); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_ENTRY_DOESNT_EXIST.get(String.valueOf(baseDN)); |
| | | throw new DirectoryException( |
| | | ResultCode.NO_SUCH_OBJECT, message, matchedDN, null); |
| | | } |
| | | |
| | | if (baseEntry != null) |
| | |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_MEMORYBACKEND_CANNOT_CREATE_LDIF_WRITER; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_CANNOT_CREATE_LDIF_WRITER.get(String.valueOf(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_CANNOT_WRITE_ENTRY_TO_LDIF; |
| | | String message = getMessage(msgID, String.valueOf(entryDN), |
| | | String.valueOf(e)); |
| | | Message message = ERR_MEMORYBACKEND_CANNOT_WRITE_ENTRY_TO_LDIF.get( |
| | | String.valueOf(entryDN), String.valueOf(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID, e); |
| | | message, e); |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_CANNOT_CREATE_LDIF_READER; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_CANNOT_CREATE_LDIF_READER.get(String.valueOf(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | if (! le.canContinueReading()) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ERROR_READING_LDIF; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_ERROR_READING_LDIF.get(String.valueOf(e)); |
| | | throw new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID, le); |
| | | message, le); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | reader.rejectLastEntry(de.getErrorMessage()); |
| | | reader.rejectLastEntry(de.getMessageObject()); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_ERROR_DURING_IMPORT; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | Message message = |
| | | ERR_MEMORYBACKEND_ERROR_DURING_IMPORT.get(String.valueOf(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID, e); |
| | | message, e); |
| | | } |
| | | finally |
| | | { |
| | |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_BACKUP_RESTORE_NOT_SUPPORTED; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message, |
| | | msgID); |
| | | Message message = ERR_MEMORYBACKEND_BACKUP_RESTORE_NOT_SUPPORTED.get(); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | | |
| | |
| | | String backupID) |
| | | throws DirectoryException |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_BACKUP_RESTORE_NOT_SUPPORTED; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message, |
| | | msgID); |
| | | Message message = ERR_MEMORYBACKEND_BACKUP_RESTORE_NOT_SUPPORTED.get(); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | | |
| | |
| | | public void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | int msgID = MSGID_MEMORYBACKEND_BACKUP_RESTORE_NOT_SUPPORTED; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message, |
| | | msgID); |
| | | Message message = ERR_MEMORYBACKEND_BACKUP_RESTORE_NOT_SUPPORTED.get(); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | } |
| | | |