From 3755ebbca2bc019cea1633897c97b08a6bad4e71 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Wed, 15 May 2013 07:11:21 +0000
Subject: [PATCH] OPENDJ-906 Upgrade: unexpected error for some tools when the server has not been upgraded - make-ldif / encode-password / ldifsearch & ldifmodify are subject to version verification between unpack/upgrade.(They are disabled at this step).
---
opends/src/server/org/opends/server/tools/LDIFModify.java | 15 ++++++++++++++-
opends/src/server/org/opends/server/tools/LDIFSearch.java | 13 +++++++++++++
opends/src/server/org/opends/server/tools/EncodePassword.java | 11 +++++++++++
opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java | 13 +++++++++++++
4 files changed, 51 insertions(+), 1 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/EncodePassword.java b/opends/src/server/org/opends/server/tools/EncodePassword.java
index 6513ad6..47518b8 100644
--- a/opends/src/server/org/opends/server/tools/EncodePassword.java
+++ b/opends/src/server/org/opends/server/tools/EncodePassword.java
@@ -65,6 +65,7 @@
import org.opends.server.types.InitializationException;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.WritabilityMode;
+import org.opends.server.util.BuildVersion;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
import org.opends.server.util.args.BooleanArgument;
@@ -313,6 +314,16 @@
return SUCCESS;
}
+ // Checks the version - if upgrade required, the tool is unusable
+ try
+ {
+ BuildVersion.checkVersionMismatch();
+ }
+ catch (InitializationException e)
+ {
+ err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
+ return 1;
+ }
// Check for conflicting arguments.
if (clearPassword.isPresent() && clearPasswordFile.isPresent())
diff --git a/opends/src/server/org/opends/server/tools/LDIFModify.java b/opends/src/server/org/opends/server/tools/LDIFModify.java
index 7a28322..b6c1bca 100644
--- a/opends/src/server/org/opends/server/tools/LDIFModify.java
+++ b/opends/src/server/org/opends/server/tools/LDIFModify.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2012 ForgeRock AS
+ * Portions Copyright 2012-2013 ForgeRock AS
*/
package org.opends.server.tools;
import org.opends.messages.Message;
@@ -51,6 +51,7 @@
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ExistingFileBehavior;
+import org.opends.server.types.InitializationException;
import org.opends.server.types.LDAPException;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
@@ -59,6 +60,7 @@
import org.opends.server.types.ObjectClass;
import org.opends.server.types.RawModification;
import org.opends.server.util.AddChangeRecordEntry;
+import org.opends.server.util.BuildVersion;
import org.opends.server.util.ChangeRecordEntry;
import org.opends.server.util.DeleteChangeRecordEntry;
import org.opends.server.util.LDIFException;
@@ -71,6 +73,7 @@
import org.opends.server.util.args.StringArgument;
import static org.opends.messages.ToolMessages.*;
+import static org.opends.server.util.ServerConstants.MAX_LINE_WIDTH;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.tools.ToolConstants.*;
@@ -532,6 +535,16 @@
return 0;
}
+ // Checks the version - if upgrade required, the tool is unusable
+ try
+ {
+ BuildVersion.checkVersionMismatch();
+ }
+ catch (InitializationException e)
+ {
+ err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
+ return 1;
+ }
if (! serverInitialized)
{
diff --git a/opends/src/server/org/opends/server/tools/LDIFSearch.java b/opends/src/server/org/opends/server/tools/LDIFSearch.java
index 8c4559a..a912630 100644
--- a/opends/src/server/org/opends/server/tools/LDIFSearch.java
+++ b/opends/src/server/org/opends/server/tools/LDIFSearch.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions copyright 2013 ForgeRock AS
*/
package org.opends.server.tools;
import org.opends.messages.Message;
@@ -46,12 +47,14 @@
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ExistingFileBehavior;
+import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.SearchFilter;
import org.opends.server.types.SearchScope;
+import org.opends.server.util.BuildVersion;
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
@@ -307,6 +310,16 @@
return 0;
}
+ // Checks the version - if upgrade required, the tool is unusable
+ try
+ {
+ BuildVersion.checkVersionMismatch();
+ }
+ catch (InitializationException e)
+ {
+ err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
+ return 1;
+ }
// Make sure that at least one filter was provided. Also get the attribute
// list at the same time because it may need to be specified in the same
diff --git a/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java b/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
index 2eead48..3ef4bc3 100644
--- a/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
+++ b/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
@@ -40,8 +40,10 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.ExistingFileBehavior;
+import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.NullOutputStream;
+import org.opends.server.util.BuildVersion;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
@@ -244,6 +246,17 @@
return 0;
}
+ // Checks the version - if upgrade required, the tool is unusable
+ try
+ {
+ BuildVersion.checkVersionMismatch();
+ }
+ catch (InitializationException e)
+ {
+ err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
+ return 1;
+ }
+
if (initializeServer)
{
// Initialize the Directory Server configuration handler using the
--
Gitblit v1.10.0