From 9b52322ea7879b26b1594b002f7107c6c2e6aeff Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 11 Jun 2014 08:14:37 +0000
Subject: [PATCH] OPENDJ-1490 (CR-3724) Replicated server fails to start after upgrade due to missing ReplicationBackend class
---
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java | 115 ++++++++++++++++++++++++++++++---------------------------
1 files changed, 60 insertions(+), 55 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java b/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
index 9b9cef9..3978ac2 100644
--- a/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
+++ b/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -85,8 +85,8 @@
static boolean isRebuildAllIndexesTaskAccepted = false;
/**
- * Returns a new upgrade task which applies an LDIF record to all
- * configuration entries matching the provided filter.
+ * Returns a new upgrade task which adds a config entry to the underlying
+ * config file.
*
* @param summary
* The summary of this upgrade task.
@@ -207,6 +207,30 @@
}
/**
+ * Returns a new upgrade task which deletes a config entry from the underlying
+ * config file.
+ *
+ * @param summary
+ * The summary of this upgrade task.
+ * @param dnInLDIF
+ * The dn to delete in the form of LDIF.
+ * @return A new upgrade task which applies an LDIF record to all
+ * configuration entries matching the provided filter.
+ */
+ public static UpgradeTask deleteConfigEntry(final Message summary,
+ final String dnInLDIF)
+ {
+ return new AbstractUpgradeTask()
+ {
+ @Override
+ public void perform(final UpgradeContext context) throws ClientException
+ {
+ perform0(summary, null, ChangeOperationType.DELETE, context, dnInLDIF);
+ }
+ };
+ }
+
+ /**
* Returns a new upgrade task which applies an LDIF record to all
* configuration entries matching the provided filter.
*
@@ -809,33 +833,7 @@
{
if (userConfirmation)
{
- displayTaskLogInformation(summary.toString(), null, ldif);
-
- final ProgressNotificationCallback pnc =
- new ProgressNotificationCallback(0, summary, 20);
-
- context.notifyProgress(pnc);
-
- try
- {
- // TODO change the directory to the config if it exists.
- final File configFile =
- new File(configDirectory,
- Installation.CURRENT_CONFIG_FILE_NAME);
-
- final int changeCount =
- updateConfigFile(configFile.getPath(), null,
- ChangeOperationType.ADD, ldif);
-
- displayChangeCount(configFile.getPath(), changeCount);
-
- context.notifyProgress(pnc.setProgress(100));
- }
- catch (final Exception e)
- {
- manageTaskException(context, Message.fromObject(e.getMessage()),
- pnc);
- }
+ perform0(summary, null, ChangeOperationType.ADD, context, ldif);
}
}
};
@@ -915,37 +913,44 @@
{
if (userConfirmation)
{
- displayTaskLogInformation(summary.toString(), filter, ldif);
-
- final ProgressNotificationCallback pnc =
- new ProgressNotificationCallback(0, summary, 20);
-
- context.notifyProgress(pnc);
-
- try
- {
- final File configFile =
- new File(configDirectory,
- Installation.CURRENT_CONFIG_FILE_NAME);
-
- final int changeCount =
- updateConfigFile(configFile.getPath(), Filter.valueOf(filter),
- ChangeOperationType.MODIFY, ldif);
-
- displayChangeCount(configFile.getPath(), changeCount);
-
- context.notifyProgress(pnc.setProgress(100));
- }
- catch (final Exception e)
- {
- manageTaskException(context, Message.fromObject(e.getMessage()),
- pnc);
- }
+ perform0(summary, filter, ChangeOperationType.MODIFY, context, ldif);
}
}
+
};
}
+ private static void perform0(final Message summary, final String filter,
+ final ChangeOperationType changeOperationType,
+ final UpgradeContext context, final String... ldif)
+ throws ClientException
+ {
+ displayTaskLogInformation(summary.toString(), filter, ldif);
+
+ final ProgressNotificationCallback pnc =
+ new ProgressNotificationCallback(0, summary, 20);
+
+ context.notifyProgress(pnc);
+
+ try
+ {
+ final File configFile =
+ new File(configDirectory, Installation.CURRENT_CONFIG_FILE_NAME);
+
+ final Filter filterVal = filter != null ? Filter.valueOf(filter) : null;
+ final int changeCount =
+ updateConfigFile(configFile.getPath(), filterVal,
+ changeOperationType, ldif);
+
+ displayChangeCount(configFile.getPath(), changeCount);
+
+ context.notifyProgress(pnc.setProgress(100));
+ }
+ catch (final Exception e)
+ {
+ manageTaskException(context, Message.fromObject(e.getMessage()), pnc);
+ }
+ }
// Prevent instantiation.
private UpgradeTasks()
--
Gitblit v1.10.0