From a4025c597224b522603858f50b0c41658234020b Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Fri, 13 Jul 2007 09:09:26 +0000
Subject: [PATCH] fix for issue #1897 (verif-index , rebuild-index return 0 in case of errors): return code '1' is now returned in case of error. In addition to that, the following argument has been add in order to get the number of errors found by verify-index: "--countErrors"
---
opends/src/server/org/opends/server/tools/VerifyIndex.java | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/VerifyIndex.java b/opends/src/server/org/opends/server/tools/VerifyIndex.java
index 9de387f..dccec9e 100644
--- a/opends/src/server/org/opends/server/tools/VerifyIndex.java
+++ b/opends/src/server/org/opends/server/tools/VerifyIndex.java
@@ -137,6 +137,7 @@
StringArgument baseDNString = null;
StringArgument indexList = null;
BooleanArgument cleanMode = null;
+ BooleanArgument countErrors = null;
BooleanArgument displayUsage = null;
@@ -189,6 +190,10 @@
MSGID_VERIFYINDEX_DESCRIPTION_VERIFY_CLEAN);
argParser.addArgument(cleanMode);
+ countErrors =
+ new BooleanArgument("counterrors", null, "countErrors",
+ MSGID_VERIFYINDEX_DESCRIPTION_COUNT_ERRORS);
+ argParser.addArgument(countErrors);
displayUsage =
new BooleanArgument("help", OPTION_SHORT_HELP, OPTION_LONG_HELP,
@@ -521,10 +526,22 @@
// Launch the verify process.
+ int returnCode = 0 ;
try
{
BackendImpl jebBackend = (BackendImpl)backend;
- jebBackend.verifyBackend(verifyConfig, null);
+ long errorCount = jebBackend.verifyBackend(verifyConfig, null);
+ if (countErrors.isPresent())
+ {
+ if (errorCount > Integer.MAX_VALUE)
+ {
+ returnCode = Integer.MAX_VALUE;
+ }
+ else
+ {
+ returnCode = (int) errorCount;
+ }
+ }
}
catch (Exception e)
{
@@ -532,6 +549,7 @@
String message = getMessage(msgID, getExceptionMessage(e));
logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message,
msgID);
+ returnCode = 1;
}
@@ -558,6 +576,6 @@
message, msgID);
}
- return 0;
+ return returnCode;
}
}
--
Gitblit v1.10.0