From 1b6b64c0e824dfbf69926d95f9e85b01ebddab03 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 14 Mar 2014 15:40:44 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1308 Migrate schema support
---
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java | 6
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/Schema.java | 934 +-----------------------------------------------
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java | 184 --------
3 files changed, 55 insertions(+), 1,069 deletions(-)
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
index 1eb234c..668fc32 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
@@ -3112,26 +3112,6 @@
directoryServer.schema.deregisterMatchingRule(matchingRule);
}
-
-
- /**
- * Retrieves the set of approximate matching rules registered with the
- * Directory Server. The mapping will be between the lowercase name or OID
- * for each approximate matching rule and the matching rule implementation.
- * The same approximate matching rule instance may be included multiple times
- * with different keys.
- *
- * @return The set of approximate matching rules registered with the
- * Directory Server.
- */
- public static ConcurrentMap<String, ApproximateMatchingRule>
- getApproximateMatchingRules()
- {
- return directoryServer.schema.getApproximateMatchingRules();
- }
-
-
-
/**
* Retrieves the approximate matching rule with the specified name or OID.
*
@@ -3144,7 +3124,7 @@
public static ApproximateMatchingRule
getApproximateMatchingRule(String lowerName)
{
- return directoryServer.schema.getApproximateMatchingRule(lowerName);
+ return (ApproximateMatchingRule) directoryServer.schema.getMatchingRule(lowerName);
}
@@ -3168,8 +3148,7 @@
boolean overwriteExisting)
throws DirectoryException
{
- directoryServer.schema.registerApproximateMatchingRule(matchingRule,
- overwriteExisting);
+ directoryServer.schema.registerMatchingRule(matchingRule, overwriteExisting);
}
@@ -3183,29 +3162,10 @@
public static void deregisterApproximateMatchingRule(ApproximateMatchingRule
matchingRule)
{
- directoryServer.schema.deregisterApproximateMatchingRule(matchingRule);
+ directoryServer.schema.deregisterMatchingRule(matchingRule);
}
-
- /**
- * Retrieves the set of equality matching rules registered with the Directory
- * Server. The mapping will be between the lowercase name or OID for each
- * equality matching rule and the matching rule implementation. The same
- * equality matching rule instance may be included multiple times with
- * different keys.
- *
- * @return The set of equality matching rules registered with the Directory
- * Server.
- */
- public static ConcurrentMap<String, MatchingRule>
- getEqualityMatchingRules()
- {
- return directoryServer.schema.getEqualityMatchingRules();
- }
-
-
-
/**
* Retrieves the equality matching rule with the specified name or OID.
*
@@ -3217,66 +3177,9 @@
*/
public static MatchingRule getEqualityMatchingRule(String lowerName)
{
- return directoryServer.schema.getEqualityMatchingRule(lowerName);
+ return directoryServer.schema.getMatchingRule(lowerName);
}
-
-
- /**
- * Registers the provided equality matching rule with the Directory Server.
- *
- * @param matchingRule The matching rule to register with the server.
- * @param overwriteExisting Indicates whether to overwrite an existing
- * mapping if there are any conflicts (i.e.,
- * another matching rule with the same OID or
- * name).
- *
- * @throws DirectoryException If a conflict is encountered and the
- * <CODE>overwriteExisting</CODE> flag is set to
- * <CODE>false</CODE>
- */
- public static void registerEqualityMatchingRule(MatchingRule
- matchingRule,
- boolean overwriteExisting)
- throws DirectoryException
- {
- directoryServer.schema.registerEqualityMatchingRule(matchingRule,
- overwriteExisting);
- }
-
-
-
- /**
- * Deregisters the provided equality matching rule with the Directory Server.
- *
- * @param matchingRule The matching rule to deregister with the server.
- */
- public static void deregisterEqualityMatchingRule(MatchingRule
- matchingRule)
- {
- directoryServer.schema.deregisterEqualityMatchingRule(matchingRule);
- }
-
-
-
- /**
- * Retrieves the set of ordering matching rules registered with the Directory
- * Server. The mapping will be between the lowercase name or OID for each
- * ordering matching rule and the matching rule implementation. The same
- * ordering matching rule instance may be included multiple times with
- * different keys.
- *
- * @return The set of ordering matching rules registered with the Directory
- * Server.
- */
- public static ConcurrentMap<String, OrderingMatchingRule>
- getOrderingMatchingRules()
- {
- return directoryServer.schema.getOrderingMatchingRules();
- }
-
-
-
/**
* Retrieves the ordering matching rule with the specified name or OID.
*
@@ -3288,11 +3191,9 @@
*/
public static OrderingMatchingRule getOrderingMatchingRule(String lowerName)
{
- return directoryServer.schema.getOrderingMatchingRule(lowerName);
+ return (OrderingMatchingRule) directoryServer.schema.getMatchingRule(lowerName);
}
-
-
/**
* Registers the provided ordering matching rule with the Directory Server.
*
@@ -3306,17 +3207,14 @@
* <CODE>overwriteExisting</CODE> flag is set to
* <CODE>false</CODE>
*/
- public static void registerOrderingMatchingRule(OrderingMatchingRule
- matchingRule,
- boolean overwriteExisting)
- throws DirectoryException
+ public static void registerOrderingMatchingRule(
+ OrderingMatchingRule matchingRule, boolean overwriteExisting)
+ throws DirectoryException
{
- directoryServer.schema.registerOrderingMatchingRule(matchingRule,
- overwriteExisting);
+ directoryServer.schema.registerMatchingRule(matchingRule, overwriteExisting);
}
-
/**
* Deregisters the provided ordering matching rule with the Directory Server.
*
@@ -3325,29 +3223,9 @@
public static void deregisterOrderingMatchingRule(OrderingMatchingRule
matchingRule)
{
- directoryServer.schema.deregisterOrderingMatchingRule(matchingRule);
+ directoryServer.schema.deregisterMatchingRule(matchingRule);
}
-
-
- /**
- * Retrieves the set of substring matching rules registered with the Directory
- * Server. The mapping will be between the lowercase name or OID for each
- * substring matching rule and the matching rule implementation. The same
- * substring matching rule instance may be included multiple times with
- * different keys.
- *
- * @return The set of substring matching rules registered with the Directory
- * Server.
- */
- public static ConcurrentMap<String, SubstringMatchingRule>
- getSubstringMatchingRules()
- {
- return directoryServer.schema.getSubstringMatchingRules();
- }
-
-
-
/**
* Retrieves the substring matching rule with the specified name or OID.
*
@@ -3359,11 +3237,9 @@
*/
public static SubstringMatchingRule getSubstringMatchingRule(String lowerName)
{
- return directoryServer.schema.getSubstringMatchingRule(lowerName);
+ return (SubstringMatchingRule) directoryServer.schema.getMatchingRule(lowerName);
}
-
-
/**
* Registers the provided substring matching rule with the Directory Server.
*
@@ -3377,17 +3253,13 @@
* <CODE>overwriteExisting</CODE> flag is set to
* <CODE>false</CODE>
*/
- public static void registerSubstringMatchingRule(SubstringMatchingRule
- matchingRule,
- boolean overwriteExisting)
- throws DirectoryException
+ public static void registerSubstringMatchingRule(
+ SubstringMatchingRule matchingRule, boolean overwriteExisting)
+ throws DirectoryException
{
- directoryServer.schema.registerSubstringMatchingRule(matchingRule,
- overwriteExisting);
+ directoryServer.schema.registerMatchingRule(matchingRule, overwriteExisting);
}
-
-
/**
* Deregisters the provided substring matching rule with the Directory Server.
*
@@ -3396,29 +3268,9 @@
public static void deregisterSubstringMatchingRule(SubstringMatchingRule
matchingRule)
{
- directoryServer.schema.deregisterSubstringMatchingRule(matchingRule);
+ directoryServer.schema.deregisterMatchingRule(matchingRule);
}
-
-
- /**
- * Retrieves the set of extensible matching rules registered with the
- * Directory Server. The mapping will be between the lowercase name or OID
- * for each extensible matching rule and the matching rule implementation. The
- * same extensible matching rule instance may be included multiple times with
- * different keys.
- *
- * @return The set of extensible matching rules registered with the Directory
- * Server.
- */
- public static Map<String,ExtensibleMatchingRule>
- getExtensibleMatchingRules()
- {
- return directoryServer.schema.getExtensibleMatchingRules();
- }
-
-
-
/**
* Retrieves the extensible matching rule with the specified name or OID.
*
@@ -3431,11 +3283,9 @@
public static ExtensibleMatchingRule
getExtensibleMatchingRule(String lowerName)
{
- return directoryServer.schema.getExtensibleMatchingRule(lowerName);
+ return (ExtensibleMatchingRule) directoryServer.schema.getMatchingRule(lowerName);
}
-
-
/**
* Retrieves the set of objectclasses defined in the Directory Server.
*
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java
index aee76e2..d75a7f2 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java
@@ -677,7 +677,7 @@
StringBuilder woidBuffer = new StringBuilder();
pos = readWOID(lowerStr, woidBuffer, pos);
OrderingMatchingRule omr =
- schema.getOrderingMatchingRule(woidBuffer.toString());
+ (OrderingMatchingRule) schema.getMatchingRule(woidBuffer.toString());
if (omr == null)
{
// This is bad because we have no idea what the ordering matching
@@ -697,7 +697,7 @@
StringBuilder woidBuffer = new StringBuilder();
pos = readWOID(lowerStr, woidBuffer, pos);
SubstringMatchingRule smr =
- schema.getSubstringMatchingRule(woidBuffer.toString());
+ (SubstringMatchingRule) schema.getMatchingRule(woidBuffer.toString());
if (smr == null)
{
// This is bad because we have no idea what the substring matching
@@ -915,7 +915,7 @@
String ruleName = approxRules.get(0);
String lowerName = toLowerCase(ruleName);
ApproximateMatchingRule amr =
- schema.getApproximateMatchingRule(lowerName);
+ (ApproximateMatchingRule) schema.getMatchingRule(lowerName);
if (amr == null)
{
// This is bad because we have no idea what the approximate matching
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/Schema.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/Schema.java
index 6cfaae9..dff9f0f 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/Schema.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/Schema.java
@@ -45,13 +45,8 @@
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;
import org.opends.server.api.MatchingRule;
-import org.opends.server.api.ExtensibleMatchingRule;
-import org.opends.server.api.OrderingMatchingRule;
-import org.opends.server.api.SubstringMatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.schema.AttributeTypeSyntax;
@@ -139,40 +134,7 @@
*/
private ConcurrentHashMap<String,MatchingRule> matchingRules;
- /**
- * The set of approximate matching rules for this schema, mapped between the
- * lowercase names and OID for the definition and the matching rule itself.
- */
- private ConcurrentHashMap<String,ApproximateMatchingRule>
- approximateMatchingRules;
- /**
- * The set of equality matching rules for this schema, mapped between the
- * lowercase names and OID for the definition and the matching rule itself.
- */
- private ConcurrentHashMap<String,MatchingRule>
- equalityMatchingRules;
-
- /**
- * The set of ordering matching rules for this schema, mapped between the
- * lowercase names and OID for the definition and the matching rule itself.
- */
- private ConcurrentHashMap<String,OrderingMatchingRule>
- orderingMatchingRules;
-
- /**
- * The set of substring matching rules for this schema, mapped between the
- * lowercase names and OID for the definition and the matching rule itself.
- */
- private ConcurrentHashMap<String,SubstringMatchingRule>
- substringMatchingRules;
-
- /**
- * The set of extensible matching rules for this schema, mapped between the
- * lowercase names and OID for the definition and the matching rule itself.
- */
- private ConcurrentHashMap<String,ExtensibleMatchingRule>
- extensibleMatchingRules;
/**
* The set of matching rule uses for this schema, mapped between the matching
@@ -273,16 +235,6 @@
objectClasses = new ConcurrentHashMap<String,ObjectClass>();
syntaxes = new ConcurrentHashMap<String,AttributeSyntax<?>>();
matchingRules = new ConcurrentHashMap<String,MatchingRule>();
- approximateMatchingRules =
- new ConcurrentHashMap<String,ApproximateMatchingRule>();
- equalityMatchingRules =
- new ConcurrentHashMap<String,MatchingRule>();
- orderingMatchingRules =
- new ConcurrentHashMap<String,OrderingMatchingRule>();
- substringMatchingRules =
- new ConcurrentHashMap<String,SubstringMatchingRule>();
- extensibleMatchingRules =
- new ConcurrentHashMap<String,ExtensibleMatchingRule>();
matchingRuleUses =
new ConcurrentHashMap<MatchingRule,MatchingRuleUse>();
ditContentRules =
@@ -1181,90 +1133,56 @@
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>
*/
- public void registerMatchingRule(MatchingRule matchingRule,
- boolean overwriteExisting)
+ public void registerMatchingRule(MatchingRule matchingRule, boolean overwriteExisting)
throws DirectoryException
{
- if (matchingRule instanceof ApproximateMatchingRule)
+ synchronized (matchingRules)
{
- registerApproximateMatchingRule(
- (ApproximateMatchingRule) matchingRule, overwriteExisting);
- }
- else if (matchingRule instanceof EqualityMatchingRule)
- {
- registerEqualityMatchingRule(
- matchingRule, overwriteExisting);
- }
- else if (matchingRule instanceof OrderingMatchingRule)
- {
- registerOrderingMatchingRule(
- (OrderingMatchingRule) matchingRule, overwriteExisting);
- }
- else if (matchingRule instanceof SubstringMatchingRule)
- {
- registerSubstringMatchingRule(
- (SubstringMatchingRule) matchingRule, overwriteExisting);
- }
- else if(matchingRule instanceof ExtensibleMatchingRule)
- {
- registerExtensibleMatchingRule(
- (ExtensibleMatchingRule) matchingRule,overwriteExisting);
- }
- else
- {
- synchronized (matchingRules)
+ if (!overwriteExisting)
{
- if (! overwriteExisting)
+ String oid = toLowerCase(matchingRule.getOID());
+ if (matchingRules.containsKey(oid))
{
- String oid = toLowerCase(matchingRule.getOID());
- if (matchingRules.containsKey(oid))
- {
- MatchingRule conflictingRule = matchingRules.get(oid);
+ MatchingRule conflictingRule = matchingRules.get(oid);
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_OID.
- get(matchingRule.getNameOrOID(), oid,
- conflictingRule.getNameOrOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- if (matchingRules.containsKey(name))
- {
- MatchingRule conflictingRule =
- matchingRules.get(name);
-
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_NAME.
- get(matchingRule.getOID(), name,
- conflictingRule.getOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION,
- message);
- }
- }
- }
+ LocalizableMessage message =
+ ERR_SCHEMA_CONFLICTING_MR_OID.get(matchingRule.getNameOrOID(),
+ oid, conflictingRule.getNameOrOID());
+ throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
}
- matchingRules.put(toLowerCase(matchingRule.getOID()),
- matchingRule);
- for(String name:matchingRule.getNames())
+ for (String name : matchingRule.getNames())
{
if (name != null)
{
- matchingRules.put(toLowerCase(name), matchingRule);
+ name = toLowerCase(name);
+ if (matchingRules.containsKey(name))
+ {
+ MatchingRule conflictingRule = matchingRules.get(name);
+
+ LocalizableMessage message =
+ ERR_SCHEMA_CONFLICTING_MR_NAME.get(matchingRule.getOID(),
+ name, conflictingRule.getOID());
+ throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
+ message);
+ }
}
}
- matchingRuleSet.add(createAttrValueForAdd(matchingRule));
}
+ matchingRules.put(toLowerCase(matchingRule.getOID()), matchingRule);
+
+ for (String name : matchingRule.getNames())
+ {
+ if (name != null)
+ {
+ matchingRules.put(toLowerCase(name), matchingRule);
+ }
+ }
+ matchingRuleSet.add(createAttrValueForAdd(matchingRule));
}
}
-
/**
* Deregisters the provided matching rule definition with this
* schema.
@@ -1274,183 +1192,15 @@
*/
public void deregisterMatchingRule(MatchingRule matchingRule)
{
- if (matchingRule instanceof ApproximateMatchingRule)
- {
- deregisterApproximateMatchingRule(
- (ApproximateMatchingRule) matchingRule);
- }
- else if (matchingRule instanceof MatchingRule)
- {
- deregisterEqualityMatchingRule(
- matchingRule);
- }
- else if (matchingRule instanceof OrderingMatchingRule)
- {
- deregisterOrderingMatchingRule(
- (OrderingMatchingRule) matchingRule);
- }
- else if (matchingRule instanceof SubstringMatchingRule)
- {
- deregisterSubstringMatchingRule(
- (SubstringMatchingRule) matchingRule);
- }
- else
- {
- synchronized (matchingRules)
- {
- matchingRules.remove(toLowerCase(matchingRule.getOID()),
- matchingRule);
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- matchingRules.remove(toLowerCase(name), matchingRule);
- }
- }
- matchingRuleSet.remove(createAttrValueForRemove(matchingRule));
- }
- }
- }
-
-
-
- /**
- * Retrieves the approximate matching rule definitions for this
- * schema, as a mapping between the lowercase names and OIDs for the
- * matching rule and the matching rule itself. Each matching rule
- * may be associated with multiple keys (once for the OID and again
- * for each name). The contents of the returned mapping must not be
- * altered.
- *
- * @return The approximate matching rule definitions for this
- * schema.
- */
- public ConcurrentHashMap<String,ApproximateMatchingRule>
- getApproximateMatchingRules()
- {
- return approximateMatchingRules;
- }
-
-
-
- /**
- * Retrieves the approximate matching rule definition with the
- * specified name or OID.
- *
- * @param lowerName The name or OID of the matching rule to
- * retrieve, formatted in all lowercase
- * characters.
- *
- * @return The requested matching rule, or <CODE>null</CODE> if no
- * approximate matching rule is registered with the
- * provided name or OID.
- */
- public ApproximateMatchingRule getApproximateMatchingRule(
- String lowerName)
- {
- return approximateMatchingRules.get(lowerName);
- }
-
-
-
- /**
- * Registers the provided approximate matching rule with this
- * schema.
- *
- * @param matchingRule The approximate matching rule to
- * register.
- * @param overwriteExisting Indicates whether to overwrite an
- * existing mapping if there are any
- * conflicts (i.e., another matching rule
- * with the same OID or name).
- *
- * @throws DirectoryException If a conflict is encountered and the
- * <CODE>overwriteExisting</CODE> flag
- * is set to <CODE>false</CODE>
- */
- public void registerApproximateMatchingRule(
- ApproximateMatchingRule matchingRule,
- boolean overwriteExisting)
- throws DirectoryException
- {
synchronized (matchingRules)
{
- if (! overwriteExisting)
- {
- String oid = toLowerCase(matchingRule.getOID());
- if (matchingRules.containsKey(oid))
- {
- MatchingRule conflictingRule = matchingRules.get(oid);
+ matchingRules.remove(toLowerCase(matchingRule.getOID()), matchingRule);
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_OID.
- get(matchingRule.getNameOrOID(), oid,
- conflictingRule.getNameOrOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- if (matchingRules.containsKey(name))
- {
- MatchingRule conflictingRule = matchingRules.get(name);
-
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_NAME.
- get(matchingRule.getOID(), name,
- conflictingRule.getOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION, message);
- }
- }
- }
- }
-
- String oid = toLowerCase(matchingRule.getOID());
- approximateMatchingRules.put(oid, matchingRule);
- matchingRules.put(oid, matchingRule);
-
- for(String name:matchingRule.getNames())
+ for (String name : matchingRule.getNames())
{
if (name != null)
{
- name = toLowerCase(name);
- approximateMatchingRules.put(name, matchingRule);
- matchingRules.put(name, matchingRule);
- }
- }
- matchingRuleSet.add(createAttrValueForAdd(matchingRule));
- }
- }
-
-
-
- /**
- * Deregisters the provided approximate matching rule definition
- * with this schema.
- *
- * @param matchingRule The approximate matching rule to deregister
- * with this schema.
- */
- public void deregisterApproximateMatchingRule(
- ApproximateMatchingRule matchingRule)
- {
- synchronized (matchingRules)
- {
- String oid = matchingRule.getOID();
- approximateMatchingRules.remove(oid, matchingRule);
- matchingRules.remove(oid, matchingRule);
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- approximateMatchingRules.remove(name, matchingRule);
- matchingRules.remove(name, matchingRule);
+ matchingRules.remove(toLowerCase(name), matchingRule);
}
}
matchingRuleSet.remove(createAttrValueForRemove(matchingRule));
@@ -1458,584 +1208,6 @@
}
-
- /**
- * Retrieves the equality matching rule definitions for this schema,
- * as a mapping between the lowercase names and OIDs for the
- * matching rule and the matching rule itself. Each matching rule
- * may be associated with multiple keys (once for the OID and again
- * for each name). The contents of the returned mapping must not be
- * altered.
- *
- * @return The equality matching rule definitions for this schema.
- */
- public ConcurrentHashMap<String,MatchingRule>
- getEqualityMatchingRules()
- {
- return equalityMatchingRules;
- }
-
-
-
- /**
- * Retrieves the equality matching rule definition with the
- * specified name or OID.
- *
- * @param lowerName The name or OID of the matching rule to
- * retrieve, formatted in all lowercase
- * characters.
- *
- * @return The requested matching rule, or <CODE>null</CODE> if no
- * equality matching rule is registered with the provided
- * name or OID.
- */
- public MatchingRule getEqualityMatchingRule(
- String lowerName)
- {
- return equalityMatchingRules.get(lowerName);
- }
-
-
-
- /**
- * Registers the provided equality matching rule with this schema.
- *
- * @param matchingRule The equality matching rule to
- * register.
- * @param overwriteExisting Indicates whether to overwrite an
- * existing mapping if there are any
- * conflicts (i.e., another matching rule
- * with the same OID or name).
- *
- * @throws DirectoryException If a conflict is encountered and the
- * <CODE>overwriteExisting</CODE> flag
- * is set to <CODE>false</CODE>
- */
- public void registerEqualityMatchingRule(MatchingRule matchingRule, boolean overwriteExisting)
- throws DirectoryException
- {
- synchronized (matchingRules)
- {
- if (! overwriteExisting)
- {
- String oid = toLowerCase(matchingRule.getOID());
- if (matchingRules.containsKey(oid))
- {
- MatchingRule conflictingRule = matchingRules.get(oid);
-
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_OID.
- get(matchingRule.getNameOrOID(), oid,
- conflictingRule.getNameOrOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- if (matchingRules.containsKey(name))
- {
- MatchingRule conflictingRule =
- matchingRules.get(name);
-
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_NAME.
- get(matchingRule.getOID(), name,
- conflictingRule.getOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION,
- message);
- }
- }
- }
- }
-
- String oid = toLowerCase(matchingRule.getOID());
- equalityMatchingRules.put(oid, matchingRule);
- matchingRules.put(oid, matchingRule);
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- equalityMatchingRules.put(name, matchingRule);
- matchingRules.put(name, matchingRule);
- }
- }
- matchingRuleSet.add(createAttrValueForAdd(matchingRule));
- }
- }
-
-
-
- /**
- * Deregisters the provided equality matching rule definition with
- * this schema.
- *
- * @param matchingRule The equality matching rule to deregister
- * with this schema.
- */
- public void deregisterEqualityMatchingRule(
- MatchingRule matchingRule)
- {
- synchronized (matchingRules)
- {
- String oid = matchingRule.getOID();
- equalityMatchingRules.remove(oid, matchingRule);
- matchingRules.remove(oid, matchingRule);
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- equalityMatchingRules.remove(name, matchingRule);
- matchingRules.remove(name, matchingRule);
- }
- }
- matchingRuleSet.remove(createAttrValueForRemove(matchingRule));
- }
- }
-
-
-
- /**
- * Retrieves the ordering matching rule definitions for this schema,
- * as a mapping between the lowercase names and OIDs for the
- * matching rule and the matching rule itself. Each matching rule
- * may be associated with multiple keys (once for the OID and again
- * for each name). The contents of the returned mapping must not be
- * altered.
- *
- * @return The ordering matching rule definitions for this schema.
- */
- public ConcurrentHashMap<String,OrderingMatchingRule>
- getOrderingMatchingRules()
- {
- return orderingMatchingRules;
- }
-
-
-
- /**
- * Retrieves the ordering matching rule definition with the
- * specified name or OID.
- *
- * @param lowerName The name or OID of the matching rule to
- * retrieve, formatted in all lowercase
- * characters.
- *
- * @return The requested matching rule, or <CODE>null</CODE> if no
- * ordering matching rule is registered with the provided
- * name or OID.
- */
- public OrderingMatchingRule getOrderingMatchingRule(
- String lowerName)
- {
- return orderingMatchingRules.get(lowerName);
- }
-
-
-
- /**
- * Registers the provided ordering matching rule with this schema.
- *
- * @param matchingRule The ordering matching rule to
- * register.
- * @param overwriteExisting Indicates whether to overwrite an
- * existing mapping if there are any
- * conflicts (i.e., another matching rule
- * with the same OID or name).
- *
- * @throws DirectoryException If a conflict is encountered and the
- * <CODE>overwriteExisting</CODE> flag
- * is set to <CODE>false</CODE>
- */
- public void registerOrderingMatchingRule(
- OrderingMatchingRule matchingRule,
- boolean overwriteExisting)
- throws DirectoryException
- {
- synchronized (matchingRules)
- {
- if (! overwriteExisting)
- {
- String oid = toLowerCase(matchingRule.getOID());
- if (matchingRules.containsKey(oid))
- {
- MatchingRule conflictingRule = matchingRules.get(oid);
-
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_OID.
- get(matchingRule.getNameOrOID(), oid,
- conflictingRule.getNameOrOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- if (matchingRules.containsKey(name))
- {
- MatchingRule conflictingRule = matchingRules.get(name);
-
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_NAME.
- get(matchingRule.getOID(), name,
- conflictingRule.getOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION,
- message);
- }
- }
- }
- }
-
- String oid = toLowerCase(matchingRule.getOID());
- orderingMatchingRules.put(oid, matchingRule);
- matchingRules.put(oid, matchingRule);
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- orderingMatchingRules.put(name, matchingRule);
- matchingRules.put(name, matchingRule);
- }
- }
- matchingRuleSet.add(createAttrValueForAdd(matchingRule));
- }
- }
-
-
-
- /**
- * Deregisters the provided ordering matching rule definition with
- * this schema.
- *
- * @param matchingRule The ordering matching rule to deregister
- * with this schema.
- */
- public void deregisterOrderingMatchingRule(
- OrderingMatchingRule matchingRule)
- {
- synchronized (matchingRules)
- {
- String oid = matchingRule.getOID();
- orderingMatchingRules.remove(oid, matchingRule);
- matchingRules.remove(oid, matchingRule);
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- orderingMatchingRules.remove(name, matchingRule);
- matchingRules.remove(name, matchingRule);
- }
- }
- matchingRuleSet.remove(createAttrValueForRemove(matchingRule));
- }
- }
-
-
-
- /**
- * Retrieves the substring matching rule definitions for this
- * schema, as a mapping between the lowercase names and OIDs for the
- * matching rule and the matching rule itself. Each matching rule
- * may be associated with multiple keys (once for the OID and again
- * for each name). The contents of the returned mapping must not be
- * altered.
- *
- * @return The substring matching rule definitions for this schema.
- */
- public ConcurrentHashMap<String,SubstringMatchingRule>
- getSubstringMatchingRules()
- {
- return substringMatchingRules;
- }
-
-
-
- /**
- * Retrieves the substring matching rule definition with the
- * specified name or OID.
- *
- * @param lowerName The name or OID of the matching rule to
- * retrieve, formatted in all lowercase
- * characters.
- *
- * @return The requested matching rule, or <CODE>null</CODE> if no
- * substring matching rule is registered with the provided
- * name or OID.
- */
- public SubstringMatchingRule getSubstringMatchingRule(
- String lowerName)
- {
- return substringMatchingRules.get(lowerName);
- }
-
-
-
- /**
- * Registers the provided substring matching rule with this schema.
- *
- * @param matchingRule The substring matching rule to
- * register.
- * @param overwriteExisting Indicates whether to overwrite an
- * existing mapping if there are any
- * conflicts (i.e., another matching rule
- * with the same OID or name).
- *
- * @throws DirectoryException If a conflict is encountered and the
- * <CODE>overwriteExisting</CODE> flag
- * is set to <CODE>false</CODE>
- */
- public void registerSubstringMatchingRule(
- SubstringMatchingRule matchingRule,
- boolean overwriteExisting)
- throws DirectoryException
- {
- synchronized (matchingRules)
- {
- if (! overwriteExisting)
- {
- String oid = toLowerCase(matchingRule.getOID());
- if (matchingRules.containsKey(oid))
- {
- MatchingRule conflictingRule = matchingRules.get(oid);
-
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_OID.
- get(matchingRule.getNameOrOID(), oid,
- conflictingRule.getNameOrOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- if (matchingRules.containsKey(name))
- {
- MatchingRule conflictingRule = matchingRules.get(name);
-
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_NAME.
- get(matchingRule.getOID(), name,
- conflictingRule.getOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION,
- message);
- }
- }
- }
- }
-
- String oid = toLowerCase(matchingRule.getOID());
- substringMatchingRules.put(oid, matchingRule);
- matchingRules.put(oid, matchingRule);
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- substringMatchingRules.put(name, matchingRule);
- matchingRules.put(name, matchingRule);
- }
- }
- matchingRuleSet.add(createAttrValueForAdd(matchingRule));
- }
- }
-
-
-
- /**
- * Deregisters the provided substring matching rule definition with
- * this schema.
- *
- * @param matchingRule The substring matching rule to deregister
- * with this schema.
- */
- public void deregisterSubstringMatchingRule(
- SubstringMatchingRule matchingRule)
- {
- synchronized (matchingRules)
- {
- String oid = matchingRule.getOID();
- substringMatchingRules.remove(oid, matchingRule);
- matchingRules.remove(oid, matchingRule);
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- substringMatchingRules.remove(name, matchingRule);
- matchingRules.remove(name, matchingRule);
- }
- }
- matchingRuleSet.remove(createAttrValueForRemove(matchingRule));
- }
- }
-
-
-
- /**
- * Retrieves the extensible matching rule definitions for this
- * schema, as a mapping between the lowercase names and OIDs for the
- * matching rule and the matching rule itself. Each matching rule
- * may be associated with multiple keys (once for the OID and again
- * for each name).
- *
- * @return The extensible matching rule definitions for this
- * schema.
- */
- public Map<String,ExtensibleMatchingRule>
- getExtensibleMatchingRules()
- {
- return Collections.unmodifiableMap(extensibleMatchingRules);
- }
-
-
-
- /**
- * Retrieves the extensible matching rule definition with the
- * specified name or OID.
- *
- * @param lowerName The name or OID of the matching rule to
- * retrieve, formatted in all lowercase
- * characters.
- *
- * @return The requested matching rule, or <CODE>null</CODE> if no
- * extensible matching rule is registered with the
- * provided name or OID.
- */
- public ExtensibleMatchingRule getExtensibleMatchingRule(
- String lowerName)
- {
- //An ExtensibleMatchingRule can be of multiple types.
- MatchingRule rule = matchingRules.get(lowerName);
- if(rule instanceof ExtensibleMatchingRule)
- {
- return (ExtensibleMatchingRule)rule;
- }
- return null;
- }
-
-
-
- /**
- * Registers the provided extensible matching rule with this
- * schema.
- *
- * @param matchingRule The extensible matching rule to
- * register.
- * @param overwriteExisting Indicates whether to overwrite an
- * existing mapping if there are any
- * conflicts (i.e., another matching rule
- * with the same OID or name).
- *
- * @throws DirectoryException If a conflict is encountered and the
- * <CODE>overwriteExisting</CODE> flag
- * is set to <CODE>false</CODE>
- */
- public void registerExtensibleMatchingRule(
- ExtensibleMatchingRule matchingRule,
- boolean overwriteExisting)
- throws DirectoryException
- {
- synchronized (matchingRules)
- {
- if (! overwriteExisting)
- {
- String oid = toLowerCase(matchingRule.getOID());
- if (matchingRules.containsKey(oid))
- {
- MatchingRule conflictingRule = matchingRules.get(oid);
-
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_OID.
- get(matchingRule.getNameOrOID(), oid,
- conflictingRule.getNameOrOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION, message);
- }
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- if (matchingRules.containsKey(name))
- {
- MatchingRule conflictingRule = matchingRules.get(name);
-
- LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MR_NAME.
- get(matchingRule.getOID(), name,
- conflictingRule.getOID());
- throw new DirectoryException(
- ResultCode.CONSTRAINT_VIOLATION, message);
- }
- }
- }
- }
-
- String oid = toLowerCase(matchingRule.getOID());
- extensibleMatchingRules.put(oid, matchingRule);
- matchingRules.put(oid, matchingRule);
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- extensibleMatchingRules.put(name, matchingRule);
- matchingRules.put(name, matchingRule);
- }
- }
- matchingRuleSet.add(createAttrValueForAdd(matchingRule));
- }
- }
-
-
-
- /**
- * Deregisters the provided extensible matching rule definition
- * with this schema.
- *
- * @param matchingRule The extensible matching rule to deregister
- * with this schema.
- */
- public void deregisterExtensibleMatchingRule(
- ExtensibleMatchingRule matchingRule)
- {
- synchronized (matchingRules)
- {
- String oid = matchingRule.getOID();
- extensibleMatchingRules.remove(oid, matchingRule);
- matchingRules.remove(oid, matchingRule);
-
- for(String name:matchingRule.getNames())
- {
- if (name != null)
- {
- name = toLowerCase(name);
- extensibleMatchingRules.remove(name, matchingRule);
- matchingRules.remove(name, matchingRule);
- }
- }
- matchingRuleSet.remove(createAttrValueForRemove(matchingRule));
- }
- }
-
-
-
/**
* Retrieves the matching rule use definitions for this schema, as a
* mapping between the matching rule for the matching rule use
@@ -3101,12 +2273,6 @@
dupSchema.objectClasses.putAll(objectClasses);
dupSchema.syntaxes.putAll(syntaxes);
dupSchema.matchingRules.putAll(matchingRules);
- dupSchema.approximateMatchingRules.putAll(
- approximateMatchingRules);
- dupSchema.equalityMatchingRules.putAll(equalityMatchingRules);
- dupSchema.orderingMatchingRules.putAll(orderingMatchingRules);
- dupSchema.substringMatchingRules.putAll(substringMatchingRules);
- dupSchema.extensibleMatchingRules.putAll(extensibleMatchingRules);
dupSchema.matchingRuleUses.putAll(matchingRuleUses);
dupSchema.ditContentRules.putAll(ditContentRules);
dupSchema.ditStructureRulesByID.putAll(ditStructureRulesByID);
@@ -3608,12 +2774,6 @@
mayInvoke=true)
public synchronized void destroy()
{
- if (approximateMatchingRules != null)
- {
- approximateMatchingRules.clear();
- approximateMatchingRules = null;
- }
-
if (attributeTypes != null)
{
attributeTypes.clear();
@@ -3656,12 +2816,6 @@
ditStructureRuleSet = null;
}
- if (equalityMatchingRules != null)
- {
- equalityMatchingRules.clear();
- equalityMatchingRules = null;
- }
-
if (matchingRules != null)
{
matchingRules.clear();
@@ -3716,24 +2870,12 @@
objectClassSet = null;
}
- if (orderingMatchingRules != null)
- {
- orderingMatchingRules.clear();
- orderingMatchingRules = null;
- }
-
if (subordinateTypes != null)
{
subordinateTypes.clear();
subordinateTypes = null;
}
- if (substringMatchingRules != null)
- {
- substringMatchingRules.clear();
- substringMatchingRules = null;
- }
-
if (extraAttributes != null)
{
extraAttributes.clear();
@@ -3752,12 +2894,6 @@
syntaxSet = null;
}
- if (extensibleMatchingRules != null)
- {
- extensibleMatchingRules.clear();
- extensibleMatchingRules = null;
- }
-
if(ldapSyntaxDescriptions != null)
{
ldapSyntaxDescriptions.clear();
--
Gitblit v1.10.0