From 5341dedbe00d044a8ee4f637137833d9c2daf971 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 06 Mar 2014 19:01:05 +0000
Subject: [PATCH] OPENDJ-1308 Migrate schema support
---
opendj-sdk/opendj-core/clirr-ignored-api-changes.xml | 2
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractApproximateMatchingRuleImpl.java | 10 +++-
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractOrderingMatchingRuleImpl.java | 18 +++++---
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java | 18 +++++++--
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleImpl.java | 7 ++-
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractEqualityMatchingRuleImpl.java | 10 +++-
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/KeywordEqualityMatchingRuleImpl.java | 7 ++-
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRule.java | 8 ++--
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java | 20 +++++----
9 files changed, 64 insertions(+), 36 deletions(-)
diff --git a/opendj-sdk/opendj-core/clirr-ignored-api-changes.xml b/opendj-sdk/opendj-core/clirr-ignored-api-changes.xml
index b7c314d..ddb722e 100644
--- a/opendj-sdk/opendj-core/clirr-ignored-api-changes.xml
+++ b/opendj-sdk/opendj-core/clirr-ignored-api-changes.xml
@@ -188,7 +188,7 @@
<difference>
<className>org/forgerock/opendj/ldap/schema/MatchingRuleImpl</className>
<differenceType>7012</differenceType>
- <method>org.forgerock.opendj.ldap.spi.Indexer getIndexer()</method>
+ <method>java.util.Collection getIndexers()</method>
<justification>OPENDJ-1308 Migrate schema support: allows decoupling indexing from a specific backend</justification>
</difference>
<difference>
diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractApproximateMatchingRuleImpl.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractApproximateMatchingRuleImpl.java
index ab84c38..bd35c91 100644
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractApproximateMatchingRuleImpl.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractApproximateMatchingRuleImpl.java
@@ -25,6 +25,9 @@
*/
package org.forgerock.opendj.ldap.schema;
+import java.util.Collection;
+import java.util.Collections;
+
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.DecodeException;
@@ -36,7 +39,8 @@
*/
abstract class AbstractApproximateMatchingRuleImpl extends AbstractMatchingRuleImpl {
- private final Indexer indexer = new DefaultIndexer("approximate");
+ private final Collection<? extends Indexer> indexers =
+ Collections.singleton(new DefaultIndexer("approximate"));
AbstractApproximateMatchingRuleImpl() {
// Nothing to do.
@@ -50,7 +54,7 @@
/** {@inheritDoc} */
@Override
- public Indexer getIndexer() {
- return indexer;
+ public Collection<? extends Indexer> getIndexers() {
+ return indexers;
}
}
diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractEqualityMatchingRuleImpl.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractEqualityMatchingRuleImpl.java
index 6744f3b..1e69e23 100644
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractEqualityMatchingRuleImpl.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractEqualityMatchingRuleImpl.java
@@ -25,6 +25,9 @@
*/
package org.forgerock.opendj.ldap.schema;
+import java.util.Collection;
+import java.util.Collections;
+
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.DecodeException;
@@ -36,7 +39,8 @@
*/
abstract class AbstractEqualityMatchingRuleImpl extends AbstractMatchingRuleImpl {
- private final Indexer indexer = new DefaultIndexer("equality");
+ private final Collection<? extends Indexer> indexers =
+ Collections.singleton(new DefaultIndexer("equality"));
AbstractEqualityMatchingRuleImpl() {
// Nothing to do.
@@ -50,7 +54,7 @@
/** {@inheritDoc} */
@Override
- public Indexer getIndexer() {
- return indexer;
+ public Collection<? extends Indexer> getIndexers() {
+ return indexers;
}
}
diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java
index 2dd602f..a34d99d 100644
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java
@@ -63,10 +63,12 @@
this.normalizedAssertionValue = normalizedAssertionValue;
}
- public ConditionResult matches(final ByteSequence attributeValue) {
- return ConditionResult.valueOf(normalizedAssertionValue.equals(attributeValue));
+ @Override
+ public ConditionResult matches(final ByteSequence normalizedAttributeValue) {
+ return ConditionResult.valueOf(normalizedAssertionValue.equals(normalizedAttributeValue));
}
+ @Override
public <T> T createIndexQuery(IndexQueryFactory<T> factory) throws DecodeException {
return factory.createExactMatchQuery(indexID, normalizedAssertionValue);
}
@@ -93,10 +95,12 @@
};
private static final Assertion UNDEFINED_ASSERTION = new Assertion() {
- public ConditionResult matches(final ByteSequence attributeValue) {
+ @Override
+ public ConditionResult matches(final ByteSequence normalizedAttributeValue) {
return ConditionResult.UNDEFINED;
}
+ @Override
public <T> T createIndexQuery(IndexQueryFactory<T> factory) throws DecodeException {
// Subclassing this class will always work, albeit inefficiently.
// This is better than throwing an exception for no good reason.
@@ -106,6 +110,7 @@
private static final Comparator<ByteSequence> DEFAULT_COMPARATOR =
new Comparator<ByteSequence>() {
+ @Override
public int compare(final ByteSequence o1, final ByteSequence o2) {
return o1.compareTo(o2);
}
@@ -115,26 +120,31 @@
// Nothing to do.
}
+ @Override
public Comparator<ByteSequence> comparator(final Schema schema) {
return DEFAULT_COMPARATOR;
}
+ @Override
public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
throws DecodeException {
return UNDEFINED_ASSERTION;
}
+ @Override
public Assertion getSubstringAssertion(final Schema schema, final ByteSequence subInitial,
final List<? extends ByteSequence> subAnyElements, final ByteSequence subFinal)
throws DecodeException {
return UNDEFINED_ASSERTION;
}
+ @Override
public Assertion getGreaterOrEqualAssertion(final Schema schema, final ByteSequence value)
throws DecodeException {
return UNDEFINED_ASSERTION;
}
+ @Override
public Assertion getLessOrEqualAssertion(final Schema schema, final ByteSequence value)
throws DecodeException {
return UNDEFINED_ASSERTION;
@@ -143,7 +153,7 @@
/** {@inheritDoc} */
@Override
public boolean isIndexingSupported() {
- return getIndexer() != null;
+ return getIndexers().isEmpty();
}
}
diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractOrderingMatchingRuleImpl.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractOrderingMatchingRuleImpl.java
index 741172b..897eea9 100644
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractOrderingMatchingRuleImpl.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractOrderingMatchingRuleImpl.java
@@ -26,6 +26,9 @@
*/
package org.forgerock.opendj.ldap.schema;
+import java.util.Collection;
+import java.util.Collections;
+
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
@@ -40,7 +43,8 @@
*/
abstract class AbstractOrderingMatchingRuleImpl extends AbstractMatchingRuleImpl {
- private final Indexer indexer = new DefaultIndexer("ordering");
+ private final Collection<? extends Indexer> indexers =
+ Collections.singleton(new DefaultIndexer("ordering"));
AbstractOrderingMatchingRuleImpl() {
// Nothing to do.
@@ -66,8 +70,8 @@
throws DecodeException {
final ByteString normAssertion = normalizeAttributeValue(schema, value);
return new Assertion() {
- public ConditionResult matches(final ByteSequence attributeValue) {
- return ConditionResult.valueOf(attributeValue.compareTo(normAssertion) >= 0);
+ public ConditionResult matches(final ByteSequence normalizedAttributeValue) {
+ return ConditionResult.valueOf(normalizedAttributeValue.compareTo(normAssertion) >= 0);
}
@Override
@@ -82,8 +86,8 @@
throws DecodeException {
final ByteString normAssertion = normalizeAttributeValue(schema, value);
return new Assertion() {
- public ConditionResult matches(final ByteSequence attributeValue) {
- return ConditionResult.valueOf(attributeValue.compareTo(normAssertion) <= 0);
+ public ConditionResult matches(final ByteSequence normalizedAttributeValue) {
+ return ConditionResult.valueOf(normalizedAttributeValue.compareTo(normAssertion) <= 0);
}
@Override
@@ -95,7 +99,7 @@
/** {@inheritDoc} */
@Override
- public Indexer getIndexer() {
- return indexer;
+ public Collection<? extends Indexer> getIndexers() {
+ return indexers;
}
}
diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java
index c825794..b731b7f 100644
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java
@@ -29,6 +29,7 @@
import static com.forgerock.opendj.ldap.CoreMessages.*;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.TreeSet;
@@ -79,8 +80,8 @@
/** {@inheritDoc} */
@Override
- public ConditionResult matches(final ByteSequence attributeValue) {
- final int valueLength = attributeValue.length();
+ public ConditionResult matches(final ByteSequence normalizedAttributeValue) {
+ final int valueLength = normalizedAttributeValue.length();
int pos = 0;
if (normInitial != null) {
@@ -90,7 +91,7 @@
}
for (; pos < initialLength; pos++) {
- if (normInitial.byteAt(pos) != attributeValue.byteAt(pos)) {
+ if (normInitial.byteAt(pos) != normalizedAttributeValue.byteAt(pos)) {
return ConditionResult.FALSE;
}
}
@@ -105,10 +106,10 @@
final int end = valueLength - anyLength;
boolean match = false;
for (; pos <= end; pos++) {
- if (element.byteAt(0) == attributeValue.byteAt(pos)) {
+ if (element.byteAt(0) == normalizedAttributeValue.byteAt(pos)) {
boolean subMatch = true;
for (int i = 1; i < anyLength; i++) {
- if (element.byteAt(i) != attributeValue.byteAt(pos + i)) {
+ if (element.byteAt(i) != normalizedAttributeValue.byteAt(pos + i)) {
subMatch = false;
break;
}
@@ -138,7 +139,7 @@
pos = valueLength - finalLength;
for (int i = 0; i < finalLength; i++, pos++) {
- if (normFinal.byteAt(i) != attributeValue.byteAt(pos)) {
+ if (normFinal.byteAt(i) != normalizedAttributeValue.byteAt(pos)) {
return ConditionResult.FALSE;
}
}
@@ -251,7 +252,8 @@
}
}
- private SubstringIndexer substringIndexer = new SubstringIndexer();
+ private final Collection<? extends Indexer> indexers =
+ Collections.singleton(new SubstringIndexer());
AbstractSubstringMatchingRuleImpl() {
// Nothing to do.
@@ -565,8 +567,8 @@
/** {@inheritDoc} */
@Override
- public Indexer getIndexer() {
- return substringIndexer;
+ public Collection<? extends Indexer> getIndexers() {
+ return indexers;
}
}
diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/KeywordEqualityMatchingRuleImpl.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/KeywordEqualityMatchingRuleImpl.java
index 8bbdbd8..dbceb6f 100644
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/KeywordEqualityMatchingRuleImpl.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/KeywordEqualityMatchingRuleImpl.java
@@ -29,6 +29,9 @@
import static com.forgerock.opendj.util.StringPrepProfile.CASE_FOLD;
import static com.forgerock.opendj.util.StringPrepProfile.TRIM;
+import java.util.Collection;
+import java.util.Collections;
+
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
@@ -119,8 +122,8 @@
/** {@inheritDoc} */
@Override
- public Indexer getIndexer() {
- return null;
+ public Collection<? extends Indexer> getIndexers() {
+ return Collections.emptySet();
}
public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRule.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRule.java
index 7fa5a11..28e3774 100644
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRule.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRule.java
@@ -359,12 +359,12 @@
}
/**
- * Returns the indexer for this matching rule.
+ * Returns the indexers for this matching rule.
*
- * @return the indexer for this matching rule.
+ * @return the collection of indexers for this matching rule.
*/
- public Indexer getIndexer() {
- return impl.getIndexer();
+ public Collection<? extends Indexer> getIndexers() {
+ return impl.getIndexers();
}
/**
diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleImpl.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleImpl.java
index bf74e88..d2a0c7f 100644
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleImpl.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleImpl.java
@@ -26,6 +26,7 @@
*/
package org.forgerock.opendj.ldap.schema;
+import java.util.Collection;
import java.util.Comparator;
import java.util.List;
@@ -141,11 +142,11 @@
throws DecodeException;
/**
- * Returns the indexer for this matching rule.
+ * Returns the indexers for this matching rule.
*
- * @return the indexer for this matching rule.
+ * @return a non null collection of indexers for this matching rule.
*/
- Indexer getIndexer();
+ Collection<? extends Indexer> getIndexers();
/**
* Returns whether a backend can build an index for this matching rule.
--
Gitblit v1.10.0