From 13f7d006945408ec430130ace6c964ccbf467be8 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 10 Feb 2015 13:52:17 +0000
Subject: [PATCH] OPENDJ-1716 Various PluggableBackend/Storage refactorings
---
opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_ja.properties | 4
opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_de.properties | 4
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java | 5
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java | 15
opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_zh_TW.properties | 4
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/ChangelogBackend.java | 27 -
opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_es.properties | 4
opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool.properties | 2
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java | 325 ++++++++------------------
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java | 8
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java | 12 -
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java | 27 -
opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_fr.properties | 4
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/Backend.java | 18 -
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MemoryBackend.java | 28 -
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/NullBackend.java | 30 -
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java | 40 +--
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java | 46 +--
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java | 8
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java | 12 -
opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_ko.properties | 4
opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_zh_CN.properties | 4
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java | 25 -
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java | 8
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java | 8
25 files changed, 204 insertions(+), 468 deletions(-)
diff --git a/opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java b/opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
index 8b590bf..0a925a4 100644
--- a/opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
+++ b/opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
@@ -22,10 +22,13 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.guitools.controlpanel.util;
+import static org.opends.messages.ConfigMessages.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
@@ -60,9 +63,6 @@
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
-import static org.opends.messages.ConfigMessages.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* A class used to read the configuration from a file. This config file
* handler does not allow to modify the configuration, only to read it.
@@ -448,13 +448,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig arg0, StringBuilder arg1)
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public boolean supportsLDIFExport()
{
return false;
diff --git a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool.properties b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool.properties
index 95d01e5..483ed41 100644
--- a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool.properties
+++ b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool.properties
@@ -468,7 +468,7 @@
ERR_BACKUPDB_NO_BACKENDS_FOR_ID_261=None of the Directory Server \
backends are configured with the requested backend ID "%s"
ERR_BACKUPDB_CANNOT_BACKUP_264=The target backend %s cannot be backed \
- up using the requested configuration: %s
+ up using the requested configuration
ERR_BACKUPDB_ERROR_DURING_BACKUP_265=An error occurred while \
attempting to back up backend %s with the requested configuration: %s
INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL_274=Back up all backends in the server
diff --git a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_de.properties b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_de.properties
index ff5ecbf..f128026 100644
--- a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_de.properties
+++ b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_de.properties
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
# Copyright 2006-2010 Sun Microsystems, Inc.
-# Portions Copyright 2011-2014 ForgeRock AS
+# Portions Copyright 2011-2015 ForgeRock AS
@@ -253,7 +253,7 @@
INFO_BACKUPDB_DESCRIPTION_HASH_251=Einen Hash der Sicherungsinhalte generieren
INFO_BACKUPDB_DESCRIPTION_SIGN_HASH_252=Hash der Sicherungsinhalte signieren
ERR_BACKUPDB_NO_BACKENDS_FOR_ID_261=Keines der Directory-Server-Backends ist mit der angeforderten Backend-ID "%s" konfiguriert
-ERR_BACKUPDB_CANNOT_BACKUP_264=Das Ziel-Backend %s kann nicht mithilfe der angeforderten Konfiguration gesichert werden: %s
+ERR_BACKUPDB_CANNOT_BACKUP_264=Das Ziel-Backend %s kann nicht mithilfe der angeforderten Konfiguration gesichert werden
ERR_BACKUPDB_ERROR_DURING_BACKUP_265=Fehler beim Versuch, Backend %s mit der angeforderten Konfiguration zu sichern: %s
INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL_274=Alle Backends im Server sichern
ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID_275=Die Argumente %s und %s k\u00f6nnen nicht zusammen verwendet werden. Exakt eines dieser beiden Elemente muss angegeben werden
diff --git a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_es.properties b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_es.properties
index 78f9d43..021451e 100644
--- a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_es.properties
+++ b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_es.properties
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
# Copyright 2006-2010 Sun Microsystems, Inc.
-# Portions Copyright 2011-2014 ForgeRock AS
+# Portions Copyright 2011-2015 ForgeRock AS
@@ -253,7 +253,7 @@
INFO_BACKUPDB_DESCRIPTION_HASH_251=Generar un hash del contenido de la copia de seguridad
INFO_BACKUPDB_DESCRIPTION_SIGN_HASH_252=Firmar el hash del contenido de copia de seguridad
ERR_BACKUPDB_NO_BACKENDS_FOR_ID_261=Ning\u00fan backend del Servidor de directorios est\u00e1 configurado con el Id. de backend "%s" solicitado
-ERR_BACKUPDB_CANNOT_BACKUP_264=No se puede realizar una copia de seguridad del backend de destino %s por medio de la configuraci\u00f3n solicitada: %s
+ERR_BACKUPDB_CANNOT_BACKUP_264=No se puede realizar una copia de seguridad del backend de destino %s por medio de la configuraci\u00f3n solicitada
ERR_BACKUPDB_ERROR_DURING_BACKUP_265=Se ha producido un error al tratar de realizar una copia de seguridad del backend %s con la configuraci\u00f3n solicitada: %s
INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL_274=Realiza una copia de seguridad de todos los servidores de fondo del servidor
ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID_275=Los argumentos %s y %s no pueden usarse conjuntamente Debe proporcionarse exclusivamente uno de ellos
diff --git a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_fr.properties b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_fr.properties
index 6946ba4..440494c 100644
--- a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_fr.properties
+++ b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_fr.properties
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
# Copyright 2006-2010 Sun Microsystems, Inc.
-# Portions Copyright 2011-2014 ForgeRock AS
+# Portions Copyright 2011-2015 ForgeRock AS
@@ -253,7 +253,7 @@
INFO_BACKUPDB_DESCRIPTION_HASH_251=G\u00e9n\u00e9rer un hachage du contenu sauvegard\u00e9
INFO_BACKUPDB_DESCRIPTION_SIGN_HASH_252=Signer le hachage du contenu sauvegard\u00e9
ERR_BACKUPDB_NO_BACKENDS_FOR_ID_261=Aucun des backends Directory Server n'est configur\u00e9 avec l'ID de backend demand\u00e9 ("%s")
-ERR_BACKUPDB_CANNOT_BACKUP_264=Impossible de sauvegarder le backend cible %s \u00e0 l'aide de la configuration demand\u00e9e\u00a0: %s
+ERR_BACKUPDB_CANNOT_BACKUP_264=Impossible de sauvegarder le backend cible %s \u00e0 l'aide de la configuration demand\u00e9e\u00a0
ERR_BACKUPDB_ERROR_DURING_BACKUP_265=Une erreur s'est produite lors de la tentative de sauvegarde du backend %s avec la configuration demand\u00e9e\u00a0: %s
INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL_274=Sauvegarder tous les backends sur le serveur
ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID_275=Les arguments %s et %s ne peuvent pas \u00eatre utilis\u00e9s ensemble. Un seul d'entre eux doit \u00eatre fourni
diff --git a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_ja.properties b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_ja.properties
index aa74b9f..7d2ceee 100644
--- a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_ja.properties
+++ b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_ja.properties
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
# Copyright 2006-2010 Sun Microsystems, Inc.
-# Portions Copyright 2011-2014 ForgeRock AS
+# Portions Copyright 2011-2015 ForgeRock AS
@@ -253,7 +253,7 @@
INFO_BACKUPDB_DESCRIPTION_HASH_251=\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30cf\u30c3\u30b7\u30e5\u3092\u751f\u6210\u3057\u307e\u3059
INFO_BACKUPDB_DESCRIPTION_SIGN_HASH_252=\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30cf\u30c3\u30b7\u30e5\u306b\u7f72\u540d\u3057\u307e\u3059
ERR_BACKUPDB_NO_BACKENDS_FOR_ID_261=\u8981\u6c42\u3055\u308c\u305f\u30d0\u30c3\u30af\u30a8\u30f3\u30c9 ID "%s" \u3067\u69cb\u6210\u3055\u308c\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30b5\u30fc\u30d0\u30fc\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u304c\u3042\u308a\u307e\u305b\u3093\u3002
-ERR_BACKUPDB_CANNOT_BACKUP_264=\u30bf\u30fc\u30b2\u30c3\u30c8\u30d0\u30c3\u30af\u30a2\u30c3\u30d7 %s \u306f\u3001\u8981\u6c42\u3055\u308c\u305f\u69cb\u6210\u3092\u4f7f\u7528\u3057\u3066\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3067\u304d\u307e\u305b\u3093: %s
+ERR_BACKUPDB_CANNOT_BACKUP_264=\u30bf\u30fc\u30b2\u30c3\u30c8\u30d0\u30c3\u30af\u30a2\u30c3\u30d7 %s \u306f\u3001\u8981\u6c42\u3055\u308c\u305f\u69cb\u6210\u3092\u4f7f\u7528\u3057\u3066\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3067\u304d\u307e\u305b\u3093
ERR_BACKUPDB_ERROR_DURING_BACKUP_265=\u8981\u6c42\u3055\u308c\u305f\u69cb\u6210\u3092\u542b\u3080\u30d0\u30c3\u30af\u30a8\u30f3\u30c9 %s \u306e\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u4e2d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f: %s
INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL_274=\u30b5\u30fc\u30d0\u30fc\u5185\u306e\u3059\u3079\u3066\u306e\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3092\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3057\u307e\u3059
ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID_275=%s \u5f15\u6570\u3068 %s \u5f15\u6570\u306f\u4e00\u7dd2\u306b\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002\u3044\u305a\u308c\u304b 1 \u3064\u306e\u307f\u3092\u6b63\u78ba\u306b\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059
diff --git a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_ko.properties b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_ko.properties
index bf12135..4808584 100644
--- a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_ko.properties
+++ b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_ko.properties
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
# Copyright 2006-2009 Sun Microsystems, Inc.
-# Portions Copyright 2011-2014 ForgeRock AS
+# Portions Copyright 2011-2015 ForgeRock AS
@@ -253,7 +253,7 @@
INFO_BACKUPDB_DESCRIPTION_HASH_251=\ubc31\uc5c5 \ub0b4\uc6a9\uc5d0 \ub300\ud55c \ud574\uc2dc\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4.
INFO_BACKUPDB_DESCRIPTION_SIGN_HASH_252=\ubc31\uc5c5 \ub0b4\uc6a9\uc758 \ud574\uc2dc\uc5d0 \uc11c\uba85\ud569\ub2c8\ub2e4.
ERR_BACKUPDB_NO_BACKENDS_FOR_ID_261=\uc694\uccad\ud55c \ubc31\uc5d4\ub4dc \uc544\uc774\ub514 \"%s\"\uc744(\ub97c) \uac00\uc9c4 \ub514\ub809\ud1a0\ub9ac \uc11c\ubc84 \ubc31\uc5d4\ub4dc\uac00 \uad6c\uc131\ub418\uc5b4 \uc788\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.
-ERR_BACKUPDB_CANNOT_BACKUP_264=\uc694\uccad\ud55c \uad6c\uc131\uc744 \uc0ac\uc6a9\ud558\uc5ec \ub300\uc0c1 \ubc31\uc5d4\ub4dc %s\uc744(\ub97c) \ubc31\uc5c5\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4: %s
+ERR_BACKUPDB_CANNOT_BACKUP_264=\uc694\uccad\ud55c \uad6c\uc131\uc744 \uc0ac\uc6a9\ud558\uc5ec \ub300\uc0c1 \ubc31\uc5d4\ub4dc %s\uc744(\ub97c) \ubc31\uc5c5\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4
ERR_BACKUPDB_ERROR_DURING_BACKUP_265=\uc694\uccad\ud55c \uad6c\uc131\uc73c\ub85c \ubc31\uc5d4\ub4dc %s\uc744(\ub97c) \ubc31\uc5c5\ud558\ub294 \ub3d9\uc548 \uc624\ub958\uac00 \ubc1c\uc0dd\ud588\uc2b5\ub2c8\ub2e4: %s
INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL_274=\uc11c\ubc84\uc758 \ubaa8\ub4e0 \ubc31\uc5d4\ub4dc\ub97c \ubc31\uc5c5\ud569\ub2c8\ub2e4.
ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID_275=%s \ubc0f %s \uc778\uc218\ub97c \ud568\uaed8 \uc0ac\uc6a9\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. \ub450 \uc778\uc218 \uc911 \ud558\ub098\ub9cc \uc81c\uacf5\ud574\uc57c \ud569\ub2c8\ub2e4.
diff --git a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_zh_CN.properties b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_zh_CN.properties
index 75046b6..cbd54a3 100644
--- a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_zh_CN.properties
+++ b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_zh_CN.properties
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
# Copyright 2006-2010 Sun Microsystems, Inc.
-# Portions Copyright 2011-2014 ForgeRock AS
+# Portions Copyright 2011-2015 ForgeRock AS
@@ -253,7 +253,7 @@
INFO_BACKUPDB_DESCRIPTION_HASH_251=\u751f\u6210\u5907\u4efd\u5185\u5bb9\u6563\u5217
INFO_BACKUPDB_DESCRIPTION_SIGN_HASH_252=\u5bf9\u5907\u4efd\u5185\u5bb9\u6563\u5217\u8fdb\u884c\u7b7e\u540d
ERR_BACKUPDB_NO_BACKENDS_FOR_ID_261=\u6ca1\u6709 Directory Server \u540e\u7aef\u4f7f\u7528\u8bf7\u6c42\u7684\u540e\u7aef ID "%s" \u8fdb\u884c\u914d\u7f6e
-ERR_BACKUPDB_CANNOT_BACKUP_264=\u76ee\u6807\u540e\u7aef %s \u65e0\u6cd5\u4f7f\u7528\u8bf7\u6c42\u7684\u914d\u7f6e\u5907\u4efd: %s
+ERR_BACKUPDB_CANNOT_BACKUP_264=\u76ee\u6807\u540e\u7aef %s \u65e0\u6cd5\u4f7f\u7528\u8bf7\u6c42\u7684\u914d\u7f6e\u5907\u4efd
ERR_BACKUPDB_ERROR_DURING_BACKUP_265=\u5728\u5c1d\u8bd5\u4ee5\u8bf7\u6c42\u7684\u914d\u7f6e\u5907\u4efd\u540e\u7aef %s \u65f6\u51fa\u73b0\u9519\u8bef: %s
INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL_274=\u5907\u4efd\u670d\u52a1\u5668\u4e2d\u7684\u6240\u6709\u540e\u7aef
ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID_275=%s \u548c %s \u53c2\u6570\u53ef\u80fd\u65e0\u6cd5\u4e00\u8d77\u4f7f\u7528\u3002\u5fc5\u987b\u6070\u597d\u63d0\u4f9b\u5176\u4e2d\u4e00\u9879
diff --git a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_zh_TW.properties b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_zh_TW.properties
index 4ffb083..7a8230d 100644
--- a/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_zh_TW.properties
+++ b/opendj-sdk/opendj3-server-dev/src/messages/org/opends/messages/tool_zh_TW.properties
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
# Copyright 2006-2009 Sun Microsystems, Inc.
-# Portions Copyright 2011-2014 ForgeRock AS
+# Portions Copyright 2011-2015 ForgeRock AS
@@ -253,7 +253,7 @@
INFO_BACKUPDB_DESCRIPTION_HASH_251=\u7522\u751f\u5099\u4efd\u5167\u5bb9\u7684\u96dc\u6e4a
INFO_BACKUPDB_DESCRIPTION_SIGN_HASH_252=\u7c3d\u7f72\u5099\u4efd\u5167\u5bb9\u7684\u96dc\u6e4a
ERR_BACKUPDB_NO_BACKENDS_FOR_ID_261=\u6c92\u6709\u4efb\u4f55\u76ee\u9304\u4f3a\u670d\u5668\u5f8c\u7aef\u4ee5\u8acb\u6c42\u7684\u5f8c\u7aef ID\u300c%s\u300d\u9032\u884c\u914d\u7f6e
-ERR_BACKUPDB_CANNOT_BACKUP_264=\u76ee\u6a19\u5f8c\u7aef %s \u7121\u6cd5\u4f7f\u7528\u8acb\u6c42\u7684\u914d\u7f6e\u9032\u884c\u5099\u4efd: %s
+ERR_BACKUPDB_CANNOT_BACKUP_264=\u76ee\u6a19\u5f8c\u7aef %s \u7121\u6cd5\u4f7f\u7528\u8acb\u6c42\u7684\u914d\u7f6e\u9032\u884c\u5099\u4efd
ERR_BACKUPDB_ERROR_DURING_BACKUP_265=\u5617\u8a66\u4f7f\u7528\u8acb\u6c42\u7684\u914d\u7f6e\u4f86\u5099\u4efd\u5f8c\u7aef %s \u6642\u767c\u751f\u932f\u8aa4: %s
INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL_274=\u5099\u4efd\u4f3a\u670d\u5668\u4e2d\u6240\u6709\u7684\u5f8c\u7aef
ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID_275=%s \u8207 %s \u5f15\u6578\u7121\u6cd5\u4e00\u8d77\u4f7f\u7528\u3002\u5fc5\u9808\u63d0\u4f9b\u5176\u4e2d\u4e00\u500b
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/Backend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
index 849e907..8c4a4c5 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
@@ -720,24 +720,6 @@
public abstract boolean supportsBackup();
/**
- * Indicates whether this backend provides a mechanism to perform a
- * backup of its contents in a form that can be restored later,
- * based on the provided configuration.
- *
- * @param backupConfig The configuration of the backup for
- * which to make the determination.
- * @param unsupportedReason A buffer to which a message can be
- * appended
- * explaining why the requested backup is
- * not supported.
- *
- * @return {@code true} if this backend provides a mechanism for
- * performing backups with the provided configuration, or
- * {@code false} if not.
- */
- public abstract boolean supportsBackup(BackupConfig backupConfig, StringBuilder unsupportedReason);
-
- /**
* Creates a backup of the contents of this backend in a form that
* may be restored at a later date if necessary. This method should
* only be called if {@code supportsBackup} returns {@code true}.
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java
index cd1d510..4594400 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java
@@ -26,6 +26,11 @@
*/
package org.opends.server.backends;
+import static org.opends.messages.BackendMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.io.File;
import java.io.IOException;
import java.util.*;
@@ -44,18 +49,13 @@
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
+import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.schema.BooleanSyntax;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.types.*;
-import static org.opends.messages.BackendMessages.*;
-import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* This class defines a backend used to present information about Directory
* Server backups. It will not actually store anything, but upon request will
@@ -1016,18 +1016,6 @@
return false;
}
-
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- return false;
- }
-
-
-
/** {@inheritDoc} */
@Override
public void createBackup(BackupConfig backupConfig)
@@ -1122,6 +1110,7 @@
/** {@inheritDoc} */
+ @Override
public void preloadEntryCache() throws UnsupportedOperationException {
throw new UnsupportedOperationException("Operation not supported.");
}
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/ChangelogBackend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/ChangelogBackend.java
index 3d729bf..a9c4f20 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/ChangelogBackend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/ChangelogBackend.java
@@ -25,6 +25,16 @@
*/
package org.opends.server.backends;
+import static org.opends.messages.BackendMessages.*;
+import static org.opends.messages.ReplicationMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.replication.plugin.MultimasterReplication.*;
+import static org.opends.server.replication.server.changelog.api.DBCursor.KeyMatchingStrategy.*;
+import static org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy.*;
+import static org.opends.server.util.LDIFWriter.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Collections;
@@ -107,16 +117,6 @@
import org.opends.server.types.WritabilityMode;
import org.opends.server.util.StaticUtils;
-import static org.opends.messages.BackendMessages.*;
-import static org.opends.messages.ReplicationMessages.*;
-import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.replication.plugin.MultimasterReplication.*;
-import static org.opends.server.replication.server.changelog.api.DBCursor.KeyMatchingStrategy.*;
-import static org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy.*;
-import static org.opends.server.util.LDIFWriter.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* A backend that provides access to the changelog, i.e. the "cn=changelog"
* suffix. It is a read-only backend that is created by a
@@ -653,13 +653,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig backupConfig, StringBuilder unsupportedReason)
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig) throws DirectoryException
{
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java
index 5913810..fa8413a 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java
@@ -1193,14 +1193,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MemoryBackend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MemoryBackend.java
index 8ddf140..8ac3984 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MemoryBackend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MemoryBackend.java
@@ -22,10 +22,14 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.backends;
+import static org.opends.messages.BackendMessages.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -35,23 +39,25 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.std.server.MemoryBackendCfg;
import org.opends.server.api.Backend;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.controls.SubtreeDeleteControl;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
+import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.Control;
-import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.IndexType;
import org.opends.server.types.InitializationException;
@@ -59,17 +65,11 @@
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.LDIFImportResult;
import org.opends.server.types.RestoreConfig;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.SearchFilter;
-import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
-import static org.opends.messages.BackendMessages.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* This class defines a very simple backend that stores its information in
* memory. This is primarily intended for testing purposes with small data
@@ -755,14 +755,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java
index 3f73e9a..52cfe7d 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java
@@ -26,12 +26,21 @@
*/
package org.opends.server.backends;
+import static org.opends.messages.BackendMessages.*;
+import static org.opends.messages.ConfigMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.util.*;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.util.Reject;
import org.opends.server.admin.server.ConfigurationChangeListener;
@@ -39,21 +48,12 @@
import org.opends.server.api.Backend;
import org.opends.server.api.MonitorProvider;
import org.opends.server.config.ConfigEntry;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.*;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.DynamicConstants;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.TimeThread;
-import static org.opends.messages.BackendMessages.*;
-import static org.opends.messages.ConfigMessages.*;
-import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* This class defines a backend to hold Directory Server monitor entries. It
* will not actually store anything, but upon request will retrieve the
@@ -72,7 +72,7 @@
private ArrayList<Attribute> userDefinedAttributes;
/** The set of objectclasses that will be used in monitor entries. */
- private HashMap<ObjectClass, String> monitorObjectClasses;
+ private final HashMap<ObjectClass, String> monitorObjectClasses = new LinkedHashMap<ObjectClass, String>(2);
/** The DN of the configuration entry for this backend. */
private DN configEntryDN;
@@ -182,31 +182,10 @@
// attributes that we don't recognize will be included directly in the base
// monitor entry.
userDefinedAttributes = new ArrayList<Attribute>();
- for (final List<Attribute> attrs : configEntry.getEntry()
- .getUserAttributes().values())
- {
- for (final Attribute a : attrs)
- {
- if (!isMonitorConfigAttribute(a))
- {
- userDefinedAttributes.add(a);
- }
- }
- }
- for (final List<Attribute> attrs : configEntry.getEntry()
- .getOperationalAttributes().values())
- {
- for (final Attribute a : attrs)
- {
- if (!isMonitorConfigAttribute(a))
- {
- userDefinedAttributes.add(a);
- }
- }
- }
+ addAll(userDefinedAttributes, configEntry.getEntry().getUserAttributes().values());
+ addAll(userDefinedAttributes, configEntry.getEntry().getOperationalAttributes().values());
// Construct the set of objectclasses to include in the base monitor entry.
- monitorObjectClasses = new LinkedHashMap<ObjectClass, String>(2);
final ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP, true);
monitorObjectClasses.put(topOC, OC_TOP);
@@ -235,6 +214,20 @@
currentConfig = cfg;
}
+ private void addAll(ArrayList<Attribute> attributes, Collection<List<Attribute>> attributesToAdd)
+ {
+ for (final List<Attribute> attrs : attributesToAdd)
+ {
+ for (final Attribute a : attrs)
+ {
+ if (!isMonitorConfigAttribute(a))
+ {
+ attributes.add(a);
+ }
+ }
+ }
+ }
+
/** {@inheritDoc} */
@Override
public void createBackup(final BackupConfig backupConfig)
@@ -279,8 +272,7 @@
final LocalizableMessage message = ERR_ROOTDSE_UNABLE_TO_CREATE_LDIF_WRITER
.get(stackTraceToSingleLineString(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message);
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message);
}
// Write the base monitor entry to the LDIF.
@@ -296,8 +288,7 @@
final LocalizableMessage message = ERR_MONITOR_UNABLE_TO_EXPORT_BASE
.get(stackTraceToSingleLineString(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message);
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message);
}
// Get all the monitor providers, convert them to entries, and write them to
@@ -316,8 +307,7 @@
close(ldifWriter);
final LocalizableMessage message = ERR_MONITOR_UNABLE_TO_EXPORT_PROVIDER_ENTRY
- .get(monitorProvider.getMonitorInstanceName(),
- stackTraceToSingleLineString(e));
+ .get(monitorProvider.getMonitorInstanceName(), stackTraceToSingleLineString(e));
throw new DirectoryException(
DirectoryServer.getServerErrorResultCode(), message);
}
@@ -409,8 +399,7 @@
if (dit.containsKey(entryDN))
{
final DN nextDN = dit.higherKey(entryDN);
- return ConditionResult.valueOf(
- nextDN != null && nextDN.isDescendantOf(entryDN));
+ return ConditionResult.valueOf(nextDN != null && nextDN.isDescendantOf(entryDN));
}
return ConditionResult.UNDEFINED;
}
@@ -579,8 +568,7 @@
}
// Walk through all entries and send the ones that match.
- for (final Map.Entry<DN, MonitorProvider<?>> e : dit.tailMap(baseDN)
- .entrySet())
+ for (final Map.Entry<DN, MonitorProvider<?>> e : dit.tailMap(baseDN).entrySet())
{
final DN dn = e.getKey();
if (dn.matchesBaseAndScope(baseDN, scope))
@@ -608,14 +596,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(final BackupConfig backupConfig,
- final StringBuilder unsupportedReason)
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public boolean supportsLDIFExport()
{
// We can export all the monitor entries as a point-in-time snapshot.
@@ -638,27 +618,6 @@
return false;
}
-
-
- /**
- * Creates an attribute for a monitor entry with the following criteria.
- *
- * @param name
- * The name for the attribute.
- * @param lowerName
- * The name for the attribute formatted in all lowercase characters.
- * @param value
- * The value to use for the attribute.
- * @return The constructed attribute.
- */
- private Attribute createAttribute(final String name, final String lowerName,
- final String value)
- {
- return Attributes.create(name, value);
- }
-
-
-
/**
* Retrieves the base monitor entry for the Directory Server.
*
@@ -666,62 +625,55 @@
*/
private Entry getBaseMonitorEntry()
{
- final HashMap<ObjectClass, String> monitorClasses =
- new LinkedHashMap<ObjectClass, String>(3);
- monitorClasses.putAll(monitorObjectClasses);
-
- final ObjectClass extensibleObjectOC = DirectoryServer.getObjectClass(
- OC_EXTENSIBLE_OBJECT_LC, true);
- monitorClasses.put(extensibleObjectOC, OC_EXTENSIBLE_OBJECT);
+ final ObjectClass extensibleObjectOC = DirectoryServer.getObjectClass(OC_EXTENSIBLE_OBJECT_LC, true);
+ final HashMap<ObjectClass, String> monitorClasses = newObjectClasses(extensibleObjectOC, OC_EXTENSIBLE_OBJECT);
final HashMap<AttributeType, List<Attribute>> monitorUserAttrs =
new LinkedHashMap<AttributeType, List<Attribute>>();
final HashMap<AttributeType, List<Attribute>> monitorOperationalAttrs =
new LinkedHashMap<AttributeType, List<Attribute>>();
- // Add the "cn" attribute.
- final Attribute cnAttr = createAttribute(ATTR_COMMON_NAME,
- ATTR_COMMON_NAME, "monitor");
- final ArrayList<Attribute> cnList = new ArrayList<Attribute>(1);
- cnList.add(cnAttr);
- monitorUserAttrs.put(cnAttr.getAttributeType(), cnList);
+ put(monitorUserAttrs, Attributes.create(ATTR_COMMON_NAME, "monitor"));
+ put(monitorUserAttrs, Attributes.create(ATTR_PRODUCT_NAME, DynamicConstants.PRODUCT_NAME));
+ put(monitorUserAttrs, Attributes.create(ATTR_VENDOR_NAME, SERVER_VENDOR_NAME));
+ put(monitorUserAttrs, Attributes.create(ATTR_VENDOR_VERSION, DirectoryServer.getVersionString()));
+ put(monitorUserAttrs, Attributes.create(ATTR_START_TIME, DirectoryServer.getStartTimeUTC()));
+ put(monitorUserAttrs, Attributes.create(ATTR_CURRENT_TIME, TimeThread.getGMTTime()));
+ put(monitorUserAttrs, Attributes.create(ATTR_UP_TIME, getHumanReadableUpTime()));
- // Add the server product name.
- final Attribute productNameAttr = createAttribute(ATTR_PRODUCT_NAME,
- ATTR_PRODUCT_NAME_LC, DynamicConstants.PRODUCT_NAME);
- final ArrayList<Attribute> productNameList = new ArrayList<Attribute>(1);
- productNameList.add(productNameAttr);
- monitorUserAttrs.put(productNameAttr.getAttributeType(), productNameList);
+ // Add the number of connections currently established.
+ final long currentConns = DirectoryServer.getCurrentConnections();
+ put(monitorUserAttrs, Attributes.create(ATTR_CURRENT_CONNS, String.valueOf(currentConns)));
- // Add the vendor name.
- final Attribute vendorNameAttr = createAttribute(ATTR_VENDOR_NAME,
- ATTR_VENDOR_NAME_LC, SERVER_VENDOR_NAME);
- final ArrayList<Attribute> vendorNameList = new ArrayList<Attribute>(1);
- vendorNameList.add(vendorNameAttr);
- monitorUserAttrs.put(vendorNameAttr.getAttributeType(), vendorNameList);
+ // Add the maximum number of connections established at one time.
+ final long maxConns = DirectoryServer.getMaxConnections();
+ put(monitorUserAttrs, Attributes.create(ATTR_MAX_CONNS, String.valueOf(maxConns)));
- // Add the vendor version.
- final Attribute versionAttr = createAttribute(ATTR_VENDOR_VERSION,
- ATTR_VENDOR_VERSION_LC, DirectoryServer.getVersionString());
- final ArrayList<Attribute> versionList = new ArrayList<Attribute>(1);
- versionList.add(versionAttr);
- monitorUserAttrs.put(versionAttr.getAttributeType(), versionList);
+ // Add the total number of connections the server has accepted.
+ final long totalConns = DirectoryServer.getTotalConnections();
+ put(monitorUserAttrs, Attributes.create(ATTR_TOTAL_CONNS, String.valueOf(totalConns)));
- // Add the server startup time.
- final Attribute startTimeAttr = createAttribute(ATTR_START_TIME,
- ATTR_START_TIME_LC, DirectoryServer.getStartTimeUTC());
- final ArrayList<Attribute> startTimeList = new ArrayList<Attribute>(1);
- startTimeList.add(startTimeAttr);
- monitorUserAttrs.put(startTimeAttr.getAttributeType(), startTimeList);
+ // Add all the user-defined attributes.
+ for (final Attribute a : userDefinedAttributes)
+ {
+ final AttributeType type = a.getAttributeType();
- // Add the current time.
- final Attribute currentTimeAttr = createAttribute(ATTR_CURRENT_TIME,
- ATTR_CURRENT_TIME_LC, TimeThread.getGMTTime());
- final ArrayList<Attribute> currentTimeList = new ArrayList<Attribute>(1);
- currentTimeList.add(currentTimeAttr);
- monitorUserAttrs.put(currentTimeAttr.getAttributeType(), currentTimeList);
+ final HashMap<AttributeType, List<Attribute>> attrsMap =
+ type.isOperational() ? monitorOperationalAttrs : monitorUserAttrs;
+ List<Attribute> attrs = attrsMap.get(type);
+ if (attrs == null)
+ {
+ attrs = new ArrayList<Attribute>();
+ attrsMap.put(type, attrs);
+ }
+ attrs.add(a);
+ }
- // Add the uptime as a human-readable string.
+ return newEntry(baseMonitorDN, monitorClasses, monitorUserAttrs, monitorOperationalAttrs);
+ }
+
+ private String getHumanReadableUpTime()
+ {
long upSeconds = (System.currentTimeMillis() - DirectoryServer.getStartTime()) / 1000;
final long upDays = upSeconds / 86400;
upSeconds %= 86400;
@@ -729,81 +681,20 @@
upSeconds %= 3600;
final long upMinutes = upSeconds / 60;
upSeconds %= 60;
- final LocalizableMessage upTimeStr = INFO_MONITOR_UPTIME.get(upDays, upHours,
- upMinutes, upSeconds);
- final Attribute upTimeAttr = createAttribute(ATTR_UP_TIME, ATTR_UP_TIME_LC,
- upTimeStr.toString());
- final ArrayList<Attribute> upTimeList = new ArrayList<Attribute>(1);
- upTimeList.add(upTimeAttr);
- monitorUserAttrs.put(upTimeAttr.getAttributeType(), upTimeList);
-
- // Add the number of connections currently established.
- final long currentConns = DirectoryServer.getCurrentConnections();
- final Attribute currentConnsAttr = createAttribute(ATTR_CURRENT_CONNS,
- ATTR_CURRENT_CONNS_LC, String.valueOf(currentConns));
- final ArrayList<Attribute> currentConnsList = new ArrayList<Attribute>(1);
- currentConnsList.add(currentConnsAttr);
- monitorUserAttrs.put(currentConnsAttr.getAttributeType(), currentConnsList);
-
- // Add the maximum number of connections established at one time.
- final long maxConns = DirectoryServer.getMaxConnections();
- final Attribute maxConnsAttr = createAttribute(ATTR_MAX_CONNS,
- ATTR_MAX_CONNS_LC, String.valueOf(maxConns));
- final ArrayList<Attribute> maxConnsList = new ArrayList<Attribute>(1);
- maxConnsList.add(maxConnsAttr);
- monitorUserAttrs.put(maxConnsAttr.getAttributeType(), maxConnsList);
-
- // Add the total number of connections the server has accepted.
- final long totalConns = DirectoryServer.getTotalConnections();
- final Attribute totalConnsAttr = createAttribute(ATTR_TOTAL_CONNS,
- ATTR_TOTAL_CONNS_LC, String.valueOf(totalConns));
- final ArrayList<Attribute> totalConnsList = new ArrayList<Attribute>(1);
- totalConnsList.add(totalConnsAttr);
- monitorUserAttrs.put(totalConnsAttr.getAttributeType(), totalConnsList);
-
- // Add all the user-defined attributes.
- for (final Attribute a : userDefinedAttributes)
- {
- final AttributeType type = a.getAttributeType();
-
- if (type.isOperational())
- {
- List<Attribute> attrs = monitorOperationalAttrs.get(type);
- if (attrs == null)
- {
- attrs = new ArrayList<Attribute>();
- attrs.add(a);
- monitorOperationalAttrs.put(type, attrs);
- }
- else
- {
- attrs.add(a);
- }
- }
- else
- {
- List<Attribute> attrs = monitorUserAttrs.get(type);
- if (attrs == null)
- {
- attrs = new ArrayList<Attribute>();
- attrs.add(a);
- monitorUserAttrs.put(type, attrs);
- }
- else
- {
- attrs.add(a);
- }
- }
- }
-
- // Construct and return the entry.
- final Entry e = new Entry(baseMonitorDN, monitorClasses, monitorUserAttrs,
- monitorOperationalAttrs);
- e.processVirtualAttributes();
- return e;
+ return INFO_MONITOR_UPTIME.get(upDays, upHours, upMinutes, upSeconds).toString();
}
+ private void put(final HashMap<AttributeType, List<Attribute>> attrsMap, final Attribute attr)
+ {
+ attrsMap.put(attr.getAttributeType(), toList(attr));
+ }
+ private ArrayList<Attribute> toList(final Attribute attr)
+ {
+ final ArrayList<Attribute> results = new ArrayList<Attribute>(1);
+ results.add(attr);
+ return results;
+ }
/**
* Retrieves the branch monitor entry for the Directory Server.
@@ -814,13 +705,8 @@
*/
private Entry getBranchMonitorEntry(final DN dn)
{
-
- final HashMap<ObjectClass, String> monitorClasses =
- new LinkedHashMap<ObjectClass, String>(3);
- monitorClasses.putAll(monitorObjectClasses);
- final ObjectClass monitorOC = DirectoryServer.getObjectClass(
- OC_MONITOR_BRANCH, true);
- monitorClasses.put(monitorOC, OC_MONITOR_BRANCH);
+ final ObjectClass monitorOC = DirectoryServer.getObjectClass(OC_MONITOR_BRANCH, true);
+ final HashMap<ObjectClass, String> monitorClasses = newObjectClasses(monitorOC, OC_MONITOR_BRANCH);
final HashMap<AttributeType, List<Attribute>> monitorUserAttrs =
new LinkedHashMap<AttributeType, List<Attribute>>();
@@ -834,20 +720,13 @@
final AttributeType attributeType = rdn.getAttributeType(i);
final ByteString value = rdn.getAttributeValue(attributeType);
final Attribute attr = Attributes.create(attributeType, value);
- final List<Attribute> attrList = new ArrayList<Attribute>(1);
- attrList.add(attr);
- monitorUserAttrs.put(attributeType, attrList);
+ monitorUserAttrs.put(attributeType, toList(attr));
}
}
- // Construct and return the entry.
- final Entry e = new Entry(dn, monitorClasses, monitorUserAttrs, null);
- e.processVirtualAttributes();
- return e;
+ return newEntry(dn, monitorClasses, monitorUserAttrs, null);
}
-
-
/**
* Returns a map containing records for each DN in the monitor backend's DIT.
* Each record maps the entry DN to the associated monitor provider, or
@@ -930,13 +809,8 @@
private Entry getMonitorEntry(final DN entryDN,
final MonitorProvider<?> monitorProvider)
{
- final HashMap<ObjectClass, String> monitorClasses =
- new LinkedHashMap<ObjectClass, String>(
- 3);
- monitorClasses.putAll(monitorObjectClasses);
-
final ObjectClass monitorOC = monitorProvider.getMonitorObjectClass();
- monitorClasses.put(monitorOC, monitorOC.getPrimaryName());
+ final HashMap<ObjectClass, String> monitorClasses = newObjectClasses(monitorOC, monitorOC.getPrimaryName());
final List<Attribute> monitorAttrs = monitorProvider.getMonitorData();
final HashMap<AttributeType, List<Attribute>> attrMap =
@@ -948,10 +822,7 @@
final AttributeType rdnType = entryRDN.getAttributeType(0);
final ByteString rdnValue = entryRDN.getAttributeValue(0);
- final Attribute rdnAttr = Attributes.create(rdnType, rdnValue);
- final ArrayList<Attribute> rdnList = new ArrayList<Attribute>(1);
- rdnList.add(rdnAttr);
- attrMap.put(rdnType, rdnList);
+ attrMap.put(rdnType, toList(Attributes.create(rdnType, rdnValue)));
// Take the rest of the information from the monitor data.
for (final Attribute a : monitorAttrs)
@@ -962,23 +833,31 @@
if (attrs == null)
{
attrs = new ArrayList<Attribute>();
- attrs.add(a);
attrMap.put(type, attrs);
}
- else
- {
- attrs.add(a);
- }
+ attrs.add(a);
}
- final Entry e = new Entry(entryDN, monitorClasses, attrMap,
- new HashMap<AttributeType, List<Attribute>>(0));
+ return newEntry(entryDN, monitorClasses, attrMap, new HashMap<AttributeType, List<Attribute>>(0));
+ }
+
+ private HashMap<ObjectClass, String> newObjectClasses(ObjectClass objectClass, String objectClassName)
+ {
+ final HashMap<ObjectClass, String> monitorClasses =
+ new LinkedHashMap<ObjectClass, String>(monitorObjectClasses.size() + 1);
+ monitorClasses.putAll(monitorObjectClasses);
+ monitorClasses.put(objectClass, objectClassName);
+ return monitorClasses;
+ }
+
+ private Entry newEntry(final DN dn, final Map<ObjectClass, String> objectClasses,
+ final Map<AttributeType, List<Attribute>> userAttrs, Map<AttributeType, List<Attribute>> opAttrs)
+ {
+ final Entry e = new Entry(dn, objectClasses, userAttrs, opAttrs);
e.processVirtualAttributes();
return e;
}
-
-
/**
* Indicates whether the provided attribute is one that is used in the
* configuration of this backend.
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/NullBackend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/NullBackend.java
index 594c413..3deeb47 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/NullBackend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/NullBackend.java
@@ -22,10 +22,14 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.backends;
+import static org.opends.messages.BackendMessages.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -34,23 +38,24 @@
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.controls.PagedResultsControl;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
+import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
-import org.forgerock.opendj.ldap.ConditionResult;
-import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.IndexType;
import org.opends.server.types.InitializationException;
@@ -59,15 +64,10 @@
import org.opends.server.types.LDIFImportResult;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.RestoreConfig;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
-import static org.opends.messages.BackendMessages.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* This class implements /dev/null like backend for development and
* testing. The following behaviors of this backend implementation
@@ -476,14 +476,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java
index 805ee19..77ac25c 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java
@@ -993,14 +993,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
index 9d545b6..a256ab7 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
@@ -26,11 +26,20 @@
*/
package org.opends.server.backends;
+import static org.opends.messages.BackendMessages.*;
+import static org.opends.messages.ConfigMessages.*;
+import static org.opends.messages.SchemaMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.schema.SchemaConstants.*;
+import static org.opends.server.types.CommonSchemaElements.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest;
import java.util.ArrayList;
@@ -57,26 +66,26 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
+import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.SchemaBackendCfg;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.config.ConfigEntry;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
+import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.core.SearchOperation;
import org.opends.server.schema.AttributeTypeSyntax;
@@ -93,15 +102,6 @@
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
-import static org.opends.messages.BackendMessages.*;
-import static org.opends.messages.ConfigMessages.*;
-import static org.opends.messages.SchemaMessages.*;
-import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.types.CommonSchemaElements.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* This class defines a backend to hold the Directory Server schema information.
* It is a kind of meta-backend in that it doesn't actually hold any data but
@@ -3995,18 +3995,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- // We should support online backup for the schema in any form. This
- // implementation does not support incremental backups, but in this case
- // even if we're asked to do an incremental we'll just do a full backup
- // instead. So the answer to this should always be "true".
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java
index 9d12d63..8bcb374 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java
@@ -26,6 +26,11 @@
*/
package org.opends.server.backends;
+import static org.opends.messages.BackendMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -45,8 +50,8 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Random;
-import java.util.SortedSet;
import java.util.Set;
+import java.util.SortedSet;
import javax.naming.ldap.Rdn;
import javax.net.ssl.KeyManager;
@@ -56,15 +61,16 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.util.Reject;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.TrustStoreBackendCfg;
import org.opends.server.api.Backend;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
@@ -72,16 +78,9 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.opends.server.types.FilePermission;
import org.opends.server.util.CertificateManager;
import org.opends.server.util.SetupUtils;
-import static org.opends.messages.BackendMessages.*;
-import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* This class defines a backend used to provide an LDAP view of public keys
* stored in a key store.
@@ -732,14 +731,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java
index 1048b25..eff2a7f 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -351,14 +351,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public boolean supportsRestore()
{
return true;
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java
index 1c6a0cf..d9c00e8 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java
@@ -323,14 +323,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public boolean supportsRestore()
{
return true;
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java
index 90c1b2b..5b9ac66 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java
@@ -1110,18 +1110,6 @@
return true;
}
-
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- return true;
- }
-
-
-
/** {@inheritDoc} */
@Override
public void createBackup(BackupConfig backupConfig)
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java
index bf715b7..6403294 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java
@@ -1976,18 +1976,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup(BackupConfig backupConfig,
- StringBuilder unsupportedReason)
- {
- // We should support online backup for the configuration in any form. This
- // implementation does not support incremental backups, but in this case
- // even if we're asked to do an incremental we'll just do a full backup
- // instead. So the answer to this should always be "true".
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
index dcc3a8b..7346f63 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
@@ -964,10 +964,9 @@
backupConfig.setSignHash(signHash.isPresent());
backupConfig.setIncrementalBaseID(incrementalBase);
- StringBuilder unsupportedReason = new StringBuilder();
- if (! b.supportsBackup(backupConfig, unsupportedReason))
+ if (!b.supportsBackup())
{
- logger.error(ERR_BACKUPDB_CANNOT_BACKUP, b.getBackendID(), unsupportedReason);
+ logger.error(ERR_BACKUPDB_CANNOT_BACKUP, b.getBackendID());
errorsEncountered = true;
try
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java
index 4b5edd5..5a70458 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java
@@ -22,10 +22,14 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.backends;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
+import static org.testng.Assert.*;
+
import java.io.File;
import java.util.UUID;
@@ -54,10 +58,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.protocols.internal.Requests.*;
-import static org.testng.Assert.*;
-
/**
* A set of test cases for the LDIF backend.
*/
@@ -629,9 +629,7 @@
@Test
public void testHasSubordinates() throws Exception
{
- Backend<?> b = DirectoryServer.getBackend("ldifRoot");
- assertNotNull(b);
- assertTrue(b instanceof LDIFBackend);
+ Backend<?> b = getLDIFBackend();
assertEquals(b.hasSubordinates(DN.valueOf("o=ldif")), ConditionResult.TRUE);
assertEquals(b.hasSubordinates(DN.valueOf("uid=user.1,ou=People,o=ldif")),
@@ -660,9 +658,7 @@
public void testNumSubordinates()
throws Exception
{
- Backend<?> b = DirectoryServer.getBackend("ldifRoot");
- assertNotNull(b);
- assertTrue(b instanceof LDIFBackend);
+ Backend<?> b = getLDIFBackend();
assertEquals(b.numSubordinates(DN.valueOf("o=ldif"), false), 1);
assertEquals(b.numSubordinates(DN.valueOf("o=ldif"), true), 26);
@@ -694,9 +690,7 @@
public void testLDIFExport()
throws Exception
{
- Backend<?> b = DirectoryServer.getBackend("ldifRoot");
- assertNotNull(b);
- assertTrue(b instanceof LDIFBackend);
+ Backend<?> b = getLDIFBackend();
assertTrue(b.supportsLDIFExport());
String tempFilePath = TestCaseUtils.createTempFile();
@@ -728,16 +722,10 @@
public void testMiscellaneousBackendMethods()
throws Exception
{
- Backend<?> b = DirectoryServer.getBackend("ldifRoot");
- assertNotNull(b);
- assertTrue(b instanceof LDIFBackend);
-
+ LDIFBackend b = getLDIFBackend();
assertTrue(b.getEntryCount() > 0);
-
assertTrue(b.isLocal());
-
assertFalse(b.supportsBackup());
- assertFalse(b.supportsBackup(null, null));
try
{
@@ -759,10 +747,16 @@
fail("Expected an exception when calling restoreBackup");
} catch (DirectoryException de) {}
- LDIFBackend ldifBackend = (LDIFBackend) b;
- assertNotNull(ldifBackend.getClassName());
- assertNotNull(ldifBackend.getAlerts());
- assertFalse(ldifBackend.getAlerts().isEmpty());
+ assertNotNull(b.getClassName());
+ assertNotNull(b.getAlerts());
+ assertFalse(b.getAlerts().isEmpty());
+ }
+
+ private LDIFBackend getLDIFBackend()
+ {
+ Backend<?> b = DirectoryServer.getBackend("ldifRoot");
+ assertNotNull(b);
+ assertTrue(b instanceof LDIFBackend);
+ return (LDIFBackend) b;
}
}
-
--
Gitblit v1.10.0