From 0a91f5af5295a2d0f5cfdad0d529d4b5d532c181 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 10 Feb 2015 15:34:15 +0000
Subject: [PATCH] OPENDJ-1716 Various PluggableBackend/Storage refactorings
---
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/GenericBackendTestCase.java | 74 +-
opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java | 33 -
opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java | 5
opendj3-server-dev/src/server/org/opends/server/tasks/RestoreTask.java | 81 +-
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java | 23
opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java | 70 +-
opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java | 3
opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java | 3
opendj3-server-dev/src/server/org/opends/server/tasks/RebuildTask.java | 3
opendj3-server-dev/src/server/org/opends/server/tasks/ExportTask.java | 264 ++++-------
opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java | 31 -
opendj3-server-dev/src/server/org/opends/server/backends/ChangelogBackend.java | 23
opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java | 25 -
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java | 24
opendj3-server-dev/src/server/org/opends/server/api/Backend.java | 74 +--
opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java | 40 -
opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java | 3
opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java | 23
opendj3-server-dev/src/server/org/opends/server/backends/NullBackend.java | 33 -
opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java | 38 -
opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java | 46 -
opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java | 5
opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java | 239 +++-------
opendj3-server-dev/src/server/org/opends/server/tasks/BackupTask.java | 69 +-
opendj3-server-dev/src/server/org/opends/server/backends/MemoryBackend.java | 34 -
opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java | 23
opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java | 3
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java | 15
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java | 31 -
opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java | 5
30 files changed, 438 insertions(+), 905 deletions(-)
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
index 0a925a4..309238c 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
@@ -441,28 +441,7 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsLDIFExport()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsLDIFImport()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsRestore()
+ public boolean supports(BackendOperation backendOperation)
{
return false;
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/api/Backend.java b/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
index 8c4a4c5..7de701e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
@@ -604,14 +604,36 @@
return supportedFeatures != null && supportedFeatures.contains(featureOID);
}
+ /** Enumeration of optional backend operations. */
+ public static enum BackendOperation
+ {
+ /** Indicates whether this backend supports indexing attributes to speed up searches. */
+ INDEXING,
+ /** Indicates whether this backend supports exporting the data it contains to an LDIF file. */
+ LDIF_EXPORT,
+ /** Indicates whether this backend supports importing its data from an LDIF file. */
+ LDIF_IMPORT,
+ /**
+ * Indicates whether this backend provides a backup mechanism of any kind. This method is used
+ * by the backup process when backing up all backends to determine whether this backend is one
+ * that should be skipped. It should only return {@code true} for backends that it is not
+ * possible to archive directly (e.g., those that don't store their data locally, but rather
+ * pass through requests to some other repository).
+ */
+ BACKUP,
+ /** Indicates whether this backend can restore a backup. */
+ RESTORE;
+ }
+
/**
- * Indicates whether this backend provides a mechanism to export the
- * data it contains to an LDIF file.
+ * Indicates whether this backend supports the provided backend operation.
*
- * @return {@code true} if this backend provides an LDIF export
- * mechanism, or {@code false} if not.
+ * @param backendOperation
+ * the backend operation
+ * @return {@code true} if this backend supports the provided backend operation, {@code false}
+ * otherwise.
*/
- public abstract boolean supportsLDIFExport();
+ public abstract boolean supports(BackendOperation backendOperation);
/**
* Exports the contents of this backend to LDIF. This method should
@@ -628,15 +650,6 @@
public abstract void exportLDIF(LDIFExportConfig exportConfig) throws DirectoryException;
/**
- * Indicates whether this backend provides a mechanism to import its
- * data from an LDIF file.
- *
- * @return {@code true} if this backend provides an LDIF import
- * mechanism, or {@code false} if not.
- */
- public abstract boolean supportsLDIFImport();
-
- /**
* Imports information from an LDIF file into this backend. This
* method should only be called if {@code supportsLDIFImport}
* returns {@code true}. Note that the server will not explicitly
@@ -654,16 +667,6 @@
throws DirectoryException;
/**
- * Indicates whether this backend supports indexing attributes to speed up searches.
- *
- * @return {@code true} if this backend supports indexing attributes, {@code false} otherwise
- */
- public boolean supportsIndexing()
- {
- return false;
- }
-
- /**
* Verify the integrity of the backend instance.
*
* @param verifyConfig
@@ -706,20 +709,6 @@
}
/**
- * Indicates whether this backend provides a backup mechanism of any
- * kind. This method is used by the backup process when backing up
- * all backends to determine whether this backend is one that should
- * be skipped. It should only return {@code true} for backends that
- * it is not possible to archive directly (e.g., those that don't
- * store their data locally, but rather pass through requests to
- * some other repository).
- *
- * @return {@code true} if this backend provides any kind of backup
- * mechanism, or {@code false} if it does not.
- */
- public abstract boolean supportsBackup();
-
- /**
* 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}.
@@ -754,15 +743,6 @@
throws DirectoryException;
/**
- * Indicates whether this backend provides a mechanism to restore a
- * backup.
- *
- * @return {@code true} if this backend provides a mechanism for
- * restoring backups, or {@code false} if not.
- */
- public abstract boolean supportsRestore();
-
- /**
* Restores a backup of the contents of this backend. This method
* should only be called if {@code supportsRestore} returns
* {@code true}. Note that the server will not explicitly
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java
index 4594400..84c8da5 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java
@@ -28,6 +28,7 @@
import static org.opends.messages.BackendMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.schema.BooleanSyntax.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -52,7 +53,6 @@
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.*;
@@ -558,14 +558,10 @@
LinkedHashMap<AttributeType,List<Attribute>> userAttrs =
new LinkedHashMap<AttributeType,List<Attribute>>(3);
- ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(t, v));
- userAttrs.put(t, attrList);
+ userAttrs.put(t, asList(t, v));
t = DirectoryServer.getAttributeType(ATTR_BACKUP_BACKEND_DN, true);
- attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(t, ByteString.valueOf(backupDirectory.getConfigEntryDN().toString())));
- userAttrs.put(t, attrList);
+ userAttrs.put(t, asList(t, ByteString.valueOf(backupDirectory.getConfigEntryDN().toString())));
Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs);
e.processVirtualAttributes();
@@ -590,28 +586,24 @@
throws DirectoryException
{
// First, get the backup ID from the entry DN.
- AttributeType idType = DirectoryServer.getAttributeType(ATTR_BACKUP_ID,
- true);
+ AttributeType idType = DirectoryServer.getAttributeType(ATTR_BACKUP_ID, true);
ByteString idValue = entryDN.rdn().getAttributeValue(idType);
if (idValue == null) {
- LocalizableMessage message = ERR_BACKUP_NO_BACKUP_ID_IN_DN.get(entryDN);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
+ throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_ID_IN_DN.get(entryDN));
}
String backupID = idValue.toString();
// Next, get the backup directory from the parent DN.
DN parentDN = entryDN.getParentDNInSuffix();
if (parentDN == null) {
- LocalizableMessage message = ERR_BACKUP_NO_BACKUP_PARENT_DN.get(entryDN);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
+ throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_PARENT_DN.get(entryDN));
}
AttributeType t = DirectoryServer.getAttributeType(
ATTR_BACKUP_DIRECTORY_PATH, true);
ByteString v = parentDN.rdn().getAttributeValue(t);
if (v == null) {
- LocalizableMessage message = ERR_BACKUP_NO_BACKUP_DIR_IN_DN.get(entryDN);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
+ throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_DIR_IN_DN.get(entryDN));
}
BackupDirectory backupDirectory;
@@ -620,8 +612,7 @@
} catch (ConfigException ce) {
logger.traceException(ce);
- LocalizableMessage message = ERR_BACKUP_INVALID_BACKUP_DIRECTORY.get(entryDN, ce.getMessageObject());
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
+ throw newConstraintViolation(ERR_BACKUP_INVALID_BACKUP_DIRECTORY.get(entryDN, ce.getMessageObject()));
} catch (Exception e) {
logger.traceException(e);
@@ -655,40 +646,21 @@
LinkedHashMap<AttributeType, List<Attribute>> userAttrs =
new LinkedHashMap<AttributeType, List<Attribute>>();
- ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(idType, idValue));
- userAttrs.put(idType, attrList);
+ userAttrs.put(idType, asList(idType, idValue));
backupInfo.getBackupDirectory();
- attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(t, v));
- userAttrs.put(t, attrList);
+ userAttrs.put(t, asList(t, v));
Date backupDate = backupInfo.getBackupDate();
if (backupDate != null) {
t = DirectoryServer.getAttributeType(ATTR_BACKUP_DATE, true);
- attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(t, ByteString.valueOf(GeneralizedTimeSyntax.format(backupDate))));
- userAttrs.put(t, attrList);
+ userAttrs.put(t,
+ asList(t, ByteString.valueOf(GeneralizedTimeSyntax.format(backupDate))));
}
- t = DirectoryServer.getAttributeType(ATTR_BACKUP_COMPRESSED, true);
- attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(t, BooleanSyntax
- .createBooleanValue(backupInfo.isCompressed())));
- userAttrs.put(t, attrList);
-
- t = DirectoryServer.getAttributeType(ATTR_BACKUP_ENCRYPTED, true);
- attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(t, BooleanSyntax
- .createBooleanValue(backupInfo.isEncrypted())));
- userAttrs.put(t, attrList);
-
- t = DirectoryServer.getAttributeType(ATTR_BACKUP_INCREMENTAL, true);
- attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(t, BooleanSyntax
- .createBooleanValue(backupInfo.isIncremental())));
- userAttrs.put(t, attrList);
+ putBoolean(userAttrs, ATTR_BACKUP_COMPRESSED, backupInfo.isCompressed());
+ putBoolean(userAttrs, ATTR_BACKUP_ENCRYPTED, backupInfo.isEncrypted());
+ putBoolean(userAttrs, ATTR_BACKUP_INCREMENTAL, backupInfo.isIncremental());
HashSet<String> dependencies = backupInfo.getDependencies();
if (dependencies != null && !dependencies.isEmpty()) {
@@ -697,34 +669,26 @@
for (String s : dependencies) {
builder.add(s);
}
- attrList = new ArrayList<Attribute>(1);
+ ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
attrList.add(builder.toAttribute());
userAttrs.put(t, attrList);
}
byte[] signedHash = backupInfo.getSignedHash();
if (signedHash != null) {
- t = DirectoryServer.getAttributeType(ATTR_BACKUP_SIGNED_HASH, true);
- attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(t, ByteString.wrap(signedHash)));
- userAttrs.put(t, attrList);
+ putByteString(userAttrs, ATTR_BACKUP_SIGNED_HASH, signedHash);
}
byte[] unsignedHash = backupInfo.getUnsignedHash();
if (unsignedHash != null) {
- t = DirectoryServer.getAttributeType(ATTR_BACKUP_UNSIGNED_HASH, true);
- attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(t, ByteString.wrap(unsignedHash)));
- userAttrs.put(t, attrList);
+ putByteString(userAttrs, ATTR_BACKUP_UNSIGNED_HASH, unsignedHash);
}
HashMap<String, String> properties = backupInfo.getBackupProperties();
if (properties != null && !properties.isEmpty()) {
for (Map.Entry<String, String> e : properties.entrySet()) {
t = DirectoryServer.getAttributeType(toLowerCase(e.getKey()), true);
- attrList = new ArrayList<Attribute>(1);
- attrList.add(Attributes.create(t, ByteString.valueOf(e.getValue())));
- userAttrs.put(t, attrList);
+ userAttrs.put(t, asList(t, ByteString.valueOf(e.getValue())));
}
}
@@ -733,7 +697,30 @@
return e;
}
+ private void putByteString(LinkedHashMap<AttributeType, List<Attribute>> userAttrs, String attrName, byte[] value)
+ {
+ AttributeType t;
+ t = DirectoryServer.getAttributeType(attrName, true);
+ userAttrs.put(t, asList(t, ByteString.wrap(value)));
+ }
+ private void putBoolean(LinkedHashMap<AttributeType, List<Attribute>> attrsMap, String attrName, boolean value)
+ {
+ AttributeType t = DirectoryServer.getAttributeType(attrName, true);
+ attrsMap.put(t, asList(t, createBooleanValue(value)));
+ }
+
+ private ArrayList<Attribute> asList(AttributeType attrType, ByteString value)
+ {
+ final ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
+ attrList.add(Attributes.create(attrType, value));
+ return attrList;
+ }
+
+ private DirectoryException newConstraintViolation(LocalizableMessage message)
+ {
+ return new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
+ }
/** {@inheritDoc} */
@Override
@@ -841,38 +828,8 @@
if (scope != SearchScope.SINGLE_LEVEL)
{
- List<Attribute> attrList =
- backupDirEntry.getAttribute(backupPathType);
- if (attrList != null && !attrList.isEmpty())
- {
- for (ByteString v : attrList.get(0))
- {
- try
- {
- File subtreeDir = new File(v.toString());
- BackupDirectory backupDirectory = backupDirectories.get(subtreeDir).getBackupDirectory();
- AttributeType idType =
- DirectoryServer.getAttributeType(ATTR_BACKUP_ID,
- true);
- for (String backupID : backupDirectory.getBackups().keySet())
- {
- DN backupEntryDN = makeChildDN(backupDirDN, idType,
- backupID);
- Entry backupEntry = getBackupEntry(backupEntryDN);
- if (filter.matchesEntry(backupEntry))
- {
- searchOperation.returnEntry(backupEntry, null);
- }
- }
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- continue;
- }
- }
- }
+ List<Attribute> attrList = backupDirEntry.getAttribute(backupPathType);
+ returnEntries(searchOperation, backupDirDN, filter, attrList);
}
}
}
@@ -893,36 +850,7 @@
AttributeType t =
DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true);
List<Attribute> attrList = backupDirEntry.getAttribute(t);
- if (attrList != null && !attrList.isEmpty())
- {
- for (ByteString v : attrList.get(0))
- {
- try
- {
- File dir = new File(v.toString());
- BackupDirectory backupDirectory = backupDirectories.get(dir).getBackupDirectory();
- AttributeType idType =
- DirectoryServer.getAttributeType(ATTR_BACKUP_ID,
- true);
- for (String backupID : backupDirectory.getBackups().keySet())
- {
- DN backupEntryDN = makeChildDN(baseDN, idType,
- backupID);
- Entry backupEntry = getBackupEntry(backupEntryDN);
- if (filter.matchesEntry(backupEntry))
- {
- searchOperation.returnEntry(backupEntry, null);
- }
- }
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- continue;
- }
- }
- }
+ returnEntries(searchOperation, baseDN, filter, attrList);
}
}
else
@@ -952,7 +880,37 @@
}
}
+ private void returnEntries(SearchOperation searchOperation, DN baseDN, SearchFilter filter, List<Attribute> attrList)
+ {
+ if (attrList != null && !attrList.isEmpty())
+ {
+ for (ByteString v : attrList.get(0))
+ {
+ try
+ {
+ File dir = new File(v.toString());
+ BackupDirectory backupDirectory = backupDirectories.get(dir).getBackupDirectory();
+ AttributeType idType = DirectoryServer.getAttributeType(ATTR_BACKUP_ID, true);
+ for (String backupID : backupDirectory.getBackups().keySet())
+ {
+ DN backupEntryDN = makeChildDN(baseDN, idType, backupID);
+ Entry backupEntry = getBackupEntry(backupEntryDN);
+ if (filter.matchesEntry(backupEntry))
+ {
+ searchOperation.returnEntry(backupEntry, null);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ logger.traceException(e);
+
+ continue;
+ }
+ }
+ }
+ }
/** {@inheritDoc} */
@Override
@@ -970,14 +928,11 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
- // We do not support LDIF exports.
return false;
}
-
-
/** {@inheritDoc} */
@Override
public void exportLDIF(LDIFExportConfig exportConfig)
@@ -987,17 +942,6 @@
ERR_BACKEND_IMPORT_AND_EXPORT_NOT_SUPPORTED.get(getBackendID()));
}
-
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsLDIFImport()
- {
- return false;
- }
-
-
-
/** {@inheritDoc} */
@Override
public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
@@ -1007,15 +951,6 @@
ERR_BACKEND_IMPORT_AND_EXPORT_NOT_SUPPORTED.get(getBackendID()));
}
-
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsBackup()
- {
- return false;
- }
-
/** {@inheritDoc} */
@Override
public void createBackup(BackupConfig backupConfig)
@@ -1025,8 +960,6 @@
ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
}
-
-
/** {@inheritDoc} */
@Override
public void removeBackup(BackupDirectory backupDirectory,
@@ -1037,17 +970,6 @@
ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
}
-
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsRestore()
- {
- return false;
- }
-
-
-
/** {@inheritDoc} */
@Override
public void restoreBackup(RestoreConfig restoreConfig)
@@ -1057,8 +979,6 @@
ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
}
-
-
/** {@inheritDoc} */
@Override
public boolean isConfigurationChangeAcceptable(
@@ -1070,8 +990,6 @@
return true;
}
-
-
/** {@inheritDoc} */
@Override
public ConfigChangeResult applyConfigurationChange(BackupBackendCfg cfg)
@@ -1090,8 +1008,6 @@
return ccr;
}
-
-
/**
* Create a new child DN from a given parent DN. The child RDN is formed
* from a given attribute type and string value.
@@ -1107,12 +1023,9 @@
return parentDN.child(RDN.create(rdnAttrType, attrValue));
}
-
-
/** {@inheritDoc} */
@Override
public void preloadEntryCache() throws UnsupportedOperationException {
throw new UnsupportedOperationException("Operation not supported.");
}
}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/ChangelogBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/ChangelogBackend.java
index a9c4f20..b91ecfc 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/ChangelogBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/ChangelogBackend.java
@@ -614,7 +614,7 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
return false;
}
@@ -630,13 +630,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFImport()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
@@ -646,13 +639,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig) throws DirectoryException
{
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
@@ -669,13 +655,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsRestore()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void restoreBackup(RestoreConfig restoreConfig) throws DirectoryException
{
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java
index fa8413a..2735035 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/LDIFBackend.java
@@ -947,9 +947,17 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
- return true;
+ switch (backendOperation)
+ {
+ case LDIF_EXPORT:
+ case LDIF_IMPORT:
+ return true;
+
+ default:
+ return false;
+ }
}
/** {@inheritDoc} */
@@ -1008,13 +1016,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFImport()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
@@ -1186,13 +1187,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
@@ -1211,13 +1205,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsRestore()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/MemoryBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/MemoryBackend.java
index 8ac3984..fdbcc79 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/MemoryBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/MemoryBackend.java
@@ -619,9 +619,17 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
- return true;
+ switch (backendOperation)
+ {
+ case LDIF_EXPORT:
+ case LDIF_IMPORT:
+ return true;
+
+ default:
+ return false;
+ }
}
/** {@inheritDoc} */
@@ -667,13 +675,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFImport()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public synchronized LDIFImportResult importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
@@ -748,13 +749,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
@@ -774,13 +768,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsRestore()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
@@ -794,4 +781,3 @@
throw new UnsupportedOperationException("Operation not supported.");
}
}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java
index 52cfe7d..82b8257 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java
@@ -589,14 +589,7 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
// We can export all the monitor entries as a point-in-time snapshot.
// TODO implementation of export is incomplete
@@ -604,20 +597,6 @@
return false;
}
- /** {@inheritDoc} */
- @Override
- public boolean supportsLDIFImport()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsRestore()
- {
- return false;
- }
-
/**
* Retrieves the base monitor entry for the Directory Server.
*
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/NullBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/NullBackend.java
index 3deeb47..7cff44e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/NullBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/NullBackend.java
@@ -361,9 +361,17 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
- return true;
+ switch (backendOperation)
+ {
+ case LDIF_EXPORT:
+ case LDIF_IMPORT:
+ return true;
+
+ default:
+ return false;
+ }
}
/** {@inheritDoc} */
@@ -388,13 +396,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFImport()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
@@ -469,13 +470,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
@@ -495,13 +489,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsRestore()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java
index 77ac25c..3b48f2b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java
@@ -919,10 +919,10 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
// We will only export the DSE entry itself.
- return true;
+ return backendOperation.equals(BackendOperation.LDIF_EXPORT);
}
/** {@inheritDoc} */
@@ -970,13 +970,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFImport()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
@@ -986,13 +979,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
@@ -1012,13 +998,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsRestore()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
index a256ab7..fcb497b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
@@ -3618,14 +3618,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
- {
- // We will only export the DSE entry itself.
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
{
@@ -3669,9 +3661,21 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFImport()
+ public boolean supports(BackendOperation backendOperation)
{
- return true;
+ switch (backendOperation)
+ {
+ case LDIF_EXPORT:
+ case LDIF_IMPORT:
+ case RESTORE:
+ // We will provide a restore, but only for offline operations.
+ case BACKUP:
+ // We do support an online backup mechanism for the schema.
+ return true;
+
+ default:
+ return false;
+ }
}
/** {@inheritDoc} */
@@ -3987,14 +3991,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- // We do support an online backup mechanism for the schema.
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
@@ -4395,14 +4391,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsRestore()
- {
- // We will provide a restore, but only for offline operations.
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java
index 8bcb374..c1deb32 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java
@@ -692,7 +692,7 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
return false;
}
@@ -708,13 +708,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFImport()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
@@ -724,13 +717,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
@@ -750,13 +736,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsRestore()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java
index eff2a7f..8ecd8aa 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -330,29 +330,9 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsLDIFImport()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsBackup()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsRestore()
- {
+ // it supports all the operations so far
return true;
}
@@ -811,13 +791,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsIndexing()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public long verifyBackend(VerifyConfig verifyConfig)
throws InitializationException, ConfigException, DirectoryException
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java
index d9c00e8..1040b87 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java
@@ -302,29 +302,9 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsLDIFImport()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsBackup()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsRestore()
- {
+ // it supports all the operations so far
return true;
}
@@ -689,13 +669,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsIndexing()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public long verifyBackend(VerifyConfig verifyConfig)
throws InitializationException, ConfigException, DirectoryException
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java
index 5b9ac66..deeff61 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java
@@ -992,8 +992,6 @@
return Collections.emptySet();
}
-
-
/** {@inheritDoc} */
@Override
public Set<String> getSupportedFeatures()
@@ -1001,18 +999,22 @@
return Collections.emptySet();
}
-
-
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
- // LDIF exports are supported.
- return true;
+ switch (backendOperation)
+ {
+ case LDIF_EXPORT:
+ case BACKUP:
+ case RESTORE:
+ return true;
+
+ default:
+ return false;
+ }
}
-
-
/** {@inheritDoc} */
@Override
public void exportLDIF(LDIFExportConfig exportConfig)
@@ -1089,13 +1091,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFImport()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
@@ -1105,13 +1100,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
@@ -1426,18 +1414,6 @@
archiveFile.delete();
}
-
-
- /** {@inheritDoc} */
- @Override
- public boolean supportsRestore()
- {
- // This backend does provide a backup/restore mechanism.
- return true;
- }
-
-
-
/** {@inheritDoc} */
@Override
public void restoreBackup(RestoreConfig restoreConfig)
diff --git a/opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java b/opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java
index 6403294..0df1892 100644
--- a/opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java
@@ -1850,10 +1850,17 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFExport()
+ public boolean supports(BackendOperation backendOperation)
{
- // TODO We would need export-ldif to initialize this backend.
- return false;
+ switch (backendOperation)
+ {
+ case BACKUP:
+ case RESTORE:
+ return true;
+
+ default:
+ return false;
+ }
}
/** {@inheritDoc} */
@@ -1865,8 +1872,6 @@
writeLDIF(exportConfig);
}
-
-
/**
* Writes the current configuration to LDIF with the provided export
* configuration.
@@ -1952,13 +1957,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsLDIFImport()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
@@ -1968,14 +1966,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsBackup()
- {
- // We do support an online backup mechanism for the configuration.
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
@@ -2332,14 +2322,6 @@
/** {@inheritDoc} */
@Override
- public boolean supportsRestore()
- {
- // We will provide a restore, but only for offline operations.
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index 6083abe..71f86ad 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -67,6 +67,7 @@
import org.opends.server.api.Backend;
import org.opends.server.api.DirectoryThread;
import org.opends.server.api.SynchronizationProvider;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.backends.task.Task;
import org.opends.server.core.*;
import org.opends.server.protocols.internal.InternalClientConnection;
@@ -3567,7 +3568,7 @@
ImportExportContext ieCtx = getImportExportContext();
try
{
- if (!backend.supportsLDIFImport())
+ if (!backend.supports(BackendOperation.LDIF_IMPORT))
{
ieCtx.setExceptionIfNoneSet(new DirectoryException(OTHER,
ERR_INIT_IMPORT_NOT_SUPPORTED.get(backend.getBackendID())));
@@ -4250,7 +4251,7 @@
public long countEntries() throws DirectoryException
{
Backend<?> backend = getBackend();
- if (!backend.supportsLDIFExport())
+ if (!backend.supports(BackendOperation.LDIF_EXPORT))
{
LocalizableMessage msg = ERR_INIT_EXPORT_NOT_SUPPORTED.get(backend.getBackendID());
logger.error(msg);
diff --git a/opendj3-server-dev/src/server/org/opends/server/tasks/BackupTask.java b/opendj3-server-dev/src/server/org/opends/server/tasks/BackupTask.java
index e2aeef1..92b5761 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tasks/BackupTask.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tasks/BackupTask.java
@@ -22,31 +22,41 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.tasks;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.messages.Severity;
-import org.opends.messages.TaskMessages;
-import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.core.DirectoryServer.getAttributeType;
import static org.opends.messages.TaskMessages.*;
import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.util.ServerConstants.DATE_FORMAT_GMT_TIME;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.core.DirectoryServer.*;
+import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-import static org.opends.server.util.ServerConstants.
- BACKUP_DIRECTORY_DESCRIPTOR_FILE;
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.messages.Severity;
+import org.opends.messages.TaskMessages;
+import org.opends.server.admin.std.server.BackendCfg;
+import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
+import org.opends.server.api.ClientConnection;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
+import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
-import org.opends.server.api.Backend;
-import org.opends.server.api.ClientConnection;
-import org.opends.server.config.ConfigEntry;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
@@ -55,17 +65,6 @@
import org.opends.server.types.Entry;
import org.opends.server.types.Operation;
import org.opends.server.types.Privilege;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.opends.server.admin.std.server.BackendCfg;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-import java.util.HashMap;
-import java.text.SimpleDateFormat;
-import java.io.File;
/**
* This class provides an implementation of a Directory Server task that may be
@@ -147,7 +146,7 @@
*/
private Map<String,ConfigEntry> configEntries;
- private ArrayList<Backend> backendsToArchive;
+ private ArrayList<Backend<?>> backendsToArchive;
/**
* {@inheritDoc}
@@ -345,14 +344,14 @@
int numBackends = configEntries.size();
- backendsToArchive = new ArrayList<Backend>(numBackends);
+ backendsToArchive = new ArrayList<Backend<?>>(numBackends);
if (backUpAll)
{
for (Map.Entry<String,ConfigEntry> mapEntry : configEntries.entrySet())
{
- Backend b = DirectoryServer.getBackend(mapEntry.getKey());
- if (b != null && b.supportsBackup())
+ Backend<?> b = DirectoryServer.getBackend(mapEntry.getKey());
+ if (b != null && b.supports(BackendOperation.BACKUP))
{
backendsToArchive.add(b);
}
@@ -364,12 +363,12 @@
// be used.
for (String id : backendIDList)
{
- Backend b = DirectoryServer.getBackend(id);
+ Backend<?> b = DirectoryServer.getBackend(id);
if (b == null || configEntries.get(id) == null)
{
logger.error(ERR_BACKUPDB_NO_BACKENDS_FOR_ID, id);
}
- else if (! b.supportsBackup())
+ else if (!b.supports(BackendOperation.BACKUP))
{
logger.warn(WARN_BACKUPDB_BACKUP_NOT_SUPPORTED, b.getBackendID());
}
@@ -405,7 +404,7 @@
* @param backupLocation The backup directory.
* @return true if the backend was successfully archived.
*/
- private boolean backupBackend(Backend b, File backupLocation)
+ private boolean backupBackend(Backend<?> b, File backupLocation)
{
// Get the config entry for this backend.
BackendCfg cfg = TaskUtils.getConfigEntry(b);
@@ -506,7 +505,7 @@
* @param b The backend on which the lock is to be acquired.
* @return true if the lock was successfully acquired.
*/
- private boolean lockBackend(Backend b)
+ private boolean lockBackend(Backend<?> b)
{
try
{
@@ -532,7 +531,7 @@
* @param b The backend on which the lock is held.
* @return true if the lock was successfully released.
*/
- private boolean unlockBackend(Backend b)
+ private boolean unlockBackend(Backend<?> b)
{
try
{
@@ -607,7 +606,7 @@
// Iterate through the backends to archive and back them up individually.
boolean errorsEncountered = false;
- for (Backend b : backendsToArchive)
+ for (Backend<?> b : backendsToArchive)
{
if (isCancelled())
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/tasks/ExportTask.java b/opendj3-server-dev/src/server/org/opends/server/tasks/ExportTask.java
index bb8aed9..b43b6d5 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tasks/ExportTask.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tasks/ExportTask.java
@@ -22,45 +22,46 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.tasks;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.messages.Severity;
-import org.opends.messages.TaskMessages;
-import static org.opends.server.core.DirectoryServer.getAttributeType;
-import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.TaskMessages.*;
import static org.opends.messages.ToolMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.util.StaticUtils.*;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.messages.Severity;
+import org.opends.messages.TaskMessages;
+import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
+import org.opends.server.api.ClientConnection;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
-import org.opends.server.api.Backend;
-import org.opends.server.api.ClientConnection;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
-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.ExistingFileBehavior;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.Operation;
import org.opends.server.types.Privilege;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.SearchFilter;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.io.File;
-
/**
* This class provides an implementation of a Directory Server task that can
* be used to export the contents of a Directory Server backend to an LDIF file.
@@ -147,24 +148,21 @@
private LDIFExportConfig exportConfig;
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public LocalizableMessage getDisplayName() {
return INFO_TASK_EXPORT_NAME.get();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public LocalizableMessage getAttributeDisplayName(String name) {
return argDisplayMap.get(name);
}
- /**
- * {@inheritDoc}
- */
- @Override public void initializeTask() throws DirectoryException
+ /** {@inheritDoc} */
+ @Override
+ public void initializeTask() throws DirectoryException
{
// If the client connection is available, then make sure the associated
// client has the LDIF_EXPORT privilege.
@@ -182,57 +180,9 @@
Entry taskEntry = getTaskEntry();
+ AttributeType typeWrapColumn = getAttributeType(ATTR_TASK_EXPORT_WRAP_COLUMN, true);
- AttributeType typeLdifFile;
- AttributeType typeBackendID;
- AttributeType typeAppendToLDIF;
- AttributeType typeCompressLDIF;
- AttributeType typeEncryptLDIF;
- AttributeType typeSignHash;
- AttributeType typeIncludeAttribute;
- AttributeType typeExcludeAttribute;
- AttributeType typeIncludeFilter;
- AttributeType typeExcludeFilter;
- AttributeType typeIncludeBranch;
- AttributeType typeExcludeBranch;
- AttributeType typeWrapColumn;
- AttributeType typeIncludeOperationalAttributes;
-
-
- typeLdifFile =
- getAttributeType(ATTR_TASK_EXPORT_LDIF_FILE, true);
- typeBackendID =
- getAttributeType(ATTR_TASK_EXPORT_BACKEND_ID, true);
- typeAppendToLDIF =
- getAttributeType(ATTR_TASK_EXPORT_APPEND_TO_LDIF, true);
- typeCompressLDIF =
- getAttributeType(ATTR_TASK_EXPORT_COMPRESS_LDIF, true);
- typeEncryptLDIF =
- getAttributeType(ATTR_TASK_EXPORT_ENCRYPT_LDIF, true);
- typeSignHash =
- getAttributeType(ATTR_TASK_EXPORT_SIGN_HASH, true);
- typeIncludeAttribute =
- getAttributeType(ATTR_TASK_EXPORT_INCLUDE_ATTRIBUTE, true);
- typeExcludeAttribute =
- getAttributeType(ATTR_TASK_EXPORT_EXCLUDE_ATTRIBUTE, true);
- typeIncludeFilter =
- getAttributeType(ATTR_TASK_EXPORT_INCLUDE_FILTER, true);
- typeExcludeFilter =
- getAttributeType(ATTR_TASK_EXPORT_EXCLUDE_FILTER, true);
- typeIncludeBranch =
- getAttributeType(ATTR_TASK_EXPORT_INCLUDE_BRANCH, true);
- typeExcludeBranch =
- getAttributeType(ATTR_TASK_EXPORT_EXCLUDE_BRANCH, true);
- typeWrapColumn =
- getAttributeType(ATTR_TASK_EXPORT_WRAP_COLUMN, true);
- typeIncludeOperationalAttributes =
- getAttributeType(ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES, true);
-
-
- List<Attribute> attrList;
-
- attrList = taskEntry.getAttribute(typeLdifFile);
- ldifFile = TaskUtils.getSingleValueString(attrList);
+ ldifFile = toString(taskEntry, ATTR_TASK_EXPORT_LDIF_FILE);
File f = new File (ldifFile);
if (! f.isAbsolute())
{
@@ -247,51 +197,47 @@
}
}
- attrList = taskEntry.getAttribute(typeBackendID);
- backendID = TaskUtils.getSingleValueString(attrList);
+ backendID = toString(taskEntry, ATTR_TASK_EXPORT_BACKEND_ID);
+ appendToLDIF = toBoolean(taskEntry, false, ATTR_TASK_EXPORT_APPEND_TO_LDIF);
+ compressLDIF = toBoolean(taskEntry, false, ATTR_TASK_EXPORT_COMPRESS_LDIF);
+ encryptLDIF = toBoolean(taskEntry, false, ATTR_TASK_EXPORT_ENCRYPT_LDIF);
+ signHash = toBoolean(taskEntry, false, ATTR_TASK_EXPORT_SIGN_HASH);
+ includeAttributeStrings = toListOfString(taskEntry, ATTR_TASK_EXPORT_INCLUDE_ATTRIBUTE);
+ excludeAttributeStrings = toListOfString(taskEntry, ATTR_TASK_EXPORT_EXCLUDE_ATTRIBUTE);
+ includeFilterStrings = toListOfString(taskEntry, ATTR_TASK_EXPORT_INCLUDE_FILTER);
+ excludeFilterStrings = toListOfString(taskEntry, ATTR_TASK_EXPORT_EXCLUDE_FILTER);
+ includeBranchStrings = toListOfString(taskEntry, ATTR_TASK_EXPORT_INCLUDE_BRANCH);
+ excludeBranchStrings = toListOfString(taskEntry, ATTR_TASK_EXPORT_EXCLUDE_BRANCH);
- attrList = taskEntry.getAttribute(typeAppendToLDIF);
- appendToLDIF = TaskUtils.getBoolean(attrList, false);
-
- attrList = taskEntry.getAttribute(typeCompressLDIF);
- compressLDIF = TaskUtils.getBoolean(attrList, false);
-
- attrList = taskEntry.getAttribute(typeEncryptLDIF);
- encryptLDIF = TaskUtils.getBoolean(attrList, false);
-
- attrList = taskEntry.getAttribute(typeSignHash);
- signHash = TaskUtils.getBoolean(attrList, false);
-
- attrList = taskEntry.getAttribute(typeIncludeAttribute);
- includeAttributeStrings = TaskUtils.getMultiValueString(attrList);
-
- attrList = taskEntry.getAttribute(typeExcludeAttribute);
- excludeAttributeStrings = TaskUtils.getMultiValueString(attrList);
-
- attrList = taskEntry.getAttribute(typeIncludeFilter);
- includeFilterStrings = TaskUtils.getMultiValueString(attrList);
-
- attrList = taskEntry.getAttribute(typeExcludeFilter);
- excludeFilterStrings = TaskUtils.getMultiValueString(attrList);
-
- attrList = taskEntry.getAttribute(typeIncludeBranch);
- includeBranchStrings = TaskUtils.getMultiValueString(attrList);
-
- attrList = taskEntry.getAttribute(typeExcludeBranch);
- excludeBranchStrings = TaskUtils.getMultiValueString(attrList);
-
- attrList = taskEntry.getAttribute(typeWrapColumn);
+ List<Attribute> attrList = taskEntry.getAttribute(typeWrapColumn);
wrapColumn = TaskUtils.getSingleValueInteger(attrList, 0);
- attrList = taskEntry.getAttribute(typeIncludeOperationalAttributes);
- includeOperationalAttributes = TaskUtils.getBoolean(attrList, true);
-
+ includeOperationalAttributes = toBoolean(taskEntry, true, ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES);
}
+ private boolean toBoolean(Entry entry, boolean defaultValue, String attrName)
+ {
+ final AttributeType attrType = getAttributeType(attrName, true);
+ final List<Attribute> attrs = entry.getAttribute(attrType);
+ return TaskUtils.getBoolean(attrs, defaultValue);
+ }
- /**
- * {@inheritDoc}
- */
+ private ArrayList<String> toListOfString(Entry entry, String attrName)
+ {
+ final AttributeType attrType = getAttributeType(attrName, true);
+ final List<Attribute> attrs = entry.getAttribute(attrType);
+ return TaskUtils.getMultiValueString(attrs);
+ }
+
+ private String toString(Entry entry, String attrName)
+ {
+ final AttributeType attrType = getAttributeType(attrName, true);
+ final List<Attribute> attrs = entry.getAttribute(attrType);
+ return TaskUtils.getSingleValueString(attrs);
+ }
+
+ /** {@inheritDoc} */
+ @Override
public void interruptTask(TaskState interruptState, LocalizableMessage interruptReason)
{
if (TaskState.STOPPED_BY_ADMINISTRATOR.equals(interruptState) &&
@@ -304,63 +250,20 @@
}
}
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public boolean isInterruptable() {
return true;
}
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
protected TaskState runTask()
{
// See if there were any user-defined sets of include/exclude attributes or
// filters. If so, then process them.
- HashSet<AttributeType> excludeAttributes;
- if (excludeAttributeStrings == null)
- {
- excludeAttributes = null;
- }
- else
- {
- excludeAttributes = new HashSet<AttributeType>();
- for (String attrName : excludeAttributeStrings)
- {
- String lowerName = attrName.toLowerCase();
- AttributeType attrType = DirectoryServer.getAttributeType(lowerName);
- if (attrType == null)
- {
- attrType = DirectoryServer.getDefaultAttributeType(attrName);
- }
-
- excludeAttributes.add(attrType);
- }
- }
-
- HashSet<AttributeType> includeAttributes;
- if (includeAttributeStrings == null)
- {
- includeAttributes = null;
- }
- else
- {
- includeAttributes = new HashSet<AttributeType>();
- for (String attrName : includeAttributeStrings)
- {
- String lowerName = attrName.toLowerCase();
- AttributeType attrType = DirectoryServer.getAttributeType(lowerName);
- if (attrType == null)
- {
- attrType = DirectoryServer.getDefaultAttributeType(attrName);
- }
-
- includeAttributes.add(attrType);
- }
- }
+ HashSet<AttributeType> excludeAttributes = toAttributeTypes(excludeAttributeStrings);
+ HashSet<AttributeType> includeAttributes = toAttributeTypes(includeAttributeStrings);
ArrayList<SearchFilter> excludeFilters;
if (excludeFilterStrings == null)
@@ -417,23 +320,21 @@
}
// Get the backend into which the LDIF should be imported.
- Backend backend;
- ArrayList<DN> defaultIncludeBranches;
- backend = DirectoryServer.getBackend(backendID);
+ Backend<?> backend = DirectoryServer.getBackend(backendID);
if (backend == null)
{
logger.error(ERR_LDIFEXPORT_NO_BACKENDS_FOR_ID, backendID);
return TaskState.STOPPED_BY_ERROR;
}
- else if (! backend.supportsLDIFExport())
+ else if (!backend.supports(BackendOperation.LDIF_EXPORT))
{
logger.error(ERR_LDIFEXPORT_CANNOT_EXPORT_BACKEND, backendID);
return TaskState.STOPPED_BY_ERROR;
}
- defaultIncludeBranches = new ArrayList<DN>(backend.getBaseDNs().length);
+ ArrayList<DN> defaultIncludeBranches = new ArrayList<DN>(backend.getBaseDNs().length);
for (DN dn : backend.getBaseDNs())
{
defaultIncludeBranches.add(dn);
@@ -625,4 +526,25 @@
// was interrupted
return getFinalTaskState();
}
+
+ private HashSet<AttributeType> toAttributeTypes(ArrayList<String> attributeStrings)
+ {
+ if (attributeStrings == null)
+ {
+ return null;
+ }
+ HashSet<AttributeType> attributes = new HashSet<AttributeType>();
+ for (String attrName : attributeStrings)
+ {
+ String lowerName = attrName.toLowerCase();
+ AttributeType attrType = DirectoryServer.getAttributeType(lowerName);
+ if (attrType == null)
+ {
+ attrType = DirectoryServer.getDefaultAttributeType(attrName);
+ }
+
+ attributes.add(attrType);
+ }
+ return attributes;
+ }
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java b/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java
index 71bfbec..bcd1072 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java
@@ -46,6 +46,7 @@
import org.opends.messages.Severity;
import org.opends.messages.TaskMessages;
import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.api.ClientConnection;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
@@ -323,7 +324,7 @@
LocalizableMessage message = ERR_LDIFIMPORT_NO_BACKENDS_FOR_ID.get();
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
- else if (! backend.supportsLDIFImport())
+ else if (!backend.supports(BackendOperation.LDIF_IMPORT))
{
LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_IMPORT.get(backendID);
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
@@ -513,7 +514,7 @@
logger.error(ERR_LDIFIMPORT_NO_BACKENDS_FOR_ID);
return TaskState.STOPPED_BY_ERROR;
}
- else if (! backend.supportsLDIFImport())
+ else if (!backend.supports(BackendOperation.LDIF_IMPORT))
{
logger.error(ERR_LDIFIMPORT_CANNOT_IMPORT, backendID);
return TaskState.STOPPED_BY_ERROR;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tasks/RebuildTask.java b/opendj3-server-dev/src/server/org/opends/server/tasks/RebuildTask.java
index 5041341..2b099d8 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tasks/RebuildTask.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tasks/RebuildTask.java
@@ -40,6 +40,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.messages.TaskMessages;
import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.api.ClientConnection;
import org.opends.server.backends.RebuildConfig;
import org.opends.server.backends.RebuildConfig.RebuildMode;
@@ -181,7 +182,7 @@
logger.error(ERR_NO_BACKENDS_FOR_BASE, baseDN);
return TaskState.STOPPED_BY_ERROR;
}
- if (!backend.supportsIndexing())
+ if (!backend.supports(BackendOperation.INDEXING))
{
logger.error(ERR_REBUILDINDEX_WRONG_BACKEND_TYPE);
return TaskState.STOPPED_BY_ERROR;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tasks/RestoreTask.java b/opendj3-server-dev/src/server/org/opends/server/tasks/RestoreTask.java
index 76f05c7..8283276 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tasks/RestoreTask.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tasks/RestoreTask.java
@@ -22,44 +22,45 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.tasks;
-import org.forgerock.i18n.LocalizableMessage;
-import org.opends.messages.Severity;
-import org.opends.messages.TaskMessages;
-import static org.opends.server.core.DirectoryServer.getAttributeType;
-import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.TaskMessages.*;
import static org.opends.messages.ToolMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.util.StaticUtils.*;
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.messages.Severity;
+import org.opends.messages.TaskMessages;
+import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
+import org.opends.server.api.ClientConnection;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
+import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
-import org.opends.server.api.Backend;
-import org.opends.server.api.ClientConnection;
-import org.opends.server.config.ConfigEntry;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.BackupInfo;
-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.Operation;
import org.opends.server.types.Privilege;
import org.opends.server.types.RestoreConfig;
-import org.forgerock.opendj.ldap.ResultCode;
-
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.io.File;
/**
* This class provides an implementation of a Directory Server task that can
@@ -90,31 +91,28 @@
}
- // The task arguments.
+ /** The task arguments. */
private File backupDirectory;
private String backupID;
private boolean verifyOnly;
private RestoreConfig restoreConfig;
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public LocalizableMessage getDisplayName() {
return INFO_TASK_RESTORE_NAME.get();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public LocalizableMessage getAttributeDisplayName(String name) {
return argDisplayMap.get(name);
}
- /**
- * {@inheritDoc}
- */
- @Override public void initializeTask() throws DirectoryException
+ /** {@inheritDoc} */
+ @Override
+ public void initializeTask() throws DirectoryException
{
// If the client connection is available, then make sure the associated
// client has the BACKEND_RESTORE privilege.
@@ -166,7 +164,7 @@
* @param backend The backend on which the lock is to be acquired.
* @return true if the lock was successfully acquired.
*/
- private boolean lockBackend(Backend backend)
+ private boolean lockBackend(Backend<?> backend)
{
try
{
@@ -191,7 +189,7 @@
* @param backend The backend on which the lock is held.
* @return true if the lock was successfully released.
*/
- private boolean unlockBackend(Backend backend)
+ private boolean unlockBackend(Backend<?> backend)
{
try
{
@@ -211,10 +209,8 @@
return true;
}
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public void interruptTask(TaskState interruptState, LocalizableMessage interruptReason)
{
if (TaskState.STOPPED_BY_ADMINISTRATOR.equals(interruptState) &&
@@ -227,18 +223,14 @@
}
}
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public boolean isInterruptable() {
return true;
}
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
protected TaskState runTask()
{
// Open the backup directory and make sure it is valid.
@@ -300,9 +292,8 @@
String backendID = TaskUtils.getBackendID(configEntry);
// Get the backend.
- Backend backend = DirectoryServer.getBackend(backendID);
-
- if (! backend.supportsRestore())
+ Backend<?> backend = DirectoryServer.getBackend(backendID);
+ if (!backend.supports(BackendOperation.RESTORE))
{
logger.error(ERR_RESTOREDB_CANNOT_RESTORE, backend.getBackendID());
return TaskState.STOPPED_BY_ERROR;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java b/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
index 7346f63..9d98eac 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
@@ -51,6 +51,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
@@ -140,20 +141,20 @@
return tool.process(args, initializeServer, outStream, errStream);
}
- // Define the command-line arguments that may be used with this program.
- private BooleanArgument backUpAll = null;
- private BooleanArgument compress = null;
- private BooleanArgument displayUsage = null;
- private BooleanArgument encrypt = null;
- private BooleanArgument hash = null;
- private BooleanArgument incremental = null;
- private BooleanArgument signHash = null;
- private StringArgument backendID = null;
- private StringArgument backupIDString = null;
- private StringArgument configClass = null;
- private StringArgument configFile = null;
- private StringArgument backupDirectory = null;
- private StringArgument incrementalBaseID = null;
+ /** Define the command-line arguments that may be used with this program. */
+ private BooleanArgument backUpAll;
+ private BooleanArgument compress;
+ private BooleanArgument displayUsage;
+ private BooleanArgument encrypt;
+ private BooleanArgument hash;
+ private BooleanArgument incremental;
+ private BooleanArgument signHash;
+ private StringArgument backendID;
+ private StringArgument backupIDString;
+ private StringArgument configClass;
+ private StringArgument configFile;
+ private StringArgument backupDirectory;
+ private StringArgument incrementalBaseID;
private int process(String[] args, boolean initializeServer,
OutputStream outStream, OutputStream errStream)
@@ -431,9 +432,7 @@
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void addTaskAttributes(List<RawAttribute> attributes)
{
@@ -531,25 +530,19 @@
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public String getTaskObjectclass() {
return "ds-task-backup";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public Class<?> getTaskClass() {
return BackupTask.class;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
protected int processLocal(boolean initializeServer,
PrintStream out,
@@ -742,15 +735,15 @@
int numBackends = backendList.size();
boolean multiple;
- ArrayList<Backend> backendsToArchive = new ArrayList<Backend>(numBackends);
+ ArrayList<Backend<?>> backendsToArchive = new ArrayList<Backend<?>>(numBackends);
HashMap<String,BackendCfg> configEntries =
new HashMap<String,BackendCfg>(numBackends);
if (backUpAll.isPresent())
{
for (int i=0; i < numBackends; i++)
{
- Backend b = backendList.get(i);
- if (b.supportsBackup())
+ Backend<?> b = backendList.get(i);
+ if (b.supports(BackendOperation.BACKUP))
{
backendsToArchive.add(b);
configEntries.put(b.getBackendID(), entryList.get(i));
@@ -771,10 +764,10 @@
for (int i=0; i < numBackends; i++)
{
- Backend b = backendList.get(i);
+ Backend<?> b = backendList.get(i);
if (requestedBackends.contains(b.getBackendID()))
{
- if (! b.supportsBackup())
+ if (!b.supports(BackendOperation.BACKUP))
{
logger.warn(WARN_BACKUPDB_BACKUP_NOT_SUPPORTED, b.getBackendID());
}
@@ -813,7 +806,7 @@
// Iterate through the backends to archive and back them up individually.
boolean errorsEncountered = false;
- for (Backend b : backendsToArchive)
+ for (Backend<?> b : backendsToArchive)
{
// Acquire a shared lock for this backend.
try
@@ -964,7 +957,7 @@
backupConfig.setSignHash(signHash.isPresent());
backupConfig.setIncrementalBaseID(incrementalBase);
- if (!b.supportsBackup())
+ if (!b.supports(BackendOperation.BACKUP))
{
logger.error(ERR_BACKUPDB_CANNOT_BACKUP, b.getBackendID());
errorsEncountered = true;
@@ -1070,16 +1063,9 @@
return ret;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public String getTaskId() {
- if (backupIDString != null) {
- return backupIDString.getValue();
- } else {
- return null;
- }
+ return backupIDString != null ? backupIDString.getValue() : null;
}
}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java b/opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java
index d347566..b827540 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java
@@ -45,6 +45,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
@@ -754,7 +755,7 @@
logger.error(ERR_LDIFEXPORT_NO_BACKENDS_FOR_ID, backendID.getValue());
return 1;
}
- else if (! backend.supportsLDIFExport())
+ else if (!backend.supports(BackendOperation.RESTORE))
{
logger.error(ERR_LDIFEXPORT_CANNOT_EXPORT_BACKEND, backendID.getValue());
return 1;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java b/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
index eade487..a91e8d4 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
@@ -49,6 +49,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
@@ -965,7 +966,7 @@
logger.error(ERR_LDIFIMPORT_NO_BACKENDS_FOR_ID);
return 1;
}
- else if (! backend.supportsLDIFImport())
+ else if (!backend.supports(BackendOperation.LDIF_IMPORT))
{
logger.error(ERR_LDIFIMPORT_CANNOT_IMPORT, backendID.getValue());
return 1;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java b/opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java
index d44b543..d5b1433 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java
@@ -45,6 +45,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.backends.RebuildConfig;
import org.opends.server.backends.RebuildConfig.RebuildMode;
import org.opends.server.core.CoreConfigManager;
@@ -662,7 +663,7 @@
{
throw new ConfigException(ERR_NO_BACKENDS_FOR_BASE.get(baseDNString.getValue()));
}
- if (!backend.supportsIndexing())
+ if (!backend.supports(BackendOperation.INDEXING))
{
throw new ConfigException(ERR_BACKEND_NO_INDEXING_SUPPORT.get());
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java b/opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java
index 14a6d3c..11316b0 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java
@@ -48,6 +48,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
@@ -594,7 +595,7 @@
logger.error(ERR_RESTOREDB_NO_BACKENDS_FOR_DN, backupDirectory.getValue(), configEntryDN);
return 1;
}
- else if (! backend.supportsRestore())
+ else if (!backend.supports(BackendOperation.RESTORE))
{
logger.error(ERR_RESTOREDB_CANNOT_RESTORE, backend.getBackendID());
return 1;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java b/opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java
index 47efd1a..d8f5f64 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java
@@ -42,11 +42,12 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.backends.VerifyConfig;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.LockFileManager;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
+import org.opends.server.core.LockFileManager;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.DN;
@@ -416,7 +417,7 @@
return 1;
}
- if (!backend.supportsIndexing())
+ if (!backend.supports(BackendOperation.INDEXING))
{
err.println(wrapText(ERR_BACKEND_NO_INDEXING_SUPPORT.get(), MAX_LINE_WIDTH));
return 1;
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/GenericBackendTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/GenericBackendTestCase.java
index 8e96d71..94c14a4 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/GenericBackendTestCase.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/GenericBackendTestCase.java
@@ -22,26 +22,23 @@
*
*
* 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.testng.Assert.*;
import java.util.ArrayList;
+import org.opends.server.TestCaseUtils;
+import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
+import org.opends.server.core.DirectoryServer;
+import org.opends.server.types.DN;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import org.opends.server.TestCaseUtils;
-import org.opends.server.api.Backend;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.DN;
-
-import static org.testng.Assert.*;
-
-
/**
* A set of generic test cases that apply to all Directory Server backends.
*/
@@ -53,9 +50,8 @@
*
* @throws Exception If an unexpected problem occurs.
*/
- @BeforeClass()
- public void startServer()
- throws Exception
+ @BeforeClass
+ public void startServer() throws Exception
{
TestCaseUtils.startServer();
TestCaseUtils.initializeTestBackend(true);
@@ -71,9 +67,7 @@
@DataProvider(name = "backends")
public Object[][] getBackends()
{
- ArrayList<Backend> backendList = new ArrayList<Backend>();
- backendList.addAll(DirectoryServer.getBackends().values());
-
+ ArrayList<Backend> backendList = new ArrayList<Backend>(DirectoryServer.getBackends().values());
Object[][] objectArray = new Object[backendList.size()][1];
for (int i=0; i < objectArray.length; i++)
{
@@ -91,7 +85,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testGetBaseDNs(Backend b)
+ public void testGetBaseDNs(Backend<?> b)
{
DN[] baseDNs = b.getBaseDNs();
assertNotNull(baseDNs);
@@ -106,7 +100,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testIsLocal(Backend b)
+ public void testIsLocal(Backend<?> b)
{
b.isLocal();
}
@@ -119,7 +113,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testGetSupportedControls(Backend b)
+ public void testGetSupportedControls(Backend<?> b)
{
assertNotNull(b.getSupportedControls());
}
@@ -132,7 +126,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testSupportsControl(Backend b)
+ public void testSupportsControl(Backend<?> b)
{
assertFalse(b.supportsControl("1.2.3.4"));
}
@@ -145,7 +139,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testGetSupportedFeatures(Backend b)
+ public void testGetSupportedFeatures(Backend<?> b)
{
assertNotNull(b.getSupportedFeatures());
b.getSupportedFeatures();
@@ -159,7 +153,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testSupportsFeature(Backend b)
+ public void testSupportsFeature(Backend<?> b)
{
assertFalse(b.supportsFeature("1.2.3.4"));
}
@@ -172,9 +166,9 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testSupportsLDIFExport(Backend b)
+ public void testSupportsLDIFExport(Backend<?> b)
{
- b.supportsLDIFExport();
+ b.supports(BackendOperation.LDIF_EXPORT);
}
@@ -185,9 +179,9 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testSupportsLDIFImport(Backend b)
+ public void testSupportsLDIFImport(Backend<?> b)
{
- b.supportsLDIFImport();
+ b.supports(BackendOperation.LDIF_IMPORT);
}
@@ -198,9 +192,9 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testSupportsBackup(Backend b)
+ public void testSupportsBackup(Backend<?> b)
{
- b.supportsBackup();
+ b.supports(BackendOperation.BACKUP);
}
@@ -211,9 +205,9 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testSupportsRestore(Backend b)
+ public void testSupportsRestore(Backend<?> b)
{
- b.supportsRestore();
+ b.supports(BackendOperation.RESTORE);
}
@@ -224,7 +218,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testGetBackendID(Backend b)
+ public void testGetBackendID(Backend<?> b)
{
assertNotNull(b.getBackendID());
assertTrue(b.getBackendID().length() > 0);
@@ -238,7 +232,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testIsPrivateBackend(Backend b)
+ public void testIsPrivateBackend(Backend<?> b)
{
b.isPrivateBackend();
}
@@ -251,7 +245,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testGetWritabilityMode(Backend b)
+ public void testGetWritabilityMode(Backend<?> b)
{
assertNotNull(b.getWritabilityMode());
}
@@ -264,7 +258,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testGetBackendMonitor(Backend b)
+ public void testGetBackendMonitor(Backend<?> b)
{
assertNotNull(b.getBackendMonitor());
}
@@ -277,7 +271,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testGetEntryCount(Backend b)
+ public void testGetEntryCount(Backend<?> b)
{
b.getEntryCount();
}
@@ -290,7 +284,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testGetParentBackend(Backend b)
+ public void testGetParentBackend(Backend<?> b)
{
b.getParentBackend();
}
@@ -303,7 +297,7 @@
* @param b The backend to test.
*/
@Test(dataProvider = "backends")
- public void testGetSubordinateBackends(Backend b)
+ public void testGetSubordinateBackends(Backend<?> b)
{
assertNotNull(b.getSubordinateBackends());
}
@@ -319,14 +313,12 @@
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "backends")
- public void testHandlesEntry(Backend b)
- throws Exception
+ public void testHandlesEntry(Backend<?> b) throws Exception
{
for (DN baseDN : b.getBaseDNs())
{
assertTrue(b.handlesEntry(baseDN));
- assertTrue(b.handlesEntry(DN.valueOf("cn=child," + baseDN.toString())));
+ assertTrue(b.handlesEntry(DN.valueOf("cn=child," + baseDN)));
}
}
}
-
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java
index 5a70458..5f9c7d7 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java
@@ -38,6 +38,7 @@
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.Backend;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.AddOperation;
@@ -70,9 +71,8 @@
*
* @throws Exception If an unexpected problem occurs.
*/
- @BeforeClass()
- public void setUp()
- throws Exception
+ @BeforeClass
+ public void setUp() throws Exception
{
TestCaseUtils.startServer();
@@ -687,11 +687,10 @@
* @throws Exception If an unexpected problem occurs.
*/
@Test
- public void testLDIFExport()
- throws Exception
+ public void testLDIFExport() throws Exception
{
Backend<?> b = getLDIFBackend();
- assertTrue(b.supportsLDIFExport());
+ assertTrue(b.supports(BackendOperation.LDIF_EXPORT));
String tempFilePath = TestCaseUtils.createTempFile();
@@ -725,7 +724,7 @@
LDIFBackend b = getLDIFBackend();
assertTrue(b.getEntryCount() > 0);
assertTrue(b.isLocal());
- assertFalse(b.supportsBackup());
+ assertFalse(b.supports(BackendOperation.BACKUP));
try
{
@@ -739,7 +738,7 @@
fail("Expected an exception when calling removeBackup");
} catch (DirectoryException de) {}
- assertFalse(b.supportsRestore());
+ assertFalse(b.supports(BackendOperation.RESTORE));
try
{
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java
index 46f8ea1..c44ac5c 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java
@@ -23,18 +23,13 @@
*
* Copyright 2015 ForgeRock AS
*/
-
package org.opends.server.backends.pluggable;
-import static org.forgerock.opendj.ldap.ModificationType.ADD;
-import static org.opends.server.protocols.internal.InternalClientConnection.getRootConnection;
-import static org.opends.server.protocols.internal.Requests.newSearchRequest;
-import static org.opends.server.types.Attributes.create;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
+import static org.forgerock.opendj.ldap.ModificationType.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
+import static org.opends.server.types.Attributes.*;
+import static org.testng.Assert.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -49,6 +44,7 @@
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
+import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -768,7 +764,7 @@
@Test(dependsOnMethods = { "testBaseSearch", "testOneLevelSearch", "testSubTreeSearch", "testUserEntrySearch" })
public void testImportLDIF() throws Exception
{
- assertTrue(backend.supportsLDIFImport(), "Import not supported");
+ assertTrue(backend.supports(BackendOperation.LDIF_IMPORT), "Import not supported");
// Import wants the backend to be configured but not initialized. Finalizing resets the status.
backend.finalizeBackend();
@@ -816,7 +812,7 @@
@Test(dependsOnMethods = "testPreloadEntryCache")
public void testBackup() throws Exception
{
- assertEquals(backend.supportsBackup(), true, "Skip Backup");
+ assertEquals(backend.supports(BackendOperation.BACKUP), true, "Skip Backup");
assertNotNull(backupID, "Need to setup a backupID");
backupPath = TestCaseUtils.createTemporaryDirectory("backup").getAbsolutePath();
@@ -830,7 +826,7 @@
@Test(dependsOnMethods = "testBackup")
public void testRestore() throws Exception
{
- assertTrue(backend.supportsRestore(), "Skip Restore");
+ assertTrue(backend.supports(BackendOperation.RESTORE), "Skip Restore");
backend.restoreBackup(new RestoreConfig(backupDirectory, backupID, true));
}
@@ -838,7 +834,7 @@
@Test(dependsOnMethods = "testRestore")
public void testExportLDIF() throws Exception
{
- assertTrue(backend.supportsLDIFExport(), "Export not supported");
+ assertTrue(backend.supports(BackendOperation.LDIF_EXPORT), "Export not supported");
ByteArrayOutputStream ldifData = new ByteArrayOutputStream();
LDIFExportConfig exportConfig = new LDIFExportConfig(ldifData);
--
Gitblit v1.10.0