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/TelephoneNumberEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java | 198 +++++
opendj3-server-dev/src/server/org/opends/server/schema/IntegerEqualityMatchingRule.java | 133 ---
opendj3-server-dev/src/server/org/opends/server/schema/WordEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/types/Schema.java | 95 +-
opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java | 14
opendj3-server-dev/src/server/org/opends/server/schema/UUIDOrderingMatchingRule.java | 62 -
opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java | 24
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringSubstringMatchingRule.java | 10
opendj3-server-dev/src/server/org/opends/server/schema/ProtocolInformationEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java | 42 +
opendj3-server-dev/src/server/org/opends/server/schema/UUIDEqualityMatchingRule.java | 29
opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java | 44
opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java | 156 ----
opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java | 14
opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierFirstComponentEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5EqualityMatchingRule.java | 17
opendj3-server-dev/src/server/org/opends/server/api/SubstringMatchingRule.java | 11
opendj3-server-dev/src/server/org/opends/server/api/MatchingRule.java | 52 -
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringSubstringMatchingRule.java | 43
opendj3-server-dev/src/server/org/opends/server/backends/jeb/SubstringIndexer.java | 18
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringOrderingMatchingRule.java | 15
opendj3-server-dev/src/server/org/opends/server/api/ExtensibleMatchingRule.java | 6
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CertificateExactMatchingRuleTest.java | 9
opendj3-server-dev/src/server/org/opends/server/controls/MatchedValuesFilter.java | 92 +-
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/OrderingMatchingRuleTest.java | 41 -
opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/UniqueMemberEqualityMatchingRule.java | 24
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierEqualityMatchingRule.java | 15
opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java | 19
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactEqualityMatchingRule.java | 9
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5SubstringMatchingRule.java | 31
opendj3-server-dev/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java | 17
opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/PatternRDN.java | 26
opendj3-server-dev/src/server/org/opends/server/schema/BooleanEqualityMatchingRule.java | 18
opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPFilter.java | 47 +
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreOrderingMatchingRule.java | 6
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualLengthApproximateMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberSubstringMatchingRule.java | 14
opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java | 25
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5SubstringMatchingRule.java | 31
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5EqualityMatchingRule.java | 21
opendj3-server-dev/src/server/org/opends/server/schema/DirectoryStringFirstComponentEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringEqualityMatchingRule.java | 15
opendj3-server-dev/src/server/org/opends/server/schema/IntegerFirstComponentEqualityMatchingRule.java | 5
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualityMatchingRuleTest.java | 11
opendj3-server-dev/src/server/org/opends/server/schema/TimeBasedMatchingRuleFactory.java | 54
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringOrderingMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/DistinguishedNameEqualityMatchingRule.java | 11
opendj3-server-dev/src/server/org/opends/server/schema/IntegerOrderingMatchingRule.java | 133 ---
opendj3-server-dev/src/server/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java | 10
opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordExactEqualityMatchingRule.java | 12
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactOrderingMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/types/AttributeValues.java | 13
opendj3-server-dev/src/server/org/opends/server/schema/CertificateExactMatchingRule.java | 44
opendj3-server-dev/src/server/org/opends/server/schema/DoubleMetaphoneApproximateMatchingRule.java | 10
opendj3-server-dev/src/server/org/opends/server/schema/BitStringEqualityMatchingRule.java | 39
opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java | 19
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreSubstringMatchingRule.java | 10
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java | 48
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaTestMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/PresentationAddressEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactSubstringMatchingRule.java | 10
opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRule.java | 6
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListSubstringMatchingRule.java | 10
69 files changed, 847 insertions(+), 1,131 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java
index 1f31185..b03077a 100644
--- a/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java
@@ -28,12 +28,13 @@
import java.util.Collection;
+import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.Syntax;
-import org.opends.server.types.DirectoryException;
/**
* This class provides default implementation of MatchingRule. A
@@ -53,7 +54,7 @@
*/
@Override
public ByteString normalizeAssertionValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
// Default implementation is to use attribute value normalization.
return normalizeAttributeValue(value);
@@ -93,16 +94,47 @@
/** {@inheritDoc} */
@Override
+ public Assertion getAssertion(final ByteSequence value)
+ throws DecodeException
+ {
+ final ByteString assertionValue = normalizeAssertionValue(value);
+ return new Assertion()
+ {
+
+ @Override
+ public ConditionResult matches(ByteSequence attributeValue)
+ {
+ return valuesMatch(attributeValue, assertionValue);
+ }
+ };
+ }
+
+ /** {@inheritDoc} */
+ @Override
public boolean isObsolete()
{
return false;
}
/**
- * {@inheritDoc}
+ * Indicates whether the provided attribute value should be
+ * considered a match for the given assertion value. This will only
+ * be used for the purpose of extensible matching. Subclasses
+ * should define more specific methods that are appropriate to the
+ * matching rule type.
+ *
+ * @param attributeValue
+ * The attribute value in a form that has been normalized
+ * according to this matching rule.
+ * @param assertionValue
+ * The assertion value in a form that has been normalized
+ * according to this matching rule.
+ * @return {@code TRUE} if the attribute value should be considered
+ * a match for the provided assertion value, {@code FALSE}
+ * if it does not match, or {@code UNDEFINED} if the result
+ * is undefined.
*/
- @Override
- public ConditionResult valuesMatch(
+ protected ConditionResult valuesMatch(
ByteSequence attributeValue, ByteSequence assertionValue)
{
//Default implementation of most rule types.
diff --git a/opendj3-server-dev/src/server/org/opends/server/api/ExtensibleMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/api/ExtensibleMatchingRule.java
index 13865a6..5a81398 100644
--- a/opendj3-server-dev/src/server/org/opends/server/api/ExtensibleMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/api/ExtensibleMatchingRule.java
@@ -31,7 +31,7 @@
import java.util.Collection;
import org.forgerock.opendj.ldap.ByteSequence;
-import org.opends.server.types.DirectoryException;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.types.IndexConfig;
@@ -76,9 +76,9 @@
* construct the index query.
* @return The index query appropriate for the provided attribute
* value assertion.
- * @throws DirectoryException
+ * @throws DecodeException
* If an error occurs while generating the index query.
*/
<T> T createIndexQuery(ByteSequence assertionValue,
- IndexQueryFactory<T> factory) throws DirectoryException;
+ IndexQueryFactory<T> factory) throws DecodeException;
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/api/MatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/api/MatchingRule.java
index 1a3a813..7d671a2 100644
--- a/opendj3-server-dev/src/server/org/opends/server/api/MatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/api/MatchingRule.java
@@ -26,17 +26,13 @@
*/
package org.opends.server.api;
-
-
import java.util.Collection;
+import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.schema.Syntax;
-import org.opends.server.types.DirectoryException;
-
-
/**
* This interface defines the set of methods that must be implemented
@@ -76,12 +72,12 @@
* @param value
* The assertion value to be normalized.
* @return The normalized version of the provided value.
- * @throws DirectoryException
+ * @throws DecodeException
* If the provided value is invalid according to the
* associated attribute syntax.
*/
ByteString normalizeAssertionValue(ByteSequence value)
- throws DirectoryException;
+ throws DecodeException;
@@ -111,7 +107,16 @@
*/
Syntax getSyntax();
-
+ /**
+ * Whole class to be replaced by the equivalent SDK class.
+ *
+ * @param value
+ * the value
+ * @return SDK syntax
+ * @throws DecodeException
+ * if problem
+ */
+ Assertion getAssertion(final ByteSequence value) throws DecodeException;
/**
* Indicates whether this matching rule is declared "OBSOLETE". The
@@ -135,37 +140,12 @@
* @param value
* The value to be normalized.
* @return The normalized version of the provided value.
- * @throws DirectoryException
+ * @throws DecodeException
* If the provided value is invalid according to the
* associated attribute syntax.
*/
ByteString normalizeAttributeValue(ByteSequence value)
- throws DirectoryException;
-
-
-
- /**
- * Indicates whether the provided attribute value should be
- * considered a match for the given assertion value. This will only
- * be used for the purpose of extensible matching. Subclasses
- * should define more specific methods that are appropriate to the
- * matching rule type.
- *
- * @param attributeValue
- * The attribute value in a form that has been normalized
- * according to this matching rule.
- * @param assertionValue
- * The assertion value in a form that has been normalized
- * according to this matching rule.
- * @return {@code TRUE} if the attribute value should be considered
- * a match for the provided assertion value, {@code FALSE}
- * if it does not match, or {@code UNDEFINED} if the result
- * is undefined.
- */
- ConditionResult valuesMatch(
- ByteSequence attributeValue, ByteSequence assertionValue);
-
-
+ throws DecodeException;
/**
* Appends a string representation of this matching rule in the
diff --git a/opendj3-server-dev/src/server/org/opends/server/api/SubstringMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/api/SubstringMatchingRule.java
index b09ba43..7984df1 100644
--- a/opendj3-server-dev/src/server/org/opends/server/api/SubstringMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/api/SubstringMatchingRule.java
@@ -26,14 +26,11 @@
*/
package org.opends.server.api;
-
-
import java.util.List;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteSequence;
-
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
/**
* This class defines the set of methods and structures that must be
@@ -57,12 +54,12 @@
*
* @return The normalized form of the value fragment.
*
- * @throws DirectoryException If the provided value fragment is
+ * @throws DecodeException If the provided value fragment is
* not acceptable according to the
* associated syntax.
*/
public abstract ByteString normalizeSubstring(
- ByteSequence substring) throws DirectoryException;
+ ByteSequence substring) throws DecodeException;
diff --git a/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/PatternRDN.java b/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/PatternRDN.java
index 83178cb..a72c887 100644
--- a/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/PatternRDN.java
+++ b/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/PatternRDN.java
@@ -24,25 +24,24 @@
* Copyright 2008 Sun Microsystems, Inc.
* Portions Copyright 2014 ForgeRock AS
*/
-
package org.opends.server.authorization.dseecompat;
-import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.api.EqualityMatchingRule;
-import static org.opends.messages.AccessControlMessages.
- WARN_PATTERN_DN_TYPE_CONTAINS_SUBSTRINGS;
-import static org.opends.messages.AccessControlMessages.
- WARN_PATTERN_DN_TYPE_WILDCARD_IN_MULTIVALUED_RDN;
import java.util.List;
import java.util.ArrayList;
import java.util.TreeMap;
import java.util.Set;
import java.util.Iterator;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.api.EqualityMatchingRule;
+import org.opends.server.core.DirectoryServer;
+import org.opends.server.types.*;
+
+import static org.opends.messages.AccessControlMessages.*;
+
/**
* This class is used to match RDN patterns containing wildcards in either
* the attribute types or the attribute values.
@@ -317,11 +316,14 @@
return mr.areEqual(thisNormValue, thatNormValue);
}
}
+ catch (DecodeException e)
+ {
+ return false;
+ }
catch (DirectoryException e)
{
return false;
}
}
-
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java
index 98a5cad..c15b923 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java
@@ -26,11 +26,15 @@
*/
package org.opends.server.backends.jeb;
-import java.util.*;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
-import org.opends.server.types.*;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.ApproximateMatchingRule;
+import org.opends.server.types.*;
/**
* An implementation of an Indexer for attribute approximate matching.
@@ -73,6 +77,7 @@
* used to name an index created using this object.
* @return A string representation of this object.
*/
+ @Override
public String toString()
{
return attributeType.getNameOrOID() + ".approximate";
@@ -85,6 +90,7 @@
*
* @return A byte array comparator.
*/
+ @Override
public Comparator<byte[]> getComparator()
{
return comparator;
@@ -96,6 +102,7 @@
* @param entry The entry.
* @param keys The set into which the generated keys will be inserted.
*/
+ @Override
public void indexEntry(Entry entry, Set<byte[]> keys)
{
List<Attribute> attrList =
@@ -114,6 +121,7 @@
* @param newEntry The new entry contents.
* @param modifiedKeys The map into which the modified keys will be inserted.
*/
+ @Override
public void replaceEntry(Entry oldEntry, Entry newEntry,
Map<byte[], Boolean> modifiedKeys)
{
@@ -133,6 +141,7 @@
* @param mods The set of modifications that were applied to the entry.
* @param modifiedKeys The map into which the modified keys will be inserted.
*/
+ @Override
public void modifyEntry(Entry oldEntry, Entry newEntry,
List<Modification> mods,
Map<byte[], Boolean> modifiedKeys)
@@ -169,7 +178,7 @@
keys.add(keyBytes);
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
}
@@ -214,7 +223,7 @@
modifiedKeys.remove(keyBytes);
}
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java
index a08d809..51aecc2 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java
@@ -31,6 +31,8 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn;
import org.opends.server.admin.std.server.LocalDBIndexCfg;
@@ -39,7 +41,6 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.monitors.DatabaseEnvironmentMonitor;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import com.sleepycat.je.*;
@@ -300,7 +301,7 @@
* Open the attribute index.
*
* @throws DatabaseException if a JE database error occurs while
- * openning the index.
+ * opening the index.
*/
public void open() throws DatabaseException
{
@@ -990,7 +991,7 @@
}
return idSet;
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
return new EntryIDSet();
@@ -1140,7 +1141,7 @@
}
return idSet;
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
return new EntryIDSet();
@@ -1224,7 +1225,7 @@
}
return idSet;
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
return new EntryIDSet();
@@ -1407,7 +1408,7 @@
return results;
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
return new EntryIDSet();
@@ -1448,7 +1449,7 @@
// Read the range: lower <= keys <= upper.
return orderingIndex.readRange(lower, upper, true, true);
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
return new EntryIDSet();
@@ -1576,7 +1577,7 @@
}
return idSet;
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
return new EntryIDSet();
@@ -2715,7 +2716,7 @@
}
return idSet;
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
return IndexQuery.createNullIndexQuery().evaluate(null);
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java
index 025813a..ab2511b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java
@@ -26,18 +26,20 @@
*/
package org.opends.server.backends.jeb;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
-import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
-import java.util.*;
-
/**
* An implementation of an Indexer for attribute ordering.
*/
@@ -76,6 +78,7 @@
* used to name an index created using this object.
* @return A string representation of this object.
*/
+ @Override
public String toString()
{
return attributeType.getNameOrOID() + ".ordering";
@@ -87,6 +90,7 @@
*
* @return A byte array comparator.
*/
+ @Override
public Comparator<byte[]> getComparator()
{
return orderingRule;
@@ -98,6 +102,7 @@
* @param entry The entry.
* @param keys The set into which the generated keys will be inserted.
*/
+ @Override
public void indexEntry(Entry entry, Set<byte[]> keys)
{
List<Attribute> attrList =
@@ -116,6 +121,7 @@
* @param newEntry The new entry contents.
* @param modifiedKeys The map into which the modified keys will be inserted.
*/
+ @Override
public void replaceEntry(Entry oldEntry, Entry newEntry,
Map<byte[], Boolean> modifiedKeys)
{
@@ -135,6 +141,7 @@
* @param mods The set of modifications that were applied to the entry.
* @param modifiedKeys The map into which the modified keys will be inserted.
*/
+ @Override
public void modifyEntry(Entry oldEntry, Entry newEntry,
List<Modification> mods,
Map<byte[], Boolean> modifiedKeys)
@@ -173,7 +180,7 @@
keys.add(keyBytes);
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
}
@@ -219,7 +226,7 @@
modifiedKeys.remove(keyBytes);
}
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/SubstringIndexer.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/SubstringIndexer.java
index 640d6dd..c742496 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/SubstringIndexer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/SubstringIndexer.java
@@ -26,10 +26,15 @@
*/
package org.opends.server.backends.jeb;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.server.types.*;
-import java.util.*;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.SubstringMatchingRule;
+import org.opends.server.types.*;
/**
* An implementation of an Indexer for attribute substrings.
@@ -74,6 +79,7 @@
* used to name an index created using this object.
* @return A string representation of this object.
*/
+ @Override
public String toString()
{
return attributeType.getNameOrOID() + ".substring";
@@ -85,6 +91,7 @@
*
* @return A byte array comparator.
*/
+ @Override
public Comparator<byte[]> getComparator()
{
return comparator;
@@ -96,6 +103,7 @@
* @param entry The entry.
* @param keys The set into which the generated keys will be inserted.
*/
+ @Override
public void indexEntry(Entry entry, Set<byte[]> keys)
{
List<Attribute> attrList =
@@ -114,6 +122,7 @@
* @param newEntry The new entry contents.
* @param modifiedKeys The map into which the modified keys will be inserted.
*/
+ @Override
public void replaceEntry(Entry oldEntry, Entry newEntry,
Map<byte[], Boolean> modifiedKeys)
{
@@ -135,6 +144,7 @@
* @param mods The set of modifications that were applied to the entry.
* @param modifiedKeys The map into which the modified keys will be inserted.
*/
+ @Override
public void modifyEntry(Entry oldEntry, Entry newEntry,
List<Modification> mods,
Map<byte[], Boolean> modifiedKeys)
@@ -175,7 +185,7 @@
substringKeys(normalizedBytes, keys);
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
}
@@ -258,7 +268,7 @@
substringKeys(normalizedBytes, modifiedKeys, insert);
}
- catch (DirectoryException e)
+ catch (DecodeException e)
{
logger.traceException(e);
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java
index a8d1b8b..74fa3e3 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java
@@ -32,7 +32,10 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.DecodeException;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ApproximateMatchingRule;
+import org.opends.server.api.MatchingRule;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
@@ -1767,8 +1770,7 @@
OrderingMatchingRule orderingRule =
attr.getAttributeType().getOrderingMatchingRule();
- normalizedBytes =
- orderingRule.normalizeAttributeValue(value.getValue()).toByteArray();
+ normalizedBytes = normalizeAttributeValue(orderingRule, value);
DatabaseEntry key = new DatabaseEntry(normalizedBytes);
try
@@ -1810,8 +1812,7 @@
ApproximateMatchingRule approximateRule =
attr.getAttributeType().getApproximateMatchingRule();
- normalizedBytes =
- approximateRule.normalizeAttributeValue(value.getValue()).toByteArray();
+ normalizedBytes = normalizeAttributeValue(approximateRule, value);
DatabaseEntry key = new DatabaseEntry(normalizedBytes);
try
@@ -1851,6 +1852,21 @@
}
}
+ private byte[] normalizeAttributeValue(MatchingRule matchingRule,
+ AttributeValue value) throws DirectoryException
+ {
+ try
+ {
+ return matchingRule.normalizeAttributeValue(value.getValue())
+ .toByteArray();
+ }
+ catch (DecodeException e)
+ {
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ e.getMessageObject(), e);
+ }
+ }
+
/**
* Get the parent DN of a given DN.
*
diff --git a/opendj3-server-dev/src/server/org/opends/server/controls/MatchedValuesFilter.java b/opendj3-server-dev/src/server/org/opends/server/controls/MatchedValuesFilter.java
index ff8489b..ed34837 100644
--- a/opendj3-server-dev/src/server/org/opends/server/controls/MatchedValuesFilter.java
+++ b/opendj3-server-dev/src/server/org/opends/server/controls/MatchedValuesFilter.java
@@ -35,6 +35,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
+import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
@@ -1293,9 +1294,11 @@
switch (matchType)
{
case EQUALITY_MATCH_TYPE:
- if ((attributeType != null) && (type != null) &&
- attributeType.equals(type) && (rawAssertionValue != null) &&
- (value != null) && (equalityMatchingRule != null))
+ if (attributeType != null
+ && attributeType.equals(type)
+ && rawAssertionValue != null
+ && value != null
+ && equalityMatchingRule != null)
{
try
{
@@ -1306,19 +1309,15 @@
catch (Exception e)
{
logger.traceException(e);
-
- return false;
}
}
- else
- {
- return false;
- }
+ return false;
case SUBSTRINGS_TYPE:
- if ((attributeType != null) && (type != null) &&
- attributeType.equals(type) && (substringMatchingRule != null))
+ if (attributeType != null
+ && attributeType.equals(type)
+ && substringMatchingRule != null)
{
try
{
@@ -1333,75 +1332,65 @@
catch (Exception e)
{
logger.traceException(e);
-
- return false;
}
}
- else
- {
- return false;
- }
+ return false;
case GREATER_OR_EQUAL_TYPE:
- if ((attributeType != null) && (type != null) &&
- attributeType.equals(type) && (assertionValue != null) &&
- (value != null) && (orderingMatchingRule != null))
+ if (attributeType != null
+ && attributeType.equals(type)
+ && assertionValue != null
+ && value != null
+ && orderingMatchingRule != null)
{
try
{
- return (orderingMatchingRule.compareValues(
+ return orderingMatchingRule.compareValues(
assertionValue.getNormalizedValue(),
orderingMatchingRule.normalizeAttributeValue(
- value.getValue())) >= 0);
+ value.getValue())) >= 0;
}
catch (Exception e)
{
logger.traceException(e);
-
- return false;
}
}
- else
- {
- return false;
- }
+ return false;
case LESS_OR_EQUAL_TYPE:
- if ((attributeType != null) && (type != null) &&
- attributeType.equals(type) && (assertionValue != null) &&
- (value != null) && (orderingMatchingRule != null))
+ if (attributeType != null
+ && attributeType.equals(type)
+ && assertionValue != null
+ && value != null
+ && orderingMatchingRule != null)
{
try
{
- return (orderingMatchingRule.compareValues(
+ return orderingMatchingRule.compareValues(
assertionValue.getNormalizedValue(),
orderingMatchingRule.normalizeAttributeValue(
- value.getValue())) <= 0);
+ value.getValue())) <= 0;
}
catch (Exception e)
{
logger.traceException(e);
-
- return false;
}
}
- else
- {
- return false;
- }
+ return false;
case PRESENT_TYPE:
- return ((attributeType != null) && (type != null) &&
- attributeType.equals(type));
+ return attributeType != null && attributeType.equals(type);
case APPROXIMATE_MATCH_TYPE:
- if ((attributeType != null) && (type != null) &&
- attributeType.equals(type) && (assertionValue != null) &&
- (value != null) && (approximateMatchingRule != null))
+ if (attributeType != null
+ && attributeType.equals(type)
+ && assertionValue != null
+ && value != null
+ && approximateMatchingRule != null)
{
try
{
@@ -1415,18 +1404,13 @@
catch (Exception e)
{
logger.traceException(e);
-
- return false;
}
}
- else
- {
- return false;
- }
+ return false;
case EXTENSIBLE_MATCH_TYPE:
- if ((assertionValue == null) || (value == null))
+ if (assertionValue == null || value == null)
{
return false;
}
@@ -1442,10 +1426,8 @@
{
ByteString nv1 =
matchingRule.normalizeAttributeValue(value.getValue());
- ByteString nv2 =
- matchingRule.normalizeAttributeValue(assertionValue.getValue());
-
- return (matchingRule.valuesMatch(nv1, nv2) == ConditionResult.TRUE);
+ Assertion assertion = matchingRule.getAssertion(assertionValue.getValue());
+ return assertion.matches(nv1) == ConditionResult.TRUE;
}
catch (Exception e)
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPFilter.java b/opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPFilter.java
index 763829a..7d17561 100644
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPFilter.java
+++ b/opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPFilter.java
@@ -25,8 +25,6 @@
* Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.protocols.ldap;
-import org.forgerock.i18n.LocalizableMessage;
-
import java.util.ArrayList;
import java.util.HashSet;
@@ -35,13 +33,16 @@
import java.util.StringTokenizer;
import java.util.Collection;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ByteStringBuilder;
+import org.forgerock.opendj.ldap.DecodeException;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
+
import static org.opends.messages.ProtocolMessages.*;
import static org.opends.server.util.StaticUtils.*;
@@ -563,9 +564,9 @@
{
boolean hasEscape = false;
byte[] valueBytes = getBytes(valueStr);
- for (int i=0; i < valueBytes.length; i++)
+ for (byte valueByte : valueBytes)
{
- if (valueBytes[i] == 0x5C) // The backslash character
+ if (valueByte == 0x5C) // The backslash character
{
hasEscape = true;
break;
@@ -1513,9 +1514,9 @@
// Parse out the attribute value.
byte[] valueBytes = getBytes(filterString.substring(equalPos+1, endPos));
boolean hasEscape = false;
- for (int i=0; i < valueBytes.length; i++)
+ for (byte valueByte : valueBytes)
{
- if (valueBytes[i] == 0x5C)
+ if (valueByte == 0x5C)
{
hasEscape = true;
break;
@@ -1700,6 +1701,7 @@
*
* @return The filter type for this search filter.
*/
+ @Override
public FilterType getFilterType()
{
return filterType;
@@ -1714,6 +1716,7 @@
* @return The set of subordinate filter components for AND and OR searches,
* or <CODE>null</CODE> if this is not an AND or OR search.
*/
+ @Override
public ArrayList<RawFilter> getFilterComponents()
{
return filterComponents;
@@ -1727,6 +1730,7 @@
* @return The subordinate filter component for NOT searches, or
* <CODE>null</CODE> if this is not a NOT search.
*/
+ @Override
public RawFilter getNOTComponent()
{
return notComponent;
@@ -1741,6 +1745,7 @@
* @return The attribute type for this search filter, or <CODE>null</CODE> if
* there is none.
*/
+ @Override
public String getAttributeType()
{
return attributeType;
@@ -1756,6 +1761,7 @@
* @return The assertion value for this search filter, or <CODE>null</CODE>
* if there is none.
*/
+ @Override
public ByteString getAssertionValue()
{
return assertionValue;
@@ -1771,6 +1777,7 @@
* @return The subInitial component for this substring filter, or
* <CODE>null</CODE> if there is none.
*/
+ @Override
public ByteString getSubInitialElement()
{
return subInitialElement;
@@ -1800,6 +1807,7 @@
* @return The set of subAny elements for this substring filter, or
* <CODE>null</CODE> if there are none.
*/
+ @Override
public ArrayList<ByteString> getSubAnyElements()
{
return subAnyElements;
@@ -1815,6 +1823,7 @@
* @return The subFinal element for this substring filter, or
* <CODE>null</CODE> if there is none.
*/
+ @Override
public ByteString getSubFinalElement()
{
return subFinalElement;
@@ -1830,6 +1839,7 @@
* @return The matching rule ID for this extensible match filter, or
* <CODE>null</CODE> if there is none.
*/
+ @Override
public String getMatchingRuleID()
{
return matchingRuleID;
@@ -1845,6 +1855,7 @@
* @return The value of the DN attributes flag for this extensibleMatch
* filter.
*/
+ @Override
public boolean getDNAttributes()
{
return dnAttributes;
@@ -1861,6 +1872,7 @@
* @throws DirectoryException If a problem occurs while attempting to
* construct the search filter.
*/
+ @Override
public SearchFilter toSearchFilter()
throws DirectoryException
{
@@ -1955,9 +1967,17 @@
}
else
{
- ByteString normalizedValue = mr.normalizeAttributeValue(assertionValue);
- value = AttributeValues.create(assertionValue,
- normalizedValue);
+ try
+ {
+ ByteString normalizedValue =
+ mr.normalizeAttributeValue(assertionValue);
+ value = AttributeValues.create(assertionValue, normalizedValue);
+ }
+ catch (DecodeException e)
+ {
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ e.getMessageObject(), e);
+ }
}
}
}
@@ -1991,6 +2011,7 @@
*
* @param buffer The buffer to which the information should be appended.
*/
+ @Override
public void toString(StringBuilder buffer)
{
switch (filterType)
diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java
index 6287837..0f68034 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java
@@ -26,19 +26,18 @@
*/
package org.opends.server.replication.plugin;
-import static org.opends.messages.ReplicationMessages.*;
-import static org.opends.server.util.StaticUtils.hexStringToByteArray;
-
import java.util.Collection;
import java.util.Collections;
-import org.opends.server.api.AbstractMatchingRule;
-import org.opends.server.api.OrderingMatchingRule;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.forgerock.opendj.ldap.ByteSequence;
+import org.forgerock.opendj.ldap.DecodeException;
+import org.opends.server.api.AbstractMatchingRule;
+import org.opends.server.api.OrderingMatchingRule;
+
+import static org.opends.messages.ReplicationMessages.*;
+import static org.opends.server.util.StaticUtils.*;
/**
* Used to establish an order between historical information and index them.
@@ -72,6 +71,7 @@
* @param value2 second value to compare
* @return 0 when equals, -1 or 1 to establish order
*/
+ @Override
public int compareValues(ByteSequence value1, ByteSequence value2)
{
return value1.compareTo(value2);
@@ -81,6 +81,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Collection<String> getNames()
{
return Collections.singleton("historicalCsnOrderingMatch");
@@ -121,11 +122,11 @@
*/
@Override
public ByteString normalizeAttributeValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
/*
* Change the format of the value to index and start with the serverId. In
- * that manner, the search response time is optimised for a particular
+ * that manner, the search response time is optimized for a particular
* serverId. The format of the key is now : serverId + timestamp + seqNum
*/
try
@@ -142,14 +143,14 @@
{
// This should never occur in practice since these attributes are managed
// internally.
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- WARN_INVALID_SYNC_HIST_VALUE.get(value), e);
+ throw DecodeException.error(WARN_INVALID_SYNC_HIST_VALUE.get(value), e);
}
}
/**
* {@inheritDoc}
*/
+ @Override
public int compare(byte[] b1, byte[] b2)
{
/*
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRule.java
index b4db0d8..ee89e34 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRule.java
@@ -33,10 +33,10 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.EqualityMatchingRule;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.DirectoryException;
import static org.opends.server.schema.SchemaConstants.*;
@@ -122,12 +122,12 @@
*
* @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
{
// We will not alter the value in any way.
return value.toByteString();
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordExactEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordExactEqualityMatchingRule.java
index 25c97b0..680a101 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordExactEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordExactEqualityMatchingRule.java
@@ -34,6 +34,7 @@
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;
@@ -123,12 +124,12 @@
*
* @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
{
try
{
@@ -154,13 +155,12 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw de;
+ throw DecodeException.error(de.getMessageObject(), de);
case WARN:
logger.error(de.getMessageObject());
- return ByteString.valueOf(value.toString());
- default:
- return ByteString.valueOf(value.toString());
+ break;
}
+ return ByteString.valueOf(value.toString());
}
}
}
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;
}
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/BooleanEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/BooleanEqualityMatchingRule.java
index f5d69bb..1e83ae3 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/BooleanEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/BooleanEqualityMatchingRule.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 org.opends.server.util.ServerConstants;
import static org.opends.messages.SchemaMessages.*;
@@ -125,12 +122,12 @@
*
* @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();
if (valueString.equals("TRUE") || valueString.equals("YES") ||
@@ -150,15 +147,12 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
logger.error(message);
- return ByteString.valueOf(valueString);
- default:
- return ByteString.valueOf(valueString);
+ break;
}
+ return ByteString.valueOf(valueString);
}
}
}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactEqualityMatchingRule.java
index 0b294f7..8cd4023 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactEqualityMatchingRule.java
@@ -26,21 +26,18 @@
*/
package org.opends.server.schema;
-
-
import java.util.Collection;
import java.util.Collections;
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.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.schema.StringPrepProfile.*;
-
/**
* This class defines the caseExactMatch matching rule defined in X.520 and
* referenced in RFC 4519.
@@ -118,12 +115,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5EqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5EqualityMatchingRule.java
index 7cc4fb8..0445725 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5EqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5EqualityMatchingRule.java
@@ -35,10 +35,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 org.opends.server.util.ServerConstants;
import static org.opends.messages.SchemaMessages.*;
@@ -128,12 +127,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD);
@@ -179,22 +178,16 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
if (! logged)
{
logger.error(message);
logged = true;
}
-
- buffer.delete(pos, pos+1);
- break;
-
- default:
- buffer.delete(pos, pos+1);
break;
}
+ buffer.delete(pos, pos + 1);
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5SubstringMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5SubstringMatchingRule.java
index bd3ff86..77f6746 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5SubstringMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5SubstringMatchingRule.java
@@ -35,10 +35,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.SubstringMatchingRule;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.DirectoryException;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.ServerConstants;
import static org.opends.messages.SchemaMessages.*;
@@ -128,12 +127,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
buffer.append(value.toString().trim());
@@ -178,22 +177,16 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
if (! logged)
{
logger.error(message);
logged = true;
}
-
- buffer.delete(pos, pos+1);
- break;
-
- default:
- buffer.delete(pos, pos+1);
break;
}
+ buffer.delete(pos, pos+1);
}
}
@@ -210,12 +203,12 @@
*
* @return The normalized form of the value fragment.
*
- * @throws DirectoryException If the provided value fragment is not
+ * @throws DecodeException If the provided value fragment is not
* acceptable according to the associated syntax.
*/
@Override
public ByteString normalizeSubstring(ByteSequence substring)
- throws DirectoryException
+ throws DecodeException
{
// In this case, the process for normalizing a substring is the same as
// normalizing a full value with the exception that it may include an
@@ -263,22 +256,16 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
if (! logged)
{
logger.error(message);
logged = true;
}
-
- buffer.delete(pos, pos+1);
- break;
-
- default:
- buffer.delete(pos, pos+1);
break;
}
+ buffer.delete(pos, pos + 1);
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactOrderingMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactOrderingMatchingRule.java
index dac533e..3b18ebe 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactOrderingMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactOrderingMatchingRule.java
@@ -33,9 +33,9 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.AbstractMatchingRule;
import org.opends.server.api.OrderingMatchingRule;
-import org.opends.server.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
@@ -132,12 +132,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactSubstringMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactSubstringMatchingRule.java
index 2971873..cf319f0 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactSubstringMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseExactSubstringMatchingRule.java
@@ -33,8 +33,8 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.SubstringMatchingRule;
-import org.opends.server.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import static org.opends.server.schema.SchemaConstants.*;
@@ -119,12 +119,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD);
@@ -171,12 +171,12 @@
*
* @return The normalized form of the value fragment.
*
- * @throws DirectoryException If the provided value fragment is not
+ * @throws DecodeException If the provided value fragment is not
* acceptable according to the associated syntax.
*/
@Override
public ByteString normalizeSubstring(ByteSequence substring)
- throws DirectoryException
+ throws DecodeException
{
// In this case, the process for normalizing a substring is the same as
// normalizing a full value with the exception that it may include an
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreEqualityMatchingRule.java
index ca6d28c..c121fb5 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreEqualityMatchingRule.java
@@ -33,8 +33,8 @@
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.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import static org.opends.server.schema.SchemaConstants.*;
@@ -119,12 +119,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, CASE_FOLD);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5EqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5EqualityMatchingRule.java
index 2e28dd5..df25dcd 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5EqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5EqualityMatchingRule.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.schema;
-
-
import java.util.Collection;
import java.util.Collections;
@@ -35,18 +33,15 @@
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 org.opends.server.util.ServerConstants;
import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.schema.StringPrepProfile.*;
-
-
/**
* This class implements the caseIgnoreIA5Match matching rule defined in RFC
* 2252.
@@ -127,12 +122,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, CASE_FOLD);
@@ -178,22 +173,16 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
if (! logged)
{
logger.error(message);
logged = true;
}
-
- buffer.delete(pos, pos+1);
- break;
-
- default:
- buffer.delete(pos, pos+1);
break;
}
+ buffer.delete(pos, pos+1);
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5SubstringMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5SubstringMatchingRule.java
index 16b2487..ead6475 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5SubstringMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5SubstringMatchingRule.java
@@ -35,10 +35,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.SubstringMatchingRule;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.DirectoryException;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.ServerConstants;
import static org.opends.messages.SchemaMessages.*;
@@ -127,12 +126,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, CASE_FOLD);
@@ -177,22 +176,16 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
if (! logged)
{
logger.error(message);
logged = true;
}
-
- buffer.delete(pos, pos+1);
- break;
-
- default:
- buffer.delete(pos, pos+1);
break;
}
+ buffer.delete(pos, pos + 1);
}
}
@@ -209,12 +202,12 @@
*
* @return The normalized form of the value fragment.
*
- * @throws DirectoryException If the provided value fragment is not
+ * @throws DecodeException If the provided value fragment is not
* acceptable according to the associated syntax.
*/
@Override
public ByteString normalizeSubstring(ByteSequence substring)
- throws DirectoryException
+ throws DecodeException
{
// In this case, the process for normalizing a substring is the same as
// normalizing a full value with the exception that it may include an
@@ -262,22 +255,16 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
if (! logged)
{
logger.error(message);
logged = true;
}
-
- buffer.delete(pos, pos+1);
- break;
-
- default:
- buffer.delete(pos, pos+1);
break;
}
+ buffer.delete(pos, pos+1);
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListEqualityMatchingRule.java
index e50d61c..b67dc5b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListEqualityMatchingRule.java
@@ -33,8 +33,8 @@
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.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import static org.opends.server.schema.SchemaConstants.*;
@@ -119,12 +119,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, CASE_FOLD);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListSubstringMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListSubstringMatchingRule.java
index bccb820..821e52b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListSubstringMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListSubstringMatchingRule.java
@@ -33,8 +33,8 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.SubstringMatchingRule;
-import org.opends.server.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import static org.opends.server.schema.SchemaConstants.*;
@@ -119,12 +119,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, CASE_FOLD);
@@ -184,12 +184,12 @@
*
* @return The normalized form of the value fragment.
*
- * @throws DirectoryException If the provided value fragment is not
+ * @throws DecodeException If the provided value fragment is not
* acceptable according to the associated syntax.
*/
@Override
public ByteString normalizeSubstring(ByteSequence substring)
- throws DirectoryException
+ throws DecodeException
{
// In this case, the process for normalizing a substring is the same as
// normalizing a full value with the exception that it may include an
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreOrderingMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreOrderingMatchingRule.java
index f739211..c29b696 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreOrderingMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreOrderingMatchingRule.java
@@ -33,9 +33,9 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.AbstractMatchingRule;
import org.opends.server.api.OrderingMatchingRule;
-import org.opends.server.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
@@ -132,12 +132,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, CASE_FOLD);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreSubstringMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreSubstringMatchingRule.java
index c2c3e00..44efcb3 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreSubstringMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreSubstringMatchingRule.java
@@ -33,8 +33,8 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.SubstringMatchingRule;
-import org.opends.server.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import static org.opends.server.schema.SchemaConstants.*;
@@ -119,12 +119,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, CASE_FOLD);
@@ -171,12 +171,12 @@
*
* @return The normalized form of the value fragment.
*
- * @throws DirectoryException If the provided value fragment is not
+ * @throws DecodeException If the provided value fragment is not
* acceptable according to the associated syntax.
*/
@Override
public ByteString normalizeSubstring(ByteSequence substring)
- throws DirectoryException
+ throws DecodeException
{
// In this case, the process for normalizing a substring is the same as
// normalizing a full value with the exception that it may include an
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CertificateExactMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/CertificateExactMatchingRule.java
index 2e64d3b..a85513e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CertificateExactMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CertificateExactMatchingRule.java
@@ -45,13 +45,12 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.EqualityMatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.GSERException;
import org.opends.server.protocols.asn1.GSERParser;
import org.opends.server.types.DN;
-import org.opends.server.types.DirectoryException;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import static org.opends.messages.SchemaMessages.*;
@@ -159,12 +158,12 @@
*
* @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
{
// The normalized form of this value is the GSER encoded ....
final BigInteger serialNumber;
@@ -211,18 +210,12 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
logger.error(message);
-
- certificateIssuer= toLowerCase(dnstring);
- break;
-
- default:
- certificateIssuer= toLowerCase(dnstring);
break;
}
+ certificateIssuer= toLowerCase(dnstring);
}
// Create the encoded value
@@ -236,7 +229,7 @@
*/
@Override
public ByteString normalizeAssertionValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
// validate and normalize the GSER structure
// according to the definitions from RFC 4523, Appendix A.1
@@ -271,8 +264,7 @@
{
LocalizableMessage message = ERR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND
.get(GSER_ID_SERIALNUMBER);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
}
// The value for the serialNumber
@@ -287,8 +279,7 @@
{
LocalizableMessage message = ERR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND
.get(GSER_ID_ISSUER);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
}
// expecting "rdnSequence:"
@@ -297,8 +288,7 @@
{
LocalizableMessage message = ERR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND
.get(GSER_ID_RDNSEQUENCE);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
}
// now the issuer dn
@@ -314,8 +304,7 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
logger.error(message);
break;
@@ -326,8 +315,7 @@
{
LocalizableMessage message = ERR_CERTIFICATE_MATCH_GSER_INVALID.get(
getExceptionMessage(e));
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
}
// Normalize the DN
@@ -349,18 +337,12 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
logger.error(message);
-
- certificateIssuer= toLowerCase(dnstring);
- break;
-
- default:
- certificateIssuer= toLowerCase(dnstring);
break;
}
+ certificateIssuer = toLowerCase(dnstring);
}
// Create the encoded value
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java b/opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java
index 1767e97..eca9268 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java
@@ -36,6 +36,8 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.DecodeException;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.CollationMatchingRuleCfgDefn.MatchingRuleType;
import org.opends.server.admin.std.server.CollationMatchingRuleCfg;
@@ -44,7 +46,6 @@
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import static org.opends.messages.ConfigMessages.*;
@@ -52,7 +53,6 @@
import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
/**
* This class is a factory class for Collation matching rules. It
@@ -687,6 +687,155 @@
/**
+ * Evaluates and converts 2 consecutive characters of the provided string
+ * starting at startPos and converts them into a single escaped char.
+ *
+ * @param hexString
+ * The hexadecimal string containing the escape sequence.
+ * @param startPos
+ * The starting position of the hexadecimal escape sequence.
+ * @return The escaped character
+ * @throws DecodeException
+ * If the provided string contains invalid hexadecimal digits .
+ */
+ private static char hexToEscapedChar(String hexString, int startPos)
+ throws DecodeException
+ {
+ // The two positions must be the hex characters that
+ // comprise the escaped value.
+ if ((startPos + 1) >= hexString.length())
+ {
+ LocalizableMessage message =
+ ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString,
+ startPos + 1);
+ throw DecodeException.error(message);
+ }
+ byte byteValue = 0;
+ switch (hexString.charAt(startPos))
+ {
+ case 0x30: // '0'
+ break;
+ case 0x31: // '1'
+ byteValue = (byte) 0x10;
+ break;
+ case 0x32: // '2'
+ byteValue = (byte) 0x20;
+ break;
+ case 0x33: // '3'
+ byteValue = (byte) 0x30;
+ break;
+ case 0x34: // '4'
+ byteValue = (byte) 0x40;
+ break;
+ case 0x35: // '5'
+ byteValue = (byte) 0x50;
+ break;
+ case 0x36: // '6'
+ byteValue = (byte) 0x60;
+ break;
+ case 0x37: // '7'
+ byteValue = (byte) 0x70;
+ break;
+ case 0x38: // '8'
+ byteValue = (byte) 0x80;
+ break;
+ case 0x39: // '9'
+ byteValue = (byte) 0x90;
+ break;
+ case 0x41: // 'A'
+ case 0x61: // 'a'
+ byteValue = (byte) 0xA0;
+ break;
+ case 0x42: // 'B'
+ case 0x62: // 'b'
+ byteValue = (byte) 0xB0;
+ break;
+ case 0x43: // 'C'
+ case 0x63: // 'c'
+ byteValue = (byte) 0xC0;
+ break;
+ case 0x44: // 'D'
+ case 0x64: // 'd'
+ byteValue = (byte) 0xD0;
+ break;
+ case 0x45: // 'E'
+ case 0x65: // 'e'
+ byteValue = (byte) 0xE0;
+ break;
+ case 0x46: // 'F'
+ case 0x66: // 'f'
+ byteValue = (byte) 0xF0;
+ break;
+ default:
+ LocalizableMessage message =
+ ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString, startPos);
+ throw DecodeException.error(message);
+ }
+
+ switch (hexString.charAt(++startPos))
+ {
+ case 0x30: // '0'
+ break;
+ case 0x31: // '1'
+ byteValue |= (byte) 0x01;
+ break;
+ case 0x32: // '2'
+ byteValue |= (byte) 0x02;
+ break;
+ case 0x33: // '3'
+ byteValue |= (byte) 0x03;
+ break;
+ case 0x34: // '4'
+ byteValue |= (byte) 0x04;
+ break;
+ case 0x35: // '5'
+ byteValue |= (byte) 0x05;
+ break;
+ case 0x36: // '6'
+ byteValue |= (byte) 0x06;
+ break;
+ case 0x37: // '7'
+ byteValue |= (byte) 0x07;
+ break;
+ case 0x38: // '8'
+ byteValue |= (byte) 0x08;
+ break;
+ case 0x39: // '9'
+ byteValue |= (byte) 0x09;
+ break;
+ case 0x41: // 'A'
+ case 0x61: // 'a'
+ byteValue |= (byte) 0x0A;
+ break;
+ case 0x42: // 'B'
+ case 0x62: // 'b'
+ byteValue |= (byte) 0x0B;
+ break;
+ case 0x43: // 'C'
+ case 0x63: // 'c'
+ byteValue |= (byte) 0x0C;
+ break;
+ case 0x44: // 'D'
+ case 0x64: // 'd'
+ byteValue |= (byte) 0x0D;
+ break;
+ case 0x45: // 'E'
+ case 0x65: // 'e'
+ byteValue |= (byte) 0x0E;
+ break;
+ case 0x46: // 'F'
+ case 0x66: // 'f'
+ byteValue |= (byte) 0x0F;
+ break;
+ default:
+ LocalizableMessage message =
+ ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString, startPos);
+ throw DecodeException.error(message);
+ }
+ return (char) byteValue;
+ }
+
+ /**
* Collation Extensible matching rule.
*/
private abstract class CollationMatchingRule
@@ -861,7 +1010,7 @@
*/
@Override
public ByteString normalizeAttributeValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
CollationKey key = collator.getCollationKey(value.toString());
return ByteString.wrap(key.toByteArray());
@@ -886,7 +1035,7 @@
*/
@Override
public <T> T createIndexQuery(ByteSequence assertionValue,
- IndexQueryFactory<T> factory) throws DirectoryException
+ IndexQueryFactory<T> factory) throws DecodeException
{
// Normalize the assertion value.
return factory.createExactMatchQuery(indexer
@@ -950,7 +1099,7 @@
*/
@Override
public ByteString normalizeAttributeValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
CollationKey key = collator.getCollationKey(value.toString());
return ByteString.wrap(key.toByteArray());
@@ -1029,18 +1178,7 @@
}
}
-
-
- /**
- * Parses the assertion from a given value.
- *
- * @param value
- * The value that needs to be parsed.
- * @return The parsed Assertion object containing the
- * @throws org.opends.server.types.DirectoryException
- */
- private Assertion parseAssertion(ByteSequence value)
- throws DirectoryException
+ private Assertion parseAssertion(ByteSequence value) throws DecodeException
{
// Get a string representation of the value.
String filterString = value.toString();
@@ -1066,10 +1204,8 @@
// If there were no asterisks, then this isn't a substring filter.
if (asteriskPositions.isEmpty())
{
- LocalizableMessage message =
- ERR_SEARCH_FILTER_SUBSTRING_NO_ASTERISKS.get(filterString,
- 0, endPos);
- throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message);
+ throw DecodeException.error(
+ ERR_SEARCH_FILTER_SUBSTRING_NO_ASTERISKS.get(filterString, 0, endPos));
}
// If the value starts with an asterisk, then there is no
@@ -1199,7 +1335,7 @@
*/
@Override
public ByteString normalizeAssertionValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
Assertion assertion = parseAssertion(value);
String subInitial = assertion.getInitial();
@@ -1621,7 +1757,7 @@
*/
@Override
public <T> T createIndexQuery(ByteSequence assertionValue,
- IndexQueryFactory<T> factory) throws DirectoryException
+ IndexQueryFactory<T> factory) throws DecodeException
{
Assertion assertion = parseAssertion(assertionValue);
String subInitial = assertion.getInitial();
@@ -1702,7 +1838,7 @@
*/
@Override
public ByteString normalizeAttributeValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
CollationKey key = collator.getCollationKey(value.toString());
return ByteString.wrap(key.toByteArray());
@@ -1783,7 +1919,7 @@
*/
@Override
public <T> T createIndexQuery(ByteSequence assertionValue,
- IndexQueryFactory<T> factory) throws DirectoryException
+ IndexQueryFactory<T> factory) throws DecodeException
{
return factory.createRangeMatchQuery(indexer
.getExtensibleIndexID(), ByteString.empty(),
@@ -1843,7 +1979,7 @@
*/
@Override
public <T> T createIndexQuery(ByteSequence assertionValue,
- IndexQueryFactory<T> factory) throws DirectoryException
+ IndexQueryFactory<T> factory) throws DecodeException
{
// Read the range: lower < keys <= upper.
return factory.createRangeMatchQuery(indexer
@@ -1904,7 +2040,7 @@
*/
@Override
public <T> T createIndexQuery(ByteSequence assertionValue,
- IndexQueryFactory<T> factory) throws DirectoryException
+ IndexQueryFactory<T> factory) throws DecodeException
{
return factory.createRangeMatchQuery(indexer
.getExtensibleIndexID(), normalizeAttributeValue(assertionValue),
@@ -1964,7 +2100,7 @@
*/
@Override
public <T> T createIndexQuery(ByteSequence assertionValue,
- IndexQueryFactory<T> factory) throws DirectoryException
+ IndexQueryFactory<T> factory) throws DecodeException
{
// Read the range: lower <= keys < upper.
return factory.createRangeMatchQuery(indexer
@@ -2020,14 +2156,14 @@
@Override
public final void getKeys(AttributeValue value, Set<byte[]> keys)
{
- ByteString key;
try
{
- key = matchingRule.normalizeAttributeValue(value.getValue());
+ ByteString key = matchingRule.normalizeAttributeValue(value.getValue());
keys.add(key.toByteArray());
}
- catch (DirectoryException de)
+ catch (DecodeException e)
{
+ logger.traceException(e);
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/DirectoryStringFirstComponentEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/DirectoryStringFirstComponentEqualityMatchingRule.java
index 6b7f00f..53fac35 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/DirectoryStringFirstComponentEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/DirectoryStringFirstComponentEqualityMatchingRule.java
@@ -33,8 +33,8 @@
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.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import static org.opends.server.schema.SchemaConstants.*;
@@ -124,12 +124,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, CASE_FOLD);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/DistinguishedNameEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/DistinguishedNameEqualityMatchingRule.java
index 75a4d8e..5d635da 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/DistinguishedNameEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/DistinguishedNameEqualityMatchingRule.java
@@ -32,12 +32,12 @@
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.AcceptRejectWarn;
import org.opends.server.types.DN;
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.*;
@@ -125,12 +125,12 @@
*
* @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
{
// Since the normalization for DNs is so complex, it will be handled
// elsewhere.
@@ -147,7 +147,7 @@
if (DirectoryServer.getSyntaxEnforcementPolicy() ==
AcceptRejectWarn.REJECT)
{
- throw de;
+ throw DecodeException.error(de.getMessageObject(), de);
}
return bestEffortNormalize(toLowerCase(value.toString()));
@@ -159,8 +159,7 @@
if (DirectoryServer.getSyntaxEnforcementPolicy() ==
AcceptRejectWarn.REJECT)
{
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- ERR_ATTR_SYNTAX_DN_INVALID.get(value, e));
+ throw DecodeException.error(ERR_ATTR_SYNTAX_DN_INVALID.get(value, e));
}
else
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/DoubleMetaphoneApproximateMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/DoubleMetaphoneApproximateMatchingRule.java
index 611d924..388ebc3 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/DoubleMetaphoneApproximateMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/DoubleMetaphoneApproximateMatchingRule.java
@@ -26,21 +26,17 @@
*/
package org.opends.server.schema;
-
-
import java.util.Collection;
import java.util.Collections;
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.ApproximateMatchingRule;
-import org.opends.server.types.DirectoryException;
import static org.opends.server.schema.SchemaConstants.*;
-
-
/**
* This class defines an approximate matching rule based on the Double Metaphone
* algorithm. The Metaphone and Double Metaphone algorithms were originally
@@ -139,12 +135,12 @@
*
* @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();
int length = valueString.length();
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java
index 0908273..4d8a15e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java
@@ -34,6 +34,7 @@
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;
@@ -123,12 +124,12 @@
*
* @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
{
try
{
@@ -142,15 +143,12 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw de;
-
+ throw DecodeException.error(de.getMessageObject(), de);
case WARN:
logger.error(de.getMessageObject());
- return value.toByteString();
-
- default:
- return value.toByteString();
+ break;
}
+ return value.toByteString();
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java
index e532a53..999161c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java
@@ -34,6 +34,7 @@
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.AbstractMatchingRule;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.core.DirectoryServer;
@@ -135,12 +136,12 @@
*
* @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
{
try
{
@@ -154,15 +155,12 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw de;
-
+ throw DecodeException.error(de.getMessageObject(), de);
case WARN:
logger.error(de.getMessageObject());
- return value.toByteString();
-
- default:
- return value.toByteString();
+ break;
}
+ return value.toByteString();
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/IntegerEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/IntegerEqualityMatchingRule.java
index 27a4784..922f7f4 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/IntegerEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/IntegerEqualityMatchingRule.java
@@ -35,10 +35,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.*;
@@ -125,12 +124,12 @@
*
* @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
{
int length = value.length();
StringBuilder buffer = new StringBuilder(length);
@@ -152,20 +151,7 @@
else
{
LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO.get(value);
-
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(message);
- }
- break;
- }
+ logged = reportInvalidSyntax(logged, message);
}
break;
case 1:
@@ -173,20 +159,7 @@
if (buffer.charAt(0) == '-')
{
LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO.get(value);
-
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(message);
- }
- break;
- }
+ logged = reportInvalidSyntax(logged, message);
}
else
{
@@ -235,92 +208,48 @@
else
{
LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_MISPLACED_DASH.get(value);
-
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(message);
- }
- break;
- }
+ logged = reportInvalidSyntax(logged, message);
}
break;
default:
LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER.get(
value, ((char) value.byteAt(i)), i);
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(message);
- }
- break;
- }
+ logged = reportInvalidSyntax(logged, message);
}
}
if (buffer.length() == 0)
{
- LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_EMPTY_VALUE.get(value);
-
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
-
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(message);
- }
-
- buffer.append("0");
- break;
-
- default:
- buffer.append("0");
- break;
- }
+ logged = reportInvalidSyntax(
+ logged, WARN_ATTR_SYNTAX_INTEGER_EMPTY_VALUE.get(value));
+ buffer.append("0");
}
else if ((buffer.length() == 1) && (buffer.charAt(0) == '-'))
{
- LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_DASH_NEEDS_VALUE.get(value);
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
-
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(message);
- }
-
- buffer.setCharAt(0, '0');
- break;
-
- default:
- buffer.setCharAt(0, '0');
- break;
- }
+ logged = reportInvalidSyntax(
+ logged, WARN_ATTR_SYNTAX_INTEGER_DASH_NEEDS_VALUE.get(value));
+ buffer.setCharAt(0, '0');
}
return ByteString.valueOf(buffer.toString());
}
+
+ private boolean reportInvalidSyntax(boolean logged, LocalizableMessage message)
+ throws DecodeException
+ {
+ switch (DirectoryServer.getSyntaxEnforcementPolicy())
+ {
+ case REJECT:
+ throw DecodeException.error(message);
+ case WARN:
+ if (! logged)
+ {
+ logged = true;
+ logger.error(message);
+ }
+ break;
+ }
+ return logged;
+ }
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/IntegerFirstComponentEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/IntegerFirstComponentEqualityMatchingRule.java
index 8385659..142de06 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/IntegerFirstComponentEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/IntegerFirstComponentEqualityMatchingRule.java
@@ -33,6 +33,7 @@
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.types.DirectoryException;
import org.forgerock.opendj.ldap.ResultCode;
@@ -128,12 +129,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
toLowerCase(value, buffer, true);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/IntegerOrderingMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/IntegerOrderingMatchingRule.java
index ab0c24f..135cce2 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/IntegerOrderingMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/IntegerOrderingMatchingRule.java
@@ -35,11 +35,10 @@
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.AbstractMatchingRule;
import org.opends.server.api.OrderingMatchingRule;
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.*;
@@ -137,12 +136,12 @@
*
* @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
{
int length = value.length();
StringBuilder buffer = new StringBuilder(length);
@@ -164,20 +163,7 @@
else
{
LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO.get(value);
-
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(message);
- }
- break;
- }
+ logged = reportInvalidSyntax(logged, message);
}
break;
case 1:
@@ -185,21 +171,7 @@
if (buffer.charAt(0) == '-')
{
LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO.get(value);
-
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(
- message);
- }
- break;
- }
+ logged = reportInvalidSyntax(logged, message);
}
else
{
@@ -248,97 +220,50 @@
else
{
LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_MISPLACED_DASH.get(value);
-
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(
- message);
- }
- break;
- }
+ logged = reportInvalidSyntax(logged, message);
}
break;
default:
LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER.get(
value, ((char) value.byteAt(i)), i);
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(
- message);
- }
- break;
- }
+ logged = reportInvalidSyntax(logged, message);
}
}
if (buffer.length() == 0)
{
LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_EMPTY_VALUE.get(value);
-
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
-
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(message);
- }
-
- buffer.append("0");
- break;
-
- default:
- buffer.append("0");
- break;
- }
+ logged = reportInvalidSyntax(logged, message);
+ buffer.append("0");
}
else if ((buffer.length() == 1) && (buffer.charAt(0) == '-'))
{
LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_DASH_NEEDS_VALUE.get(value);
-
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
-
- case WARN:
- if (! logged)
- {
- logged = true;
- logger.error(message);
- }
-
- buffer.setCharAt(0, '0');
- break;
-
- default:
- buffer.setCharAt(0, '0');
- break;
- }
+ logged = reportInvalidSyntax(logged, message);
+ buffer.setCharAt(0, '0');
}
return ByteString.valueOf(buffer.toString());
}
+ private boolean reportInvalidSyntax(boolean logged, LocalizableMessage message)
+ throws DecodeException
+ {
+ switch (DirectoryServer.getSyntaxEnforcementPolicy())
+ {
+ case REJECT:
+ throw DecodeException.error(message);
+ case WARN:
+ if (! logged)
+ {
+ logged = true;
+ logger.error(message);
+ }
+ break;
+ }
+ return logged;
+ }
+
/**
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java b/opendj3-server-dev/src/server/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java
index 269a9eb..a2c4da1 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java
@@ -37,12 +37,16 @@
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.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.*;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.types.CommonSchemaElements;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.LDAPSyntaxDescription;
+import org.opends.server.types.Schema;
import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
@@ -1607,7 +1611,7 @@
*/
@Override
public ByteString normalizeAttributeValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, CASE_FOLD);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringEqualityMatchingRule.java
index f9d60bd..711515d 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringEqualityMatchingRule.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.schema;
-
-
import java.util.Collection;
import java.util.Collections;
@@ -35,18 +33,15 @@
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.*;
import static org.opends.server.schema.StringPrepProfile.*;
import static org.opends.server.util.StaticUtils.*;
-
-
/**
* This class implements the numericStringMatch matching rule defined in X.520
* and referenced in RFC 2252. It allows for values with numeric digits and
@@ -128,12 +123,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD);
@@ -158,14 +153,14 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
if (! logged)
{
logger.error(message);
logged = true;
}
+ break;
}
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringOrderingMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringOrderingMatchingRule.java
index 3946649..0539f26 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringOrderingMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringOrderingMatchingRule.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.schema;
-
-
import java.util.Collection;
import java.util.Collections;
@@ -35,11 +33,10 @@
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.AbstractMatchingRule;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.DirectoryException;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import static org.opends.messages.SchemaMessages.*;
@@ -47,8 +44,6 @@
import static org.opends.server.schema.StringPrepProfile.*;
import static org.opends.server.util.StaticUtils.*;
-
-
/**
* This implements defines the numericStringOrderingMatch matching rule defined
* in X.520 and referenced in RFC 2252.
@@ -140,12 +135,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD);
@@ -170,14 +165,14 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
if (! logged)
{
logger.error(message);
logged = true;
}
+ break;
}
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringSubstringMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringSubstringMatchingRule.java
index 52870c2..d9bf586 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringSubstringMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/NumericStringSubstringMatchingRule.java
@@ -35,10 +35,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.SubstringMatchingRule;
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.*;
@@ -127,12 +126,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD);
@@ -153,19 +152,7 @@
// This is an illegal character. Either log it or reject it.
LocalizableMessage message = WARN_ATTR_SYNTAX_NUMERIC_STRING_ILLEGAL_CHAR.get(
value, c, pos);
-
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- case WARN:
- if (! logged)
- {
- logger.error(message);
- logged = true;
- }
- }
+ logged = reportInvalidSyntax(logged, message);
}
}
}
@@ -178,6 +165,24 @@
+ private boolean reportInvalidSyntax(boolean logged, LocalizableMessage message)
+ throws DecodeException
+ {
+ switch (DirectoryServer.getSyntaxEnforcementPolicy())
+ {
+ case REJECT:
+ throw DecodeException.error(message);
+ case WARN:
+ if (! logged)
+ {
+ logger.error(message);
+ logged = true;
+ }
+ break;
+ }
+ return logged;
+ }
+
/**
* Normalizes the provided value fragment into a form that can be used to
* efficiently compare values.
@@ -186,12 +191,12 @@
*
* @return The normalized form of the value fragment.
*
- * @throws DirectoryException If the provided value fragment is not
+ * @throws DecodeException If the provided value fragment is not
* acceptable according to the associated syntax.
*/
@Override
public ByteString normalizeSubstring(ByteSequence substring)
- throws DirectoryException
+ throws DecodeException
{
return normalizeAttributeValue(substring);
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierEqualityMatchingRule.java
index 17ea188..4a866ea 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierEqualityMatchingRule.java
@@ -33,11 +33,13 @@
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.api.MatchingRule;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.types.AttributeType;
+import org.opends.server.types.NameForm;
+import org.opends.server.types.ObjectClass;
import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
@@ -124,12 +126,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
toLowerCase(value, buffer, true);
@@ -190,9 +192,8 @@
}
else
{
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- ERR_ATTR_SYNTAX_OID_INVALID_VALUE.get(
- lowerValue, invalidReason));
+ throw DecodeException.error(
+ ERR_ATTR_SYNTAX_OID_INVALID_VALUE.get(lowerValue, invalidReason));
}
case WARN:
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierFirstComponentEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierFirstComponentEqualityMatchingRule.java
index 03c617c..a0235ae 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierFirstComponentEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierFirstComponentEqualityMatchingRule.java
@@ -33,12 +33,12 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.EqualityMatchingRule;
import org.opends.server.api.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
-import org.opends.server.types.DirectoryException;
import org.opends.server.types.NameForm;
import org.opends.server.types.ObjectClass;
import org.opends.server.util.ServerConstants;
@@ -129,12 +129,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
toLowerCase(value, buffer, true);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringEqualityMatchingRule.java
index 869e925..a31de1f 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringEqualityMatchingRule.java
@@ -33,8 +33,8 @@
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.types.DirectoryException;
import static org.opends.server.schema.SchemaConstants.*;
@@ -118,12 +118,12 @@
*
* @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
{
return value.toByteString();
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringOrderingMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringOrderingMatchingRule.java
index c3d54d7..3134234 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringOrderingMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringOrderingMatchingRule.java
@@ -33,9 +33,9 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.AbstractMatchingRule;
import org.opends.server.api.OrderingMatchingRule;
-import org.opends.server.types.DirectoryException;
import org.opends.server.util.StaticUtils;
import static org.opends.server.schema.SchemaConstants.*;
@@ -131,12 +131,12 @@
*
* @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
{
return value.toByteString();
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringSubstringMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringSubstringMatchingRule.java
index ba5bfd3..3d46805 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringSubstringMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/OctetStringSubstringMatchingRule.java
@@ -33,8 +33,8 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.SubstringMatchingRule;
-import org.opends.server.types.DirectoryException;
import static org.opends.server.schema.SchemaConstants.*;
@@ -118,12 +118,12 @@
*
* @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
{
return value.toByteString();
}
@@ -138,12 +138,12 @@
*
* @return The normalized form of the value fragment.
*
- * @throws DirectoryException If the provided value fragment is not
+ * @throws DecodeException If the provided value fragment is not
* acceptable according to the associated syntax.
*/
@Override
public ByteString normalizeSubstring(ByteSequence substring)
- throws DirectoryException
+ throws DecodeException
{
// This is exactly the same as normalizing a full value.
return substring.toByteString();
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/PresentationAddressEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/PresentationAddressEqualityMatchingRule.java
index 9996f24..4086e53 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/PresentationAddressEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/PresentationAddressEqualityMatchingRule.java
@@ -33,8 +33,8 @@
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.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import static org.opends.server.schema.SchemaConstants.*;
@@ -121,12 +121,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
toLowerCase(value, buffer, true);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/ProtocolInformationEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/ProtocolInformationEqualityMatchingRule.java
index 4736b53..8b4f216 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/ProtocolInformationEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/ProtocolInformationEqualityMatchingRule.java
@@ -33,8 +33,8 @@
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.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import static org.opends.server.schema.SchemaConstants.*;
@@ -121,12 +121,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
toLowerCase(value, buffer, true);
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberEqualityMatchingRule.java
index dc18078..1678dae 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberEqualityMatchingRule.java
@@ -33,8 +33,8 @@
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.types.DirectoryException;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -120,12 +120,12 @@
*
* @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();
int valueLength = valueString.length();
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberSubstringMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberSubstringMatchingRule.java
index f634818..2e66c7d 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberSubstringMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberSubstringMatchingRule.java
@@ -34,9 +34,8 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.SubstringMatchingRule;
-import org.opends.server.types.DirectoryException;
-import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -123,12 +122,12 @@
*
* @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();
int valueLength = valueString.length();
@@ -160,20 +159,19 @@
*
* @return The normalized form of the value fragment.
*
- * @throws DirectoryException If the provided value fragment is not
+ * @throws DecodeException If the provided value fragment is not
* acceptable according to the associated syntax.
*/
@Override
public ByteString normalizeSubstring(ByteSequence substring)
- throws DirectoryException
+ throws DecodeException
{
// In this case, the logic used to normalize a substring is identical to the
// logic used to normalize a full value.
ByteString value = normalizeAttributeValue(substring);
if (value.length() == 0)
{
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- LocalizableMessage.EMPTY);
+ throw DecodeException.error(LocalizableMessage.EMPTY);
}
return value;
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/TimeBasedMatchingRuleFactory.java b/opendj3-server-dev/src/server/org/opends/server/schema/TimeBasedMatchingRuleFactory.java
index 56cbc02..06b5e16 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/TimeBasedMatchingRuleFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/TimeBasedMatchingRuleFactory.java
@@ -37,12 +37,15 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.*;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.types.AttributeValue;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.IndexConfig;
+import org.opends.server.types.InitializationException;
import org.opends.server.util.StaticUtils;
import static org.opends.messages.SchemaMessages.*;
@@ -165,7 +168,7 @@
*/
@Override
public ByteString normalizeAttributeValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
try
{
@@ -177,15 +180,13 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw de;
+ throw DecodeException.error(de.getMessageObject(), de);
case WARN:
logger.error(de.getMessageObject());
- return value.toByteString();
-
- default:
- return value.toByteString();
+ break;
}
+ return value.toByteString();
}
}
}
@@ -221,7 +222,7 @@
*/
@Override
public ByteString normalizeAssertionValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
/**
An assertion value may contain one of the following:
@@ -351,8 +352,7 @@
{
//Log the message and throw an exception.
logger.error(message);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
+ throw DecodeException.error(message);
}
else
{
@@ -484,7 +484,7 @@
*/
@Override
public <T> T createIndexQuery(ByteSequence assertionValue,
- IndexQueryFactory<T> factory) throws DirectoryException
+ IndexQueryFactory<T> factory) throws DecodeException
{
return factory.createRangeMatchQuery(indexer
.getExtensibleIndexID(), normalizeAssertionValue(assertionValue),
@@ -563,7 +563,7 @@
*/
@Override
public <T> T createIndexQuery(ByteSequence assertionValue,
- IndexQueryFactory<T> factory) throws DirectoryException
+ IndexQueryFactory<T> factory) throws DecodeException
{
return factory.createRangeMatchQuery(indexer
.getExtensibleIndexID(), ByteString.empty(),
@@ -619,13 +619,12 @@
@Override
public final void getKeys(AttributeValue value, Set<byte[]> keys)
{
- ByteString key;
try
{
- key = matchingRule.normalizeAttributeValue(value.getValue());
+ ByteString key = matchingRule.normalizeAttributeValue(value.getValue());
keys.add(key.toByteArray());
}
- catch (DirectoryException de)
+ catch (DecodeException de)
{
//don't do anything.
}
@@ -711,7 +710,7 @@
*/
@Override
public ByteString normalizeAssertionValue(ByteSequence value)
- throws DirectoryException
+ throws DecodeException
{
/**
An assertion value may contain one or all of the following:
@@ -870,8 +869,7 @@
if(message !=null)
{
logger.error(message);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
+ throw DecodeException.error(message);
}
else
{
@@ -886,7 +884,7 @@
//A future date is allowed.
LocalizableMessage message = WARN_ATTR_INVALID_YEAR_ASSERTION_FORMAT.get(value, year);
logger.warn(message);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
+ throw DecodeException.error(message);
}
switch(month)
@@ -933,7 +931,7 @@
default:
LocalizableMessage message = WARN_ATTR_INVALID_MONTH_ASSERTION_FORMAT.get(value, month);
logger.warn(message);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
+ throw DecodeException.error(message);
}
boolean invalidDate = false;
@@ -964,28 +962,28 @@
{
LocalizableMessage message = WARN_ATTR_INVALID_DATE_ASSERTION_FORMAT.get(value, date);
logger.warn(message);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
+ throw DecodeException.error(message);
}
if(!(hour >=-1 && hour <=23))
{
- LocalizableMessage message = WARN_ATTR_INVALID_HOUR_ASSERTION_FORMAT.get(value, date);
- logger.warn(message);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
+ LocalizableMessage message = WARN_ATTR_INVALID_HOUR_ASSERTION_FORMAT.get(value, date);
+ logger.warn(message);
+ throw DecodeException.error(message);
}
if(!(minute >=-1 && minute <=59))
{
LocalizableMessage message = WARN_ATTR_INVALID_MINUTE_ASSERTION_FORMAT.get(value, date);
logger.warn(message);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
+ throw DecodeException.error(message);
}
if(!(second >=-1 && second <=60)) //Consider leap seconds.
{
LocalizableMessage message = WARN_ATTR_INVALID_SECOND_ASSERTION_FORMAT.get(value, date);
logger.warn(message);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
+ throw DecodeException.error(message);
}
/**
@@ -1068,7 +1066,7 @@
*/
@Override
public <T> T createIndexQuery(ByteSequence assertionValue,
- IndexQueryFactory<T> factory) throws DirectoryException
+ IndexQueryFactory<T> factory) throws DecodeException
{
//Build the information from the assertion value.
byte[] arr = normalizeAssertionValue(assertionValue).toByteArray();
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/UUIDEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/UUIDEqualityMatchingRule.java
index f48db90..b640335 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/UUIDEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/UUIDEqualityMatchingRule.java
@@ -35,10 +35,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.*;
@@ -125,17 +124,17 @@
*
* @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
{
if (value.length() != 36)
{
- return reportInvalidAttrSyntax(value,
- WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(value, value.length()));
+ reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(value, value.length()));
+ return value.toByteString();
}
StringBuilder builder = new StringBuilder(36);
@@ -153,8 +152,8 @@
case 23:
if (c != '-')
{
- return reportInvalidAttrSyntax(value,
- WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(value, i, c));
+ reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(value, i, c));
+ return value.toByteString();
}
builder.append(c);
break;
@@ -199,8 +198,8 @@
builder.append('f');
break;
default:
- return reportInvalidAttrSyntax(value,
- WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(value, i, value.byteAt(i)));
+ reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(value, i, value.byteAt(i)));
+ return value.toByteString();
}
}
}
@@ -208,18 +207,16 @@
return ByteString.valueOf(builder.toString());
}
- private ByteString reportInvalidAttrSyntax(ByteSequence value, LocalizableMessage message)
- throws DirectoryException
+ private void reportInvalidSyntax(LocalizableMessage message)
+ throws DecodeException
{
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
+ throw DecodeException.error(message);
case WARN:
logger.error(message);
- return value.toByteString();
- default:
- return value.toByteString();
+ break;
}
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/UUIDOrderingMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/UUIDOrderingMatchingRule.java
index 44d2c13..182a325 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/UUIDOrderingMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/UUIDOrderingMatchingRule.java
@@ -35,11 +35,10 @@
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.AbstractMatchingRule;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.DirectoryException;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import static org.opends.messages.SchemaMessages.*;
@@ -138,27 +137,17 @@
*
* @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
{
if (value.length() != 36)
{
- LocalizableMessage message = WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(value, value.length());
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- case WARN:
- logger.error(message);
- return value.toByteString();
- default:
- return value.toByteString();
- }
+ reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(value, value.length()));
+ return value.toByteString();
}
StringBuilder builder = new StringBuilder(36);
@@ -176,18 +165,8 @@
case 23:
if (c != '-')
{
- LocalizableMessage message = WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(value, i, c);
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- logger.error(message);
- return value.toByteString();
- default:
- return value.toByteString();
- }
+ reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(value, i, c));
+ return value.toByteString();
}
builder.append(c);
break;
@@ -232,18 +211,8 @@
builder.append('f');
break;
default:
- LocalizableMessage message = WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(value, i, c);
- switch (DirectoryServer.getSyntaxEnforcementPolicy())
- {
- case REJECT:
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- case WARN:
- logger.error(message);
- return value.toByteString();
- default:
- return value.toByteString();
- }
+ reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(value, i, c));
+ return value.toByteString();
}
}
}
@@ -251,6 +220,19 @@
return ByteString.valueOf(builder.toString());
}
+ private void reportInvalidSyntax(LocalizableMessage message)
+ throws DecodeException
+ {
+ switch (DirectoryServer.getSyntaxEnforcementPolicy())
+ {
+ case REJECT:
+ throw DecodeException.error(message);
+ case WARN:
+ logger.error(message);
+ break;
+ }
+ }
+
/**
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/UniqueMemberEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/UniqueMemberEqualityMatchingRule.java
index 7c3de91..da4f785 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/UniqueMemberEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/UniqueMemberEqualityMatchingRule.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.schema;
-
-
import java.util.Collection;
import java.util.Collections;
@@ -35,18 +33,15 @@
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.DN;
-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.*;
import static org.opends.server.util.StaticUtils.*;
-
-
/**
* This class implements the uniqueMemberMatch matching rule defined in X.520
* and referenced in RFC 2252. It is based on the name and optional UID syntax,
@@ -130,12 +125,12 @@
*
* @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().trim();
int valueLength = valueString.length();
@@ -176,18 +171,12 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
logger.error(message);
-
- valueBuffer.append(toLowerCase(valueString).substring(0, dnEndPos));
- break;
-
- default:
- valueBuffer.append(toLowerCase(valueString).substring(0, dnEndPos));
break;
}
+ valueBuffer.append(toLowerCase(valueString).substring(0, dnEndPos));
}
@@ -216,8 +205,7 @@
switch (DirectoryServer.getSyntaxEnforcementPolicy())
{
case REJECT:
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ throw DecodeException.error(message);
case WARN:
if (! logged)
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordEqualityMatchingRule.java
index 0d970cc..2af5146 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordEqualityMatchingRule.java
@@ -35,10 +35,10 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.EqualityMatchingRule;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.DirectoryException;
import static org.opends.server.schema.SchemaConstants.*;
@@ -125,12 +125,12 @@
*
* @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
{
// We will not alter the value in any way
return value.toByteString();
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRule.java
index 1837fd9..9cfa308 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRule.java
@@ -33,8 +33,8 @@
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.types.DirectoryException;
import org.opends.server.util.StaticUtils;
import static org.opends.server.schema.SchemaConstants.*;
@@ -119,12 +119,12 @@
*
* @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
{
// The normalized form of this matching rule is exactly equal to the
// non-normalized form, except that the scheme needs to be converted to
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/WordEqualityMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/schema/WordEqualityMatchingRule.java
index 0ebf86f..f19e065 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/WordEqualityMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/WordEqualityMatchingRule.java
@@ -33,8 +33,8 @@
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.types.DirectoryException;
import org.opends.server.util.ServerConstants;
import static org.opends.server.schema.SchemaConstants.*;
@@ -135,12 +135,12 @@
*
* @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
{
StringBuilder buffer = new StringBuilder();
prepareUnicode(buffer, value, TRIM, CASE_FOLD);
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/AttributeValues.java b/opendj3-server-dev/src/server/org/opends/server/types/AttributeValues.java
index fa2b801..18432ec 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/AttributeValues.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/AttributeValues.java
@@ -29,6 +29,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.EqualityMatchingRule;
@@ -148,7 +149,7 @@
* Construct a new DelayedNormalizationValue.
*
* @param attributeType The attribute type.
- * @param value The value of the attriute.
+ * @param value The value of the attribute.
*/
private DelayedNormalizationValue(
AttributeType attributeType, ByteString value)
@@ -177,7 +178,15 @@
ResultCode.INAPPROPRIATE_MATCHING, message);
}
- normalizedValue = equalityMatchingRule.normalizeAttributeValue(value);
+ try
+ {
+ normalizedValue = equalityMatchingRule.normalizeAttributeValue(value);
+ }
+ catch (DecodeException e)
+ {
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ e.getMessageObject(), e);
+ }
}
return normalizedValue;
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/Schema.java b/opendj3-server-dev/src/server/org/opends/server/types/Schema.java
index 4f7b31c..59bc495 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/Schema.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/Schema.java
@@ -39,11 +39,12 @@
import java.util.concurrent.ConcurrentHashMap;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg;
import org.opends.server.api.ApproximateMatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.EqualityMatchingRule;
@@ -449,14 +450,25 @@
// that would kill performance.
String valueString = attributeType.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
attributeTypeSet.add(AttributeValues.create(rawValue,
normValue));
}
}
-
+ private ByteString normalizeAttributeValue(ByteString rawValue)
+ throws DirectoryException
+ {
+ try
+ {
+ return normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ }
+ catch (DecodeException e)
+ {
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ e.getMessageObject(), e);
+ }
+ }
/**
* Deregisters the provided attribute type definition with this
@@ -496,8 +508,7 @@
{
String valueString = attributeType.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
attributeTypeSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -741,8 +752,7 @@
// that would kill performance.
String valueString = objectClass.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
objectClassSet.add(AttributeValues.create(rawValue, normValue));
}
}
@@ -780,8 +790,7 @@
{
String valueString = objectClass.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
objectClassSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -952,8 +961,7 @@
// that would kill performance.
String valueString = syntax.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
syntaxSet.add(AttributeValues.create(rawValue, normValue));
}
}
@@ -981,8 +989,7 @@
{
String valueString = syntax.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
syntaxSet.remove(AttributeValues.create(rawValue, normValue));
}
catch (Exception e)
@@ -1302,8 +1309,7 @@
// match) that would kill performance.
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.add(
AttributeValues.create(rawValue, normValue));
}
@@ -1364,8 +1370,7 @@
{
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -1497,8 +1502,7 @@
// that would kill performance.
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.add(AttributeValues.create(rawValue,
normValue));
}
@@ -1539,8 +1543,7 @@
{
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -1671,8 +1674,7 @@
// that would kill performance.
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.add(AttributeValues.create(rawValue,
normValue));
}
@@ -1714,8 +1716,7 @@
{
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -1845,8 +1846,7 @@
// that would kill performance.
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.add(AttributeValues.create(rawValue,
normValue));
}
@@ -1887,8 +1887,7 @@
{
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -2018,8 +2017,7 @@
// that would kill performance.
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.add(AttributeValues.create(rawValue,
normValue));
}
@@ -2060,8 +2058,7 @@
{
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -2197,8 +2194,7 @@
// that would kill performance.
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue = normalizationMatchingRule.normalizeAttributeValue(
- rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.add(
AttributeValues.create(rawValue, normValue));
}
@@ -2239,8 +2235,7 @@
{
String valueString = matchingRule.toString();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -2369,8 +2364,7 @@
// that would kill performance.
String valueString = matchingRuleUse.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleUseSet.add(AttributeValues.create(rawValue,
normValue));
}
@@ -2401,8 +2395,7 @@
{
String valueString = matchingRuleUse.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
matchingRuleUseSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -2530,8 +2523,7 @@
// that would kill performance.
String valueString = ditContentRule.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
ditContentRuleSet.add(AttributeValues.create(rawValue,
normValue));
}
@@ -2561,8 +2553,7 @@
{
String valueString = ditContentRule.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
ditContentRuleSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -2759,8 +2750,7 @@
// that would kill performance.
String valueString = ditStructureRule.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
ditStructureRuleSet.add(AttributeValues.create(rawValue,
normValue));
}
@@ -2793,8 +2783,7 @@
{
String valueString = ditStructureRule.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
ditStructureRuleSet.remove(AttributeValues.create(rawValue,
normValue));
}
@@ -3012,8 +3001,7 @@
// that would kill performance.
String valueString = nameForm.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
nameFormSet.add(AttributeValues.create(rawValue, normValue));
}
}
@@ -3056,8 +3044,7 @@
{
String valueString = nameForm.getDefinition();
ByteString rawValue = ByteString.valueOf(valueString);
- ByteString normValue =
- normalizationMatchingRule.normalizeAttributeValue(rawValue);
+ ByteString normValue = normalizeAttributeValue(rawValue);
nameFormSet.remove(AttributeValues.create(rawValue,
normValue));
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java b/opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java
index b355c5d..09d4546 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java
@@ -38,9 +38,11 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.MatchingRule;
import org.opends.server.api.SubstringMatchingRule;
@@ -2086,8 +2088,16 @@
}
else
{
- value = AttributeValues.create(userValue,
- mr.normalizeAttributeValue(userValue));
+ try
+ {
+ value = AttributeValues.create(
+ userValue, mr.normalizeAttributeValue(userValue));
+ }
+ catch (DecodeException e)
+ {
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ e.getMessageObject(), e);
+ }
}
}
}
@@ -3314,12 +3324,10 @@
// Normalize the assertion value using the matching rule.
- ByteString normalizedValue;
+ Assertion assertion;
try
{
- normalizedValue =
- matchingRule.
- normalizeAssertionValue(assertionValue.getValue());
+ assertion = matchingRule.getAssertion(assertionValue.getValue());
}
catch (Exception e)
{
@@ -3348,8 +3356,7 @@
{
ByteString nv =
matchingRule.normalizeAttributeValue(v.getValue());
- ConditionResult r =
- matchingRule.valuesMatch(nv, normalizedValue);
+ ConditionResult r = assertion.matches(nv);
switch (r)
{
case TRUE:
@@ -3391,8 +3398,7 @@
{
ByteString nv =
matchingRule.normalizeAttributeValue(v.getValue());
- ConditionResult r =
- matchingRule.valuesMatch(nv, normalizedValue);
+ ConditionResult r = assertion.matches(nv);
switch (r)
{
case TRUE:
@@ -3429,8 +3435,7 @@
try
{
ByteString nv = matchingRule.normalizeAttributeValue(v.getValue());
- ConditionResult r =
- matchingRule.valuesMatch(nv, normalizedValue);
+ ConditionResult r = assertion.matches(nv);
switch (r)
{
case TRUE:
@@ -3471,8 +3476,7 @@
{
ByteString nv =
matchingRule.normalizeAttributeValue(v.getValue());
- ConditionResult r =
- matchingRule.valuesMatch(nv, normalizedValue);
+ ConditionResult r = assertion.matches(nv);
switch (r)
{
case TRUE:
@@ -3526,8 +3530,7 @@
AttributeValue v = rdn.getAttributeValue(i);
ByteString nv =
matchingRule.normalizeAttributeValue(v.getValue());
- ConditionResult r =
- matchingRule.valuesMatch(nv, normalizedValue);
+ ConditionResult r = assertion.matches(nv);
switch (r)
{
case TRUE:
@@ -3821,13 +3824,8 @@
{
try
{
- ConditionResult cr = mr.valuesMatch(
- mr.normalizeAttributeValue(assertionValue.getValue()),
- mr.normalizeAttributeValue(f.assertionValue.getValue()));
- if (cr != ConditionResult.TRUE)
- {
- return false;
- }
+ Assertion assertion = mr.getAssertion(f.assertionValue.getValue());
+ return assertion.matches(mr.normalizeAttributeValue(assertionValue.getValue())) == ConditionResult.TRUE;
}
catch (Exception e)
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java b/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
index ddfd661..fc42f49 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
@@ -54,12 +54,10 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
-import static org.opends.messages.CoreMessages.*;
import static org.opends.messages.UtilityMessages.*;
import static org.opends.server.util.ServerConstants.*;
@@ -4216,160 +4214,6 @@
/**
- * Evaluates and converts 2 consequetive characters of the provided
- * string starting at startPos and converts them into a single escaped
- * char.
- *
- * @param hexString
- * The hexadecimal string containing the escape sequence.
- * @param startPos
- * The starting position of the hexadecimal escape sequence.
- * @return The escaped character
- * @throws DirectoryException
- * If the provided string contains invalid hexadecimal
- * digits .
- */
- public static char hexToEscapedChar(String hexString, int startPos)
- throws DirectoryException
- {
- // The two positions must be the hex characters that
- // comprise the escaped value.
- if ((startPos + 1) >= hexString.length())
- {
- LocalizableMessage message =
- ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString,
- startPos + 1);
-
- throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message);
- }
- byte byteValue = 0;
- switch (hexString.charAt(startPos))
- {
- case 0x30: // '0'
- break;
- case 0x31: // '1'
- byteValue = (byte) 0x10;
- break;
- case 0x32: // '2'
- byteValue = (byte) 0x20;
- break;
- case 0x33: // '3'
- byteValue = (byte) 0x30;
- break;
- case 0x34: // '4'
- byteValue = (byte) 0x40;
- break;
- case 0x35: // '5'
- byteValue = (byte) 0x50;
- break;
- case 0x36: // '6'
- byteValue = (byte) 0x60;
- break;
- case 0x37: // '7'
- byteValue = (byte) 0x70;
- break;
- case 0x38: // '8'
- byteValue = (byte) 0x80;
- break;
- case 0x39: // '9'
- byteValue = (byte) 0x90;
- break;
- case 0x41: // 'A'
- case 0x61: // 'a'
- byteValue = (byte) 0xA0;
- break;
- case 0x42: // 'B'
- case 0x62: // 'b'
- byteValue = (byte) 0xB0;
- break;
- case 0x43: // 'C'
- case 0x63: // 'c'
- byteValue = (byte) 0xC0;
- break;
- case 0x44: // 'D'
- case 0x64: // 'd'
- byteValue = (byte) 0xD0;
- break;
- case 0x45: // 'E'
- case 0x65: // 'e'
- byteValue = (byte) 0xE0;
- break;
- case 0x46: // 'F'
- case 0x66: // 'f'
- byteValue = (byte) 0xF0;
- break;
- default:
- LocalizableMessage message =
- ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString,
- startPos);
- throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message);
- }
-
- switch (hexString.charAt(++startPos))
- {
- case 0x30: // '0'
- break;
- case 0x31: // '1'
- byteValue |= (byte) 0x01;
- break;
- case 0x32: // '2'
- byteValue |= (byte) 0x02;
- break;
- case 0x33: // '3'
- byteValue |= (byte) 0x03;
- break;
- case 0x34: // '4'
- byteValue |= (byte) 0x04;
- break;
- case 0x35: // '5'
- byteValue |= (byte) 0x05;
- break;
- case 0x36: // '6'
- byteValue |= (byte) 0x06;
- break;
- case 0x37: // '7'
- byteValue |= (byte) 0x07;
- break;
- case 0x38: // '8'
- byteValue |= (byte) 0x08;
- break;
- case 0x39: // '9'
- byteValue |= (byte) 0x09;
- break;
- case 0x41: // 'A'
- case 0x61: // 'a'
- byteValue |= (byte) 0x0A;
- break;
- case 0x42: // 'B'
- case 0x62: // 'b'
- byteValue |= (byte) 0x0B;
- break;
- case 0x43: // 'C'
- case 0x63: // 'c'
- byteValue |= (byte) 0x0C;
- break;
- case 0x44: // 'D'
- case 0x64: // 'd'
- byteValue |= (byte) 0x0D;
- break;
- case 0x45: // 'E'
- case 0x65: // 'e'
- byteValue |= (byte) 0x0E;
- break;
- case 0x46: // 'F'
- case 0x66: // 'f'
- byteValue |= (byte) 0x0F;
- break;
- default:
- LocalizableMessage message =
- ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString,
- startPos);
- throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message);
- }
- return (char) byteValue;
- }
-
- /**
* Add all of the superior objectclasses to the specified objectclass
* map if they don't already exist. Used by add and import-ldif to
* add missing superior objectclasses to entries that don't have them.
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaTestMatchingRule.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaTestMatchingRule.java
index 476f4f9..5a8f6da 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaTestMatchingRule.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaTestMatchingRule.java
@@ -33,9 +33,9 @@
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.schema.CaseIgnoreEqualityMatchingRuleFactory;
-import org.opends.server.types.DirectoryException;
/**
@@ -185,12 +185,12 @@
*
* @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
{
return caseIgnoreMatchingRule.normalizeAttributeValue(value);
}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CertificateExactMatchingRuleTest.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CertificateExactMatchingRuleTest.java
index 23f9663..aa2d10f 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CertificateExactMatchingRuleTest.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CertificateExactMatchingRuleTest.java
@@ -28,9 +28,8 @@
package org.opends.server.schema;
import org.forgerock.opendj.ldap.ByteString;
-import org.opends.server.types.DirectoryException;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.util.Base64;
-
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -206,7 +205,7 @@
CertificateExactMatchingRule rule = getRule();
// normalize the provided assertion values
- rule.normalizeAssertionValue(ByteString.valueOf(value));
+ rule.getAssertion(ByteString.valueOf(value));
}
@@ -215,7 +214,7 @@
* Test that invalid assertion values are rejected.
*/
@Test(dataProvider= "certificateExactMatchInvalidAssertionValues",
- expectedExceptions={ DirectoryException.class })
+ expectedExceptions={ DecodeException.class })
public void certificateExactMatchingRuleInvalidAssertionValues(String value)
throws Exception
{
@@ -223,7 +222,7 @@
CertificateExactMatchingRule rule = getRule();
// normalize the provided assertion value
- rule.normalizeAssertionValue(ByteString.valueOf(value));
+ rule.getAssertion(ByteString.valueOf(value));
}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualLengthApproximateMatchingRule.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualLengthApproximateMatchingRule.java
index 7833554..6ffae1e 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualLengthApproximateMatchingRule.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualLengthApproximateMatchingRule.java
@@ -33,8 +33,8 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.ApproximateMatchingRule;
-import org.opends.server.types.DirectoryException;
import static org.opends.server.schema.SchemaConstants.*;
@@ -117,12 +117,12 @@
*
* @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
{
// Any value is acceptable, so we can just return a copy of the
// value.
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualityMatchingRuleTest.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualityMatchingRuleTest.java
index aa54007..12bc077 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualityMatchingRuleTest.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualityMatchingRuleTest.java
@@ -26,12 +26,13 @@
*/
package org.opends.server.schema;
+import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.EqualityMatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AcceptRejectWarn;
-import org.opends.server.types.DirectoryException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -133,7 +134,7 @@
fail("The matching rule : " + rule.getNameOrOID()
+ " should detect that value \"" + value + "\" is invalid");
}
- catch (DirectoryException ignored)
+ catch (DecodeException ignored)
{
}
}
@@ -161,11 +162,9 @@
// normalize the 2 provided values and check that they are equals
ByteString normalizedValue1 =
rule.normalizeAttributeValue(ByteString.valueOf(value1));
- ByteString normalizedValue2 =
- rule.normalizeAttributeValue(ByteString.valueOf(value2));
+ Assertion assertion = rule.getAssertion(ByteString.valueOf(value2));
- ConditionResult liveResult =
- rule.valuesMatch(normalizedValue1, normalizedValue2);
+ ConditionResult liveResult = assertion.matches(normalizedValue1);
assertEquals(liveResult, ConditionResult.valueOf(result));
}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/OrderingMatchingRuleTest.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/OrderingMatchingRuleTest.java
index 62833f7..d1b40c8 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/OrderingMatchingRuleTest.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/OrderingMatchingRuleTest.java
@@ -26,16 +26,16 @@
*/
package org.opends.server.schema;
-import static org.testng.Assert.*;
-
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AcceptRejectWarn;
-import org.forgerock.opendj.ldap.ByteString;
-import org.opends.server.types.DirectoryException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
/**
* Test The Ordering matching rules and the Ordering matching rule api.
*/
@@ -125,7 +125,7 @@
try
{
ruleInstance.normalizeAttributeValue(ByteString.valueOf(value));
- } catch (DirectoryException e) {
+ } catch (DecodeException e) {
// that's the expected path : the matching rule has detected that
// the value is incorrect.
return;
@@ -163,35 +163,4 @@
}
}
- private void dummy ()
- {
-
- Object a = new Object[][] {
-
-
-
-
-
-
-
-
-
-
- };
-
- }
-
-
- private Object dummy_invalid()
- {
- return new Object[][] {
-
-
-
-
-
-
-
- };
- }
}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java
index ab03de1..fec76c3 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java
@@ -24,41 +24,35 @@
* Copyright 2009-2010 Sun Microsystems, Inc.
* Portions Copyright 2010-2014 ForgeRock AS.
*/
-
-
package org.opends.server.schema;
import java.util.Calendar;
import java.util.GregorianCalendar;
-import static org.testng.Assert.*;
-
import java.util.List;
-
import java.util.TimeZone;
+
+import org.forgerock.opendj.ldap.*;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.ldap.LDAPFilter;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ConditionResult;
import org.opends.server.types.DN;
-import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
-import org.opends.server.types.DirectoryException;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.SearchResultEntry;
-import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.util.TimeThread;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+
import static org.opends.server.schema.GeneralizedTimeSyntax.*;
import static org.opends.server.schema.SchemaConstants.*;
+import static org.testng.Assert.*;
/**
* This class tests various time-based matching rules.
*/
+@SuppressWarnings("javadoc")
public final class TimeBasedMatchingRuleTest
extends SchemaTestCase
{
@@ -329,8 +323,8 @@
{
MatchingRule partialTimeRule = DirectoryServer.getMatchingRule(
EXT_PARTIAL_DATE_TIME_NAME.toLowerCase());
- ByteString str = partialTimeRule.normalizeAssertionValue(ByteString.valueOf(assertionValue));
- assertEquals(partialTimeRule.valuesMatch(ByteString.valueOf(attributeValue), str), ConditionResult.TRUE);
+ Assertion assertion = partialTimeRule.getAssertion(ByteString.valueOf(assertionValue));
+ assertEquals(assertion.matches(ByteString.valueOf(attributeValue)), ConditionResult.TRUE);
}
@@ -344,21 +338,16 @@
MatchingRule relativeTimeLTRule =
DirectoryServer.getOrderingMatchingRule(
EXT_OMR_RELATIVE_TIME_LT_ALT_NAME.toLowerCase());
- boolean exception = false;
try
{
- relativeTimeLTRule.normalizeAssertionValue(ByteString.valueOf(assertion));
+ relativeTimeLTRule.getAssertion(ByteString.valueOf(assertion));
+ // An invalid value can't get away without throwing exception.
+ assertTrue(isValid);
}
- catch(DirectoryException e)
+ catch (DecodeException e)
{
//invalid values will throw an exception.
- exception = true;
- assertTrue(!isValid);
- }
- if(!isValid)
- {
- //An invalid value can't get away without throwing exception.
- assertTrue(exception);
+ assertFalse(isValid);
}
}
@@ -372,20 +361,15 @@
{
MatchingRule partialDTRule =
DirectoryServer.getMatchingRule(EXT_PARTIAL_DATE_TIME_OID);
- boolean exception = false;
try
{
- partialDTRule.normalizeAssertionValue(ByteString.valueOf(assertion));
+ partialDTRule.getAssertion(ByteString.valueOf(assertion));
+ assertTrue(isValid);
}
- catch(DirectoryException e)
+ catch (DecodeException e)
{
//invalid values will throw an exception.
- exception = true;
- assertTrue(!isValid);
- }
- if(!isValid)
- {
- assertTrue(exception);
+ assertFalse(isValid);
}
}
--
Gitblit v1.10.0