From 1053b6f18761ae2238e8a0e83567113415697b4a Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Fri, 17 Aug 2007 14:35:22 +0000
Subject: [PATCH] Fixed some minor issues that were pointed out in review of the messages commit. This biggest issues here is the reversion of the Validator class to use String based messages instead of the message framework as the class is only used internally.
---
/dev/null | 43 ---------------------
opendj-sdk/opends/src/server/org/opends/server/core/PasswordPolicy.java | 4 +-
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebBrowserErrorDialog.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java | 2
opendj-sdk/opends/src/server/org/opends/server/util/Validator.java | 59 ++++++++++++++---------------
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/util/ValidatorTests.java | 8 ++--
6 files changed, 36 insertions(+), 82 deletions(-)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
index d924a48..62bf36c 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
@@ -69,7 +69,7 @@
*
*/
public class StatusPanelController implements ServerStatusChangeListener,
-StatusPanelButtonListener
+ StatusPanelButtonListener
{
private LoginDialog loginDialog;
private StatusPanelDialog controlPanelDialog;
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebBrowserErrorDialog.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebBrowserErrorDialog.java
index ab42ee7..5ec26bd 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebBrowserErrorDialog.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebBrowserErrorDialog.java
@@ -189,7 +189,7 @@
// UIFactory.initialize();
WebBrowserErrorDialog dlg =
new WebBrowserErrorDialog(new JFrame(),
- new WebBrowserException("http://www.yahoo.com",
+ new WebBrowserException("http://opends.org",
Message.raw("toto"), null));
dlg.packAndShow();
} catch (Exception ex)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/core/PasswordPolicy.java b/opendj-sdk/opends/src/server/org/opends/server/core/PasswordPolicy.java
index 1383260..e34864a 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/core/PasswordPolicy.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/core/PasswordPolicy.java
@@ -414,7 +414,7 @@
}
Message message =
-ERR_PWPOLICY_CANNOT_DETERMINE_DEPRECATED_STORAGE_SCHEMES.
+ ERR_PWPOLICY_CANNOT_DETERMINE_DEPRECATED_STORAGE_SCHEMES.
get(String.valueOf(configEntryDN), getExceptionMessage(e));
throw new InitializationException(message, e);
}
@@ -789,7 +789,7 @@
}
Message message =
-ERR_PWPOLICY_CANNOT_DETERMINE_PREVIOUS_LAST_LOGIN_TIME_FORMAT.
+ ERR_PWPOLICY_CANNOT_DETERMINE_PREVIOUS_LAST_LOGIN_TIME_FORMAT.
get(String.valueOf(configEntryDN), getExceptionMessage(e));
throw new InitializationException(message, e);
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/types/ErrorLogSeverity.java b/opendj-sdk/opends/src/server/org/opends/server/types/ErrorLogSeverity.java
deleted file mode 100644
index e1a566e..0000000
--- a/opendj-sdk/opends/src/server/org/opends/server/types/ErrorLogSeverity.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at
- * trunk/opends/resource/legal-notices/OpenDS.LICENSE
- * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at
- * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
- * add the following below this CDDL HEADER, with the fields enclosed
- * by brackets "[]" replaced with your own identifying information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Portions Copyright 2006-2007 Sun Microsystems, Inc.
- */
-package org.opends.server.types;
-
-/**
- * This enumeration defines the set of severity levels that may be
- * used when writing a message to an error logger.
- *
- * TODO: delete me
- */
-@org.opends.server.types.PublicAPI(
- stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
- mayInstantiate=false,
- mayExtend=false,
- mayInvoke=true)
-public enum ErrorLogSeverity
-{
-}
-
diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/Validator.java b/opendj-sdk/opends/src/server/org/opends/server/util/Validator.java
index 35c6a40..ec24463 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/Validator.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/Validator.java
@@ -31,9 +31,6 @@
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.loggers.ErrorLogger;
-
-import org.opends.messages.MessageBuilder;
-
/**
* This utility class provides static methods that make parameter checking
* easier (e.g. in constructors and setters).
@@ -154,7 +151,7 @@
public static boolean ensureNotNull(Object param)
throws AssertionError {
if (ENABLE_CHECKS) {
- if (param == null) throwNull(Message.EMPTY);
+ if (param == null) throwNull("");
}
return true;
}
@@ -186,8 +183,8 @@
public static boolean ensureNotNull(Object param1, Object param2)
throws AssertionError {
if (ENABLE_CHECKS) {
- if (param1 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[1]));
- if (param2 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[2]));
+ if (param1 == null) throwNull(PARAM_DESCRIPTIONS[1]);
+ if (param2 == null) throwNull(PARAM_DESCRIPTIONS[2]);
}
return true;
}
@@ -221,9 +218,9 @@
Object param3)
throws AssertionError {
if (ENABLE_CHECKS) {
- if (param1 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[1]));
- if (param2 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[2]));
- if (param3 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[3]));
+ if (param1 == null) throwNull(PARAM_DESCRIPTIONS[1]);
+ if (param2 == null) throwNull(PARAM_DESCRIPTIONS[2]);
+ if (param3 == null) throwNull(PARAM_DESCRIPTIONS[3]);
}
return true;
}
@@ -258,10 +255,10 @@
Object param3, Object param4)
throws AssertionError {
if (ENABLE_CHECKS) {
- if (param1 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[1]));
- if (param2 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[2]));
- if (param3 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[3]));
- if (param4 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[4]));
+ if (param1 == null) throwNull(PARAM_DESCRIPTIONS[1]);
+ if (param2 == null) throwNull(PARAM_DESCRIPTIONS[2]);
+ if (param3 == null) throwNull(PARAM_DESCRIPTIONS[3]);
+ if (param4 == null) throwNull(PARAM_DESCRIPTIONS[4]);
}
return true;
}
@@ -289,7 +286,7 @@
throws AssertionError {
if (ENABLE_CHECKS) {
if (!condition) {
- ensureTrue(condition, Message.EMPTY);
+ ensureTrue(condition, "");
}
}
return true;
@@ -317,18 +314,18 @@
*
* @throws AssertionError if condition is false
*/
- public static boolean ensureTrue(boolean condition, Message message)
+ public static boolean ensureTrue(boolean condition, String message)
throws AssertionError {
if (ENABLE_CHECKS) {
if (!condition) {
- MessageBuilder mb = new MessageBuilder();
+ StringBuilder mb = new StringBuilder();
mb.append("The specified condition must be true. ");
mb.append(message);
- Message fullMessage = generateLineSpecificErrorMessage(mb.toMessage());
+ String fullString = generateLineSpecificErrorString(mb.toString());
- logError(fullMessage);
+ logError(fullString);
- throw new AssertionError(fullMessage);
+ throw new AssertionError(fullString);
}
}
return true;
@@ -377,37 +374,37 @@
////////////////////////////////////////////////////////////////////////////
- private static Message generateLineSpecificErrorMessage(Message message) {
- MessageBuilder mb = new MessageBuilder();
+ private static String generateLineSpecificErrorString(String message) {
+ StringBuilder mb = new StringBuilder();
mb.append(message);
mb.append(" The error occurred at ");
mb.append(getOriginalCallerLineInfo());
- return mb.toMessage();
+ return mb.toString();
}
- private static void throwNull(Message message)
+ private static void throwNull(String message)
throws AssertionError {
- MessageBuilder mb = new MessageBuilder();
+ StringBuilder mb = new StringBuilder();
mb.append("The specified parameter must not be null. ");
mb.append(message);
- Message fullMessage = generateLineSpecificErrorMessage(mb.toMessage());
+ String fullString = generateLineSpecificErrorString(mb.toString());
- logError(fullMessage);
+ logError(fullString);
- throw new AssertionError(fullMessage);
+ throw new AssertionError(fullString);
}
- private static void logError(Message message) {
+ private static void logError(String message) {
incrementErrorCount();
- MessageBuilder mb = new MessageBuilder();
+ StringBuilder mb = new StringBuilder();
mb.append(message);
mb.append(ServerConstants.EOL);
mb.append(getCallingStack());
- Message messageWithStack = mb.toMessage();
+ String messageWithStack = mb.toString();
// Log to the debug log.
if (debugEnabled())
@@ -416,7 +413,7 @@
}
// Log to the error log.
- ErrorLogger.logError(messageWithStack);
+ ErrorLogger.logError(Message.raw(messageWithStack));
}
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/util/ValidatorTests.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/util/ValidatorTests.java
index 53f4eab..f5caf69 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/util/ValidatorTests.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/util/ValidatorTests.java
@@ -75,7 +75,7 @@
@Test
public void testEnsureTrueWithMessage() {
- boolean returnValue = Validator.ensureTrue(true, Message.raw("some message"));
+ boolean returnValue = Validator.ensureTrue(true, "some message");
assertTrue(returnValue); // must always return true
}
@@ -144,20 +144,20 @@
@Test(expectedExceptions = {RuntimeException.class, AssertionError.class})
public void testEnsureTrueWithMessageWithFalse() {
- Validator.ensureTrue(false, Message.raw("some message"));
+ Validator.ensureTrue(false, "some message");
}
@Test
public void testMessageContents() {
Validator.resetErrorCount();
- Message myMessage = Message.raw("some test message");
+ String myMessage = "some test message";
String thisMethod = ValidatorTests.class.getName() + "." + "testMessageContents(ValidatorTests.java:";
try {
Validator.ensureTrue(false, myMessage);
} catch (Throwable e) {
String caughtMessage = e.getMessage();
- assertTrue(caughtMessage.indexOf(myMessage.toString()) >= 0);
+ assertTrue(caughtMessage.indexOf(myMessage) >= 0);
assertTrue(caughtMessage.indexOf(thisMethod) >= 0);
assertEquals(Validator.getErrorCount(), 1);
--
Gitblit v1.10.0