| | |
| | | import org.opends.server.types.SearchScope; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.BackendMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | extends Backend |
| | | implements ConfigurableComponent |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.backends.BackupBackend"; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | super(); |
| | | |
| | | assert debugConstructor(CLASS_NAME); |
| | | |
| | | |
| | | // Perform all initialization in initializeBackend. |
| | |
| | | public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "initializeBackend", |
| | | String.valueOf(configEntry)); |
| | | |
| | | |
| | | // Make sure that a configuration entry was provided. If not, then we will |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "initializeBackend", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_BACKUP_CANNOT_DECODE_BACKUP_ROOT_DN; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "initializeBackend", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_BACKUP_CANNOT_DETERMINE_BACKUP_DIR_LIST; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | | throw new InitializationException(msgID, message,e); |
| | | throw new InitializationException(msgID, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "initializeBackend", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_BACKEND_CANNOT_REGISTER_BASEDN; |
| | | String message = getMessage(msgID, backupBaseDN.toString(), |
| | |
| | | */ |
| | | public void finalizeBackend() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "finalizeBackend"); |
| | | |
| | | DirectoryServer.deregisterConfigurableComponent(this); |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "finalizeBackend", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public DN[] getBaseDNs() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getBaseDNs"); |
| | | |
| | | return baseDNs; |
| | | } |
| | |
| | | */ |
| | | public long getEntryCount() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getEntryCount"); |
| | | |
| | | int numEntries = 1; |
| | | |
| | |
| | | */ |
| | | public boolean isLocal() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isLocal"); |
| | | |
| | | // For the purposes of this method, this is a local backend. |
| | | return true; |
| | |
| | | public Entry getEntry(DN entryDN) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getEntry", String.valueOf(entryDN)); |
| | | |
| | | |
| | | // If the requested entry was null, then throw an exception. |
| | |
| | | private Entry getBackupDirectoryEntry(DN entryDN) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getBackupDirectoryEntry", |
| | | String.valueOf(entryDN)); |
| | | |
| | | |
| | | // Make sure that the DN specifies a backup directory. |
| | |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | assert debugException(CLASS_NAME, "getBackupDirectoryEntry", ce); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ce); |
| | | } |
| | | |
| | | int msgID = MSGID_BACKUP_INVALID_BACKUP_DIRECTORY; |
| | | int msgID = MSGID_BACKUP_INVALID_BACKUP_DIRECTORY; |
| | | String message = getMessage(msgID, String.valueOf(entryDN), |
| | | ce.getMessage()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "getBackupDirectoryEntry", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_BACKUP_ERROR_GETTING_BACKUP_DIRECTORY; |
| | | int msgID = MSGID_BACKUP_ERROR_GETTING_BACKUP_DIRECTORY; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID); |
| | |
| | | private Entry getBackupEntry(DN entryDN) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getBackupEntry", String.valueOf(entryDN)); |
| | | |
| | | |
| | | // First, get the backup ID from the entry DN. |
| | |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | assert debugException(CLASS_NAME, "getBackupEntry", ce); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ce); |
| | | } |
| | | |
| | | int msgID = MSGID_BACKUP_INVALID_BACKUP_DIRECTORY; |
| | | int msgID = MSGID_BACKUP_INVALID_BACKUP_DIRECTORY; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, |
| | | msgID); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "getBackupEntry", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_BACKUP_ERROR_GETTING_BACKUP_DIRECTORY; |
| | | int msgID = MSGID_BACKUP_ERROR_GETTING_BACKUP_DIRECTORY; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID); |
| | |
| | | public void addEntry(Entry entry, AddOperation addOperation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "addEntry", String.valueOf(entry), |
| | | String.valueOf(addOperation)); |
| | | |
| | | int msgID = MSGID_BACKUP_ADD_NOT_SUPPORTED; |
| | | String message = getMessage(msgID); |
| | |
| | | public void deleteEntry(DN entryDN, DeleteOperation deleteOperation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "deleteEntry", String.valueOf(entryDN), |
| | | String.valueOf(deleteOperation)); |
| | | |
| | | int msgID = MSGID_BACKUP_DELETE_NOT_SUPPORTED; |
| | | String message = getMessage(msgID); |
| | |
| | | public void replaceEntry(Entry entry, ModifyOperation modifyOperation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "replaceEntry", String.valueOf(entry), |
| | | String.valueOf(modifyOperation)); |
| | | |
| | | int msgID = MSGID_BACKUP_MODIFY_NOT_SUPPORTED; |
| | | String message = getMessage(msgID); |
| | |
| | | ModifyDNOperation modifyDNOperation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "renameEntry", String.valueOf(currentDN), |
| | | String.valueOf(entry), String.valueOf(modifyDNOperation)); |
| | | |
| | | int msgID = MSGID_BACKUP_MODIFY_DN_NOT_SUPPORTED; |
| | | String message = getMessage(msgID); |
| | |
| | | public void search(SearchOperation searchOperation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "search", String.valueOf(searchOperation)); |
| | | |
| | | |
| | | // Get the base entry for the search, if possible. If it doesn't exist, |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "search", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | continue; |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "search", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | continue; |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "search", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | continue; |
| | | } |
| | |
| | | */ |
| | | public HashSet<String> getSupportedControls() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSupportedControls"); |
| | | |
| | | return supportedControls; |
| | | } |
| | |
| | | */ |
| | | public HashSet<String> getSupportedFeatures() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSupportedFeatures"); |
| | | |
| | | return supportedFeatures; |
| | | } |
| | |
| | | */ |
| | | public boolean supportsLDIFExport() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsLDIFExport"); |
| | | |
| | | // We do not support LDIF exports. |
| | | return false; |
| | |
| | | LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "exportLDIF", String.valueOf(exportConfig)); |
| | | |
| | | int msgID = MSGID_BACKUP_EXPORT_NOT_SUPPORTED; |
| | | String message = getMessage(msgID); |
| | |
| | | */ |
| | | public boolean supportsLDIFImport() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsLDIFImport"); |
| | | |
| | | // This backend does not support LDIF imports. |
| | | return false; |
| | |
| | | LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "importLDIF", String.valueOf(importConfig)); |
| | | |
| | | |
| | | // This backend does not support LDIF imports. |
| | |
| | | */ |
| | | public boolean supportsBackup() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsBackup"); |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | | return false; |
| | |
| | | public boolean supportsBackup(BackupConfig backupConfig, |
| | | StringBuilder unsupportedReason) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsBackup"); |
| | | |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "createBackup", String.valueOf(backupConfig)); |
| | | |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | String backupID) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "removeBackup", |
| | | String.valueOf(backupDirectory), |
| | | String.valueOf(backupID)); |
| | | |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | */ |
| | | public boolean supportsRestore() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsRestore"); |
| | | |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "restoreBackup", |
| | | String.valueOf(restoreConfig)); |
| | | |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | */ |
| | | public DN getConfigurableComponentEntryDN() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConfigurableComponentEntryDN"); |
| | | |
| | | return configEntryDN; |
| | | } |
| | |
| | | */ |
| | | public List<ConfigAttribute> getConfigurationAttributes() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConfigurationAttributes"); |
| | | |
| | | |
| | | LinkedList<ConfigAttribute> attrs = new LinkedList<ConfigAttribute>(); |
| | |
| | | public boolean hasAcceptableConfiguration(ConfigEntry configEntry, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "hasAcceptableConfiguration", |
| | | String.valueOf(configEntry), "java.util.List<String>"); |
| | | |
| | | |
| | | // We'll accept anything here. The only configurable attribute is the |
| | |
| | | public ConfigChangeResult applyNewConfiguration(ConfigEntry configEntry, |
| | | boolean detailedResults) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "applyNewConfiguration", |
| | | String.valueOf(configEntry), |
| | | String.valueOf(detailedResults)); |
| | | |
| | | |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "initializeBackend", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_BACKUP_CANNOT_DETERMINE_BACKUP_DIR_LIST; |
| | | messages.add(getMessage(msgID, stackTraceToSingleLineString(e))); |