From 9defd2349274d077ad120d780a6fac5f6d594c7f Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 22 May 2015 15:58:46 +0000
Subject: [PATCH] OPENDJ-1631 CR-6864 Migrate server to SDK syntaxes
---
opendj-server-legacy/src/main/java/org/opends/server/schema/NameFormSyntax.java | 131 +++++--------------------------------------
1 files changed, 16 insertions(+), 115 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/NameFormSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/NameFormSyntax.java
index 970c4b9..f5cb0f1 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/NameFormSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/NameFormSyntax.java
@@ -26,27 +26,28 @@
*/
package org.opends.server.schema;
+import static org.opends.messages.SchemaMessages.*;
+import static org.opends.server.schema.SchemaConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.ldap.schema.ObjectClassType;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
-import org.opends.server.api.AttributeSyntax;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.*;
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.*;
+import org.forgerock.opendj.ldap.schema.ObjectClassType;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+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.types.Schema;
/**
* This class implements the name form description syntax, which is used to
@@ -56,16 +57,6 @@
public class NameFormSyntax
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
- /** The default ordering matching rule for this syntax. */
- private MatchingRule defaultOrderingMatchingRule;
-
- /** The default substring matching rule for this syntax. */
- private MatchingRule defaultSubstringMatchingRule;
/**
* Creates a new instance of this syntax. Note that the only thing that
@@ -80,35 +71,9 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException, InitializationException
+ public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE.get(
- EMR_CASE_IGNORE_OID, SYNTAX_NAME_FORM_NAME);
- throw new InitializationException(message);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE.get(
- OMR_CASE_IGNORE_OID, SYNTAX_NAME_FORM_NAME);
- throw new InitializationException(message);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE.get(
- SMR_CASE_IGNORE_OID, SYNTAX_NAME_FORM_NAME);
- throw new InitializationException(message);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_NAME_FORM_OID);
}
/** {@inheritDoc} */
@@ -132,56 +97,6 @@
return SYNTAX_NAME_FORM_DESCRIPTION;
}
- /** {@inheritDoc} */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /** {@inheritDoc} */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /** {@inheritDoc} */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /** {@inheritDoc} */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // We'll use the decodeNameForm method to determine if the value is
- // acceptable.
- try
- {
- decodeNameForm(value, DirectoryServer.getSchema(), true);
- return true;
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- invalidReason.append(de.getMessageObject());
- return false;
- }
- }
-
/**
* Decodes the contents of the provided ASN.1 octet string as a name form
* definition according to the rules of this syntax. Note that the provided
@@ -1215,19 +1130,5 @@
return startPos;
}
-
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return true;
- }
}
--
Gitblit v1.10.0