From 2d7aad2c25507ea427980b54848c26594c607ae2 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 20 Feb 2014 11:20:22 +0000
Subject: [PATCH] OPENDJ-1308 Migrate schema support
---
opendj3-server-dev/src/server/org/opends/server/schema/BitStringEqualityMatchingRule.java | 39 +++++++++++++++++----------------------
1 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/BitStringEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/BitStringEqualityMatchingRule.java
index 4ea4258..552816b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/BitStringEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/BitStringEqualityMatchingRule.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.schema;
-
-
import java.util.Collection;
import java.util.Collections;
@@ -35,10 +33,9 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.EqualityMatchingRule;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.DirectoryException;
-import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
@@ -124,28 +121,28 @@
*
* @return The normalized version of the provided value.
*
- * @throws DirectoryException If the provided value is invalid according to
+ * @throws DecodeException If the provided value is invalid according to
* the associated attribute syntax.
*/
@Override
public ByteString normalizeAttributeValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
String valueString = value.toString().toUpperCase();
int length = valueString.length();
if (length < 3)
{
- return reportInvalidSyntax(valueString,
- WARN_ATTR_SYNTAX_BIT_STRING_TOO_SHORT.get(value));
+ reportInvalidSyntax(WARN_ATTR_SYNTAX_BIT_STRING_TOO_SHORT.get(value));
+ return ByteString.valueOf(valueString);
}
if ((valueString.charAt(0) != '\'') ||
(valueString.charAt(length-2) != '\'') ||
(valueString.charAt(length-1) != 'B'))
{
- return reportInvalidSyntax(valueString,
- WARN_ATTR_SYNTAX_BIT_STRING_NOT_QUOTED.get(value));
+ reportInvalidSyntax(WARN_ATTR_SYNTAX_BIT_STRING_NOT_QUOTED.get(value));
+ return ByteString.valueOf(valueString);
}
for (int i=1; i < (length-2); i++)
@@ -157,27 +154,25 @@
// These characters are fine.
break;
default:
-
- return reportInvalidSyntax(valueString,
- WARN_ATTR_SYNTAX_BIT_STRING_INVALID_BIT.get(value, valueString.charAt(i)));
+ reportInvalidSyntax(WARN_ATTR_SYNTAX_BIT_STRING_INVALID_BIT.get(
+ value, valueString.charAt(i)));
+ return ByteString.valueOf(valueString);
}
}
return ByteString.valueOf(valueString);
}
- private ByteString reportInvalidSyntax(String valueString, LocalizableMessage message)
- throws DirectoryException
+ private void reportInvalidSyntax(LocalizableMessage message)
+ throws DecodeException
{
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
- case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- logger.error(message);
- return ByteString.valueOf(valueString);
- default:
- return ByteString.valueOf(valueString);
+ case REJECT:
+ throw DecodeException.error(message);
+ case WARN:
+ logger.error(message);
+ break;
}
}
}
--
Gitblit v1.10.0