| | |
| | | import java.util.zip.ZipInputStream; |
| | | import java.util.zip.ZipOutputStream; |
| | | |
| | | import static org.opends.server.loggers.Debug.debugEnter; |
| | | import static org.opends.server.loggers.Debug.debugException; |
| | | 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.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.JebMessages.*; |
| | |
| | | */ |
| | | public static final String ZIPENTRY_EMPTY_PLACEHOLDER = "empty.placeholder"; |
| | | |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.backends.jeb.BackupManager"; |
| | | |
| | | /** |
| | | * The backend ID. |
| | |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "createBackup", String.valueOf(backupConfig)); |
| | | |
| | | |
| | | // Parse our backend configuration. |
| | |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | e.getMessage(), |
| | | e.getMessageID()); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_GET_MAC; |
| | | String message = getMessage(msgID, macAlgorithm, |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_GET_DIGEST; |
| | | String message = getMessage(msgID, digestAlgorithm, |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_CREATE_ARCHIVE_FILE; |
| | | String message = getMessage(msgID, String.valueOf(archiveFilename), |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_GET_CIPHER; |
| | | String message = getMessage(msgID, cipherAlgorithm, |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_JEB_BACKUP_CANNOT_LIST_LOG_FILES; |
| | | message = getMessage(msgID, backendDir.getAbsolutePath(), |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | msgID = MSGID_JEB_BACKUP_CANNOT_WRITE_ARCHIVE_FILE; |
| | | message = getMessage(msgID, ZIPENTRY_EMPTY_PLACEHOLDER, |
| | | stackTraceToSingleLineString(e)); |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | msgID = MSGID_JEB_BACKUP_CANNOT_WRITE_ARCHIVE_FILE; |
| | | message = getMessage(msgID, zipEntryName, |
| | | stackTraceToSingleLineString(e)); |
| | |
| | | } |
| | | catch (FileNotFoundException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | // A log file has been deleted by the cleaner since we started. |
| | | deletedFiles = true; |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | msgID = MSGID_JEB_BACKUP_CANNOT_WRITE_ARCHIVE_FILE; |
| | | message = getMessage(msgID, logFile.getName(), |
| | | stackTraceToSingleLineString(e)); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_JEB_BACKUP_CANNOT_LIST_LOG_FILES; |
| | | message = getMessage(msgID, backendDir.getAbsolutePath(), |
| | |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_JEB_BACKUP_CANNOT_CLOSE_ZIP_STREAM; |
| | | message = getMessage(msgID, archiveFilename, backupDir.getPath(), |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_JEB_BACKUP_CANNOT_UPDATE_BACKUP_DESCRIPTOR; |
| | | message = getMessage(msgID, backupDir.getDescriptorPath(), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID, e); } |
| | | message, msgID, e); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | e.getMessage(), |
| | | e.getMessageID()); |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "restoreBackup", e); |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_RESTORE; |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_RESTORE; |
| | | String message = getMessage(msgID, backupInfo.getBackupID(), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "restoreBackup", e); |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_RESTORE; |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_RESTORE; |
| | | String message = getMessage(msgID, dependent.getBackupID(), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "restoreBackup", e); |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_RESTORE; |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_RESTORE; |
| | | String message = getMessage(msgID, backupInfo.getBackupID(), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | assert debugException(CLASS_NAME, "removeBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | e.getMessage(), |
| | | e.getMessageID()); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createBackup", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_UPDATE_BACKUP_DESCRIPTOR; |
| | | String message = getMessage(msgID, backupDir.getDescriptorPath(), |
| | |
| | | Set<String> includeFiles) |
| | | throws DirectoryException,IOException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "restoreArchive", |
| | | String.valueOf(restoreConfig)); |
| | | |
| | | |
| | | BackupDirectory backupDir = restoreConfig.getBackupDirectory(); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "restoreArchive", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_GET_MAC; |
| | | String message = getMessage(msgID, macAlgorithm, |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "restoreArchive", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_GET_DIGEST; |
| | | String message = getMessage(msgID, digestAlgorithm, |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "restoreArchive", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_GET_CIPHER; |
| | | String message = getMessage(msgID, cipherAlgorithm, |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "restoreArchive", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_JEB_BACKUP_CANNOT_GET_CIPHER; |
| | | String message = getMessage(msgID, cipherAlgorithm, |