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/DITContentRuleSyntax.java | 132
opendj-server-legacy/src/main/java/org/opends/server/schema/OIDSyntax.java | 132
opendj-server-legacy/src/main/java/org/opends/server/schema/SchemaUpdater.java | 14
opendj-server-legacy/src/main/java/org/opends/server/schema/UTCTimeSyntax.java | 797 ---
opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java | 4
opendj-server-legacy/src/main/java/org/opends/server/schema/NumericStringSyntax.java | 166
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java | 4
opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java | 4
opendj-server-legacy/src/test/java/org/opends/server/types/TestAttributeType.java | 12
opendj-server-legacy/src/test/java/org/opends/server/schema/BitStringSyntaxTest.java | 16
opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleUseSyntax.java | 126
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java | 6
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AttributeSyntaxPanel.java | 4
opendj-server-legacy/src/test/java/org/opends/server/schema/BinaryAttributeSyntaxTest.java | 11
opendj-server-legacy/src/test/java/org/opends/server/types/AttributeTypeConstants.java | 7
opendj-server-legacy/src/test/java/org/opends/server/api/AlertHandlerTestCase.java | 2
opendj-server-legacy/src/test/java/org/opends/server/schema/OtherMailboxSyntaxTest.java | 2
opendj-server-legacy/src/main/java/org/opends/server/types/LDAPSyntaxDescription.java | 51
opendj-server-legacy/src/test/java/org/opends/server/api/DITCacheMapTestCase.java | 2
opendj-server-legacy/src/main/java/org/opends/server/schema/DistinguishedNameSyntax.java | 152
opendj-server-legacy/src/main/java/org/opends/server/schema/SubstringAssertionSyntax.java | 178
opendj-server-legacy/src/main/java/org/opends/server/schema/TeletexTerminalIdentifierSyntax.java | 283 -
opendj-server-legacy/src/main/java/org/opends/server/monitors/DatabaseEnvironmentMonitor.java | 433 ++
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SchemaBrowserRightPanel.java | 4
opendj-server-legacy/src/main/java/org/opends/server/types/SubtreeSpecification.java | 2
opendj-server-legacy/src/main/java/org/opends/server/schema/GuideSyntax.java | 157
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java | 6
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java | 131
opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java | 4
opendj-server-legacy/src/main/java/org/opends/server/schema/AciSyntaxImpl.java | 103
opendj-server-legacy/src/main/java/org/opends/server/schema/PresentationAddressSyntax.java | 149
opendj-server-legacy/src/main/java/org/opends/server/schema/BinarySyntax.java | 140
opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java | 4
opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java | 198
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java | 13
opendj-server-legacy/src/main/java/org/opends/server/schema/AciSyntax.java | 153
opendj-server-legacy/src/main/java/org/opends/server/schema/ProtocolInformationSyntax.java | 152
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java | 88
opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java | 2
opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateListSyntax.java | 139
opendj-server-legacy/src/main/java/org/opends/server/schema/OtherMailboxSyntax.java | 200
opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java | 18
opendj-server-legacy/src/main/java/org/opends/server/config/ReadOnlyConfigAttribute.java | 4
opendj-server-legacy/src/test/java/org/opends/server/schema/UUIDSyntaxTest.java | 2
opendj-server-legacy/src/main/java/org/opends/server/schema/OctetStringSyntax.java | 139
opendj-server-legacy/src/main/java/org/opends/server/schema/DeliveryMethodSyntax.java | 199
opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java | 4
opendj-server-legacy/src/test/java/org/opends/server/schema/GuideSyntaxTest.java | 2
opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java | 1
opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateExactAssertionSyntax.java | 104
opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java | 2
opendj-server-legacy/src/main/java/org/opends/server/schema/DITStructureRuleSyntax.java | 129
opendj-server-legacy/src/main/java/org/opends/server/schema/IntegerSyntax.java | 258 -
opendj-server-legacy/src/main/java/org/opends/server/schema/PrintableStringSyntax.java | 185
opendj-server-legacy/src/test/java/org/opends/server/api/TestTaskListener.java | 2
opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java | 40
opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java | 31
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java | 4
opendj-server-legacy/src/main/java/org/opends/server/schema/JPEGSyntax.java | 202
opendj-server-legacy/src/test/java/org/opends/server/schema/IA5StringSyntaxTest.java | 2
opendj-server-legacy/src/test/java/org/opends/server/core/ConfigurationHandlerTestCase.java | 4
opendj-server-legacy/src/main/java/org/opends/server/schema/IA5StringSyntax.java | 163
opendj-server-legacy/src/main/java/org/opends/server/schema/ObjectClassSyntax.java | 135
opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java | 4
opendj-server-legacy/src/main/java/org/opends/server/schema/SubtreeSpecificationSyntaxImpl.java | 115
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewAttributePanel.java | 18
opendj-server-legacy/src/test/java/org/opends/server/schema/DITContentRuleSyntaxTest.java | 22
opendj-server-legacy/src/main/java/org/opends/server/schema/BooleanSyntax.java | 142
opendj-server-legacy/src/test/java/org/opends/server/schema/MatchingRuleSyntaxTest.java | 12
opendj-server-legacy/src/main/java/org/opends/server/schema/DirectoryStringSyntax.java | 186
opendj-server-legacy/src/test/java/org/opends/server/schema/JPEGSyntaxTest.java | 124
opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java | 9
opendj-server-legacy/src/main/java/org/opends/server/schema/PostalAddressSyntax.java | 132
opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java | 4
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/DatabaseEnvironmentMonitor.java | 9
opendj-server-legacy/src/main/java/org/opends/server/api/AttributeSyntax.java | 71
opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java | 4
opendj-server-legacy/src/test/java/org/opends/server/schema/ConfigurableAttributeSyntaxTest.java | 54
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java | 11
opendj-server-legacy/src/main/java/org/opends/server/types/AttributeType.java | 10
opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeTypeSyntaxTest.java | 27
opendj-server-legacy/src/test/java/org/opends/server/core/SchemaHandlerTestCase.java | 30
opendj-server-legacy/src/main/java/org/opends/server/schema/FaxNumberSyntax.java | 251 -
opendj-server-legacy/src/main/java/org/opends/server/schema/CertificatePairSyntax.java | 139
opendj-server-legacy/src/test/java/org/opends/server/schema/GeneralizedTimeSyntaxTest.java | 2
opendj-server-legacy/src/test/java/org/opends/server/schema/IntegerSyntaxTest.java | 2
opendj-server-legacy/src/main/java/org/opends/server/schema/SupportedAlgorithmSyntax.java | 142
opendj-server-legacy/src/main/java/org/opends/server/schema/SubtreeSpecificationSyntax.java | 113
opendj-server-legacy/src/main/java/org/opends/server/controls/MatchedValuesFilter.java | 7
opendj-server-legacy/src/main/java/org/opends/server/schema/NameAndOptionalUIDSyntax.java | 186
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java | 5
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/SchemaLoader.java | 11
opendj-server-legacy/src/main/java/org/opends/server/schema/EnhancedGuideSyntax.java | 214
opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java | 4
opendj-server-legacy/src/main/java/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java | 844 ---
opendj-server-legacy/src/test/java/org/opends/server/schema/LDAPSyntaxTest.java | 4
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java | 8
opendj-server-legacy/src/main/java/org/opends/server/schema/CountryStringSyntax.java | 212
opendj-server-legacy/src/test/java/org/opends/server/schema/CollationMatchingRuleTest.java | 2
opendj-server-legacy/src/main/java/org/opends/server/schema/CoreSchemaProvider.java | 2
opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java | 169
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/MatchingRulePanel.java | 6
opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java | 18
opendj-server-legacy/src/main/java/org/opends/server/schema/AuthPasswordSyntax.java | 140
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java | 12
opendj-server-legacy/src/main/java/org/opends/server/schema/FaxSyntax.java | 139
opendj-server-legacy/src/main/java/org/opends/server/schema/BitStringSyntax.java | 157
opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java | 4
opendj-server-legacy/src/main/java/org/opends/server/schema/NameFormSyntax.java | 131
opendj-server-legacy/src/main/java/org/opends/server/schema/UserPasswordSyntax.java | 126
opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java | 4
opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java | 38
opendj-server-legacy/src/test/java/org/opends/server/schema/CountryStringSyntaxTest.java | 23
opendj-server-legacy/src/test/java/org/opends/server/schema/MatchingRuleUseSyntaxTest.java | 11
opendj-server-legacy/src/test/java/org/opends/server/api/AuthenticationPolicyTestCase.java | 2
opendj-server-legacy/replace.rb | 76
opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeSyntaxTest.java | 29
opendj-server-legacy/src/test/java/org/opends/server/schema/CertificateSyntaxTest.java | 22
opendj-server-legacy/src/main/java/org/opends/server/core/CoreConfigManager.java | 22
opendj-server-legacy/src/main/java/org/opends/server/schema/UUIDSyntax.java | 191
opendj-server-legacy/src/main/java/org/opends/server/schema/TelephoneNumberSyntax.java | 251 -
opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java | 15
opendj-server-legacy/src/test/java/org/opends/server/api/APITestCase.java | 3
opendj-server-legacy/src/main/java/org/opends/server/core/ServerContext.java | 11
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java | 4
opendj-server-legacy/src/main/java/org/opends/server/core/AttributeSyntaxConfigManager.java | 42
opendj-server-legacy/src/main/java/org/opends/server/schema/TelexNumberSyntax.java | 245 -
/dev/null | 235 -
opendj-server-legacy/src/main/java/org/opends/server/schema/GeneralizedTimeSyntax.java | 157
opendj-server-legacy/src/main/java/org/opends/server/monitors/TraditionalWorkQueueMonitor.java | 9
opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleSyntax.java | 1009 ----
opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateSyntax.java | 393 -
opendj-server-legacy/src/test/java/org/opends/server/schema/TelexSyntaxTest.java | 2
opendj-server-legacy/src/test/java/org/opends/server/api/ConfigChangeListenerTestCase.java | 2
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/AttributeSyntaxTreeNode.java | 10
135 files changed, 2,225 insertions(+), 10,428 deletions(-)
diff --git a/opendj-server-legacy/replace.rb b/opendj-server-legacy/replace.rb
index d3210ab..282a7cf 100755
--- a/opendj-server-legacy/replace.rb
+++ b/opendj-server-legacy/replace.rb
@@ -40,12 +40,60 @@
class Replace
# All directories that contains java code
- JAVA_DIRS = ["src/server", "src/quicksetup", "src/ads", "src/guitools", "tests/unit-tests-testng/src"]
+ JAVA_DIRS = ["src/main/java", "src/test/java"]
TOOLS_DIR = ["src/server/org/opends/server/tools", "src/quicksetup", "src/ads", "src/guitools",
"tests/unit-tests-testng/src/server/org/opends/server/tools" ]
SNMP_DIR = ["src/snmp/src"]
DSML_DIR = ["src/dsml/org"]
+ # Replacement for syntaxes
+ SYNTAXES_TO_SDK = {
+ :dirs => JAVA_DIRS + SNMP_DIR,
+ :extensions => ["java"],
+ :stoplist => ["Syntax"],
+ :replacements =>
+ [
+ /import org.opends.server.api.AttributeSyntax;/,
+ 'import org.forgerock.opendj.ldap.schema.Syntax;',
+
+ /package org.opends.server.api;/,
+ "package org.opends.server.api;\n\nimport org.forgerock.opendj.ldap.schema.Syntax;",
+
+ /import org.opends.server.api.\*;/,
+ "import org.forgerock.opendj.ldap.schema.Syntax;\nimport org.opends.server.api.*;",
+
+ /\bAttributeSyntax\b(<AttributeSyntaxCfg>)/,
+ "Syntax",
+
+ /\bAttributeSyntax\b(<\w*>)?/,
+ "Syntax",
+
+ /\bSyntax\b<\w*>/,
+ "Syntax",
+
+ /\bSyntax\b<\?>/,
+ "Syntax",
+
+ ]
+ }
+
+ SYNTAXES_TO_SDK_SCM = {
+ :dirs => JAVA_DIRS,
+ :extensions => ["java"],
+ :whitelist => ["SchemaConfigManager"],
+ :replacements =>
+ [
+ /\b\w*Syntax\b\s+(\w+Syntax);/,
+ 'Syntax \1;',
+
+ /\((\w*Syntax)\)\s*schema.getSyntax/m,
+ 'schema.getSyntax',
+
+ /\w*Syntax.initializeSyntax\(null\);\s/,
+ ''
+ ]
+ }
+
# Replacement for matching rules
MRULES_TO_SDK = {
:dirs => JAVA_DIRS + SNMP_DIR,
@@ -109,30 +157,6 @@
]
}
- # Replacement for syntaxes
- SYNTAX = {
- :dirs => JAVA_DIRS + SNMP_DIR,
- :extensions => ["java"],
- :stoplist => ["Syntax"],
- :replacements =>
- [
-
- /import org.opends.server.api.AttributeSyntax;/,
- 'import org.forgerock.opendj.ldap.schema.Syntax;',
-
- /package org.opends.server.api;/,
- "package org.opends.server.api;\n\nimport org.forgerock.opendj.ldap.schema.Syntax;",
-
- /import org.opends.server.api.\*;/,
- "import org.forgerock.opendj.ldap.schema.Syntax;\nimport org.opends.server.api.*;",
-
- /\bAttributeSyntax\b<[^>]+>/,
- 'Syntax',
-
- /\bAttributeSyntax\b/,
- 'Syntax'
- ]
- }
# Replacement for attribute type
ATTRTYPE = {
@@ -382,7 +406,7 @@
############################### List of replacements to run #################################
- REPLACEMENTS = [ MRULES_TO_SDK, MRULES_FACTORIES, MRULES_API_PACKAGE ]
+ REPLACEMENTS = [ SYNTAXES_TO_SDK, SYNTAXES_TO_SDK_SCM ]
################################### Processing methods ########################################
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AttributeSyntaxPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AttributeSyntaxPanel.java
index a01d41b..2c023bc 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AttributeSyntaxPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AttributeSyntaxPanel.java
@@ -47,7 +47,7 @@
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Schema;
@@ -185,7 +185,7 @@
* @param syntax the attribute syntax that the panel must display.
* @param schema the schema.
*/
- public void update(AttributeSyntax<?> syntax, Schema schema)
+ public void update(Syntax syntax, Schema schema)
{
String n = syntax.getName();
if (n == null)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
index a303d06..5dce5a9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
@@ -88,7 +88,7 @@
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.guitools.controlpanel.util.ViewPositions;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.types.AttributeType;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.ObjectClass;
@@ -792,7 +792,7 @@
TreeSet<String> syntaxNames = new TreeSet<>(lowerCaseComparator);
HashMap<String, AttributeSyntaxTreeNode> hmSyntaxes = new HashMap<>();
- for (AttributeSyntax<?> syntax : lastSchema.getSyntaxes().values())
+ for (Syntax syntax : lastSchema.getSyntaxes().values())
{
if (mustAdd(syntax))
{
@@ -1519,7 +1519,7 @@
* @return <CODE>true</CODE> if the attribute syntax must be added and
* <CODE>false</CODE> otherwise.
*/
- private boolean mustAdd(AttributeSyntax<?> syntax)
+ private boolean mustAdd(Syntax syntax)
{
String f = filter.getText().trim();
if (f.length () > 0)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
index fa93190..3c1d768 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
@@ -86,7 +86,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.schema.MatchingRule;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.types.ObjectClass;
@@ -676,7 +676,7 @@
@Override
public void configurationChanged(ConfigurationChangeEvent ev)
{
- ArrayList<AttributeSyntax<?>> newSyntaxes = new ArrayList<>();
+ ArrayList<Syntax> newSyntaxes = new ArrayList<>();
final ServerDescriptor desc = ev.getNewDescriptor();
Schema s = desc.getSchema();
@@ -701,10 +701,10 @@
if (schemaChanged)
{
schema = s;
- HashMap<String, AttributeSyntax<?>> syntaxNameMap = new HashMap<>();
+ HashMap<String, Syntax> syntaxNameMap = new HashMap<>();
for (String key : schema.getSyntaxes().keySet())
{
- AttributeSyntax<?> syntax = schema.getSyntax(key);
+ Syntax syntax = schema.getSyntax(key);
String name = syntax.getName();
if (name == null)
{
@@ -1246,7 +1246,7 @@
getOID(),
getDescription(),
getSuperior(),
- (AttributeSyntax<?>)syntax.getSelectedItem(),
+ (Syntax)syntax.getSelectedItem(),
getApproximateMatchingRule(),
getEqualityMatchingRule(),
getOrderingMatchingRule(),
@@ -1259,7 +1259,7 @@
private void updateDefaultMatchingRuleNames()
{
- AttributeSyntax<?> syn = (AttributeSyntax<?>)syntax.getSelectedItem();
+ Syntax syn = (Syntax)syntax.getSelectedItem();
if (syn != null)
{
MatchingRule[] rules = {syn.getApproximateMatchingRule(),
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/MatchingRulePanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/MatchingRulePanel.java
index 47c5023..1a899d1 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/MatchingRulePanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/MatchingRulePanel.java
@@ -45,7 +45,7 @@
import org.opends.guitools.controlpanel.ui.components.TitlePanel;
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Schema;
@@ -206,9 +206,9 @@
titlePanel.setDetails(LocalizableMessage.raw(n));
name.setText(n);
oid.setText(matchingRule.getOID());
- AttributeSyntax<?> s = null;
+ Syntax s = null;
String syntaxOID = matchingRule.getSyntax().getOID();
- for (AttributeSyntax<?> candidate : schema.getSyntaxes().values())
+ for (Syntax candidate : schema.getSyntaxes().values())
{
if (candidate.getOID().equals(syntaxOID))
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewAttributePanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewAttributePanel.java
index 2a763f9..110da6a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewAttributePanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewAttributePanel.java
@@ -65,7 +65,7 @@
import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer;
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.config.ConfigConstants;
import org.opends.server.types.AttributeType;
import org.opends.server.types.ObjectClass;
@@ -173,7 +173,7 @@
@Override
public void configurationChanged(ConfigurationChangeEvent ev)
{
- ArrayList<AttributeSyntax<?>> newSyntaxes = new ArrayList<>();
+ ArrayList<Syntax> newSyntaxes = new ArrayList<>();
final ServerDescriptor desc = ev.getNewDescriptor();
Schema s = desc.getSchema();
@@ -203,10 +203,11 @@
{
schema = s;
- HashMap<String, AttributeSyntax<?>> syntaxNameMap = new HashMap<>();
+ HashMap<String, Syntax> syntaxNameMap = new HashMap<>();
+
for (String key : schema.getSyntaxes().keySet())
{
- AttributeSyntax<?> syntax = schema.getSyntax(key);
+ Syntax syntax = schema.getSyntax(key);
String name = syntax.getName();
if (name == null)
{
@@ -316,8 +317,7 @@
{
for (int i=0; i<syntax.getModel().getSize(); i++)
{
- AttributeSyntax<?> syn =
- (AttributeSyntax<?>)syntax.getModel().getElementAt(i);
+ Syntax syn = (Syntax)syntax.getModel().getElementAt(i);
if ("DirectoryString".equals(syn.getName()))
{
syntax.setSelectedIndex(i);
@@ -508,7 +508,7 @@
return INFO_CTRL_PANEL_TYPE_MATCHING_RULE.get();
}
- for (AttributeSyntax<?> attr : schema.getSyntaxes().values())
+ for (Syntax attr : schema.getSyntaxes().values())
{
if (name.equalsIgnoreCase(attr.getName()))
{
@@ -675,7 +675,7 @@
private void updateDefaultMatchingRuleNames()
{
- AttributeSyntax<?> syn = (AttributeSyntax<?>)syntax.getSelectedItem();
+ Syntax syn = (Syntax)syntax.getSelectedItem();
if (syn != null)
{
MatchingRule[] rules = {syn.getApproximateMatchingRule(),
@@ -810,7 +810,7 @@
getOID(),
getDescription(),
getSuperior(),
- (AttributeSyntax<?>)syntax.getSelectedItem(),
+ (Syntax)syntax.getSelectedItem(),
getApproximateMatchingRule(),
getEqualityMatchingRule(),
getOrderingMatchingRule(),
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SchemaBrowserRightPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SchemaBrowserRightPanel.java
index 6dc5a36..39be96f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SchemaBrowserRightPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SchemaBrowserRightPanel.java
@@ -42,7 +42,7 @@
import org.opends.guitools.controlpanel.event.SchemaElementSelectionListener;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
import org.opends.server.types.ObjectClass;
@@ -271,7 +271,7 @@
* @param syntax the attribute syntax.
* @param schema the schema.
*/
- public void updateAttributeSyntax(AttributeSyntax<?> syntax, Schema schema)
+ public void updateAttributeSyntax(Syntax syntax, Schema schema)
{
attributeSyntaxPanel.update(syntax, schema);
schemaElementPanel = attributeSyntaxPanel;
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
index 97e9b5c..2f42048 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
@@ -52,7 +52,7 @@
import org.opends.guitools.controlpanel.ui.nodes.BasicNode;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
@@ -517,7 +517,7 @@
Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase());
if (attr != null)
{
- AttributeSyntax<?> syntax = attr.getSyntax();
+ Syntax syntax = attr.getSyntax();
if (syntax != null)
{
isCertificate = syntax.getOID().equals(
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/AttributeSyntaxTreeNode.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/AttributeSyntaxTreeNode.java
index cfd5aee..2f4c666 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/AttributeSyntaxTreeNode.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/AttributeSyntaxTreeNode.java
@@ -22,11 +22,13 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
+ * Portions Copyright 2015 ForgeRock AS.
*/
package org.opends.guitools.controlpanel.ui.nodes;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
+
/**
* Class of the nodes that represent an attribute syntax in the 'Manage Schema'
@@ -36,14 +38,14 @@
public class AttributeSyntaxTreeNode extends SchemaElementTreeNode
{
private static final long serialVersionUID = 2439971368723239776L;
- private AttributeSyntax<?> syntax;
+ private Syntax syntax;
/**
* Constructor of the node.
* @param name the name of the node.
* @param syntax the attribute syntax.
*/
- public AttributeSyntaxTreeNode(String name, AttributeSyntax<?> syntax)
+ public AttributeSyntaxTreeNode(String name, Syntax syntax)
{
super(name, syntax);
this.syntax = syntax;
@@ -53,7 +55,7 @@
* Returns the attribute syntax represented by this node.
* @return the attribute syntax represented by this node.
*/
- public AttributeSyntax<?> getAttributeSyntax()
+ public Syntax getAttributeSyntax()
{
return syntax;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java
index b779dbe..fb64477 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java
@@ -33,7 +33,7 @@
import javax.swing.JComboBox;
import javax.swing.JList;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.types.CommonSchemaElements;
@@ -66,12 +66,12 @@
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus)
{
- if (value instanceof AttributeSyntax<?>)
+ if (value instanceof Syntax)
{
- String syntaxName = ((AttributeSyntax<?>)value).getName();
+ String syntaxName = ((Syntax)value).getName();
if (syntaxName == null)
{
- value = ((AttributeSyntax<?>)value).getOID();
+ value = ((Syntax)value).getOID();
}
else
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/SchemaLoader.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/SchemaLoader.java
index fb92b68..bb7e11d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/SchemaLoader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/SchemaLoader.java
@@ -35,7 +35,7 @@
import java.util.Arrays;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.config.ConfigConstants;
import org.forgerock.opendj.config.server.ConfigException;
@@ -69,8 +69,7 @@
new ArrayList<AttributeType>();
private final ArrayList<MatchingRule> matchingRulesToKeep =
new ArrayList<MatchingRule>();
- private final ArrayList<AttributeSyntax<?>> syntaxesToKeep =
- new ArrayList<AttributeSyntax<?>>();
+ private final ArrayList<Syntax> syntaxesToKeep = new ArrayList<>();
/**
* Constructor.
@@ -147,6 +146,7 @@
FileFilter ldifFiles = new FileFilter()
{
/** {@inheritDoc} */
+ @Override
public boolean accept(File f)
{
boolean accept = false;
@@ -202,7 +202,8 @@
// initialize the server schema.
for (String schemaFile : fileNames)
{
- SchemaConfigManager.loadSchemaFile(schema, schemaFile);
+ // no server context to pass
+ SchemaConfigManager.loadSchemaFile(null, schema, schemaFile);
}
}
@@ -221,7 +222,7 @@
{
schema.registerMatchingRule(mr, true);
}
- for (AttributeSyntax<?> syntax : syntaxesToKeep)
+ for (Syntax syntax : syntaxesToKeep)
{
schema.registerSyntax(syntax, true);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
index e66cf6f..865f5ab 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -123,8 +123,8 @@
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.ui.UIFactory;
import org.opends.quicksetup.util.Utils;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.ClassLoaderProvider;
-import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.ConfigHandler;
import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
@@ -2127,7 +2127,7 @@
* @param syntax the attribute syntax.
* @return the string representation of an attribute syntax.
*/
- public static String getSyntaxText(AttributeSyntax<?> syntax)
+ public static String getSyntaxText(Syntax syntax)
{
String syntaxName = syntax.getName();
String syntaxOID = syntax.getOID();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/AttributeSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/api/AttributeSyntax.java
index 1fa4a5a..5a1b7be 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/AttributeSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/AttributeSyntax.java
@@ -31,10 +31,14 @@
import java.util.List;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.core.ServerContext;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.InitializationException;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.schema.MatchingRule;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.i18n.LocalizableMessageBuilder;
/**
@@ -50,6 +54,7 @@
mayInstantiate=false,
mayExtend=true,
mayInvoke=false)
+@RemoveOnceSDKSchemaIsUsed("All descendants classes can be removed as well")
public abstract class AttributeSyntax<T extends AttributeSyntaxCfg>
{
/**
@@ -58,6 +63,8 @@
*
* @param configuration The configuration to use to initialize
* this attribute syntax.
+ * @param serverContext
+ * The server context.
*
* @throws ConfigException If an unrecoverable problem arises in
* the process of performing the
@@ -68,10 +75,25 @@
* related to the server
* configuration.
*/
- public abstract void initializeSyntax(T configuration)
- throws ConfigException, InitializationException;
+ public void initializeSyntax(T configuration, ServerContext serverContext)
+ throws ConfigException, InitializationException
+ {
+ // not implemented
+ }
-
+ /**
+ * Returns the SDK Syntax equivalent to this syntax.
+ * <p>
+ * This method allow smooth migration to SDK syntax. It will disappear
+ * once the the migration to SDK schema is complete, together with
+ * this class and all its implementation.
+ *
+ * @param schema
+ * Schema to use to retrieve the syntax
+ *
+ * @return the equivalent SDK syntax.
+ */
+ public abstract Syntax getSDKSyntax(Schema schema);
/**
* Indicates whether the provided configuration is acceptable for
@@ -151,7 +173,10 @@
* attributes with this syntax, or {@code null} if equality
* matches will not be allowed for this type by default.
*/
- public abstract MatchingRule getEqualityMatchingRule();
+ public MatchingRule getEqualityMatchingRule()
+ {
+ return null;
+ }
@@ -163,8 +188,10 @@
* attributes with this syntax, or {@code null} if ordering
* matches will not be allowed for this type by default.
*/
- public abstract MatchingRule getOrderingMatchingRule();
-
+ public MatchingRule getOrderingMatchingRule()
+ {
+ return null;
+ }
/**
@@ -176,8 +203,10 @@
* substring matches will not be allowed for this type by
* default.
*/
- public abstract MatchingRule getSubstringMatchingRule();
-
+ public MatchingRule getSubstringMatchingRule()
+ {
+ return null;
+ }
/**
@@ -189,7 +218,10 @@
* approximate matches will not be allowed for this type by
* default.
*/
- public abstract MatchingRule getApproximateMatchingRule();
+ public MatchingRule getApproximateMatchingRule()
+ {
+ return null;
+ }
@@ -206,8 +238,11 @@
* @return {@code true} if the provided value is acceptable for use
* with this syntax, or {@code false} if not.
*/
- public abstract boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason);
+ public boolean valueIsAcceptable(ByteSequence value,
+ LocalizableMessageBuilder invalidReason)
+ {
+ return true;
+ }
@@ -216,7 +251,10 @@
*
* @return {@code true} if this syntax required BER encoding.
*/
- public abstract boolean isBEREncodingRequired();
+ public boolean isBEREncodingRequired()
+ {
+ return true;
+ }
@@ -225,8 +263,10 @@
*
* @return {@code true} if this syntax is human readable.
*/
- public abstract boolean isHumanReadable();
-
+ public boolean isHumanReadable()
+ {
+ return true;
+ }
/**
@@ -235,6 +275,7 @@
*
* @return The hash code for this attribute syntax.
*/
+ @Override
public final int hashCode()
{
int hashCode = 0;
@@ -262,6 +303,7 @@
* @return {@code true} if the provided object is equal to this
* attribute syntax, or {@code false} if it is not.
*/
+ @Override
public final boolean equals(Object o)
{
if (this == o)
@@ -284,6 +326,7 @@
* @return A string representation of this attribute syntax in the
* format defined in RFC 2252.
*/
+ @Override
public String toString()
{
StringBuilder buffer = new StringBuilder();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
index 8456367..b7a97a5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -66,8 +66,11 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
+import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.SchemaBackendCfg;
import org.opends.server.api.AlertGenerator;
@@ -91,6 +94,7 @@
import org.opends.server.schema.MatchingRuleUseSyntax;
import org.opends.server.schema.NameFormSyntax;
import org.opends.server.schema.ObjectClassSyntax;
+import org.opends.server.schema.SchemaUpdater;
import org.opends.server.types.*;
import org.opends.server.util.BackupManager;
import org.opends.server.util.DynamicConstants;
@@ -233,7 +237,7 @@
*/
private String stripMinUpperBoundRegEx = "\\{\\d+\\}";
-
+ private ServerContext serverContext;
/**
* Creates a new backend with the provided information. All backend
@@ -251,6 +255,8 @@
@Override
public void configureBackend(SchemaBackendCfg cfg, ServerContext serverContext) throws ConfigException
{
+ this.serverContext = serverContext;
+
// Make sure that a configuration entry was provided. If not, then we will
// not be able to complete initialization.
if (cfg == null)
@@ -1007,7 +1013,7 @@
LDAPSyntaxDescription lsd;
try
{
- lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, newSchema, false);
+ lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, newSchema, false, false);
}
catch (DirectoryException de)
{
@@ -1182,7 +1188,7 @@
LDAPSyntaxDescription lsd;
try
{
- lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, newSchema, false);
+ lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, newSchema, false, true);
}
catch (DirectoryException de)
{
@@ -2814,7 +2820,7 @@
throws DirectoryException
{
//Check if there is an existing syntax with this oid.
- String oid = ldapSyntaxDesc.getLdapSyntaxDescriptionSyntax().getOID();
+ String oid = ldapSyntaxDesc.getSyntax().getOID();
// We allow only unimplemented syntaxes to be substituted.
if(schema.getSyntax(oid) !=null)
@@ -2825,8 +2831,9 @@
message);
}
- LDAPSyntaxDescription existingLSD =
- schema.getLdapSyntaxDescription(oid);
+ LDAPSyntaxDescription existingLSD = schema.getLdapSyntaxDescription(oid);
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ org.forgerock.opendj.ldap.schema.Schema newSchema = null;
// If there is no existing lsd, then we're adding a new ldapsyntax.
// Otherwise, we're replacing an existing one.
@@ -2834,14 +2841,23 @@
{
schema.registerLdapSyntaxDescription(ldapSyntaxDesc, false);
addNewSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc);
+
+ // update schema NG
+ newSchema = schemaUpdater.getSchemaBuilder().buildSyntax(ldapSyntaxDesc.getSyntax()).addToSchema().toSchema();
+ schemaUpdater.updateSchema(newSchema);
}
else
{
schema.deregisterLdapSyntaxDescription(existingLSD);
schema.registerLdapSyntaxDescription(ldapSyntaxDesc, false);
+ // update schema NG
+ SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder();
+ schemaBuilder.removeSyntax(oid);
+ newSchema = schemaBuilder.buildSyntax(ldapSyntaxDesc.getSyntax()).addToSchema().toSchema();
+ schemaUpdater.updateSchema(newSchema);
+
schema.rebuildDependentElements(existingLSD);
- replaceExistingSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc,
- existingLSD);
+ replaceExistingSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc, existingLSD);
}
}
@@ -2853,11 +2869,13 @@
Set<String> modifiedSchemaFiles)
throws DirectoryException
{
- //See if the specified ldap syntax description is actually defined in the
- //server schema. If not, then fail. Note that we are checking only the
- //real part of the ldapsyntaxes attribute. A virtual value is not searched
- // and hence never deleted.
- String oid = ldapSyntaxDesc.getLdapSyntaxDescriptionSyntax().getOID();
+ /*
+ * See if the specified ldap syntax description is actually defined in the
+ * server schema. If not, then fail. Note that we are checking only the real
+ * part of the ldapsyntaxes attribute. A virtual value is not searched and
+ * hence never deleted.
+ */
+ String oid = ldapSyntaxDesc.getSyntax().getOID();
LDAPSyntaxDescription removeLSD = schema.getLdapSyntaxDescription(oid);
if (removeLSD == null || !removeLSD.equals(ldapSyntaxDesc))
@@ -2867,6 +2885,12 @@
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
+ // update schema NG
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder();
+ schemaBuilder.removeSyntax(oid);
+ schemaUpdater.updateSchema(schemaBuilder.toSchema());
+
schema.deregisterLdapSyntaxDescription(removeLSD);
String schemaFile = getSchemaFile(removeLSD);
if (schemaFile != null)
@@ -3717,26 +3741,13 @@
TreeSet<String> modifiedSchemaFiles = new TreeSet<String>();
// Get the attributeTypes attribute from the entry.
- AttributeTypeSyntax attrTypeSyntax;
- try
+ Syntax attrTypeSyntax = schema.getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID);
+ if (attrTypeSyntax == null)
{
- attrTypeSyntax = (AttributeTypeSyntax)
- schema.getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID);
- if (attrTypeSyntax == null)
- {
- attrTypeSyntax = new AttributeTypeSyntax();
- attrTypeSyntax.initializeSyntax(null);
- }
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- attrTypeSyntax = new AttributeTypeSyntax();
+ attrTypeSyntax = CoreSchema.getAttributeTypeDescriptionSyntax();
}
- AttributeType attributeAttrType =
- schema.getAttributeType(ATTR_ATTRIBUTE_TYPES_LC);
+ AttributeType attributeAttrType = schema.getAttributeType(ATTR_ATTRIBUTE_TYPES_LC);
if (attributeAttrType == null)
{
attributeAttrType =
@@ -3822,21 +3833,10 @@
// loop on the objectClasses from the entry, search if they are
// already in the current schema, add them if not.
- ObjectClassSyntax ocSyntax;
- try
+ Syntax ocSyntax = schema.getSyntax(SYNTAX_OBJECTCLASS_OID);
+ if (ocSyntax == null)
{
- ocSyntax = (ObjectClassSyntax) schema.getSyntax(SYNTAX_OBJECTCLASS_OID);
- if (ocSyntax == null)
- {
- ocSyntax = new ObjectClassSyntax();
- ocSyntax.initializeSyntax(null);
- }
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- ocSyntax = new ObjectClassSyntax();
+ ocSyntax = CoreSchema.getObjectClassDescriptionSyntax();
}
AttributeType objectclassAttrType =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/DatabaseEnvironmentMonitor.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/DatabaseEnvironmentMonitor.java
index 5749e5f..d8d93ee 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/DatabaseEnvironmentMonitor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/DatabaseEnvironmentMonitor.java
@@ -33,8 +33,8 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.MonitorProviderCfg;
-import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MonitorProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
@@ -65,6 +65,7 @@
private long maxMatchingEntries = -1;
private final AtomicInteger hits = new AtomicInteger();
+ @Override
public int compareTo(FilterStats that) {
return this.hits.get() - that.hits.get();
}
@@ -122,6 +123,7 @@
/** {@inheritDoc} */
+ @Override
public void initializeMonitorProvider(MonitorProviderCfg configuration)
throws ConfigException, InitializationException
{
@@ -133,6 +135,7 @@
*
* @return The name of this monitor provider.
*/
+ @Override
public String getMonitorInstanceName()
{
return name;
@@ -166,8 +169,7 @@
Class<?> returnType = method.getReturnType();
if (returnType.equals(int.class) || returnType.equals(long.class))
{
- AttributeSyntax<?> integerSyntax =
- DirectoryServer.getDefaultIntegerSyntax();
+ Syntax integerSyntax = DirectoryServer.getDefaultIntegerSyntax();
// Remove the 'get' from the method name and add the prefix.
String attrName = attrPrefix + method.getName().substring(3);
@@ -201,6 +203,7 @@
* returned to the client if the corresponding monitor entry is
* requested.
*/
+ @Override
public List<Attribute> getMonitorData()
{
EnvironmentStats environmentStats = null;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java
index 5a33f6e..32f0d6d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.backends.task;
@@ -40,6 +40,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.ServerContext;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
@@ -124,10 +125,15 @@
private final boolean[] monthArray;
private final boolean[] weekdayArray;
+ private final ServerContext serverContext;
+
/**
* Creates a new recurring task based on the information in the provided
* entry.
*
+ * @param serverContext
+ * The server context.
+ *
* @param taskScheduler A reference to the task scheduler that may be
* used to schedule new tasks.
* @param recurringTaskEntry The entry containing the information to use to
@@ -136,9 +142,10 @@
* @throws DirectoryException If the provided entry does not contain a valid
* recurring task definition.
*/
- public RecurringTask(TaskScheduler taskScheduler, Entry recurringTaskEntry)
+ public RecurringTask(ServerContext serverContext, TaskScheduler taskScheduler, Entry recurringTaskEntry)
throws DirectoryException
{
+ this.serverContext = serverContext;
this.taskScheduler = taskScheduler;
this.recurringTaskEntry = recurringTaskEntry;
this.recurringTaskEntryDN = recurringTaskEntry.getName();
@@ -308,7 +315,7 @@
// provided entry.
try
{
- task.initializeTaskInternal(taskScheduler, recurringTaskEntry);
+ task.initializeTaskInternal(serverContext, taskScheduler, recurringTaskEntry);
}
catch (InitializationException ie)
{
@@ -422,7 +429,7 @@
taskStartTimeAttrType, nextTaskStartTime);
nextTaskEntry.replaceAttribute(nextTaskStartTimeAttr);
- nextTask.initializeTaskInternal(taskScheduler, nextTaskEntry);
+ nextTask.initializeTaskInternal(serverContext, taskScheduler, nextTaskEntry);
nextTask.initializeTask();
} catch (Exception e) {
// Should not happen, debug log it otherwise.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
index 6fdd5c3..e82a6bd 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
@@ -45,6 +45,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.messages.Severity;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.ServerContext;
import org.opends.server.types.*;
import org.opends.server.types.LockManager.DNLock;
import org.opends.server.util.EMailMessage;
@@ -137,6 +138,18 @@
/** The scheduler with which this task is associated. */
private TaskScheduler taskScheduler;
+ private ServerContext serverContext;
+
+ /**
+ * Returns the server context.
+ *
+ * @return the server context.
+ */
+ protected ServerContext getServerContext()
+ {
+ return serverContext;
+ }
+
/**
* Gets a message that identifies this type of task suitable for
* presentation to humans in monitoring tools.
@@ -170,16 +183,19 @@
* Performs generic initialization for this task based on the information in
* the provided task entry.
*
+ * @param serverContext
+ * The server context.
* @param taskScheduler The scheduler with which this task is associated.
* @param taskEntry The entry containing the task configuration.
*
* @throws InitializationException If a problem occurs while performing the
* initialization.
*/
- public final void initializeTaskInternal(TaskScheduler taskScheduler,
+ public final void initializeTaskInternal(ServerContext serverContext, TaskScheduler taskScheduler,
Entry taskEntry)
throws InitializationException
{
+ this.serverContext = serverContext;
this.taskScheduler = taskScheduler;
this.taskEntry = taskEntry;
this.taskEntryDN = taskEntry.getName();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java
index ac91490..38fb253 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java
@@ -122,7 +122,7 @@
*/
private TaskScheduler taskScheduler;
-
+ private ServerContext serverContext;
/**
* Creates a new backend with the provided information. All backend
@@ -143,6 +143,7 @@
public void configureBackend(TaskBackendCfg cfg, ServerContext serverContext) throws ConfigException
{
Reject.ifNull(cfg);
+ this.serverContext = serverContext;
final DN[] baseDNs = new DN[cfg.getBaseDN().size()];
cfg.getBaseDN().toArray(baseDNs);
@@ -238,7 +239,7 @@
throws ConfigException, InitializationException
{
// Create the scheduler and initialize it from the backing file.
- taskScheduler = new TaskScheduler(this);
+ taskScheduler = new TaskScheduler(serverContext, this);
taskScheduler.start();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java
index 28c80ff..41660e0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java
@@ -42,6 +42,7 @@
import org.opends.server.api.DirectoryThread;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
+import org.opends.server.core.ServerContext;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.*;
import org.opends.server.types.LockManager.DNLock;
@@ -127,23 +128,25 @@
/** The set of tasks that are currently running. */
private TreeSet<Task> runningTasks;
-
+ private ServerContext serverContext;
/**
* Creates a new task scheduler that will be used to ensure that tasks are
* invoked at the appropriate times.
- *
+ * @param serverContext
+ * The server context
* @param taskBackend The task backend with which this scheduler is
* associated.
*
* @throws InitializationException If a problem occurs while initializing
* the scheduler from the backing file.
*/
- public TaskScheduler(TaskBackend taskBackend)
+ public TaskScheduler(ServerContext serverContext, TaskBackend taskBackend)
throws InitializationException
{
super("Task Scheduler Thread");
+ this.serverContext = serverContext;
this.taskBackend = taskBackend;
@@ -1898,7 +1901,7 @@
// Perform the necessary internal and external initialization for the task.
try
{
- task.initializeTaskInternal(this, entry);
+ task.initializeTaskInternal(serverContext, this, entry);
}
catch (InitializationException ie)
{
@@ -1949,7 +1952,7 @@
public RecurringTask entryToRecurringTask(Entry entry)
throws DirectoryException
{
- return new RecurringTask(this, entry);
+ return new RecurringTask(serverContext, this, entry);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java
index ce5a19c..96478fd 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/BooleanConfigAttribute.java
@@ -37,7 +37,7 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanParameterInfo;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.forgerock.opendj.ldap.ByteString;
@@ -164,7 +164,7 @@
*
* @return The attribute syntax for this configuration attribute.
*/
- public AttributeSyntax<?> getSyntax()
+ public Syntax getSyntax()
{
return DirectoryServer.getDefaultBooleanSyntax();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java
index faaf8e2..1891782 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java
@@ -36,7 +36,7 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanParameterInfo;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.types.Attribute;
import org.forgerock.opendj.ldap.ByteString;
@@ -274,7 +274,7 @@
*
* @return The attribute syntax for this configuration attribute.
*/
- public abstract AttributeSyntax<?> getSyntax();
+ public abstract Syntax getSyntax();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
index 8c90629..d45f7b6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
@@ -37,7 +37,7 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanParameterInfo;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
@@ -233,7 +233,7 @@
*
* @return The attribute syntax for this configuration attribute.
*/
- public AttributeSyntax<?> getSyntax()
+ public Syntax getSyntax()
{
return DirectoryServer.getDefaultStringSyntax();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
index c3c8de5..22036e2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
@@ -37,7 +37,7 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanParameterInfo;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
@@ -307,7 +307,7 @@
*
* @return The attribute syntax for this configuration attribute.
*/
- public AttributeSyntax<?> getSyntax()
+ public Syntax getSyntax()
{
return DirectoryServer.getDefaultIntegerSyntax();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java
index 894be75..e293e32 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerWithUnitConfigAttribute.java
@@ -39,7 +39,7 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanParameterInfo;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
@@ -307,7 +307,7 @@
*
* @return The attribute syntax for this configuration attribute.
*/
- public AttributeSyntax<?> getSyntax()
+ public Syntax getSyntax()
{
return DirectoryServer.getDefaultStringSyntax();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
index 3471af1..f5ba3ee 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
@@ -37,7 +37,7 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanParameterInfo;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
@@ -271,7 +271,7 @@
*
* @return The attribute syntax for this configuration attribute.
*/
- public AttributeSyntax<?> getSyntax()
+ public Syntax getSyntax()
{
return DirectoryServer.getDefaultStringSyntax();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/ReadOnlyConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/ReadOnlyConfigAttribute.java
index 1cb23f6..751bd09 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/ReadOnlyConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/ReadOnlyConfigAttribute.java
@@ -35,7 +35,7 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanParameterInfo;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.forgerock.opendj.ldap.ByteString;
@@ -152,7 +152,7 @@
*
* @return The attribute syntax for this configuration attribute.
*/
- public AttributeSyntax<?> getSyntax()
+ public Syntax getSyntax()
{
return DirectoryServer.getDefaultStringSyntax();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
index 62f5a55..b3b7b0f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
@@ -37,7 +37,7 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanParameterInfo;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
@@ -238,7 +238,7 @@
*
* @return The attribute syntax for this configuration attribute.
*/
- public AttributeSyntax<?> getSyntax()
+ public Syntax getSyntax()
{
return DirectoryServer.getDefaultStringSyntax();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/controls/MatchedValuesFilter.java b/opendj-server-legacy/src/main/java/org/opends/server/controls/MatchedValuesFilter.java
index 89bf599..1226920 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/controls/MatchedValuesFilter.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/controls/MatchedValuesFilter.java
@@ -954,8 +954,11 @@
{
try
{
- substringAssertion =
- getSubstringMatchingRule().getSubstringAssertion(subInitial, subAny, subFinal);
+ MatchingRule rule = getSubstringMatchingRule();
+ if (rule != null)
+ {
+ substringAssertion = rule.getSubstringAssertion(subInitial, subAny, subFinal);
+ }
}
catch (DecodeException e)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/AttributeSyntaxConfigManager.java b/opendj-server-legacy/src/main/java/org/opends/server/core/AttributeSyntaxConfigManager.java
index 7800951..a08130f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/AttributeSyntaxConfigManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/AttributeSyntaxConfigManager.java
@@ -48,6 +48,7 @@
import org.opends.server.api.AttributeSyntax;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
@@ -129,12 +130,11 @@
String className = syntaxConfiguration.getJavaClass();
try
{
- AttributeSyntax syntax = loadSyntax(className, syntaxConfiguration,
- true);
-
+ AttributeSyntax<?> syntax = loadSyntax(className, syntaxConfiguration, true);
try
{
- serverContext.getSchema().registerSyntax(syntax, false);
+ Syntax sdkSyntax = syntax.getSDKSyntax(serverContext.getSchemaNG());
+ serverContext.getSchema().registerSyntax(sdkSyntax, false);
syntaxes.put(syntaxConfiguration.dn(), syntax);
}
catch (DirectoryException de)
@@ -207,7 +207,8 @@
try
{
- serverContext.getSchema().registerSyntax(syntax, false);
+ Syntax sdkSyntax = syntax.getSDKSyntax(serverContext.getSchemaNG());
+ serverContext.getSchema().registerSyntax(sdkSyntax, false);
syntaxes.put(configuration.dn(), syntax);
}
catch (DirectoryException de)
@@ -267,10 +268,11 @@
{
final ConfigChangeResult ccr = new ConfigChangeResult();
- AttributeSyntax syntax = syntaxes.remove(configuration.dn());
+ AttributeSyntax<?> syntax = syntaxes.remove(configuration.dn());
if (syntax != null)
{
- serverContext.getSchema().deregisterSyntax(syntax);
+ Syntax sdkSyntax = syntax.getSDKSyntax(serverContext.getSchemaNG());
+ serverContext.getSchema().deregisterSyntax(sdkSyntax);
syntax.finalizeSyntax();
}
@@ -304,7 +306,7 @@
{
// If the syntax is currently enabled and the change would make it
// disabled, then only allow it if the syntax isn't already in use.
- AttributeSyntax syntax = syntaxes.get(configuration.dn());
+ AttributeSyntax<?> syntax = syntaxes.get(configuration.dn());
if (syntax != null)
{
String oid = syntax.getOID();
@@ -313,9 +315,7 @@
if (oid.equals(at.getSyntax().getOID()))
{
LocalizableMessage message =
- WARN_CONFIG_SCHEMA_CANNOT_DISABLE_SYNTAX_IN_USE.get(
- syntax.getName(),
- at.getNameOrOID());
+ WARN_CONFIG_SCHEMA_CANNOT_DISABLE_SYNTAX_IN_USE.get(syntax.getName(), at.getNameOrOID());
unacceptableReasons.add(message);
return false;
}
@@ -331,14 +331,13 @@
/** {@inheritDoc} */
@Override
- public ConfigChangeResult applyConfigurationChange(
- AttributeSyntaxCfg configuration)
+ public ConfigChangeResult applyConfigurationChange(AttributeSyntaxCfg configuration)
{
final ConfigChangeResult ccr = new ConfigChangeResult();
// Get the existing syntax if it's already enabled.
- AttributeSyntax existingSyntax = syntaxes.get(configuration.dn());
+ AttributeSyntax<?> existingSyntax = syntaxes.get(configuration.dn());
// If the new configuration has the syntax disabled, then disable it if it
@@ -347,9 +346,9 @@
{
if (existingSyntax != null)
{
- serverContext.getSchema().deregisterSyntax(existingSyntax);
-
- AttributeSyntax syntax = syntaxes.remove(configuration.dn());
+ Syntax sdkSyntax = existingSyntax.getSDKSyntax(serverContext.getSchemaNG());
+ serverContext.getSchema().deregisterSyntax(sdkSyntax);
+ AttributeSyntax<?> syntax = syntaxes.remove(configuration.dn());
if (syntax != null)
{
syntax.finalizeSyntax();
@@ -376,14 +375,15 @@
return ccr;
}
- AttributeSyntax syntax = null;
+ AttributeSyntax<?> syntax = null;
try
{
syntax = loadSyntax(className, configuration, true);
try
{
- serverContext.getSchema().registerSyntax(syntax, false);
+ Syntax sdkSyntax = syntax.getSDKSyntax(serverContext.getSchemaNG());
+ serverContext.getSchema().registerSyntax(sdkSyntax, false);
syntaxes.put(configuration.dn(), syntax);
}
catch (DirectoryException de)
@@ -420,7 +420,7 @@
* @throws InitializationException If a problem occurred while attempting to
* initialize the attribute syntax.
*/
- private AttributeSyntax loadSyntax(String className,
+ private AttributeSyntax<?> loadSyntax(String className,
AttributeSyntaxCfg configuration,
boolean initialize)
throws InitializationException
@@ -437,7 +437,7 @@
if (initialize)
{
- syntax.initializeSyntax(configuration);
+ syntax.initializeSyntax(configuration, serverContext);
}
else
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/CoreConfigManager.java b/opendj-server-legacy/src/main/java/org/opends/server/core/CoreConfigManager.java
index ec61016..1d7971b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/CoreConfigManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/CoreConfigManager.java
@@ -32,6 +32,9 @@
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+import org.forgerock.opendj.ldap.schema.SchemaOptions;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ServerManagementContext;
import org.opends.server.admin.std.meta.GlobalCfgDefn;
@@ -41,6 +44,7 @@
import org.opends.server.admin.std.server.GlobalCfg;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.api.AuthenticationPolicy;
+import org.opends.server.schema.SchemaUpdater;
import org.opends.server.types.*;
import static org.opends.messages.ConfigMessages.*;
@@ -117,7 +121,7 @@
// Apply the configuration to the server.
- applyGlobalConfiguration(globalConfig);
+ applyGlobalConfiguration(globalConfig, serverContext);
}
@@ -127,7 +131,7 @@
*
* @param globalConfig The configuration settings to be applied.
*/
- private static void applyGlobalConfiguration(GlobalCfg globalConfig)
+ private static void applyGlobalConfiguration(GlobalCfg globalConfig, ServerContext serverContext)
{
setCheckSchema(globalConfig.isCheckSchema());
setDefaultPasswordPolicyDN(globalConfig.getDefaultPasswordPolicyDN());
@@ -157,6 +161,18 @@
setMaxAllowedConnections(globalConfig.getMaxAllowedClientConnections());
setMaxPersistentSearchLimit(globalConfig.getMaxPsearches());
setMaxInternalBufferSize((int) globalConfig.getMaxInternalBufferSize());
+
+ // Update the "new" schema with configuration changes
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder();
+ boolean allowMalformedNames = globalConfig.isAllowAttributeNameExceptions();
+ schemaBuilder.setOption(SchemaOptions.ALLOW_MALFORMED_NAMES_AND_OPTIONS, allowMalformedNames);
+ Schema schema = schemaBuilder.toSchema();
+ if (!globalConfig.isCheckSchema())
+ {
+ schema = schema.asNonStrictSchema();
+ }
+ schemaUpdater.updateSchema(schema);
}
private static AcceptRejectWarn convert(InvalidAttributeSyntaxBehavior invalidAttributeSyntaxBehavior)
@@ -354,7 +370,7 @@
{
final ConfigChangeResult ccr = new ConfigChangeResult();
- applyGlobalConfiguration(configuration);
+ applyGlobalConfiguration(configuration, serverContext);
return ccr;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
index 61b0672..f6ff265 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -69,6 +69,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
@@ -79,10 +80,8 @@
import org.opends.server.admin.ClassLoaderProvider;
import org.opends.server.admin.server.ServerManagementContext;
import org.opends.server.admin.std.server.AlertHandlerCfg;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.admin.std.server.ConnectionHandlerCfg;
import org.opends.server.admin.std.server.CryptoManagerCfg;
-import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg;
import org.opends.server.admin.std.server.MonitorProviderCfg;
import org.opends.server.admin.std.server.PasswordValidatorCfg;
import org.opends.server.admin.std.server.RootCfg;
@@ -92,7 +91,7 @@
import org.opends.server.api.AccountStatusNotificationHandler;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.AlertHandler;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.Backend;
import org.opends.server.api.BackendInitializationListener;
@@ -151,10 +150,7 @@
import org.opends.server.monitors.ConnectionHandlerMonitor;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalConnectionHandler;
-import org.opends.server.schema.AttributeTypeSyntax;
-import org.opends.server.schema.BinarySyntax;
import org.opends.server.schema.BooleanEqualityMatchingRuleFactory;
-import org.opends.server.schema.BooleanSyntax;
import org.opends.server.schema.CaseExactEqualityMatchingRuleFactory;
import org.opends.server.schema.CaseExactIA5EqualityMatchingRuleFactory;
import org.opends.server.schema.CaseExactIA5SubstringMatchingRuleFactory;
@@ -165,19 +161,12 @@
import org.opends.server.schema.CaseIgnoreIA5SubstringMatchingRuleFactory;
import org.opends.server.schema.CaseIgnoreOrderingMatchingRuleFactory;
import org.opends.server.schema.CaseIgnoreSubstringMatchingRuleFactory;
-import org.opends.server.schema.DirectoryStringSyntax;
import org.opends.server.schema.DistinguishedNameEqualityMatchingRuleFactory;
-import org.opends.server.schema.DistinguishedNameSyntax;
import org.opends.server.schema.DoubleMetaphoneApproximateMatchingRuleFactory;
import org.opends.server.schema.GeneralizedTimeEqualityMatchingRuleFactory;
import org.opends.server.schema.GeneralizedTimeOrderingMatchingRuleFactory;
-import org.opends.server.schema.GeneralizedTimeSyntax;
-import org.opends.server.schema.IA5StringSyntax;
import org.opends.server.schema.IntegerEqualityMatchingRuleFactory;
import org.opends.server.schema.IntegerOrderingMatchingRuleFactory;
-import org.opends.server.schema.IntegerSyntax;
-import org.opends.server.schema.OIDSyntax;
-import org.opends.server.schema.ObjectClassSyntax;
import org.opends.server.schema.ObjectIdentifierEqualityMatchingRuleFactory;
import org.opends.server.schema.OctetStringEqualityMatchingRuleFactory;
import org.opends.server.schema.OctetStringOrderingMatchingRuleFactory;
@@ -185,7 +174,6 @@
import org.opends.server.schema.SchemaUpdater;
import org.opends.server.schema.TelephoneNumberEqualityMatchingRuleFactory;
import org.opends.server.schema.TelephoneNumberSubstringMatchingRuleFactory;
-import org.opends.server.schema.TelephoneNumberSyntax;
import org.opends.server.tools.ConfigureWindowsService;
import org.opends.server.types.AcceptRejectWarn;
import org.opends.server.types.AttributeType;
@@ -212,8 +200,11 @@
import org.opends.server.types.Schema;
import org.opends.server.types.VirtualAttributeRule;
import org.opends.server.types.WritabilityMode;
+import org.opends.server.util.ActivateOnceNewConfigFrameworkIsUsed;
+import org.opends.server.util.ActivateOnceSDKSchemaIsUsed;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.MultiOutputStream;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.opends.server.util.RuntimeInformation;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.TimeThread;
@@ -308,18 +299,18 @@
private AccountStatusNotificationHandlerConfigManager accountStatusNotificationHandlerConfigManager;
/** The default syntax to use for binary attributes. */
- private AttributeSyntax<AttributeSyntaxCfg> defaultBinarySyntax;
+ private Syntax defaultBinarySyntax;
/** The default syntax to use for Boolean attributes. */
- private AttributeSyntax<AttributeSyntaxCfg> defaultBooleanSyntax;
+ private Syntax defaultBooleanSyntax;
/** The default syntax to use for DN attributes. */
- private AttributeSyntax<AttributeSyntaxCfg> defaultDNSyntax;
+ private Syntax defaultDNSyntax;
/** The default syntax to use for integer attributes. */
- private AttributeSyntax<AttributeSyntaxCfg> defaultIntegerSyntax;
+ private Syntax defaultIntegerSyntax;
/** The default syntax to use for string attributes. */
- private AttributeSyntax<DirectoryStringAttributeSyntaxCfg> defaultStringSyntax;
+ private Syntax defaultStringSyntax;
/** The default attribute syntax to use for attributes with no defined syntax. */
- private AttributeSyntax<DirectoryStringAttributeSyntaxCfg> defaultSyntax;
+ private Syntax defaultSyntax;
/** The attribute type used to reference the "objectclass" attribute. */
private AttributeType objectClassAttributeType;
/** The authenticated users manager for the server. */
@@ -721,8 +712,17 @@
/** The schema for the Directory Server. */
private Schema schema;
- /** The schema for the Directory Server. */
- // TODO : temporary field to be removed once old schema is completely removed
+ /**
+ * The schema for the Directory Server.
+ * <p>
+ * This schema is synchronized indirectly to the existing schema, because
+ * syntaxes are defined in schemaNG (i.e, migrated to SDK classes) and there
+ * is currently no way to handle the SchemaOptions in the configuration (e.g.
+ * SchemaOptions.ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS).
+ * Thus, configuration of the legacy syntaxes are kept, and any change related
+ * to them is synchronized with this schema.
+ */
+ @RemoveOnceSDKSchemaIsUsed("'schema' field will then be a reference to a SDK schema")
private org.forgerock.opendj.ldap.schema.Schema schemaNG;
/** The schema configuration manager for the Directory Server. */
@@ -867,6 +867,13 @@
/** {@inheritDoc} */
@Override
+ public org.forgerock.opendj.ldap.schema.Schema getSchemaNG()
+ {
+ return directoryServer.schemaNG;
+ }
+
+ /** {@inheritDoc} */
+ @Override
public DirectoryEnvironmentConfig getEnvironment()
{
return directoryServer.environmentConfig;
@@ -879,9 +886,9 @@
return new SchemaUpdater()
{
@Override
- public boolean updateSchema(SchemaBuilder schemaBuilder)
+ public boolean updateSchema(org.forgerock.opendj.ldap.schema.Schema schema)
{
- schemaNG = schemaBuilder.toSchema();
+ schemaNG = schema;
return true;
}
@@ -1040,8 +1047,7 @@
/**
* Bootstraps the appropriate Directory Server structures that may be needed
- * by client-side tools. This is not intended for use in running the server
- * itself.
+ * by both server and client-side tools.
*/
public static void bootstrapClient()
{
@@ -1056,6 +1062,7 @@
// Create the server schema and initialize and register a minimal set of
// matching rules and attribute syntaxes.
directoryServer.schema = new Schema();
+ directoryServer.schemaNG = new SchemaBuilder("mainSchema").addSchema(CoreSchema.getInstance(), true).toSchema();
directoryServer.bootstrapMatchingRules();
directoryServer.bootstrapAttributeSyntaxes();
@@ -1283,7 +1290,7 @@
}
/**
- * Initialize this server.
+ * Initializes this server.
* <p>
* Initialization involves the following steps:
* <ul>
@@ -1292,6 +1299,8 @@
* </ul>
* @throws InitializationException
*/
+ @ActivateOnceNewConfigFrameworkIsUsed("it will need adaptation to be activated before sdk schema is ready")
+ @ActivateOnceSDKSchemaIsUsed
private void initializeNG() throws InitializationException
{
serverManagementContext = ConfigurationBootstrapper.bootstrap(serverContext);
@@ -1305,6 +1314,7 @@
/**
* Initialize the schema of this server.
*/
+ @ActivateOnceSDKSchemaIsUsed
private void initializeSchemaNG() throws InitializationException
{
SchemaHandler schemaHandler = new SchemaHandler();
@@ -1728,41 +1738,42 @@
*/
private void bootstrapAttributeSyntaxes()
{
- initAndRegister(new AttributeTypeSyntax());
- defaultBinarySyntax = initAndRegister(new BinarySyntax());
- defaultBooleanSyntax = initAndRegister(new BooleanSyntax());
- defaultStringSyntax = initAndRegister(new DirectoryStringSyntax());
+ defaultBinarySyntax = CoreSchema.getBinarySyntax();
+ defaultBooleanSyntax = CoreSchema.getBooleanSyntax();
+ defaultStringSyntax = CoreSchema.getDirectoryStringSyntax();
+ defaultDNSyntax = CoreSchema.getDNSyntax();
+ defaultIntegerSyntax = CoreSchema.getIntegerSyntax();
defaultSyntax = defaultStringSyntax;
schema.registerDefaultSyntax(defaultSyntax);
- defaultDNSyntax = initAndRegister(new DistinguishedNameSyntax());
- initAndRegister(new IA5StringSyntax());
- defaultIntegerSyntax = initAndRegister(new IntegerSyntax());
- initAndRegister(new GeneralizedTimeSyntax());
- initAndRegister(new ObjectClassSyntax());
- initAndRegister(new OIDSyntax());
- initAndRegister(new TelephoneNumberSyntax());
+
+ Syntax[] syntaxes = {
+ defaultBinarySyntax, defaultBooleanSyntax, defaultStringSyntax, defaultDNSyntax, defaultIntegerSyntax,
+ CoreSchema.getAttributeTypeDescriptionSyntax(),
+ CoreSchema.getIA5StringSyntax(),
+ CoreSchema.getGeneralizedTimeSyntax(),
+ CoreSchema.getObjectClassDescriptionSyntax(),
+ CoreSchema.getOIDSyntax(),
+ CoreSchema.getTelephoneNumberSyntax()
+ };
+ for (Syntax syntax : syntaxes)
+ {
+ registerSyntax(syntax);
+ }
}
-
- private <T extends AttributeSyntaxCfg> AttributeSyntax<T> initAndRegister(
- AttributeSyntax<T> syntax)
+ private Syntax registerSyntax(Syntax syntax)
{
try
{
- syntax.initializeSyntax(null);
- directoryServer.schema.registerSyntax(syntax, true);
+ schema.registerSyntax(syntax, true);
}
catch (Exception e)
{
- logger.traceException(e);
- logger.error(ERR_CANNOT_BOOTSTRAP_SYNTAX, syntax.getClass().getName(),
- stackTraceToSingleLineString(e));
+ logger.error(ERR_CANNOT_BOOTSTRAP_SYNTAX, syntax.getClass().getName(), stackTraceToSingleLineString(e));
}
return syntax;
}
-
-
/**
* Retrieves the authenticated users manager for the Directory Server.
*
@@ -2988,14 +2999,12 @@
if (directoryServer.objectClassAttributeType == null)
{
- AttributeSyntax oidSyntax =
- directoryServer.schema.getSyntax(SYNTAX_OID_NAME);
+ Syntax oidSyntax = directoryServer.schema.getSyntax(SYNTAX_OID_NAME);
if (oidSyntax == null)
{
try
{
- OIDSyntax newOIDSyntax = new OIDSyntax();
- newOIDSyntax.initializeSyntax(null);
+ Syntax newOIDSyntax = CoreSchema.getOIDSyntax();
oidSyntax = newOIDSyntax;
directoryServer.schema.registerSyntax(oidSyntax, true);
}
@@ -3061,8 +3070,7 @@
*
* @return The constructed attribute type definition.
*/
- public static AttributeType getDefaultAttributeType(String name,
- AttributeSyntax syntax)
+ public static AttributeType getDefaultAttributeType(String name, Syntax syntax)
{
String oid = toLowerCase(name) + "-oid";
String definition = "( " + oid + " NAME '" + name + "' SYNTAX " +
@@ -3082,8 +3090,7 @@
*
* @return The set of attribute syntaxes defined in the Directory Server.
*/
- public static ConcurrentMap<String,
- AttributeSyntax<?>> getAttributeSyntaxes()
+ public static ConcurrentMap<String, Syntax> getAttributeSyntaxes()
{
return directoryServer.schema.getSyntaxes();
}
@@ -3095,7 +3102,7 @@
* @return The default attribute syntax that should be used for attributes
* that are not defined in the server schema.
*/
- public static AttributeSyntax getDefaultAttributeSyntax()
+ public static Syntax getDefaultAttributeSyntax()
{
return directoryServer.defaultSyntax;
}
@@ -3111,7 +3118,7 @@
* that are not defined in the server schema and are meant to store
* binary values.
*/
- public static AttributeSyntax getDefaultBinarySyntax()
+ public static Syntax getDefaultBinarySyntax()
{
return directoryServer.defaultBinarySyntax;
}
@@ -3127,7 +3134,7 @@
* that are not defined in the server schema and are meant to store
* Boolean values.
*/
- public static AttributeSyntax getDefaultBooleanSyntax()
+ public static Syntax getDefaultBooleanSyntax()
{
return directoryServer.defaultBooleanSyntax;
}
@@ -3142,7 +3149,7 @@
* that are not defined in the server schema and are meant to store
* DN values.
*/
- public static AttributeSyntax getDefaultDNSyntax()
+ public static Syntax getDefaultDNSyntax()
{
return directoryServer.defaultDNSyntax;
}
@@ -3158,7 +3165,7 @@
* that are not defined in the server schema and are meant to store
* integer values.
*/
- public static AttributeSyntax getDefaultIntegerSyntax()
+ public static Syntax getDefaultIntegerSyntax()
{
return directoryServer.defaultIntegerSyntax;
}
@@ -3174,7 +3181,7 @@
* that are not defined in the server schema and are meant to store
* string values.
*/
- public static AttributeSyntax getDefaultStringSyntax()
+ public static Syntax getDefaultStringSyntax()
{
return directoryServer.defaultStringSyntax;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java b/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java
index 58f2652..635cead 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java
@@ -38,7 +38,9 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
+import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.schema.*;
import org.opends.server.types.*;
import org.opends.server.util.LDIFReader;
@@ -298,7 +300,7 @@
// from that entry and parse them to initialize the server schema.
for (String schemaFile : fileNames)
{
- loadSchemaFile(schema, schemaFile, false);
+ loadSchemaFile(serverContext, schema, schemaFile, false);
}
}
@@ -307,6 +309,9 @@
/**
* Loads the contents of the specified schema file into the provided schema.
*
+ * @param serverContext
+ * The server context.
+ *
* @param schema The schema in which the contents of the schema file are
* to be loaded.
* @param schemaFile The name of the schema file to be loaded into the
@@ -322,11 +327,10 @@
* the schema elements that is not related
* to the server configuration.
*/
- public static List<Modification> loadSchemaFile(Schema schema,
- String schemaFile)
+ public static List<Modification> loadSchemaFile(ServerContext serverContext, Schema schema, String schemaFile)
throws ConfigException, InitializationException
{
- return loadSchemaFile(schema, schemaFile, true);
+ return loadSchemaFile(serverContext, schema, schemaFile, true);
}
@@ -356,10 +360,8 @@
* the schema elements that is not related
* to the server configuration.
*/
- private static List<Modification> loadSchemaFile(Schema schema,
- String schemaFile,
- boolean failOnError)
- throws ConfigException, InitializationException
+ private static List<Modification> loadSchemaFile(ServerContext serverContext, Schema schema, String schemaFile,
+ boolean failOnError) throws ConfigException, InitializationException
{
// Create an LDIF reader to use when reading the files.
String schemaDirPath = getSchemaDirectoryPath();
@@ -465,7 +467,7 @@
}
}
- parseLdapSyntaxesDefinitions(schema, schemaFile, failOnError,
+ parseLdapSyntaxesDefinitions(serverContext, schema, schemaFile, failOnError,
ldapSyntaxList);
parseAttributeTypeDefinitions(schema, schemaFile, failOnError, attrList);
parseObjectclassDefinitions(schema, schemaFile, failOnError, ocList);
@@ -480,27 +482,13 @@
private static List<Attribute> getLdapSyntaxesAttributes(Schema schema,
Entry entry, List<Modification> mods) throws ConfigException
{
- LDAPSyntaxDescriptionSyntax ldapSyntax;
- try
+ Syntax syntax = schema.getSyntax(SYNTAX_LDAP_SYNTAX_OID);
+ if (syntax == null)
{
- ldapSyntax = (LDAPSyntaxDescriptionSyntax) schema.getSyntax(
- SYNTAX_LDAP_SYNTAX_OID);
- if (ldapSyntax == null)
- {
- ldapSyntax = new LDAPSyntaxDescriptionSyntax();
- ldapSyntax.initializeSyntax(null);
- }
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- ldapSyntax = new LDAPSyntaxDescriptionSyntax();
- ldapSyntax.initializeSyntax(null);
+ syntax = CoreSchema.getLDAPSyntaxDescriptionSyntax();
}
- AttributeType ldapSyntaxAttrType = getAttributeType(
- schema, ATTR_LDAP_SYNTAXES, ATTR_LDAP_SYNTAXES_LC, ldapSyntax);
+ AttributeType ldapSyntaxAttrType = getAttributeType(schema, ATTR_LDAP_SYNTAXES, ATTR_LDAP_SYNTAXES_LC, syntax);
return createAddModifications(entry, mods, ldapSyntaxAttrType);
}
@@ -508,27 +496,13 @@
Entry entry, List<Modification> mods) throws ConfigException,
InitializationException
{
- AttributeTypeSyntax attrTypeSyntax;
- try
+ Syntax syntax = schema.getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID);
+ if (syntax == null)
{
- attrTypeSyntax = (AttributeTypeSyntax)
- schema.getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID);
- if (attrTypeSyntax == null)
- {
- attrTypeSyntax = new AttributeTypeSyntax();
- attrTypeSyntax.initializeSyntax(null);
- }
+ syntax = CoreSchema.getAttributeTypeDescriptionSyntax();
}
- catch (Exception e)
- {
- logger.traceException(e);
-
- attrTypeSyntax = new AttributeTypeSyntax();
- attrTypeSyntax.initializeSyntax(null);
- }
-
AttributeType attributeAttrType = getAttributeType(
- schema, ATTR_ATTRIBUTE_TYPES, ATTR_ATTRIBUTE_TYPES_LC, attrTypeSyntax);
+ schema, ATTR_ATTRIBUTE_TYPES, ATTR_ATTRIBUTE_TYPES_LC, syntax);
return createAddModifications(entry, mods, attributeAttrType);
}
@@ -537,26 +511,12 @@
Entry entry, List<Modification> mods) throws ConfigException,
InitializationException
{
- ObjectClassSyntax ocSyntax;
- try
+ Syntax syntax = schema.getSyntax(SYNTAX_OBJECTCLASS_OID);
+ if (syntax == null)
{
- ocSyntax = (ObjectClassSyntax) schema.getSyntax(SYNTAX_OBJECTCLASS_OID);
- if (ocSyntax == null)
- {
- ocSyntax = new ObjectClassSyntax();
- ocSyntax.initializeSyntax(null);
- }
+ syntax = CoreSchema.getObjectClassDescriptionSyntax();
}
- catch (Exception e)
- {
- logger.traceException(e);
-
- ocSyntax = new ObjectClassSyntax();
- ocSyntax.initializeSyntax(null);
- }
-
- AttributeType objectclassAttrType = getAttributeType(
- schema, ATTR_OBJECTCLASSES, ATTR_OBJECTCLASSES_LC, ocSyntax);
+ AttributeType objectclassAttrType = getAttributeType(schema, ATTR_OBJECTCLASSES, ATTR_OBJECTCLASSES_LC, syntax);
return createAddModifications(entry, mods, objectclassAttrType);
}
@@ -565,26 +525,13 @@
Entry entry, List<Modification> mods) throws ConfigException,
InitializationException
{
- NameFormSyntax nfSyntax;
- try
+ Syntax syntax = schema.getSyntax(SYNTAX_NAME_FORM_OID);
+ if (syntax == null)
{
- nfSyntax = (NameFormSyntax) schema.getSyntax(SYNTAX_NAME_FORM_OID);
- if (nfSyntax == null)
- {
- nfSyntax = new NameFormSyntax();
- nfSyntax.initializeSyntax(null);
- }
+ syntax = CoreSchema.getNameFormDescriptionSyntax();
}
- catch (Exception e)
- {
- logger.traceException(e);
-
- nfSyntax = new NameFormSyntax();
- nfSyntax.initializeSyntax(null);
- }
-
AttributeType nameFormAttrType = getAttributeType(
- schema, ATTR_NAME_FORMS, ATTR_NAME_FORMS_LC, nfSyntax);
+ schema, ATTR_NAME_FORMS, ATTR_NAME_FORMS_LC, syntax);
return createAddModifications(entry, mods, nameFormAttrType);
}
@@ -593,27 +540,13 @@
Entry entry, List<Modification> mods) throws ConfigException,
InitializationException
{
- DITContentRuleSyntax dcrSyntax;
- try
+ Syntax syntax = schema.getSyntax(SYNTAX_DIT_CONTENT_RULE_OID);
+ if (syntax == null)
{
- dcrSyntax = (DITContentRuleSyntax)
- schema.getSyntax(SYNTAX_DIT_CONTENT_RULE_OID);
- if (dcrSyntax == null)
- {
- dcrSyntax = new DITContentRuleSyntax();
- dcrSyntax.initializeSyntax(null);
- }
+ syntax = CoreSchema.getDITContentRuleDescriptionSyntax();
}
- catch (Exception e)
- {
- logger.traceException(e);
-
- dcrSyntax = new DITContentRuleSyntax();
- dcrSyntax.initializeSyntax(null);
- }
-
AttributeType dcrAttrType = getAttributeType(
- schema, ATTR_DIT_CONTENT_RULES, ATTR_DIT_CONTENT_RULES_LC, dcrSyntax);
+ schema, ATTR_DIT_CONTENT_RULES, ATTR_DIT_CONTENT_RULES_LC, syntax);
return createAddModifications(entry, mods, dcrAttrType);
}
@@ -622,27 +555,12 @@
Entry entry, List<Modification> mods) throws ConfigException,
InitializationException
{
- DITStructureRuleSyntax dsrSyntax;
- try
+ Syntax syntax = schema.getSyntax(SYNTAX_DIT_STRUCTURE_RULE_OID);
+ if (syntax == null)
{
- dsrSyntax = (DITStructureRuleSyntax)
- schema.getSyntax(SYNTAX_DIT_STRUCTURE_RULE_OID);
- if (dsrSyntax == null)
- {
- dsrSyntax = new DITStructureRuleSyntax();
- dsrSyntax.initializeSyntax(null);
- }
+ syntax = CoreSchema.getDITStructureRuleDescriptionSyntax();
}
- catch (Exception e)
- {
- logger.traceException(e);
-
- dsrSyntax = new DITStructureRuleSyntax();
- dsrSyntax.initializeSyntax(null);
- }
-
- AttributeType dsrAttrType = getAttributeType(
- schema, ATTR_DIT_STRUCTURE_RULES, ATTR_DIT_STRUCTURE_RULES_LC, dsrSyntax);
+ AttributeType dsrAttrType = getAttributeType(schema, ATTR_DIT_STRUCTURE_RULES, ATTR_DIT_STRUCTURE_RULES_LC, syntax);
return createAddModifications(entry, mods, dsrAttrType);
}
@@ -651,32 +569,17 @@
Entry entry, List<Modification> mods) throws ConfigException,
InitializationException
{
- MatchingRuleUseSyntax mruSyntax;
- try
+ Syntax syntax = schema.getSyntax(SYNTAX_MATCHING_RULE_USE_OID);
+ if (syntax == null)
{
- mruSyntax = (MatchingRuleUseSyntax)
- schema.getSyntax(SYNTAX_MATCHING_RULE_USE_OID);
- if (mruSyntax == null)
- {
- mruSyntax = new MatchingRuleUseSyntax();
- mruSyntax.initializeSyntax(null);
- }
+ syntax = CoreSchema.getMatchingRuleUseDescriptionSyntax();
}
- catch (Exception e)
- {
- logger.traceException(e);
-
- mruSyntax = new MatchingRuleUseSyntax();
- mruSyntax.initializeSyntax(null);
- }
-
- AttributeType mruAttrType = getAttributeType(
- schema, ATTR_MATCHING_RULE_USE, ATTR_MATCHING_RULE_USE_LC, mruSyntax);
+ AttributeType mruAttrType = getAttributeType(schema, ATTR_MATCHING_RULE_USE, ATTR_MATCHING_RULE_USE_LC, syntax);
return createAddModifications(entry, mods, mruAttrType);
}
private static AttributeType getAttributeType(Schema schema, String attrName,
- String attrLowerName, AttributeSyntax<?> syntax)
+ String attrLowerName, Syntax syntax)
{
final AttributeType attrType = schema.getAttributeType(attrLowerName);
if (attrType != null)
@@ -701,7 +604,7 @@
}
/** Parse the ldapsyntaxes definitions if there are any. */
- private static void parseLdapSyntaxesDefinitions(Schema schema,
+ private static void parseLdapSyntaxesDefinitions(ServerContext serverContext, Schema schema,
String schemaFile, boolean failOnError, List<Attribute> ldapSyntaxList)
throws ConfigException
{
@@ -714,7 +617,7 @@
LDAPSyntaxDescription syntaxDescription;
try
{
- syntaxDescription = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, schema, false);
+ syntaxDescription = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, schema, false, false);
setExtraProperty(syntaxDescription, SCHEMA_PROPERTY_FILENAME, null);
setSchemaFile(syntaxDescription, schemaFile);
}
@@ -743,8 +646,8 @@
// to trap them and log a warning.
try
{
- schema.registerLdapSyntaxDescription(
- syntaxDescription, failOnError);
+ schema.registerLdapSyntaxDescription(syntaxDescription, failOnError);
+ registerLdapSyntaxInSchemaNG(serverContext, syntaxDescription, failOnError);
}
catch (DirectoryException de)
{
@@ -755,6 +658,7 @@
try
{
schema.registerLdapSyntaxDescription(syntaxDescription, true);
+ registerLdapSyntaxInSchemaNG(serverContext, syntaxDescription, true);
}
catch (Exception e)
{
@@ -767,6 +671,16 @@
}
}
+ private static void registerLdapSyntaxInSchemaNG(ServerContext serverContext, LDAPSyntaxDescription syntaxDescription,
+ boolean overwrite)
+ {
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ Syntax.Builder builder = schemaUpdater.getSchemaBuilder()
+ .buildSyntax(syntaxDescription.getSyntax());
+ SchemaBuilder schemaBuilder = overwrite ? builder.addToSchemaOverwrite() : builder.addToSchema();
+ schemaUpdater.updateSchema(schemaBuilder.toSchema());
+ }
+
/** Parse the attribute type definitions if there are any. */
private static void parseAttributeTypeDefinitions(Schema schema,
String schemaFile, boolean failOnError, List<Attribute> attrList)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java
index 4ae89ae..59fd1aa 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java
@@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
- * Copyright 2014 ForgeRock AS
+ * Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.core;
@@ -112,7 +112,7 @@
// Take schema files into account (TODO : or load files using provider mechanism ?)
completeSchemaFromFiles(schemaBuilder);
- schemaUpdater.updateSchema(schemaBuilder);
+ schemaUpdater.updateSchema(schemaBuilder.toSchema());
}
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/ServerContext.java b/opendj-server-legacy/src/main/java/org/opends/server/core/ServerContext.java
index a27dde7..ba1db9a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/ServerContext.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/ServerContext.java
@@ -59,6 +59,17 @@
Schema getSchema();
/**
+ * Returns the new schema of the server (SDK schema).
+ * <p>
+ * This method will disappear once migration to new schema
+ * is finished. Meanwhile, it is necessary to keep both the
+ * legacy version and the new version.
+ *
+ * @return the new version of the schema
+ */
+ org.forgerock.opendj.ldap.schema.Schema getSchemaNG();
+
+ /**
* Returns the schema updater, which provides
* a mean to update the server's current schema.
*
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java
index 41e2ea4..05f22e6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java
@@ -52,7 +52,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.admin.std.server.MonitorProviderCfg;
import org.opends.server.api.AlertGenerator;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.DiskSpaceMonitorHandler;
import org.opends.server.api.MonitorProvider;
import org.opends.server.api.ServerShutdownListener;
@@ -144,7 +144,7 @@
this.lowThreshold = lowThreshold;
}
- private Attribute attr(String name, AttributeSyntax<?> syntax, Object value)
+ private Attribute attr(String name, Syntax syntax, Object value)
{
AttributeType attrType = DirectoryServer.getDefaultAttributeType(name, syntax);
return Attributes.create(attrType, String.valueOf(value));
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/monitors/DatabaseEnvironmentMonitor.java b/opendj-server-legacy/src/main/java/org/opends/server/monitors/DatabaseEnvironmentMonitor.java
new file mode 100644
index 0000000..9d443ea
--- /dev/null
+++ b/opendj-server-legacy/src/main/java/org/opends/server/monitors/DatabaseEnvironmentMonitor.java
@@ -0,0 +1,433 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2006-2010 Sun Microsystems, Inc.
+ * Portions Copyright 2014-2015 ForgeRock AS
+ */
+package org.opends.server.monitors;
+
+
+
+import java.lang.reflect.Method;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.forgerock.i18n.LocalizableMessage;
+import org.opends.server.admin.std.server.MonitorProviderCfg;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.api.MonitorProvider;
+import org.opends.server.backends.jeb.DatabaseContainer;
+import org.opends.server.backends.jeb.EntryContainer;
+import org.opends.server.backends.jeb.Index;
+import org.opends.server.backends.jeb.RootContainer;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.opends.server.core.DirectoryServer;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.opends.server.types.*;
+import com.sleepycat.je.DatabaseException;
+import com.sleepycat.je.EnvironmentStats;
+import com.sleepycat.je.JEVersion;
+import com.sleepycat.je.StatsConfig;
+import com.sleepycat.je.TransactionStats;
+import org.opends.server.util.TimeThread;
+
+
+/**
+ * A monitor provider for a Berkeley DB JE environment.
+ * It uses reflection on the environment statistics object
+ * so that we don't need to keep a list of all the stats.
+ */
+public class DatabaseEnvironmentMonitor
+ extends MonitorProvider<MonitorProviderCfg>
+{
+ private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
+
+ /**
+ * Represents the statistical information kept for each search filter.
+ */
+ private static class FilterStats implements Comparable<FilterStats>
+ {
+ private volatile LocalizableMessage failureReason = LocalizableMessage.EMPTY;
+ private long maxMatchingEntries = -1;
+ private final AtomicInteger hits = new AtomicInteger();
+
+ public int compareTo(FilterStats that) {
+ return this.hits.get() - that.hits.get();
+ }
+
+ private void update(int hitCount, LocalizableMessage failureReason)
+ {
+ this.hits.getAndAdd(hitCount);
+ this.failureReason = failureReason;
+ }
+
+ private void update(int hitCount, long matchingEntries)
+ {
+ this.hits.getAndAdd(hitCount);
+ this.failureReason = LocalizableMessage.EMPTY;
+ synchronized(this)
+ {
+ if(matchingEntries > maxMatchingEntries)
+ {
+ maxMatchingEntries = matchingEntries;
+ }
+ }
+ }
+ }
+
+ /**
+ * The name of this monitor instance.
+ */
+ private String name;
+
+ /**
+ * The root container to be monitored.
+ */
+ private RootContainer rootContainer;
+
+ private int maxEntries = 1024;
+ private boolean filterUseEnabled;
+ private String startTimeStamp;
+ private final HashMap<SearchFilter, FilterStats> filterToStats =
+ new HashMap<SearchFilter, FilterStats>();
+ private final AtomicInteger indexedSearchCount = new AtomicInteger();
+ private final AtomicInteger unindexedSearchCount = new AtomicInteger();
+
+ /**
+ * Creates a new database environment monitor.
+ * @param name The monitor instance name.
+ * @param rootContainer A root container handle for the database to be
+ * monitored.
+ */
+ public DatabaseEnvironmentMonitor(String name, RootContainer rootContainer)
+ {
+ this.name = name;
+ this.rootContainer = rootContainer;
+ }
+
+
+
+ /** {@inheritDoc} */
+ public void initializeMonitorProvider(MonitorProviderCfg configuration)
+ throws ConfigException, InitializationException
+ {
+ }
+
+ /**
+ * Retrieves the name of this monitor provider. It should be unique among all
+ * monitor providers, including all instances of the same monitor provider.
+ *
+ * @return The name of this monitor provider.
+ */
+ public String getMonitorInstanceName()
+ {
+ return name;
+ }
+
+ /**
+ * Creates monitor attribute values for a given JE statistics object,
+ * using reflection to call all the getter methods of the statistics object.
+ * The attribute type names of the created attribute values are derived from
+ * the names of the getter methods.
+ * @param monitorAttrs The monitor attribute values are inserted into this
+ * attribute list.
+ * @param stats The JE statistics object.
+ * @param attrPrefix A common prefix for the attribute type names of the
+ * monitor attribute values, to distinguish the attributes of one
+ * type of statistical object from another, and to avoid attribute name
+ * collisions.
+ */
+ private void addAttributesForStatsObject(ArrayList<Attribute> monitorAttrs,
+ Object stats, String attrPrefix)
+ {
+ Class<?> c = stats.getClass();
+ Method[] methods = c.getMethods();
+
+ // Iterate through all the statistic class methods.
+ for (Method method : methods)
+ {
+ // Invoke all the getters returning integer values.
+ if (method.getName().startsWith("get"))
+ {
+ Class<?> returnType = method.getReturnType();
+ if (returnType.equals(int.class) || returnType.equals(long.class))
+ {
+ Syntax integerSyntax = DirectoryServer.getDefaultIntegerSyntax();
+
+ // Remove the 'get' from the method name and add the prefix.
+ String attrName = attrPrefix + method.getName().substring(3);
+
+ try
+ {
+ // Read the statistic.
+ Object statValue = method.invoke(stats);
+
+ // Create an attribute from the statistic.
+ AttributeType attrType =
+ DirectoryServer.getDefaultAttributeType(attrName,
+ integerSyntax);
+ monitorAttrs.add(Attributes.create(attrType, String
+ .valueOf(statValue)));
+
+ } catch (Exception e)
+ {
+ logger.traceException(e);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Retrieves a set of attributes containing monitor data that should be
+ * returned to the client if the corresponding monitor entry is requested.
+ *
+ * @return A set of attributes containing monitor data that should be
+ * returned to the client if the corresponding monitor entry is
+ * requested.
+ */
+ public ArrayList<Attribute> getMonitorData()
+ {
+ EnvironmentStats environmentStats = null;
+ TransactionStats transactionStats = null;
+ StatsConfig statsConfig = new StatsConfig();
+ ArrayList<Attribute> monitorAttrs = new ArrayList<Attribute>();
+
+ try
+ {
+ environmentStats = rootContainer.getEnvironmentStats(statsConfig);
+ transactionStats =
+ rootContainer.getEnvironmentTransactionStats(statsConfig);
+ } catch (DatabaseException e)
+ {
+ logger.traceException(e);
+ return monitorAttrs;
+ }
+
+ String jeVersion = JEVersion.CURRENT_VERSION.getVersionString();
+ AttributeType versionType =
+ DirectoryServer.getDefaultAttributeType("JEVersion");
+ monitorAttrs.add(Attributes.create(versionType, jeVersion));
+
+ addAttributesForStatsObject(monitorAttrs, environmentStats, "Environment");
+ addAttributesForStatsObject(monitorAttrs, transactionStats, "Transaction");
+
+ AttributeBuilder needReindex = new AttributeBuilder("need-reindex");
+ for(EntryContainer ec : rootContainer.getEntryContainers())
+ {
+ List<DatabaseContainer> databases = new ArrayList<DatabaseContainer>();
+ ec.listDatabases(databases);
+ for(DatabaseContainer dc : databases)
+ {
+ if(dc instanceof Index && !((Index)dc).isTrusted())
+ {
+ needReindex.add(dc.getName());
+ }
+ }
+ }
+ if(needReindex.size() > 0)
+ {
+ monitorAttrs.add(needReindex.toAttribute());
+ }
+
+ if(filterUseEnabled)
+ {
+ monitorAttrs.add(Attributes.create("filter-use-startTime",
+ startTimeStamp));
+ AttributeBuilder builder = new AttributeBuilder("filter-use");
+
+ StringBuilder stringBuilder = new StringBuilder();
+ synchronized(filterToStats)
+ {
+ for(Map.Entry<SearchFilter, FilterStats> entry :
+ filterToStats.entrySet())
+ {
+ entry.getKey().toString(stringBuilder);
+ stringBuilder.append(" hits:");
+ stringBuilder.append(entry.getValue().hits.get());
+ stringBuilder.append(" maxmatches:");
+ stringBuilder.append(entry.getValue().maxMatchingEntries);
+ stringBuilder.append(" message:");
+ stringBuilder.append(entry.getValue().failureReason);
+ builder.add(stringBuilder.toString());
+ stringBuilder.setLength(0);
+ }
+ }
+ monitorAttrs.add(builder.toAttribute());
+ monitorAttrs.add(Attributes.create("filter-use-indexed",
+ String.valueOf(indexedSearchCount.get())));
+ monitorAttrs.add(Attributes.create("filter-use-unindexed",
+ String.valueOf(unindexedSearchCount.get())));
+ }
+
+ return monitorAttrs;
+ }
+
+
+ /**
+ * Updates the index filter statistics with this latest search filter
+ * and the reason why an index was not used.
+ *
+ * @param searchFilter The search filter that was evaluated.
+ * @param failureMessage The reason why an index was not used.
+ */
+ public void updateStats(SearchFilter searchFilter, LocalizableMessage failureMessage)
+ {
+ if(!filterUseEnabled)
+ {
+ return;
+ }
+
+ FilterStats stats;
+ synchronized(filterToStats)
+ {
+ stats = filterToStats.get(searchFilter);
+
+
+ if(stats != null)
+ {
+ stats.update(1, failureMessage);
+ }
+ else
+ {
+ stats = new FilterStats();
+ stats.update(1, failureMessage);
+ removeLowestHit();
+ filterToStats.put(searchFilter, stats);
+ }
+ }
+ }
+
+ /**
+ * Updates the index filter statistics with this latest search filter
+ * and the number of entries matched by the index lookup.
+ *
+ * @param searchFilter The search filter that was evaluated.
+ * @param matchingEntries The number of entries matched by the successful
+ * index lookup.
+ */
+ public void updateStats(SearchFilter searchFilter, long matchingEntries)
+ {
+ if(!filterUseEnabled)
+ {
+ return;
+ }
+
+ FilterStats stats;
+ synchronized(filterToStats)
+ {
+ stats = filterToStats.get(searchFilter);
+
+
+ if(stats != null)
+ {
+ stats.update(1, matchingEntries);
+ }
+ else
+ {
+ stats = new FilterStats();
+ stats.update(1, matchingEntries);
+ removeLowestHit();
+ filterToStats.put(searchFilter, stats);
+ }
+ }
+ }
+
+ /**
+ * Enable or disable index filter statistics gathering.
+ *
+ * @param enabled <code>true></code> to enable index filter statics gathering.
+ */
+ public void enableFilterUseStats(boolean enabled)
+ {
+ if(enabled && !filterUseEnabled)
+ {
+ startTimeStamp = TimeThread.getGMTTime();
+ indexedSearchCount.set(0);
+ unindexedSearchCount.set(0);
+ }
+ else if(!enabled)
+ {
+ filterToStats.clear();
+ }
+ filterUseEnabled = enabled;
+ }
+
+ /**
+ * Indicates if index filter statistics gathering is enabled.
+ *
+ * @return <code>true</code> If index filter statistics gathering is enabled.
+ */
+ public boolean isFilterUseEnabled()
+ {
+ return filterUseEnabled;
+ }
+
+ /**
+ * Sets the maximum number of search filters statistics entries to keep
+ * before ones with the least hits will be removed.
+ *
+ * @param maxEntries The maximum number of search filters statistics
+ * entries to keep
+ */
+ public void setMaxEntries(int maxEntries) {
+ this.maxEntries = maxEntries;
+ }
+
+ /**
+ * Updates the statistics counter to include an indexed search.
+ */
+ public void updateIndexedSearchCount()
+ {
+ indexedSearchCount.getAndIncrement();
+ }
+
+ /**
+ * Updates the statistics counter to include an unindexed search.
+ */
+ public void updateUnindexedSearchCount()
+ {
+ unindexedSearchCount.getAndIncrement();
+ }
+
+ private void removeLowestHit()
+ {
+ while(!filterToStats.isEmpty() && filterToStats.size() > maxEntries)
+ {
+ Iterator<Map.Entry<SearchFilter, FilterStats>> i =
+ filterToStats.entrySet().iterator();
+ Map.Entry<SearchFilter, FilterStats> lowest = i.next();
+ Map.Entry<SearchFilter, FilterStats> entry;
+ while(lowest.getValue().hits.get() > 1 && i.hasNext())
+ {
+ entry = i.next();
+ if(entry.getValue().hits.get() < lowest.getValue().hits.get())
+ {
+ lowest = entry;
+ }
+ }
+
+ filterToStats.remove(lowest.getKey());
+ }
+ }
+}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java b/opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java
index 64a09ce..96cd9f2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java
@@ -32,7 +32,7 @@
import java.util.concurrent.TimeUnit;
import org.opends.server.admin.std.server.MonitorProviderCfg;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.MonitorProvider;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
@@ -114,6 +114,7 @@
/** {@inheritDoc} */
+ @Override
public void initializeMonitorProvider(MonitorProviderCfg configuration)
throws ConfigException, InitializationException
{
@@ -131,6 +132,7 @@
*
* @return The name of this monitor provider.
*/
+ @Override
public String getMonitorInstanceName()
{
return "Work Queue";
@@ -138,6 +140,7 @@
/** {@inheritDoc} */
+ @Override
public void run()
{
int backlog = workQueue.size();
@@ -160,6 +163,7 @@
* returned to the client if the corresponding monitor entry is
* requested.
*/
+ @Override
public ArrayList<Attribute> getMonitorData()
{
int backlog = workQueue.size();
@@ -175,8 +179,7 @@
long opsSubmitted = workQueue.getOpsSubmitted();
ArrayList<Attribute> monitorAttrs = new ArrayList<Attribute>();
- AttributeSyntax<?> integerSyntax = DirectoryServer
- .getDefaultIntegerSyntax();
+ Syntax integerSyntax = DirectoryServer.getDefaultIntegerSyntax();
// The current backlog.
AttributeType attrType = DirectoryServer.getDefaultAttributeType(
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/monitors/TraditionalWorkQueueMonitor.java b/opendj-server-legacy/src/main/java/org/opends/server/monitors/TraditionalWorkQueueMonitor.java
index 7e171b5..af7ea48 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/monitors/TraditionalWorkQueueMonitor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/monitors/TraditionalWorkQueueMonitor.java
@@ -32,7 +32,7 @@
import java.util.concurrent.TimeUnit;
import org.opends.server.admin.std.server.MonitorProviderCfg;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.MonitorProvider;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
@@ -123,6 +123,7 @@
/** {@inheritDoc} */
+ @Override
public void initializeMonitorProvider(MonitorProviderCfg configuration)
throws ConfigException, InitializationException
{
@@ -140,6 +141,7 @@
*
* @return The name of this monitor provider.
*/
+ @Override
public String getMonitorInstanceName()
{
return "Work Queue";
@@ -147,6 +149,7 @@
/** {@inheritDoc} */
+ @Override
public void run()
{
int backlog = workQueue.size();
@@ -169,6 +172,7 @@
* returned to the client if the corresponding monitor entry is
* requested.
*/
+ @Override
public ArrayList<Attribute> getMonitorData()
{
int backlog = workQueue.size();
@@ -185,8 +189,7 @@
long rejectedQueueFull = workQueue.getOpsRejectedDueToQueueFull();
ArrayList<Attribute> monitorAttrs = new ArrayList<Attribute>();
- AttributeSyntax<?> integerSyntax = DirectoryServer
- .getDefaultIntegerSyntax();
+ Syntax integerSyntax = DirectoryServer.getDefaultIntegerSyntax();
// The current backlog.
AttributeType attrType = DirectoryServer.getDefaultAttributeType(
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/AciSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/AciSyntax.java
index e22148a..8efd993 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/AciSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/AciSyntax.java
@@ -22,24 +22,18 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2011-2014 ForgeRock AS
+ * Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
+import static org.opends.server.schema.SchemaConstants.*;
+
import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
+import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+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.authorization.dseecompat.Aci;
-import org.opends.server.authorization.dseecompat.AciException;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.DN;
-
-import static org.opends.messages.SchemaMessages.*;
-import static org.opends.server.schema.SchemaConstants.*;
+import org.opends.server.core.ServerContext;
/**
* This class implements the access control information (aci) attribute syntax.
@@ -47,14 +41,6 @@
public class AciSyntax
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
- /** The default substring matching rule for this syntax. */
- private MatchingRule defaultSubstringMatchingRule;
-
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -68,19 +54,22 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration) throws ConfigException
+ public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext) throws ConfigException
{
- defaultEqualityMatchingRule = DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_IA5_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_IA5_OID, SYNTAX_ACI_NAME);
- }
+ // Add the Aci syntax to the "new" schema
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ SchemaBuilder builder = schemaUpdater.getSchemaBuilder().buildSyntax(SYNTAX_ACI_OID)
+ .description(SYNTAX_ACI_DESCRIPTION)
+ .implementation(new AciSyntaxImpl())
+ .addToSchema();
+ schemaUpdater.updateSchema(builder.toSchema());
+ }
- defaultSubstringMatchingRule = DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_IA5_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_IA5_OID, SYNTAX_ACI_NAME);
- }
+ /** {@inheritDoc} */
+ @Override
+ public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema)
+ {
+ return schema.getSyntax(SchemaConstants.SYNTAX_ACI_OID);
}
/**
@@ -115,107 +104,5 @@
{
return SYNTAX_ACI_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- // We don't have an orderingMatchingRule
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- // we don't have an approximateMatchingRule
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- @Override
- public boolean valueIsAcceptable(ByteSequence value, LocalizableMessageBuilder invalidReason)
- {
- try
- {
- Aci.decode(value, DN.rootDN());
- return true;
- }
- catch (AciException e)
- {
- logger.traceException(e);
-
- logger.warn(e.getMessageObject());
- invalidReason.append(e.getMessageObject());
- return false;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/AciSyntaxImpl.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/AciSyntaxImpl.java
new file mode 100644
index 0000000..fc613b5
--- /dev/null
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/AciSyntaxImpl.java
@@ -0,0 +1,103 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2011-2015 ForgeRock AS
+ */
+package org.opends.server.schema;
+
+import static org.opends.server.schema.SchemaConstants.*;
+
+import org.forgerock.i18n.LocalizableMessageBuilder;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteSequence;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SyntaxImpl;
+import org.opends.server.authorization.dseecompat.Aci;
+import org.opends.server.authorization.dseecompat.AciException;
+import org.opends.server.types.DN;
+
+/**
+ * Implementation of Access control information (aci) attribute syntax.
+ */
+final class AciSyntaxImpl implements SyntaxImpl {
+
+ private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
+
+ AciSyntaxImpl() {
+ // // nothing to do
+ }
+
+ @Override
+ public String getApproximateMatchingRule() {
+ return null;
+ }
+
+ @Override
+ public String getEqualityMatchingRule() {
+ return EMR_CASE_IGNORE_IA5_OID;
+ }
+
+ @Override
+ public String getOrderingMatchingRule() {
+ return null;
+ }
+
+ @Override
+ public String getSubstringMatchingRule() {
+ return SMR_CASE_IGNORE_IA5_OID;
+ }
+
+ @Override
+ public String getName() {
+ return SYNTAX_ACI_NAME;
+ }
+
+ @Override
+ public boolean isHumanReadable() {
+ return true;
+ }
+
+ @Override
+ public boolean valueIsAcceptable(final Schema schema, final ByteSequence value,
+ final LocalizableMessageBuilder invalidReason) {
+ try
+ {
+ Aci.decode(value, DN.rootDN());
+ return true;
+ }
+ catch (AciException e)
+ {
+ logger.traceException(e);
+ logger.warn(e.getMessageObject());
+ invalidReason.append(e.getMessageObject());
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isBEREncodingRequired()
+ {
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java
index a0c86c9..39a99cf 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java
@@ -26,6 +26,12 @@
*/
package org.opends.server.schema;
+import static org.opends.messages.SchemaMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.schema.SchemaConstants.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -33,25 +39,25 @@
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
+import org.forgerock.opendj.ldap.Option;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
+import org.forgerock.opendj.ldap.schema.MatchingRule;
+import org.forgerock.opendj.ldap.schema.SchemaOptions;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.AttributeTypeDescriptionAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.*;
-
-import static org.opends.messages.SchemaMessages.*;
-import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
+import org.opends.server.core.ServerContext;
+import org.opends.server.types.AttributeType;
+import org.opends.server.types.CommonSchemaElements;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.InitializationException;
+import org.opends.server.types.Schema;
/**
* This class defines the attribute type description syntax, which is used to
@@ -62,9 +68,6 @@
extends AttributeSyntax<AttributeTypeDescriptionAttributeSyntaxCfg>
implements
ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> {
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
-
/**
* The reference to the configuration for this attribute type description
@@ -74,18 +77,11 @@
- /** 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;
-
/** If true strip the suggested minimum upper bound from the syntax OID. */
private static boolean stripMinimumUpperBound;
+ private ServerContext serverContext;
+
/**
* Creates a new instance of this syntax. Note that the only thing that
@@ -103,35 +99,10 @@
/** {@inheritDoc} */
@Override
public void
- initializeSyntax(AttributeTypeDescriptionAttributeSyntaxCfg configuration)
+ initializeSyntax(AttributeTypeDescriptionAttributeSyntaxCfg configuration, ServerContext serverContext)
throws ConfigException, InitializationException
{
- 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_ATTRIBUTE_TYPE_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_ATTRIBUTE_TYPE_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_ATTRIBUTE_TYPE_NAME);
- throw new InitializationException(message);
- }
+ this.serverContext = serverContext;
// This syntax is one of the Directory Server's core syntaxes and therefore
// it may be instantiated at times without a configuration entry. If that
@@ -145,9 +116,27 @@
currentConfig = configuration;
currentConfig.addAttributeTypeDescriptionChangeListener(this);
stripMinimumUpperBound=configuration.isStripSyntaxMinUpperBound();
+ updateNewSchema();
}
+ /** Update the option in new schema if it changes from current value. */
+ private void updateNewSchema()
+ {
+ Option<Boolean> option = SchemaOptions.STRIP_UPPER_BOUND_FOR_ATTRIBUTE_TYPE;
+ if (isStripSyntaxMinimumUpperBound() != serverContext.getSchemaNG().getOption(option))
+ {
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ schemaUpdater.updateSchema(
+ schemaUpdater.getSchemaBuilder().setOption(option, stripMinimumUpperBound).toSchema());
+ }
+ }
+ /** {@inheritDoc} */
+ @Override
+ public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema)
+ {
+ return schema.getSyntax(SchemaConstants.SYNTAX_ATTRIBUTE_TYPE_OID);
+ }
/** {@inheritDoc} */
@Override
@@ -176,66 +165,6 @@
- /** {@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 decodeAttributeType method to determine if the value is
- // acceptable.
- try
- {
- decodeAttributeType(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 an attribute
* type definition according to the rules of this syntax. Note that the
@@ -426,7 +355,7 @@
List<String> typeNames = new LinkedList<String>();
String description = null;
AttributeType superiorType = null;
- AttributeSyntax<?> syntax = DirectoryServer.getDefaultAttributeSyntax();
+ Syntax syntax = DirectoryServer.getDefaultAttributeSyntax();
MatchingRule approximateMatchingRule = null;
MatchingRule equalityMatchingRule = null;
MatchingRule orderingMatchingRule = null;
@@ -1492,7 +1421,7 @@
{
currentConfig = configuration;
stripMinimumUpperBound = configuration.isStripSyntaxMinUpperBound();
-
+ updateNewSchema();
return new ConfigChangeResult();
}
@@ -1517,22 +1446,4 @@
public static boolean isStripSyntaxMinimumUpperBound() {
return stripMinimumUpperBound;
}
-
-
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
-
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/AuthPasswordSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/AuthPasswordSyntax.java
index c28f8cc..4361312 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/AuthPasswordSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/AuthPasswordSyntax.java
@@ -25,24 +25,18 @@
* Portions Copyright 2012-2015 ForgeRock AS.
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-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.DirectoryException;
-
-
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteSequence;
-
import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.ByteSequence;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.schema.Schema;
+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.types.DirectoryException;
+
/**
* This class defines the auth password attribute syntax, which is defined in
@@ -53,11 +47,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -71,16 +60,9 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_AUTH_PASSWORD_EXACT_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_AUTH_PASSWORD_EXACT_NAME, SYNTAX_AUTH_PASSWORD_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_AUTH_PASSWORD_OID);
}
/**
@@ -117,93 +99,6 @@
}
/**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- // There is no ordering matching rule by default.
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- // There is no substring matching rule by default.
- return null;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- try
- {
- decodeAuthPassword(value.toString());
- return true;
- }
- catch (DirectoryException de)
- {
- invalidReason.append(de.getMessageObject());
- return false;
- }
- }
-
- /**
* Decodes the provided authentication password value into its component
* parts.
*
@@ -473,18 +368,5 @@
return false;
}
}
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/BinarySyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/BinarySyntax.java
index 0010fc1..29984da 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/BinarySyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/BinarySyntax.java
@@ -26,17 +26,12 @@
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ByteSequence;
+import static org.opends.server.schema.SchemaConstants.*;
+
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
-import org.opends.server.core.DirectoryServer;
-
-import static org.opends.messages.SchemaMessages.*;
-import static org.opends.server.schema.SchemaConstants.*;
/**
* This class defines the binary attribute syntax, which is essentially a byte
@@ -47,18 +42,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -72,29 +55,9 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_BINARY_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_BINARY_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_BINARY_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_BINARY_OID);
}
/**
@@ -129,96 +92,5 @@
{
return SYNTAX_BINARY_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // All values will be acceptable for the binary syntax.
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return false;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/BitStringSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/BitStringSyntax.java
index 7620f03..b21bf71 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/BitStringSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/BitStringSyntax.java
@@ -26,20 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class defines the bit string attribute syntax, which is comprised of
@@ -50,11 +43,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -67,15 +55,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_BIT_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_BIT_STRING_OID, SYNTAX_BIT_STRING_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_BIT_STRING_OID);
}
/**
@@ -83,6 +66,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_BIT_STRING_NAME;
@@ -93,6 +77,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_BIT_STRING_OID;
@@ -103,130 +88,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_BIT_STRING_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- // Ordering matches are not allowed by default.
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- // Substring matches are not allowed by default.
- return null;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // Approximate matches are not allowed by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- String valueString = value.toString().toUpperCase();
-
- int length = valueString.length();
- if (length < 3)
- {
- invalidReason.append(WARN_ATTR_SYNTAX_BIT_STRING_TOO_SHORT.get(value));
- return false;
- }
-
-
- if ((valueString.charAt(0) != '\'') ||
- (valueString.charAt(length-2) != '\'') ||
- (valueString.charAt(length-1) != 'B'))
- {
- invalidReason.append(WARN_ATTR_SYNTAX_BIT_STRING_NOT_QUOTED.get(value));
- return false;
- }
-
-
- for (int i=1; i < (length-2); i++)
- {
- switch (valueString.charAt(i))
- {
- case '0':
- case '1':
- // These characters are fine.
- break;
- default:
- invalidReason.append(WARN_ATTR_SYNTAX_BIT_STRING_INVALID_BIT.get(
- value, valueString.charAt(i)));
- return false;
- }
- }
-
-
- // If we've gotten here, then everything is fine.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/BooleanSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/BooleanSyntax.java
index f79500e..8d15d34 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/BooleanSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/BooleanSyntax.java
@@ -26,20 +26,15 @@
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.ldap.ByteString;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
-import org.opends.server.api.AttributeSyntax;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.util.ServerConstants;
-
-import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.Schema;
+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.util.ServerConstants;
+
/**
* This class defines the Boolean attribute syntax, which only allows values of
* "TRUE" or "FALSE" (although this implementation is more flexible and will
@@ -51,11 +46,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -69,15 +59,9 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_BOOLEAN_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_BOOLEAN_OID, SYNTAX_BOOLEAN_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_BOOLEAN_OID);
}
/**
@@ -114,100 +98,6 @@
}
/**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- // Ordering matches are not allowed by default.
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- // Substring matches are not allowed by default.
- return null;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- // Approximate matches are not allowed by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- String valueString = value.toString().toUpperCase();
-
- boolean returnValue = (valueString.equals("TRUE") ||
- valueString.equals("YES") ||
- valueString.equals("ON") ||
- valueString.equals("1") ||
- valueString.equals("FALSE") ||
- valueString.equals("NO") ||
- valueString.equals("OFF") ||
- valueString.equals("0"));
-
- if (! returnValue)
- {
- invalidReason.append(WARN_ATTR_SYNTAX_ILLEGAL_BOOLEAN.get(value));
- }
-
- return returnValue;
- }
-
- /**
* Retrieves an attribute value containing a representation of the provided
* boolean value.
*
@@ -219,19 +109,5 @@
{
return b ? ServerConstants.TRUE_VALUE : ServerConstants.FALSE_VALUE;
}
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateExactAssertionSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateExactAssertionSyntax.java
index 99fafa9..79c1bd2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateExactAssertionSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateExactAssertionSyntax.java
@@ -27,19 +27,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class defines the Certificate Exact Assertion attribute syntax,
@@ -49,17 +43,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -72,96 +55,31 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_OID, SYNTAX_CERTIFICATE_EXACT_ASSERTION_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_CASE_IGNORE_OID, SYNTAX_CERTIFICATE_EXACT_ASSERTION_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_CERTIFICATE_EXACT_ASSERTION_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_CERTIFICATE_EXACT_ASSERTION_OID);
}
/** {@inheritDoc} */
+ @Override
public String getName()
{
return SYNTAX_CERTIFICATE_EXACT_ASSERTION_NAME;
}
/** {@inheritDoc} */
+ @Override
public String getOID()
{
return SYNTAX_CERTIFICATE_EXACT_ASSERTION_OID;
}
/** {@inheritDoc} */
+ @Override
public String getDescription()
{
return SYNTAX_CERTIFICATE_EXACT_ASSERTION_DESCRIPTION;
}
-
- /** {@inheritDoc} */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /** {@inheritDoc} */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /** {@inheritDoc} */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /** {@inheritDoc} */
- public MatchingRule getApproximateMatchingRule()
- {
- // Approximate matching will not be allowed by default.
- return null;
- }
-
- /** {@inheritDoc} */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // This method will never be called because this syntax is only used
- // within assertions.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateListSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateListSyntax.java
index cbaa430..7335d34 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateListSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateListSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the certificate list attribute syntax. This should be
@@ -50,17 +44,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -73,29 +56,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_CERTLIST_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_CERTLIST_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_CERTLIST_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_CERTLIST_OID);
}
/**
@@ -103,6 +67,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_CERTLIST_NAME;
@@ -113,6 +78,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_CERTLIST_OID;
@@ -123,93 +89,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_CERTLIST_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // All values will be acceptable for the certificate list syntax.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return false;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificatePairSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificatePairSyntax.java
index 395a267..1dd4fbf 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificatePairSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificatePairSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the certificate pair attribute syntax. This should be
@@ -50,17 +44,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -73,29 +56,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_CERTPAIR_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_CERTPAIR_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_CERTPAIR_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_CERTPAIR_OID);
}
/**
@@ -103,6 +67,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_CERTPAIR_NAME;
@@ -113,6 +78,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_CERTPAIR_OID;
@@ -123,93 +89,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_CERTPAIR_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // All values will be acceptable for the certificate pair syntax.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return false;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateSyntax.java
index fcd6c25..11a17ae 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateSyntax.java
@@ -27,27 +27,21 @@
*/
package org.opends.server.schema;
-import java.io.IOException;
+import static org.opends.server.schema.SchemaConstants.*;
+
import java.util.List;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-import org.opends.server.admin.server.ConfigurationChangeListener;
-import org.opends.server.admin.std.server.CertificateAttributeSyntaxCfg;
-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.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.io.ASN1;
-import org.forgerock.opendj.ldap.DecodeException;
-import org.forgerock.opendj.io.ASN1Reader;
-
-import static org.opends.messages.SchemaMessages.*;
import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.Option;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SchemaOptions;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.std.server.CertificateAttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+import org.opends.server.core.ServerContext;
/**
@@ -59,20 +53,11 @@
implements ConfigurationChangeListener<CertificateAttributeSyntaxCfg>
{
- 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;
-
/** The current configuration. */
private volatile CertificateAttributeSyntaxCfg config;
+ private ServerContext serverContext;
+
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -85,38 +70,37 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(CertificateAttributeSyntaxCfg configuration)
+ @Override
+ public void initializeSyntax(CertificateAttributeSyntaxCfg configuration, ServerContext serverContext)
throws ConfigException
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CERTIFICATE_EXACT_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CERTIFICATE_EXACT_OID, SYNTAX_CERTIFICATE_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_OCTET_STRING_OID, SYNTAX_CERTIFICATE_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_OCTET_STRING_OID, SYNTAX_CERTIFICATE_NAME);
- }
-
this.config = configuration;
+ this.serverContext = serverContext;
+ updateNewSchema();
config.addCertificateChangeListener(this);
}
+ /** Update the option in new schema if it changes from current value. */
+ private void updateNewSchema()
+ {
+ Option<Boolean> option = SchemaOptions.ALLOW_MALFORMED_CERTIFICATES;
+ if (config.isStrictFormat() == serverContext.getSchemaNG().getOption(option))
+ {
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ schemaUpdater.updateSchema(
+ schemaUpdater.getSchemaBuilder().setOption(option, !config.isStrictFormat()).toSchema());
+ }
+ }
+
/** {@inheritDoc} */
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
+ {
+ return schema.getSyntax(SchemaConstants.SYNTAX_CERTIFICATE_OID);
+ }
+
+ /** {@inheritDoc} */
+ @Override
public boolean isConfigurationChangeAcceptable(
CertificateAttributeSyntaxCfg configuration,
List<LocalizableMessage> unacceptableReasons)
@@ -126,10 +110,12 @@
}
/** {@inheritDoc} */
+ @Override
public ConfigChangeResult applyConfigurationChange(
CertificateAttributeSyntaxCfg configuration)
{
this.config = configuration;
+ updateNewSchema();
return new ConfigChangeResult();
}
@@ -138,6 +124,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_CERTIFICATE_NAME;
@@ -148,6 +135,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_CERTIFICATE_OID;
@@ -158,305 +146,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_CERTIFICATE_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Skip validation if strict validation is disabled.
- if (!config.isStrictFormat())
- {
- return true;
- }
-
- // Validate the ByteSequence against the definitions of X.509, clause 7
- long x509Version=0;
- ASN1Reader reader = ASN1.getReader(value);
- try
- {
- // Certificate SIGNED SEQUENCE
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.readStartSequence();
-
- // CertificateContent SEQUENCE
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.readStartSequence();
-
- // Optional Version
- if (reader.hasNextElement() &&
- reader.peekType() == (ASN1.TYPE_MASK_CONTEXT | ASN1.TYPE_MASK_CONSTRUCTED))
- {
- reader.readStartExplicitTag();
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_INTEGER_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- x509Version=reader.readInteger();
- if (x509Version < 0 || x509Version >2)
- {
- // invalid Version specified
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_INVALID_VERSION
- .get(x509Version));
- return false;
- }
- if (x509Version == 0)
- {
- // DEFAULT values shall not be included in DER encoded SEQUENCE
- // (X.690, 11.5)
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_INVALID_DER.get());
- return false;
- }
- reader.readEndExplicitTag();
- }
-
- // serialNumber
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_INTEGER_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.skipElement();
-
- // signature AlgorithmIdentifier
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.skipElement();
-
- // issuer name (SEQUENCE as of X.501, 9.2)
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.skipElement();
-
- // validity (SEQUENCE)
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.skipElement();
-
- // subject name (SEQUENCE as of X.501, 9.2)
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.skipElement();
-
- // SubjectPublicKeyInfo (SEQUENCE)
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.skipElement();
-
- // OPTIONAL issuerUniqueIdentifier
- if (reader.hasNextElement() &&
- reader.peekType() == (ASN1.TYPE_MASK_CONTEXT + 1))
- {
- if (x509Version < 1)
- {
- // only valid in v2 and v3
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.skipElement();
- }
-
- // OPTIONAL subjectUniqueIdentifier
- if (reader.hasNextElement() &&
- reader.peekType() == (ASN1.TYPE_MASK_CONTEXT + 2))
- {
- if (x509Version < 1)
- {
- // only valid in v2 and v3
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.skipElement();
- }
-
- // OPTIONAL extensions
- if (reader.hasNextElement() &&
- reader.peekType() == ((ASN1.TYPE_MASK_CONTEXT|ASN1.TYPE_MASK_CONSTRUCTED) + 3))
- {
- if (x509Version < 2)
- {
- // only valid in v3
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.readStartExplicitTag(); // read Tag
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE)
- {
- // only valid in v3
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.readEndExplicitTag(); // read end Tag
- }
-
- // There should not be any further ASN.1 elements within this SEQUENCE
- if (reader.hasNextElement())
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.readEndSequence(); // End CertificateContent SEQUENCE
-
- // AlgorithmIdentifier SEQUENCE
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.skipElement();
-
- // ENCRYPTED HASH BIT STRING
- if (!reader.hasNextElement() ||
- reader.peekType() != ASN1.UNIVERSAL_BIT_STRING_TYPE)
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.skipElement();
-
- // There should not be any further ASN.1 elements within this SEQUENCE
- if (reader.hasNextElement())
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- reader.readEndSequence(); // End Certificate SEQUENCE
-
- // There should not be any further ASN.1 elements
- if (reader.hasNextElement())
- {
- invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get());
- return false;
- }
- // End of the certificate
- }
- catch (DecodeException e)
- {
- invalidReason.append(e.getMessageObject());
- return false;
- }
- catch (IOException e)
- {
- invalidReason.append(e.getMessage());
- return false;
- }
-
- // The basic structure of the value is an X.509 certificate
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return false;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/CoreSchemaProvider.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/CoreSchemaProvider.java
index 0737798..1e1dd78 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/CoreSchemaProvider.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/CoreSchemaProvider.java
@@ -153,7 +153,7 @@
updateSchemaFromConfiguration(currentSchemaBuilder, configuration);
- final boolean isUpdated = schemaUpdater.updateSchema(currentSchemaBuilder);
+ final boolean isUpdated = schemaUpdater.updateSchema(currentSchemaBuilder.toSchema());
// TODO : fix result code + log an error in case of failure
final ConfigChangeResult result = new ConfigChangeResult();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/CountryStringSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/CountryStringSyntax.java
index dd9bd9d..f2d1ada 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/CountryStringSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/CountryStringSyntax.java
@@ -28,22 +28,21 @@
package org.opends.server.schema;
-import java.util.List;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
+import static org.opends.server.schema.SchemaConstants.*;
+import java.util.List;
+
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.Option;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SchemaOptions;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.CountryStringAttributeSyntaxCfg;
-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.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import static org.opends.server.schema.PrintableString.*;
-import static org.opends.server.schema.SchemaConstants.*;
+import org.opends.server.core.ServerContext;
/**
* This class defines the country string attribute syntax, which should be a
@@ -56,23 +55,11 @@
implements ConfigurationChangeListener<CountryStringAttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default approximate matching rule for this syntax. */
- private MatchingRule defaultApproximateMatchingRule;
-
- /** 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;
-
/** The current configuration. */
private volatile CountryStringAttributeSyntaxCfg config;
+ private ServerContext serverContext;
+
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -85,46 +72,37 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(CountryStringAttributeSyntaxCfg configuration)
+ @Override
+ public void initializeSyntax(CountryStringAttributeSyntaxCfg configuration, ServerContext serverContext)
throws ConfigException
{
- defaultApproximateMatchingRule =
- DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID);
- if (defaultApproximateMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE,
- AMR_DOUBLE_METAPHONE_OID, SYNTAX_COUNTRY_STRING_NAME);
- }
-
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_OID, SYNTAX_COUNTRY_STRING_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_CASE_IGNORE_OID, SYNTAX_COUNTRY_STRING_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_COUNTRY_STRING_NAME);
- }
-
this.config = configuration;
+ this.serverContext = serverContext;
+ updateNewSchema();
config.addCountryStringChangeListener(this);
}
+ /** Update the option in new schema if it changes from current value. */
+ private void updateNewSchema()
+ {
+ Option<Boolean> option = SchemaOptions.STRICT_FORMAT_FOR_COUNTRY_STRINGS;
+ if (config.isStrictFormat() != serverContext.getSchemaNG().getOption(option))
+ {
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ schemaUpdater.updateSchema(
+ schemaUpdater.getSchemaBuilder().setOption(option, config.isStrictFormat()).toSchema());
+ }
+ }
+
/** {@inheritDoc} */
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
+ {
+ return schema.getSyntax(SchemaConstants.SYNTAX_COUNTRY_STRING_OID);
+ }
+
+ /** {@inheritDoc} */
+ @Override
public boolean isConfigurationChangeAcceptable(
CountryStringAttributeSyntaxCfg configuration,
List<LocalizableMessage> unacceptableReasons)
@@ -134,10 +112,12 @@
}
/** {@inheritDoc} */
+ @Override
public ConfigChangeResult applyConfigurationChange(
CountryStringAttributeSyntaxCfg configuration)
{
this.config = configuration;
+ updateNewSchema();
return new ConfigChangeResult();
}
@@ -149,6 +129,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_COUNTRY_STRING_NAME;
@@ -159,6 +140,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_COUNTRY_STRING_OID;
@@ -169,120 +151,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_COUNTRY_STRING_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- return defaultApproximateMatchingRule;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- String stringValue = value.toString();
- if (stringValue.length() != 2)
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_COUNTRY_STRING_INVALID_LENGTH.get(stringValue));
- return false;
- }
-
- if (config.isStrictFormat())
- {
- // Check for a string containing [A-Z][A-Z]
- if (stringValue.charAt(0) < 'A' || stringValue.charAt(0) > 'Z' ||
- stringValue.charAt(1) < 'A' || stringValue.charAt(1) > 'Z')
- {
- invalidReason.append(ERR_ATTR_SYNTAX_COUNTRY_NO_VALID_ISO_CODE.get(value));
- return false;
- }
- }
- else
- {
- // Just validate as string containing 2 printable characters
- if ((! isPrintableCharacter(stringValue.charAt(0))) ||
- (! isPrintableCharacter(stringValue.charAt(1))))
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_COUNTRY_STRING_NOT_PRINTABLE.get(stringValue));
- return false;
- }
- }
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/DITContentRuleSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/DITContentRuleSyntax.java
index 74fe234..1cfc5a2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/DITContentRuleSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/DITContentRuleSyntax.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.DITContentRule;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.ObjectClass;
+import org.opends.server.types.Schema;
/**
* This class implements the DIT content rule description syntax, which is used
@@ -56,18 +57,6 @@
public class DITContentRuleSyntax
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
* should be done here is to invoke the default constructor for the
@@ -81,35 +70,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_DIT_CONTENT_RULE_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_DIT_CONTENT_RULE_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_DIT_CONTENT_RULE_NAME);
- throw new InitializationException(message);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_DIT_CONTENT_RULE_OID);
}
/** {@inheritDoc} */
@@ -133,56 +96,6 @@
return SYNTAX_DIT_CONTENT_RULE_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 decodeDITContentRule method to determine if the value is
- // acceptable.
- try
- {
- decodeDITContentRule(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 DIT content
* rule definition according to the rules of this syntax. Note that the
@@ -1376,18 +1289,5 @@
return startPos;
}
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/DITStructureRuleSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/DITStructureRuleSyntax.java
index f141a4e..2970414 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/DITStructureRuleSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/DITStructureRuleSyntax.java
@@ -25,27 +25,26 @@
* Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessage;
+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.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.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteSequence;
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.StaticUtils.*;
+import org.forgerock.opendj.ldap.ResultCode;
+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.DITStructureRule;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.NameForm;
+import org.opends.server.types.Schema;
/**
* This class implements the DIT structure rule description syntax, which is
@@ -55,17 +54,6 @@
public class DITStructureRuleSyntax
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
@@ -79,100 +67,33 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException, InitializationException
+ @Override
+ 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_DIT_STRUCTURE_RULE_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_DIT_STRUCTURE_RULE_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_DIT_STRUCTURE_RULE_NAME);
- throw new InitializationException(message);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_DIT_STRUCTURE_RULE_OID);
}
/** {@inheritDoc} */
+ @Override
public String getName()
{
return SYNTAX_DIT_STRUCTURE_RULE_NAME;
}
/** {@inheritDoc} */
+ @Override
public String getOID()
{
return SYNTAX_DIT_STRUCTURE_RULE_OID;
}
/** {@inheritDoc} */
+ @Override
public String getDescription()
{
return SYNTAX_DIT_STRUCTURE_RULE_DESCRIPTION;
}
- /** {@inheritDoc} */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /** {@inheritDoc} */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /** {@inheritDoc} */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /** {@inheritDoc} */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /** {@inheritDoc} */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // We'll use the decodeDITStructureRule method to determine if the value is
- // acceptable.
- try
- {
- decodeDITStructureRule(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 DIT structure
* rule definition according to the rules of this syntax. Note that the
@@ -1139,17 +1060,5 @@
return startPos;
}
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/DeliveryMethodSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/DeliveryMethodSyntax.java
index e957910..813bfcd 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/DeliveryMethodSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/DeliveryMethodSyntax.java
@@ -26,22 +26,12 @@
*/
package org.opends.server.schema;
-import java.util.HashSet;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import java.util.StringTokenizer;
-
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.StaticUtils.*;
+
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
/**
* This class defines the delivery method attribute syntax. This contains one
@@ -66,40 +56,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /**
- * The set of values that may be used as delivery methods.
- */
- private static final String[] ALLOWED_VALUES =
- {
- "any",
- "mhs",
- "physical",
- "telex",
- "teletex",
- "g3fax",
- "g4fax",
- "ia5",
- "videotex",
- "telephone"
- };
-
- /** The hash set containing the allowed values. */
- private HashSet<String> allowedValues;
-
- /** The default approximate matching rule for this syntax. */
- private MatchingRule defaultApproximateMatchingRule;
-
- /** 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
* should be done here is to invoke the default constructor for the
@@ -112,46 +68,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- allowedValues = new HashSet<String>(ALLOWED_VALUES.length);
- for (String s : ALLOWED_VALUES)
- {
- allowedValues.add(s);
- }
-
- defaultApproximateMatchingRule =
- DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID);
- if (defaultApproximateMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE,
- AMR_DOUBLE_METAPHONE_OID, SYNTAX_DELIVERY_METHOD_NAME);
- }
-
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_OID, SYNTAX_DELIVERY_METHOD_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_CASE_IGNORE_OID, SYNTAX_DELIVERY_METHOD_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_DELIVERY_METHOD_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_DELIVERY_METHOD_OID);
}
/**
@@ -159,6 +79,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_DELIVERY_METHOD_NAME;
@@ -169,6 +90,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_DELIVERY_METHOD_OID;
@@ -179,109 +101,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_DELIVERY_METHOD_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- return defaultApproximateMatchingRule;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- String stringValue = toLowerCase(value.toString());
- StringTokenizer tokenizer = new StringTokenizer(stringValue, " $");
- if (! tokenizer.hasMoreTokens())
- {
- invalidReason.append(ERR_ATTR_SYNTAX_DELIVERY_METHOD_NO_ELEMENTS.get(value));
- return false;
- }
-
- while (tokenizer.hasMoreTokens())
- {
- String token = tokenizer.nextToken();
- if (! allowedValues.contains(token))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_DELIVERY_METHOD_INVALID_ELEMENT.get(value, token));
- return false;
- }
- }
-
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/DirectoryStringSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/DirectoryStringSyntax.java
index faea3bd..0df279c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/DirectoryStringSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/DirectoryStringSyntax.java
@@ -25,22 +25,21 @@
* Portions Copyright 2012-2015 ForgeRock AS
*/
package org.opends.server.schema;
+import static org.opends.server.schema.SchemaConstants.*;
+
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ByteSequence;
+import org.forgerock.opendj.ldap.Option;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SchemaOptions;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
-import org.opends.server.core.DirectoryServer;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-
-import static org.opends.messages.SchemaMessages.*;
-import static org.opends.server.schema.SchemaConstants.*;
+import org.opends.server.core.ServerContext;
/**
@@ -54,26 +53,13 @@
implements ConfigurationChangeListener<DirectoryStringAttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default approximate matching rule for this syntax. */
- private MatchingRule defaultApproximateMatchingRule;
-
/** Indicates whether we will allow zero-length values. */
private boolean allowZeroLengthValues;
/** The reference to the configuration for this directory string syntax. */
private DirectoryStringAttributeSyntaxCfg currentConfig;
- /** 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;
-
+ private ServerContext serverContext;
/**
* Creates a new instance of this syntax. Note that the only thing that
@@ -88,41 +74,10 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(DirectoryStringAttributeSyntaxCfg configuration)
+ public void initializeSyntax(DirectoryStringAttributeSyntaxCfg configuration, ServerContext serverContext)
throws ConfigException
{
- defaultApproximateMatchingRule =
- DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID);
- if (defaultApproximateMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE,
- AMR_DOUBLE_METAPHONE_OID, SYNTAX_DIRECTORY_STRING_NAME);
- }
-
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_OID, SYNTAX_DIRECTORY_STRING_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_CASE_IGNORE_OID, SYNTAX_DIRECTORY_STRING_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_DIRECTORY_STRING_NAME);
- }
-
+ this.serverContext = serverContext;
// This syntax is one of the Directory Server's core syntaxes and therefore
// it may be instantiated at times without a configuration entry. If that
@@ -136,6 +91,26 @@
currentConfig = configuration;
currentConfig.addDirectoryStringChangeListener(this);
allowZeroLengthValues = currentConfig.isAllowZeroLengthValues();
+ updateNewSchema();
+ }
+
+ /** Update the option in new schema if it changes from current value. */
+ private void updateNewSchema()
+ {
+ Option<Boolean> option = SchemaOptions.ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS;
+ if (allowZeroLengthValues != serverContext.getSchemaNG().getOption(option))
+ {
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ schemaUpdater.updateSchema(
+ schemaUpdater.getSchemaBuilder().setOption(option, allowZeroLengthValues).toSchema());
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
+ {
+ return schema.getSyntax(SchemaConstants.SYNTAX_DIRECTORY_STRING_OID);
}
/**
@@ -181,90 +156,6 @@
}
/**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- return defaultApproximateMatchingRule;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- if (allowZeroLengthValues || (value.length() > 0))
- {
- return true;
- }
- else
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_DIRECTORYSTRING_INVALID_ZEROLENGTH_VALUE.get());
- return false;
- }
- }
-
- /**
* Indicates whether zero-length values will be allowed. This is technically
* forbidden by the LDAP specification, but it was allowed in earlier versions
* of the server, and the discussion of the directory string syntax in RFC
@@ -296,22 +187,9 @@
{
currentConfig = configuration;
allowZeroLengthValues = configuration.isAllowZeroLengthValues();
+ updateNewSchema();
return new ConfigChangeResult();
}
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/DistinguishedNameSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/DistinguishedNameSyntax.java
index 4895c2a..ac64747 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/DistinguishedNameSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/DistinguishedNameSyntax.java
@@ -26,20 +26,13 @@
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
-import org.opends.server.api.AttributeSyntax;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.DN;
-import org.opends.server.types.DirectoryException;
-
-import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class defines the distinguished name attribute syntax, which is used for
@@ -49,14 +42,6 @@
public class DistinguishedNameSyntax
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
- /** The default substring matching rule for this syntax. */
- private MatchingRule defaultSubstringMatchingRule;
-
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -70,22 +55,9 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_DN_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_DN_OID, SYNTAX_DN_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_DN_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_DN_OID);
}
/**
@@ -120,115 +92,5 @@
{
return SYNTAX_DN_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- // There is no ordering matching rule by default.
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Use the DN code to make this determination.
- try
- {
- DN.valueOf(value.toString());
-
- return true;
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- invalidReason.append(de.getMessageObject());
- return false;
- }
- catch (Exception e)
- {
- logger.traceException(e);
- invalidReason.append(ERR_ATTR_SYNTAX_DN_INVALID.get(value, e));
- return false;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/EnhancedGuideSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/EnhancedGuideSyntax.java
index 50a5e99..41d8185 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/EnhancedGuideSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/EnhancedGuideSyntax.java
@@ -26,19 +26,12 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.StaticUtils.*;
+
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
/**
* This class implements the enhanced guide attribute syntax, which may be used
@@ -49,17 +42,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -72,32 +54,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_OCTET_STRING_OID, SYNTAX_ENHANCED_GUIDE_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_OCTET_STRING_OID, SYNTAX_ENHANCED_GUIDE_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_OCTET_STRING_OID, SYNTAX_ENHANCED_GUIDE_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_ENHANCED_GUIDE_OID);
}
/**
@@ -105,6 +65,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_ENHANCED_GUIDE_NAME;
@@ -115,6 +76,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_ENHANCED_GUIDE_OID;
@@ -125,164 +87,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_ENHANCED_GUIDE_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Get a lowercase string version of the provided value.
- String valueStr = toLowerCase(value.toString());
-
-
- // Find the position of the first octothorpe. It should denote the end of
- // the objectclass.
- int sharpPos = valueStr.indexOf('#');
- if (sharpPos < 0)
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_SHARP.get(valueStr));
- return false;
- }
-
-
- // Get the objectclass and see if it is a valid name or OID.
- String ocName = valueStr.substring(0, sharpPos).trim();
- int ocLength = ocName.length();
- if (ocLength == 0)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_OC.get(valueStr));
- return false;
- }
-
- if (! isValidSchemaElement(ocName, 0, ocLength, invalidReason))
- {
- return false;
- }
-
-
- // Find the last octothorpe and make sure it is followed by a valid scope.
- int lastSharpPos = valueStr.lastIndexOf('#');
- if (lastSharpPos == sharpPos)
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_FINAL_SHARP.get(valueStr));
- return false;
- }
-
- String scopeStr = valueStr.substring(lastSharpPos+1).trim();
- if (!scopeStr.equals("baseobject")
- && !scopeStr.equals("onelevel")
- && !scopeStr.equals("wholesubtree")
- && !scopeStr.equals("subordinatesubtree"))
- {
- if (scopeStr.length() == 0)
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_SCOPE.get(valueStr));
- }
- else
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_ENHANCEDGUIDE_INVALID_SCOPE.get(
- valueStr, scopeStr));
- }
-
- return false;
- }
-
-
- // Everything between the two octothorpes must be the criteria. Make sure
- // it is valid.
- String criteria = valueStr.substring(sharpPos+1, lastSharpPos).trim();
- int criteriaLength = criteria.length();
- if (criteriaLength == 0)
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_CRITERIA.get(valueStr));
- return false;
- }
-
- return GuideSyntax.criteriaIsValid(criteria, valueStr, invalidReason);
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/FaxNumberSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/FaxNumberSyntax.java
index ee3c6d2..db50803 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/FaxNumberSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/FaxNumberSyntax.java
@@ -26,21 +26,12 @@
*/
package org.opends.server.schema;
-import java.util.HashSet;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.StaticUtils.*;
+
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
/**
* This class implements the facsimile telephone number attribute syntax, which
@@ -61,35 +52,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /**
- * The set of allowed fax parameter values, formatted entirely in lowercase
- * characters.
- */
- public static final HashSet<String> ALLOWED_FAX_PARAMETERS =
- new HashSet<String>(7);
-
- static
- {
- ALLOWED_FAX_PARAMETERS.add("twodimensional");
- ALLOWED_FAX_PARAMETERS.add("fineresolution");
- ALLOWED_FAX_PARAMETERS.add("unlimitedlength");
- ALLOWED_FAX_PARAMETERS.add("b4length");
- ALLOWED_FAX_PARAMETERS.add("a3width");
- ALLOWED_FAX_PARAMETERS.add("b4width");
- ALLOWED_FAX_PARAMETERS.add("uncompressed");
- }
-
- /** 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
* should be done here is to invoke the default constructor for the
@@ -102,29 +64,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_OID, SYNTAX_FAXNUMBER_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_CASE_IGNORE_OID, SYNTAX_FAXNUMBER_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_FAXNUMBER_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_FAXNUMBER_OID);
}
/**
@@ -132,6 +75,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_FAXNUMBER_NAME;
@@ -142,6 +86,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_FAXNUMBER_OID;
@@ -152,184 +97,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_FAXNUMBER_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Get a lowercase string representation of the value and find its length.
- String valueString = toLowerCase(value.toString());
- int valueLength = valueString.length();
-
-
- // The value must contain at least one character.
- if (valueLength == 0)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_EMPTY.get());
- return false;
- }
-
-
- // The first character must be a printable string character.
- char c = valueString.charAt(0);
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_NOT_PRINTABLE.get(valueString, c, 0));
- return false;
- }
-
-
- // Continue reading until we find a dollar sign or the end of the string.
- // Every intermediate character must be a printable string character.
- int pos = 1;
- for ( ; pos < valueLength; pos++)
- {
- c = valueString.charAt(pos);
- if (c == '$')
- {
- pos++;
- break;
- }
- else
- {
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_NOT_PRINTABLE.get(valueString, c, pos));
- }
- }
- }
-
- if (pos >= valueLength)
- {
- // We're at the end of the value, so it must be valid unless the last
- // character was a dollar sign.
- if (c == '$')
- {
- invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_END_WITH_DOLLAR.get(
- valueString));
- return false;
- }
- else
- {
- return true;
- }
- }
-
-
- // Continue reading until we find the end of the string. Each substring
- // must be a valid fax parameter.
- int paramStartPos = pos;
- while (pos < valueLength)
- {
- c = valueString.charAt(pos++);
- if (c == '$')
- {
- String paramStr = valueString.substring(paramStartPos, pos);
- if (! ALLOWED_FAX_PARAMETERS.contains(paramStr))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_ILLEGAL_PARAMETER.get(
- valueString, paramStr, paramStartPos, (pos-1)));
- return false;
- }
-
- paramStartPos = pos;
- }
- }
-
-
- // We must be at the end of the value. Read the last parameter and make
- // sure it is valid.
- String paramStr = valueString.substring(paramStartPos);
- if (! ALLOWED_FAX_PARAMETERS.contains(paramStr))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_ILLEGAL_PARAMETER.get(
- valueString, paramStr, paramStartPos, (pos-1)));
- return false;
- }
-
-
- // If we've gotten here, then the value must be valid.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/FaxSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/FaxSyntax.java
index ffde107..32ba050 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/FaxSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/FaxSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the fax attribute syntax. This should be restricted to
@@ -49,17 +43,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -72,29 +55,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_FAX_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_FAX_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_FAX_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_FAX_OID);
}
/**
@@ -102,6 +66,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_FAX_NAME;
@@ -112,6 +77,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_FAX_OID;
@@ -122,93 +88,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_FAX_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // All values will be acceptable for the fax syntax.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return false;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/GeneralizedTimeSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/GeneralizedTimeSyntax.java
index 72420e0..e700455 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/GeneralizedTimeSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/GeneralizedTimeSyntax.java
@@ -27,26 +27,25 @@
*/
package org.opends.server.schema;
+import static org.opends.messages.SchemaMessages.*;
+import static org.opends.server.schema.SchemaConstants.*;
+import static org.opends.server.util.ServerConstants.*;
+
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-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.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteSequence;
-import static org.opends.messages.SchemaMessages.*;
-import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.ServerConstants.*;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.schema.Schema;
+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.types.DirectoryException;
/**
* This class defines the generalized time attribute syntax, which is a way of
@@ -64,15 +63,6 @@
private static final TimeZone TIME_ZONE_UTC_OBJ =
TimeZone.getTimeZone(TIME_ZONE_UTC);
- /** 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
* should be done here is to invoke the default constructor for the
@@ -86,32 +76,9 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_GENERALIZED_TIME_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_GENERALIZED_TIME_OID, SYNTAX_GENERALIZED_TIME_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_GENERALIZED_TIME_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_GENERALIZED_TIME_OID, SYNTAX_GENERALIZED_TIME_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_GENERALIZED_TIME_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_GENERALIZED_TIME_OID);
}
/**
@@ -148,91 +115,6 @@
}
/**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- // Approximate matching will not be allowed by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- try
- {
- decodeGeneralizedTimeValue(value);
- return true;
- }
- catch (DirectoryException de)
- {
- invalidReason.append(de.getMessageObject());
- return false;
- }
- }
-
- /**
* Retrieves the generalized time representation of the provided date.
*
* @param d The date to retrieve in generalized time form.
@@ -1554,18 +1436,5 @@
// time zone by using "GMT" followed by the offset.
return TimeZone.getTimeZone("GMT" + offSetStr);
}
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/GuideSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/GuideSyntax.java
index 7caac20..3b22f10 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/GuideSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/GuideSyntax.java
@@ -27,16 +27,13 @@
package org.opends.server.schema;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.AttributeSyntax;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.opends.server.core.DirectoryServer;
-import org.forgerock.opendj.ldap.ByteSequence;
-
-
import static org.opends.messages.SchemaMessages.*;
+
import org.forgerock.i18n.LocalizableMessageBuilder;
+
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -49,17 +46,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -72,29 +58,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_GUIDE_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_GUIDE_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_GUIDE_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_GUIDE_OID);
}
/**
@@ -102,6 +69,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_GUIDE_NAME;
@@ -112,6 +80,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_GUIDE_OID;
@@ -122,107 +91,13 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_GUIDE_DESCRIPTION;
}
/**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Get a lowercase string version of the provided value.
- String valueStr = toLowerCase(value.toString());
-
-
- // Find the position of the octothorpe. If there isn't one, then the entire
- // value should be the criteria.
- int sharpPos = valueStr.indexOf('#');
- if (sharpPos < 0)
- {
- return criteriaIsValid(valueStr, valueStr, invalidReason);
- }
-
-
- // Get the objectclass and see if it is a valid name or OID.
- String ocName = valueStr.substring(0, sharpPos).trim();
- int ocLength = ocName.length();
- if (ocLength == 0)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_GUIDE_NO_OC.get(valueStr));
- return false;
- }
-
- return isValidSchemaElement(ocName, 0, ocLength, invalidReason)
- // The rest of the value must be the criteria.
- && criteriaIsValid(valueStr.substring(sharpPos+1), valueStr, invalidReason);
- }
-
- /**
* Determines whether the provided string represents a valid criteria
* according to the guide syntax.
*
@@ -508,17 +383,5 @@
}
}
}
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/IA5StringSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/IA5StringSyntax.java
index 85201bc..139f2c0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/IA5StringSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/IA5StringSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-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.forgerock.opendj.ldap.ByteSequence;
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the IA5 string attribute syntax, which is simply a
* set of ASCII characters. By default, they will be treated in a
@@ -49,20 +43,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default approximate matching rule for this syntax. */
- private MatchingRule defaultApproximateMatchingRule;
-
- /** 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
* should be done here is to invoke the default constructor for the
@@ -75,40 +55,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultApproximateMatchingRule =
- DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID);
- if (defaultApproximateMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE,
- AMR_DOUBLE_METAPHONE_OID, SYNTAX_IA5_STRING_NAME);
- }
-
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_IA5_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_IA5_OID, SYNTAX_IA5_STRING_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_CASE_IGNORE_OID, SYNTAX_IA5_STRING_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_IA5_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_IA5_OID, SYNTAX_IA5_STRING_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_IA5_STRING_OID);
}
/**
@@ -116,6 +66,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_IA5_STRING_NAME;
@@ -126,6 +77,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_IA5_STRING_OID;
@@ -136,103 +88,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_IA5_STRING_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- return defaultApproximateMatchingRule;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // We will allow any value that does not contain any non-ASCII characters.
- // Empty values are acceptable as well.
- byte b;
- for (int i = 0; i < value.length(); i++)
- {
- b = value.byteAt(i);
- if ((b & 0x7F) != b)
- {
- invalidReason.append(WARN_ATTR_SYNTAX_IA5_ILLEGAL_CHARACTER.get(value, b));
- return false;
- }
- }
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/IntegerSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/IntegerSyntax.java
index 69b5963..8129b79 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/IntegerSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/IntegerSyntax.java
@@ -26,18 +26,13 @@
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
-import org.opends.server.api.AttributeSyntax;
-import org.opends.server.core.DirectoryServer;
-
-import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class defines the integer attribute syntax, which holds an
@@ -48,18 +43,6 @@
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 should be done here is to invoke the default constructor for
@@ -73,29 +56,9 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_INTEGER_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_INTEGER_OID, SYNTAX_INTEGER_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_INTEGER_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_INTEGER_OID, SYNTAX_INTEGER_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_EXACT_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_EXACT_OID, SYNTAX_INTEGER_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_INTEGER_OID);
}
/**
@@ -130,212 +93,5 @@
{
return SYNTAX_INTEGER_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- String valueString = value.toString();
- int length = valueString.length();
-
- if (length == 0)
- {
- invalidReason.append(
- WARN_ATTR_SYNTAX_INTEGER_EMPTY_VALUE.get(valueString));
- return false;
- }
- else if (length == 1)
- {
- switch (valueString.charAt(0))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- return true;
- case '-':
- invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_DASH_NEEDS_VALUE
- .get(valueString));
- return false;
- default:
- invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER
- .get(valueString, valueString.charAt(0), 0));
- return false;
- }
- }
- else
- {
- boolean negative = false;
-
- switch (valueString.charAt(0))
- {
- case '0':
- invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO
- .get(valueString));
- return false;
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- case '-':
- // This is fine too.
- negative = true;
- break;
- default:
- invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER
- .get(valueString, valueString.charAt(0), 0));
- return false;
- }
-
- switch (valueString.charAt(1))
- {
- case '0':
- // This is fine as long as the value isn't negative.
- if (negative)
- {
- invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO
- .get(valueString));
- return false;
- }
- break;
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER
- .get(valueString, valueString.charAt(1), 1));
- return false;
- }
-
- for (int i=2; i < length; i++)
- {
- switch (valueString.charAt(i))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER
- .get(valueString, valueString.charAt(i), i));
- return false;
- }
- }
-
- return true;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/JPEGSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/JPEGSyntax.java
index cdbe709..1db6ee6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/JPEGSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/JPEGSyntax.java
@@ -27,23 +27,21 @@
*/
package org.opends.server.schema;
-import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
import java.util.List;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-import org.opends.server.admin.server.ConfigurationChangeListener;
-import org.opends.server.admin.std.server.JPEGAttributeSyntaxCfg;
-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.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.Option;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SchemaOptions;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.std.server.JPEGAttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+import org.opends.server.core.ServerContext;
/**
* This class implements the JPEG attribute syntax. This is actually
@@ -56,20 +54,11 @@
implements ConfigurationChangeListener<JPEGAttributeSyntaxCfg>
{
- 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;
-
/** The current configuration for this JPEG syntax. */
private volatile JPEGAttributeSyntaxCfg config;
+ private ServerContext serverContext;
+
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -82,39 +71,41 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(JPEGAttributeSyntaxCfg configuration)
+ @Override
+ public void initializeSyntax(JPEGAttributeSyntaxCfg configuration, ServerContext serverContext)
throws ConfigException
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_JPEG_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_JPEG_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_JPEG_NAME);
- }
-
this.config = configuration;
+ this.serverContext = serverContext;
+ updateNewSchema();
config.addJPEGChangeListener(this);
}
+ /** Update the option in new schema if it changes from current value. */
+ private void updateNewSchema()
+ {
+ Option<Boolean> option = SchemaOptions.ALLOW_MALFORMED_JPEG_PHOTOS;
+ if (config.isStrictFormat() == serverContext.getSchemaNG().getOption(option))
+ {
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ schemaUpdater.updateSchema(
+ schemaUpdater.getSchemaBuilder().setOption(option, !config.isStrictFormat()).toSchema());
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
+ {
+ return schema.getSyntax(SchemaConstants.SYNTAX_JPEG_OID);
+ }
+
/**
* Retrieves the common name for this attribute syntax.
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_JPEG_NAME;
@@ -125,6 +116,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_JPEG_OID;
@@ -135,115 +127,14 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_JPEG_DESCRIPTION;
}
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // anything is acceptable if we're not strict.
- if (!config.isStrictFormat())
- return true;
-
- /* JFIF files start:
- * 0xff 0xd8 0xff 0xe0 LH LL 0x4a 0x46 0x49 0x46 ...
- * SOI APP0 len "JFIF"
- *
- * Exif files (from most digital cameras) start:
- * 0xff 0xd8 0xff 0xe1 LH LL 0x45 0x78 0x69 0x66 ...
- * SOI APP1 len "Exif"
- *
- * So all legal values must be at least 10 bytes long
- */
- if (value.length() < 10)
- return false;
-
- if (value.byteAt(0) != (byte)0xff && value.byteAt(1) != (byte)0xd8)
- return false;
-
- if (value.byteAt(2) == (byte)0xff && value.byteAt(3) == (byte)0xe0 &&
- value.byteAt(6) == 'J' && value.byteAt(7) == 'F' &&
- value.byteAt(8) == 'I' && value.byteAt(9) == 'F')
- return true;
-
- if (value.byteAt(2) == (byte)0xff && value.byteAt(3) == (byte)0xe1 &&
- value.byteAt(6) == 'E' && value.byteAt(7) == 'x' &&
- value.byteAt(8) == 'i' && value.byteAt(9) == 'f')
- return true;
-
- // No JFIF or Exif header found
- return false;
- }
-
-
/** {@inheritDoc} */
+ @Override
public boolean isConfigurationChangeAcceptable(
JPEGAttributeSyntaxCfg configuration,
List<LocalizableMessage> unacceptableReasons)
@@ -253,24 +144,13 @@
}
/** {@inheritDoc} */
+ @Override
public ConfigChangeResult applyConfigurationChange(
JPEGAttributeSyntaxCfg configuration)
{
this.config = configuration;
+ updateNewSchema();
return new ConfigChangeResult();
}
-
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return false;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java
index 53e3a28..419f9d8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java
@@ -26,36 +26,34 @@
*/
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.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
-import java.util.regex.Pattern;
import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+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.core.ServerContext;
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.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
* This class defines the LDAP syntax description syntax, which is used to
* hold attribute syntax definitions in the server schema. The format of this
@@ -88,29 +86,9 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_OID, SYNTAX_LDAP_SYNTAX_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_CASE_IGNORE_OID, SYNTAX_LDAP_SYNTAX_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_LDAP_SYNTAX_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_LDAP_SYNTAX_OID);
}
/**
@@ -212,6 +190,8 @@
* @param value The byte sequence containing the value
* to decode (it does not need to be
* normalized).
+ * @param serverContext
+ * The server context.
* @param schema The schema to use to resolve references to
* other schema elements.
* @param allowUnknownElements Indicates whether to allow values that are
@@ -219,15 +199,16 @@
* should only be true when called by
* {@code valueIsAcceptable}.
* Not used for LDAP Syntaxes
+ * @param forDelete
+ * {@code true} if used for deletion.
*
* @return The decoded ldapsyntax definition.
*
* @throws DirectoryException If the provided value cannot be decoded as an
* ldapsyntax definition.
*/
- public static LDAPSyntaxDescription decodeLDAPSyntax(ByteSequence value,
- Schema schema,
- boolean allowUnknownElements) throws DirectoryException
+ public static LDAPSyntaxDescription decodeLDAPSyntax(ByteSequence value, ServerContext serverContext,
+ Schema schema, boolean allowUnknownElements, boolean forDelete) throws DirectoryException
{
// Get string representations of the provided value using the provided form.
String valueStr = value.toString();
@@ -355,11 +336,7 @@
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message);
}
- else
- {
- oid = toLowerCase(valueStr.substring(oidStartPos, pos));
- }
-
+ oid = toLowerCase(valueStr.substring(oidStartPos, pos));
// Skip over the space(s) after the OID.
while ((pos < length) && ((c = valueStr.charAt(pos)) == ' '))
@@ -385,9 +362,8 @@
// we get to the end of the value. But before we start, set default values
// for everything else we might need to know.
String description = null;
- LDAPSyntaxDescriptionSyntax syntax = null;
- HashMap<String,List<String>> extraProperties =
- new LinkedHashMap<String,List<String>>();
+ Syntax syntax = null;
+ HashMap<String,List<String>> extraProperties = new LinkedHashMap<String,List<String>>();
boolean hasXSyntaxToken = false;
while (true)
@@ -418,168 +394,146 @@
pos = readQuotedString(valueStr, descriptionBuffer, pos);
description = descriptionBuffer.toString();
}
- else if (lowerTokenName.equals("x-subst"))
- {
- if (hasXSyntaxToken)
- {
- // We've already seen syntax extension. More than 1 is not allowed
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
- hasXSyntaxToken = true;
- StringBuilder woidBuffer = new StringBuilder();
- pos = readQuotedString(valueStr, woidBuffer, pos);
- String syntaxOID = toLowerCase(woidBuffer.toString());
- AttributeSyntax<?> subSyntax = schema.getSyntax(syntaxOID);
- if (subSyntax == null)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_UNKNOWN_SYNTAX.get(oid, syntaxOID);
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
- }
- syntax = new SubstitutionSyntax(subSyntax,valueStr,description,oid);
- }
-
- else if(lowerTokenName.equals("x-pattern"))
- {
- if (hasXSyntaxToken)
- {
- // We've already seen syntax extension. More than 1 is not allowed
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
- hasXSyntaxToken = true;
- StringBuilder regexBuffer = new StringBuilder();
- pos = readQuotedString(valueStr, regexBuffer, pos);
- String regex = regexBuffer.toString().trim();
- if(regex.length() == 0)
- {
- LocalizableMessage message = WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_NO_PATTERN.get(
- valueStr);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
-
- try
- {
- Pattern pattern = Pattern.compile(regex);
- syntax = new RegexSyntax(pattern,valueStr,description,oid);
- }
- catch(Exception e)
- {
- LocalizableMessage message =
- WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_INVALID_PATTERN.get
- (valueStr,regex);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
- }
- else if(lowerTokenName.equals("x-enum"))
- {
- if (hasXSyntaxToken)
- {
- // We've already seen syntax extension. More than 1 is not allowed
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
- hasXSyntaxToken = true;
- LinkedList<String> values = new LinkedList<String>();
- pos = readExtraParameterValues(valueStr, values, pos);
-
- if (values.isEmpty())
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_LDAPSYNTAX_ENUM_NO_VALUES.get(valueStr);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
- // Parse all enum values, check for uniqueness
- LinkedList<ByteSequence> entries = new LinkedList<ByteSequence>();
- for (String v : values)
- {
- ByteString entry = ByteString.valueOf(v);
- if (entries.contains(entry))
- {
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- WARN_ATTR_SYNTAX_LDAPSYNTAX_ENUM_DUPLICATE_VALUE.get(
- valueStr, entry,pos));
- }
- entries.add(entry);
- }
- syntax = new EnumSyntax(entries, valueStr,description, oid);
- }
- else if (tokenName.matches("X\\-[_\\p{Alpha}-]+"))
- {
- // This must be a non-standard property and it must be followed by
- // either a single value in single quotes or an open parenthesis
- // followed by one or more values in single quotes separated by spaces
- // followed by a close parenthesis.
- List<String> valueList = new ArrayList<String>();
- pos = readExtraParameterValues(valueStr, valueList, pos);
- extraProperties.put(tokenName, valueList);
- }
else
{
- // Unknown Token
- LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_UNKNOWN_EXT.get(
- valueStr, tokenName, pos);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
+ SchemaBuilder schemaBuilder = serverContext != null ?
+ serverContext.getSchemaUpdater().getSchemaBuilder() : new SchemaBuilder(CoreSchema.getInstance());
+
+ if (lowerTokenName.equals("x-subst"))
+ {
+ if (hasXSyntaxToken)
+ {
+ // We've already seen syntax extension. More than 1 is not allowed
+ LocalizableMessage message =
+ ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ message);
+ }
+ hasXSyntaxToken = true;
+ StringBuilder woidBuffer = new StringBuilder();
+ pos = readQuotedString(valueStr, woidBuffer, pos);
+ String syntaxOID = toLowerCase(woidBuffer.toString());
+ Syntax subSyntax = schema.getSyntax(syntaxOID);
+ if (subSyntax == null)
+ {
+ LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_UNKNOWN_SYNTAX.get(oid, syntaxOID);
+ throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
+ }
+ syntax = forDelete ? schema.getSyntax(oid) : schemaBuilder.buildSyntax(oid)
+ .extraProperties("x-subst", syntaxOID)
+ .addToSchema().toSchema().getSyntax(oid);
+ }
+
+ else if(lowerTokenName.equals("x-pattern"))
+ {
+ if (hasXSyntaxToken)
+ {
+ // We've already seen syntax extension. More than 1 is not allowed
+ LocalizableMessage message =
+ ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ message);
+ }
+ hasXSyntaxToken = true;
+ StringBuilder regexBuffer = new StringBuilder();
+ pos = readQuotedString(valueStr, regexBuffer, pos);
+ String regex = regexBuffer.toString().trim();
+ if(regex.length() == 0)
+ {
+ LocalizableMessage message = WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_NO_PATTERN.get(
+ valueStr);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ message);
+ }
+
+ try
+ {
+ syntax = forDelete ? schema.getSyntax(oid) : schemaBuilder.buildSyntax(oid)
+ .extraProperties("x-pattern", regex)
+ .addToSchema().toSchema().getSyntax(oid);
+ }
+ catch(Exception e)
+ {
+ LocalizableMessage message =
+ WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_INVALID_PATTERN.get
+ (valueStr,regex);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ message);
+ }
+ }
+ else if(lowerTokenName.equals("x-enum"))
+ {
+ if (hasXSyntaxToken)
+ {
+ // We've already seen syntax extension. More than 1 is not allowed
+ LocalizableMessage message =
+ ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ message);
+ }
+ hasXSyntaxToken = true;
+ LinkedList<String> values = new LinkedList<String>();
+ pos = readExtraParameterValues(valueStr, values, pos);
+
+ if (values.isEmpty())
+ {
+ LocalizableMessage message =
+ ERR_ATTR_SYNTAX_LDAPSYNTAX_ENUM_NO_VALUES.get(valueStr);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ message);
+ }
+ // Parse all enum values, check for uniqueness
+ List<String> entries = new LinkedList<>();
+ for (String v : values)
+ {
+ ByteString entry = ByteString.valueOf(v);
+ if (entries.contains(entry))
+ {
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ WARN_ATTR_SYNTAX_LDAPSYNTAX_ENUM_DUPLICATE_VALUE.get(
+ valueStr, entry,pos));
+ }
+ entries.add(v);
+ }
+
+ syntax = forDelete ? schema.getSyntax(oid) : schemaBuilder
+ .addEnumerationSyntax(oid, description, true, entries.toArray(new String[0]))
+ .toSchema().getSyntax(oid);
+ }
+ else if (tokenName.matches("X\\-[_\\p{Alpha}-]+"))
+ {
+ // This must be a non-standard property and it must be followed by
+ // either a single value in single quotes or an open parenthesis
+ // followed by one or more values in single quotes separated by spaces
+ // followed by a close parenthesis.
+ List<String> valueList = new ArrayList<String>();
+ pos = readExtraParameterValues(valueStr, valueList, pos);
+ extraProperties.put(tokenName, valueList);
+ }
+ else
+ {
+ // Unknown Token
+ LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_UNKNOWN_EXT.get(
+ valueStr, tokenName, pos);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ message);
+ }
}
}
if (syntax == null)
{
- // Create a plain Syntax. That seems to be required by export/import
- // Schema backend.
- syntax = new LDAPSyntaxDescriptionSyntax();
+ // TODO : add localized message
+ throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
+ LocalizableMessage.raw("no LDAP syntax for:" + value));
}
CommonSchemaElements.checkSafeProperties(extraProperties);
//Since we reached here it means everything is OK.
- return new LDAPSyntaxDescription(valueStr,syntax,
- description,extraProperties);
+ return new LDAPSyntaxDescription(valueStr, syntax, extraProperties);
}
/**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // We'll use the decodeAttributeType method to determine if the value is
- // acceptable.
- try
- {
- decodeLDAPSyntax(value, DirectoryServer.getSchema(), true);
- return true;
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- invalidReason.append(de.getMessageObject());
- return false;
- }
- }
-
-
- /**
* Reads the next token name from the attribute syntax definition, skipping
* over any leading or trailing spaces, and appends it to the provided buffer.
*
@@ -870,512 +824,4 @@
return startPos;
}
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return true;
- }
-
- /**
- * This class provides a substitution mechanism where one unimplemented
- * syntax can be substituted by another defined syntax. A substitution syntax
- * is an LDAPSyntaxDescriptionSyntax with X-SUBST extension.
- */
- private static class SubstitutionSyntax extends
- LDAPSyntaxDescriptionSyntax
- {
- /** The syntax that will substitute the unimplemented syntax. */
- private AttributeSyntax<?> subSyntax;
-
- /** The description of this syntax. */
- private String description;
-
- /** The definition of this syntax. */
- private String definition;
-
-
- /** The oid of this syntax. */
- private String oid;
-
- /** Creates a new instance of this syntax. */
- private SubstitutionSyntax(AttributeSyntax<?> subSyntax,
- String definition,
- String description,
- String oid)
- {
- super();
- this.subSyntax = subSyntax;
- this.definition = definition;
- this.description = description;
- this.oid = oid;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getName()
- {
- // There is no name for a substitution syntax.
- return null;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getOID()
- {
- return oid;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getDescription()
- {
- return description;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString()
- {
- return definition;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- return subSyntax.valueIsAcceptable(value, invalidReason);
- }
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return subSyntax.getEqualityMatchingRule();
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- return subSyntax.getOrderingMatchingRule();
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- return subSyntax.getSubstringMatchingRule();
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- return subSyntax.getApproximateMatchingRule();
- }
- }
-
- /**
- * This class provides a regex mechanism where a new syntax and its
- * corresponding matching rules can be created on-the-fly. A regex
- * syntax is an LDAPSyntaxDescriptionSyntax with X-PATTERN extension.
- */
- private static class RegexSyntax extends
- LDAPSyntaxDescriptionSyntax
- {
- /** The Pattern associated with the regex. */
- private Pattern pattern;
-
- /** The description of this syntax. */
- private String description;
-
- /** The oid of this syntax. */
- private String oid;
-
- /** The definition of this syntax. */
- private String definition;
-
- /** The equality matching rule. */
- private MatchingRule equalityMatchingRule;
-
- /** The substring matching rule. */
- private MatchingRule substringMatchingRule;
-
- /** The ordering matching rule. */
- private MatchingRule orderingMatchingRule;
-
- /** The approximate matching rule. */
- private MatchingRule approximateMatchingRule;
-
-
- /** Creates a new instance of this syntax. */
- private RegexSyntax(Pattern pattern,
- String definition,
- String description,
- String oid)
- {
- super();
- this.definition = definition;
- this.pattern = pattern;
- this.description = description;
- this.oid = oid;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getName()
- {
- // There is no name for a regex syntax.
- return null;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getOID()
- {
- return oid;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getDescription()
- {
- return description;
- }
-
-
- /** {@inheritDoc} */
- @Override
- public String toString()
- {
- return definition;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- String strValue = value.toString();
- boolean matches = pattern.matcher(strValue).matches();
- if(!matches)
- {
- LocalizableMessage message = WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_INVALID_VALUE.get(
- strValue,pattern.pattern());
- invalidReason.append(message);
- }
- return matches;
- }
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- if(equalityMatchingRule == null)
- {
- //This has already been verified.
- equalityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- }
- return equalityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- if(orderingMatchingRule == null)
- {
- orderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- }
- return orderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- if(substringMatchingRule == null)
- {
- substringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- }
- return substringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- if(approximateMatchingRule == null)
- {
- approximateMatchingRule =
- DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID);
- }
- return approximateMatchingRule;
- }
- }
-
- /**
- * This class provides an enumeration-based mechanism where a new syntax
- * and its corresponding matching rules can be created on-the-fly. An enum
- * syntax is an LDAPSyntaxDescriptionSyntax with X-PATTERN extension.
- */
- private static class EnumSyntax extends
- LDAPSyntaxDescriptionSyntax
- {
- /** Set of read-only enum entries. */
- LinkedList<ByteSequence> entries;
-
- /** The description of this syntax. */
- private String description;
-
- /** The oid of this syntax. */
- private String oid;
-
- /** The equality matching rule. */
- private MatchingRule equalityMatchingRule;
-
- /** The substring matching rule. */
- private MatchingRule substringMatchingRule;
-
- /** The ordering matching rule. */
- private MatchingRule orderingMatchingRule;
-
- /** The approximate matching rule. */
- private MatchingRule approximateMatchingRule;
-
- /** The definition of this syntax. */
- private String definition;
-
-
- /** Creates a new instance of this syntax. */
- private EnumSyntax(LinkedList<ByteSequence> entries,
- String definition,
- String description,
- String oid)
- {
- super();
- this.entries = entries;
- this.definition = definition;
- this.description = description;
- this.oid = oid;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getName()
- {
- // There is no name for a enum syntax.
- return null;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getOID()
- {
- return oid;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString()
- {
- return definition;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getDescription()
- {
- return description;
- }
-
- /** {@inheritDoc} */
- @Override
- public void finalizeSyntax()
- {
- DirectoryServer.deregisterMatchingRule(orderingMatchingRule);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- //The value is acceptable if it belongs to the set.
- boolean isAllowed = entries.contains(value);
- if (!isAllowed)
- {
- invalidReason.append(WARN_ATTR_SYNTAX_LDAPSYNTAX_ENUM_INVALID_VALUE.get(value,oid));
- }
- return isAllowed;
- }
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- if(equalityMatchingRule == null)
- {
- //This has already been verified.
- equalityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- }
- return equalityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- if (orderingMatchingRule == null)
- {
- /*
- * It is not sufficient to build the enum matching rule alone here, we
- * need to build enum syntax as well otherwise the schema is not valid. The
- * enum matching rule is automatically built with the enum syntax by the
- * builder.
- */
- String[] enumerations = new String[entries.size()];
- Iterator<ByteSequence> it = entries.iterator();
- for (int i=0; i < entries.size(); i++)
- {
- enumerations[i] = it.next().toString();
- }
- SchemaBuilder builder = new SchemaBuilder(CoreSchema.getInstance()).addEnumerationSyntax(
- oid, getDescription(), true, enumerations);
- orderingMatchingRule = builder.toSchema().getMatchingRule(OMR_OID_GENERIC_ENUM + "." + oid);
- try
- {
- DirectoryServer.registerMatchingRule(orderingMatchingRule, false);
- }
- catch(DirectoryException de)
- {
- logger.error(de.getMessageObject());
- }
- }
- return orderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- if(substringMatchingRule == null)
- {
- substringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- }
- return substringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- if(approximateMatchingRule == null)
- {
- approximateMatchingRule =
- DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID);
- }
- return approximateMatchingRule;
- }
-
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleSyntax.java
index 932f992..493f807 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleSyntax.java
@@ -25,28 +25,12 @@
* Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessage;
+import static org.opends.server.schema.SchemaConstants.*;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
-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 org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-import static org.opends.messages.SchemaMessages.*;
-
-import org.forgerock.i18n.LocalizableMessageBuilder;
-
-import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.StaticUtils.*;
/**
* This class implements the matching rule description syntax, which is used to
@@ -56,17 +40,6 @@
public class MatchingRuleSyntax
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
* should be done here is to invoke the default constructor for the
@@ -80,29 +53,9 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_OID, SYNTAX_MATCHING_RULE_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_CASE_IGNORE_OID, SYNTAX_MATCHING_RULE_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_MATCHING_RULE_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_MATCHING_RULE_OID);
}
/**
@@ -137,957 +90,5 @@
{
return SYNTAX_MATCHING_RULE_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- @Override
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Get string representations of the provided value using the provided form
- // and with all lowercase characters.
- String valueStr = value.toString();
- String lowerStr = toLowerCase(valueStr);
-
-
- // We'll do this a character at a time. First, skip over any leading
- // whitespace.
- int pos = 0;
- int length = valueStr.length();
- while ((pos < length) && (valueStr.charAt(pos) == ' '))
- {
- pos++;
- }
-
- if (pos >= length)
- {
- // This means that the value was empty or contained only whitespace. That
- // is illegal.
-
- invalidReason.append(ERR_ATTR_SYNTAX_MR_EMPTY_VALUE.get());
- return false;
- }
-
-
- // The next character must be an open parenthesis. If it is not, then that
- // is an error.
- char c = valueStr.charAt(pos++);
- if (c != '(')
- {
- invalidReason.append(ERR_ATTR_SYNTAX_MR_EXPECTED_OPEN_PARENTHESIS.get(valueStr, (pos-1), c));
- return false;
- }
-
-
- // Skip over any spaces immediately following the opening parenthesis.
- while ((pos < length) && ((c = valueStr.charAt(pos)) == ' '))
- {
- pos++;
- }
-
- if (pos >= length)
- {
- // This means that the end of the value was reached before we could find
- // the OID. Ths is illegal.
-
- invalidReason.append(ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr));
- return false;
- }
-
-
- if (isDigit(c))
- {
- // This must be a numeric OID. In that case, we will accept only digits
- // and periods, but not consecutive periods.
- boolean lastWasPeriod = false;
- while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' '))
- {
- if (c == '.')
- {
- if (lastWasPeriod)
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_MR_DOUBLE_PERIOD_IN_NUMERIC_OID.get(
- valueStr, (pos-1)));
- return false;
- }
- else
- {
- lastWasPeriod = true;
- }
- }
- else if (! isDigit(c))
- {
- // This must have been an illegal character.
- invalidReason.append(ERR_ATTR_SYNTAX_MR_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos-1));
- return false;
- }
- else
- {
- lastWasPeriod = false;
- }
- }
- }
- else
- {
- // This must be a "fake" OID. In this case, we will only accept
- // alphabetic characters, numeric digits, and the hyphen.
- while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' '))
- {
- if (isAlpha(c) || isDigit(c) || (c == '-') ||
- ((c == '_') && DirectoryServer.allowAttributeNameExceptions()))
- {
- // This is fine. It is an acceptable character.
- }
- else
- {
- // This must have been an illegal character.
- invalidReason.append(ERR_ATTR_SYNTAX_MR_ILLEGAL_CHAR_IN_STRING_OID.get(valueStr, c, (pos-1)));
- return false;
- }
- }
- }
-
-
- // If we're at the end of the value, then it isn't a valid matching rule
- // description. Otherwise, parse out the OID.
- if (pos >= length)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr));
- return false;
- }
-
-
- // Skip over the space(s) after the OID.
- while ((pos < length) && ((c = valueStr.charAt(pos)) == ' '))
- {
- pos++;
- }
-
- if (pos >= length)
- {
- // This means that the end of the value was reached before we could find
- // the OID. Ths is illegal.
-
- invalidReason.append(ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr));
- return false;
- }
-
-
- // At this point, we should have a pretty specific syntax that describes
- // what may come next, but some of the components are optional and it would
- // be pretty easy to put something in the wrong order, so we will be very
- // flexible about what we can accept. Just look at the next token, figure
- // out what it is and how to treat what comes after it, then repeat until
- // we get to the end of the value. But before we start, set default values
- // for everything else we might need to know.
- ConcurrentHashMap<String,String> names =
- new ConcurrentHashMap<String,String>();
- AttributeSyntax<?> syntax = null;
- ConcurrentHashMap<String,CopyOnWriteArrayList<String>> extraProperties =
- new ConcurrentHashMap<String,CopyOnWriteArrayList<String>>();
-
-
- while (true)
- {
- StringBuilder tokenNameBuffer = new StringBuilder();
-
- try
- {
- pos = readTokenName(valueStr, tokenNameBuffer, pos);
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- invalidReason.append(de.getMessageObject());
- return false;
- }
-
- String tokenName = tokenNameBuffer.toString();
- String lowerTokenName = toLowerCase(tokenName);
- if (tokenName.equals(")"))
- {
- // We must be at the end of the value. If not, then that's a problem.
- if (pos < length)
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_MR_UNEXPECTED_CLOSE_PARENTHESIS.get(
- valueStr, (pos-1)));
- return false;
- }
-
- break;
- }
- else if (lowerTokenName.equals("name"))
- {
- // This specifies the set of names for the matching rule. It may be a
- // single name in single quotes, or it may be an open parenthesis
- // followed by one or more names in single quotes separated by spaces.
- c = valueStr.charAt(pos++);
- if (c == '\'')
- {
- StringBuilder userBuffer = new StringBuilder();
- StringBuilder lowerBuffer = new StringBuilder();
-
- try
- {
- pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer,
- (pos-1));
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- invalidReason.append(de.getMessageObject());
- return false;
- }
-
- names.put(lowerBuffer.toString(), userBuffer.toString());
- }
- else if (c == '(')
- {
- StringBuilder userBuffer = new StringBuilder();
- StringBuilder lowerBuffer = new StringBuilder();
-
- try
- {
- pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer,
- pos);
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- invalidReason.append(de.getMessageObject());
- return false;
- }
-
- names.put(lowerBuffer.toString(), userBuffer.toString());
-
-
- while (true)
- {
- if (valueStr.charAt(pos) == ')')
- {
- // Skip over any spaces after the parenthesis.
- pos++;
- while ((pos < length) && ((c = valueStr.charAt(pos)) == ' '))
- {
- pos++;
- }
-
- break;
- }
- else
- {
- userBuffer = new StringBuilder();
- lowerBuffer = new StringBuilder();
-
- try
- {
- pos = readQuotedString(valueStr, lowerStr, userBuffer,
- lowerBuffer, pos);
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- invalidReason.append(de.getMessageObject());
- return false;
- }
-
- names.put(lowerBuffer.toString(), userBuffer.toString());
- }
- }
- }
- else
- {
- // This is an illegal character.
- invalidReason.append(ERR_ATTR_SYNTAX_MR_ILLEGAL_CHAR.get(valueStr, c, (pos-1)));
- return false;
- }
- }
- else if (lowerTokenName.equals("desc"))
- {
- // This specifies the description for the matching rule. It is an
- // arbitrary string of characters enclosed in single quotes.
- StringBuilder descriptionBuffer = new StringBuilder();
-
- try
- {
- pos = readQuotedString(valueStr, descriptionBuffer, pos);
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- invalidReason.append(de.getMessageObject());
- return false;
- }
- }
- else if (lowerTokenName.equals("obsolete"))
- {
- // This indicates whether the matching rule should be considered
- // obsolete. We do not need to do any more parsing for this token.
- }
- else if (lowerTokenName.equals("syntax"))
- {
- // This specifies the syntax for the matching rule. Read the next
- // token, which should be the OID of the associated syntax.
- StringBuilder oidBuffer = new StringBuilder();
-
- try
- {
- pos = readWOID(lowerStr, oidBuffer, pos);
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- invalidReason.append(de.getMessageObject());
- return false;
- }
-
- // See if the server recognizes that syntax. If not, then log a
- // warning.
- syntax = DirectoryServer.getSchema().getSyntax(oidBuffer.toString(), false);
- if (syntax == null)
- {
- logger.error(ERR_ATTR_SYNTAX_MR_UNKNOWN_SYNTAX, valueStr, oidBuffer);
-
- syntax = DirectoryServer.getDefaultAttributeSyntax();
- }
- }
- else
- {
- // This must be a non-standard property and it must be followed by
- // either a single value in single quotes or an open parenthesis
- // followed by one or more values in single quotes separated by spaces
- // followed by a close parenthesis.
- CopyOnWriteArrayList<String> valueList =
- new CopyOnWriteArrayList<String>();
-
- try
- {
- pos = readExtraParameterValues(valueStr, valueList, pos);
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- invalidReason.append(de.getMessageObject());
- return false;
- }
-
- extraProperties.put(tokenName, valueList);
- }
- }
-
-
- // Make sure that a syntax was specified.
- if (syntax == null)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_MR_NO_SYNTAX.get(valueStr));
- return false;
- }
-
-
- // If we've gotten here, then the value is acceptable.
- return true;
- }
-
- /**
- * Reads the next token name from the matching rule definition, skipping over
- * any leading or trailing spaces, and appends it to the provided buffer.
- *
- * @param valueStr The string representation of the matching rule
- * definition.
- * @param tokenName The buffer into which the token name will be written.
- * @param startPos The position in the provided string at which to start
- * reading the token name.
- *
- * @return The position of the first character that is not part of the token
- * name or one of the trailing spaces after it.
- *
- * @throws DirectoryException If a problem is encountered while reading the
- * token name.
- */
- private static int readTokenName(String valueStr, StringBuilder tokenName,
- int startPos)
- throws DirectoryException
- {
- // Skip over any spaces at the beginning of the value.
- char c = '\u0000';
- int length = valueStr.length();
- while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
- {
- startPos++;
- }
-
- if (startPos >= length)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // Read until we find the next space.
- while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' '))
- {
- tokenName.append(c);
- }
-
-
- // Skip over any trailing spaces after the value.
- while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
- {
- startPos++;
- }
-
-
- // Return the position of the first non-space character after the token.
- return startPos;
- }
-
- /**
- * Reads the value of a string enclosed in single quotes, skipping over the
- * quotes and any leading or trailing spaces, and appending the string to the
- * provided buffer.
- *
- * @param valueStr The user-provided representation of the matching rule
- * definition.
- * @param valueBuffer The buffer into which the user-provided representation
- * of the value will be placed.
- * @param startPos The position in the provided string at which to start
- * reading the quoted string.
- *
- * @return The position of the first character that is not part of the quoted
- * string or one of the trailing spaces after it.
- *
- * @throws DirectoryException If a problem is encountered while reading the
- * quoted string.
- */
- private static int readQuotedString(String valueStr,
- StringBuilder valueBuffer, int startPos)
- throws DirectoryException
- {
- // Skip over any spaces at the beginning of the value.
- char c = '\u0000';
- int length = valueStr.length();
- while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
- {
- startPos++;
- }
-
- if (startPos >= length)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // The next character must be a single quote.
- if (c != '\'')
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_MR_EXPECTED_QUOTE_AT_POS.get(valueStr, startPos, c);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // Read until we find the closing quote.
- startPos++;
- while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\''))
- {
- valueBuffer.append(c);
- startPos++;
- }
-
-
- // Skip over any trailing spaces after the value.
- startPos++;
- while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
- {
- startPos++;
- }
-
-
- // If we're at the end of the value, then that's illegal.
- if (startPos >= length)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // Return the position of the first non-space character after the token.
- return startPos;
- }
-
- /**
- * Reads the value of a string enclosed in single quotes, skipping over the
- * quotes and any leading or trailing spaces, and appending the string to the
- * provided buffer.
- *
- * @param valueStr The user-provided representation of the matching rule
- * definition.
- * @param lowerStr The all-lowercase representation of the matching rule
- * definition.
- * @param userBuffer The buffer into which the user-provided representation
- * of the value will be placed.
- * @param lowerBuffer The buffer into which the all-lowercase representation
- * of the value will be placed.
- * @param startPos The position in the provided string at which to start
- * reading the quoted string.
- *
- * @return The position of the first character that is not part of the quoted
- * string or one of the trailing spaces after it.
- *
- * @throws DirectoryException If a problem is encountered while reading the
- * quoted string.
- */
- private static int readQuotedString(String valueStr, String lowerStr,
- StringBuilder userBuffer,
- StringBuilder lowerBuffer, int startPos)
- throws DirectoryException
- {
- // Skip over any spaces at the beginning of the value.
- char c = '\u0000';
- int length = lowerStr.length();
- while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' '))
- {
- startPos++;
- }
-
- if (startPos >= length)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(lowerStr);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // The next character must be a single quote.
- if (c != '\'')
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_MR_EXPECTED_QUOTE_AT_POS.get(valueStr, startPos, c);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // Read until we find the closing quote.
- startPos++;
- while ((startPos < length) && ((c = lowerStr.charAt(startPos)) != '\''))
- {
- lowerBuffer.append(c);
- userBuffer.append(valueStr.charAt(startPos));
- startPos++;
- }
-
-
- // Skip over any trailing spaces after the value.
- startPos++;
- while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' '))
- {
- startPos++;
- }
-
-
- // If we're at the end of the value, then that's illegal.
- if (startPos >= length)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(lowerStr);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // Return the position of the first non-space character after the token.
- return startPos;
- }
-
- /**
- * Reads the attribute type/objectclass description or numeric OID from the
- * provided string, skipping over any leading or trailing spaces, and
- * appending the value to the provided buffer.
- *
- * @param lowerStr The string from which the name or OID is to be read.
- * @param woidBuffer The buffer into which the name or OID should be
- * appended.
- * @param startPos The position at which to start reading.
- *
- * @return The position of the first character after the name or OID that is
- * not a space.
- *
- * @throws DirectoryException If a problem is encountered while reading the
- * name or OID.
- */
- private static int readWOID(String lowerStr, StringBuilder woidBuffer,
- int startPos)
- throws DirectoryException
- {
- // Skip over any spaces at the beginning of the value.
- char c = '\u0000';
- int length = lowerStr.length();
- while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' '))
- {
- startPos++;
- }
-
- if (startPos >= length)
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_OBJECTCLASS_TRUNCATED_VALUE.get(lowerStr);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // The next character must be either numeric (for an OID) or alphabetic (for
- // an objectclass description).
- if (isDigit(c))
- {
- // This must be a numeric OID. In that case, we will accept only digits
- // and periods, but not consecutive periods.
- boolean lastWasPeriod = false;
- while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' '))
- {
- if (c == '.')
- {
- if (lastWasPeriod)
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_OBJECTCLASS_DOUBLE_PERIOD_IN_NUMERIC_OID.
- get(lowerStr, (startPos-1));
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
- else
- {
- woidBuffer.append(c);
- lastWasPeriod = true;
- }
- }
- else if (! isDigit(c))
- {
- // Technically, this must be an illegal character. However, it is
- // possible that someone just got sloppy and did not include a space
- // between the name/OID and a closing parenthesis. In that case,
- // we'll assume it's the end of the value. What's more, we'll have
- // to prematurely return to nasty side effects from stripping off
- // additional characters.
- if (c == ')')
- {
- return (startPos-1);
- }
-
- // This must have been an illegal character.
- LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR_IN_NUMERIC_OID.get(
- lowerStr, c, (startPos - 1));
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
- else
- {
- woidBuffer.append(c);
- lastWasPeriod = false;
- }
- }
- }
- else if (isAlpha(c))
- {
- // This must be an objectclass description. In this case, we will only
- // accept alphabetic characters, numeric digits, and the hyphen.
- while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' '))
- {
- if (isAlpha(c) || isDigit(c) || (c == '-') ||
- ((c == '_') && DirectoryServer.allowAttributeNameExceptions()))
- {
- woidBuffer.append(c);
- }
- else
- {
- // Technically, this must be an illegal character. However, it is
- // possible that someone just got sloppy and did not include a space
- // between the name/OID and a closing parenthesis. In that case,
- // we'll assume it's the end of the value. What's more, we'll have
- // to prematurely return to nasty side effects from stripping off
- // additional characters.
- if (c == ')')
- {
- return (startPos-1);
- }
-
- // This must have been an illegal character.
- LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR_IN_STRING_OID.get(
- lowerStr, c, (startPos - 1));
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
- }
- }
- else
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR.get(lowerStr, c, startPos);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // Skip over any trailing spaces after the value.
- while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' '))
- {
- startPos++;
- }
-
-
- // If we're at the end of the value, then that's illegal.
- if (startPos >= length)
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_OBJECTCLASS_TRUNCATED_VALUE.get(lowerStr);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // Return the position of the first non-space character after the token.
- return startPos;
- }
-
- /**
- * Reads the value for an "extra" parameter. It will handle a single unquoted
- * word (which is technically illegal, but we'll allow it), a single quoted
- * string, or an open parenthesis followed by a space-delimited set of quoted
- * strings or unquoted words followed by a close parenthesis.
- *
- * @param valueStr The string containing the information to be read.
- * @param valueList The list of "extra" parameter values read so far.
- * @param startPos The position in the value string at which to start
- * reading.
- *
- * @return The "extra" parameter value that was read.
- *
- * @throws DirectoryException If a problem occurs while attempting to read
- * the value.
- */
- private static int readExtraParameterValues(String valueStr,
- CopyOnWriteArrayList<String> valueList, int startPos)
- throws DirectoryException
- {
- // Skip over any leading spaces.
- int length = valueStr.length();
- char c = '\u0000';
- while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
- {
- startPos++;
- }
-
- if (startPos >= length)
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
-
- // Look at the next character. If it is a quote, then parse until the next
- // quote and end. If it is an open parenthesis, then parse individual
- // values until the close parenthesis and end. Otherwise, parse until the
- // next space and end.
- if (c == '\'')
- {
- // Parse until the closing quote.
- StringBuilder valueBuffer = new StringBuilder();
- startPos++;
- while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\''))
- {
- valueBuffer.append(c);
- startPos++;
- }
- startPos++;
- valueList.add(valueBuffer.toString());
- }
- else if (c == '(')
- {
- startPos++;
- // We're expecting a list of values. Quoted, space separated.
- while (true)
- {
- // Skip over any leading spaces;
- while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
- {
- startPos++;
- }
-
- if (startPos >= length)
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
-
- if (c == ')')
- {
- // This is the end of the list.
- startPos++;
- break;
- }
- else if (c == '(')
- {
- // This is an illegal character.
- LocalizableMessage message = ERR_ATTR_SYNTAX_MR_ILLEGAL_CHAR.get(valueStr, c, startPos);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
- else if (c == '\'')
- {
- // We have a quoted string
- StringBuilder valueBuffer = new StringBuilder();
- startPos++;
- while ((startPos < length) &&
- ((c = valueStr.charAt(startPos)) != '\''))
- {
- valueBuffer.append(c);
- startPos++;
- }
-
- valueList.add(valueBuffer.toString());
- startPos++;
- }
- else
- {
- //Consider unquoted string
- StringBuilder valueBuffer = new StringBuilder();
- while ((startPos < length) &&
- ((c = valueStr.charAt(startPos)) != ' '))
- {
- valueBuffer.append(c);
- startPos++;
- }
-
- valueList.add(valueBuffer.toString());
- }
-
- if (startPos >= length)
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
- }
- }
- else
- {
- // Parse until the next space.
- StringBuilder valueBuffer = new StringBuilder();
- while ((startPos < length) && ((c = valueStr.charAt(startPos)) != ' '))
- {
- valueBuffer.append(c);
- startPos++;
- }
-
- valueList.add(valueBuffer.toString());
- }
-
- // Skip over any trailing spaces.
- while ((startPos < length) && (valueStr.charAt(startPos) == ' '))
- {
- startPos++;
- }
-
- if (startPos >= length)
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
- return startPos;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleUseSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleUseSyntax.java
index 04a74c1..26ca87f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleUseSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleUseSyntax.java
@@ -25,27 +25,27 @@
* Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessage;
+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.opendj.ldap.ByteSequence;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.schema.MatchingRule;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
-import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
-
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteSequence;
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.StaticUtils.*;
+import org.opends.server.types.AttributeType;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.MatchingRuleUse;
+import org.opends.server.types.Schema;
/**
* This class implements the matching rule use description syntax, which is used
@@ -55,17 +55,6 @@
public class MatchingRuleUseSyntax
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
@@ -79,100 +68,33 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException, InitializationException
+ @Override
+ 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_MATCHING_RULE_USE_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_MATCHING_RULE_USE_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_MATCHING_RULE_USE_NAME);
- throw new InitializationException(message);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_MATCHING_RULE_USE_OID);
}
/** {@inheritDoc} */
+ @Override
public String getName()
{
return SYNTAX_MATCHING_RULE_USE_NAME;
}
/** {@inheritDoc} */
+ @Override
public String getOID()
{
return SYNTAX_MATCHING_RULE_USE_OID;
}
/** {@inheritDoc} */
+ @Override
public String getDescription()
{
return SYNTAX_MATCHING_RULE_USE_DESCRIPTION;
}
- /** {@inheritDoc} */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /** {@inheritDoc} */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /** {@inheritDoc} */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /** {@inheritDoc} */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /** {@inheritDoc} */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // We'll use the decodeMatchingRuleUse method to determine if the value is
- // acceptable.
- try
- {
- decodeMatchingRuleUse(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 matching rule
* use definition according to the rules of this syntax. Note that the
@@ -1077,17 +999,5 @@
return startPos;
}
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/NameAndOptionalUIDSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/NameAndOptionalUIDSyntax.java
index 1482c0a..ea97445 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/NameAndOptionalUIDSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/NameAndOptionalUIDSyntax.java
@@ -26,19 +26,12 @@
*/
package org.opends.server.schema;
-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.DN;
-
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.ldap.ByteSequence;
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.StaticUtils.*;
+
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
/**
* This class implements the name and optional UID attribute syntax, which holds
@@ -48,14 +41,6 @@
public class NameAndOptionalUIDSyntax
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
- /** The default substring matching rule for this syntax. */
- private MatchingRule defaultSubstringMatchingRule;
-
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -68,24 +53,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_UNIQUE_MEMBER_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_UNIQUE_MEMBER_OID, SYNTAX_NAME_AND_OPTIONAL_UID_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_NAME_AND_OPTIONAL_UID_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_NAME_AND_OPTIONAL_UID_OID);
}
/**
@@ -93,6 +64,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_NAME_AND_OPTIONAL_UID_NAME;
@@ -103,6 +75,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_NAME_AND_OPTIONAL_UID_OID;
@@ -113,147 +86,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_NAME_AND_OPTIONAL_UID_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- // There is no ordering matching rule by default.
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- String valueString = value.toString().trim();
- int valueLength = valueString.length();
-
-
- // See if the value contains the "optional uid" portion. If we think it
- // does, then mark its location.
- int dnEndPos = valueLength;
- int sharpPos = -1;
- if (valueString.endsWith("'B") || valueString.endsWith("'b"))
- {
- sharpPos = valueString.lastIndexOf("#'");
- if (sharpPos > 0)
- {
- dnEndPos = sharpPos;
- }
- }
-
-
- // Take the DN portion of the string and try to normalize it.
- try
- {
- DN.valueOf(valueString.substring(0, dnEndPos));
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- // We couldn't normalize the DN for some reason. The value cannot be
- // acceptable.
-
- invalidReason.append(ERR_ATTR_SYNTAX_NAMEANDUID_INVALID_DN.get(
- valueString, getExceptionMessage(e)));
- return false;
- }
-
- // If there is an "optional uid", then normalize it and make sure it only
- // contains valid binary digits.
- if (sharpPos > 0)
- {
- int endPos = valueLength - 2;
- for (int i=sharpPos+2; i < endPos; i++)
- {
- char c = valueString.charAt(i);
- if (c != '0' && c != '1')
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_NAMEANDUID_ILLEGAL_BINARY_DIGIT.get(valueString, c, i));
- return false;
- }
- }
- }
-
-
- // If we've gotten here, then the value is acceptable.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
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;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/NumericStringSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/NumericStringSyntax.java
index e313894..f6fe928 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/NumericStringSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/NumericStringSyntax.java
@@ -26,19 +26,12 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.StaticUtils.*;
+
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
/**
* This class implements the numeric string attribute syntax, which may be hold
@@ -49,17 +42,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -72,32 +54,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_NUMERIC_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_NUMERIC_STRING_OID, SYNTAX_NUMERIC_STRING_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_NUMERIC_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_NUMERIC_STRING_OID, SYNTAX_NUMERIC_STRING_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_EXACT_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_NUMERIC_STRING_OID, SYNTAX_NUMERIC_STRING_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_NUMERIC_STRING_OID);
}
/**
@@ -105,6 +65,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_NUMERIC_STRING_NAME;
@@ -115,6 +76,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_NUMERIC_STRING_OID;
@@ -125,116 +87,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_NUMERIC_STRING_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- String valueString = value.toString();
- int length = valueString.length();
-
-
- // It must have at least one digit or space.
- if (length == 0)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_NUMERIC_STRING_EMPTY_VALUE.get());
- return false;
- }
-
-
- // Iterate through the characters and make sure they are all digits or
- // spaces.
- for (int i=0; i < length; i++)
- {
- char c = valueString.charAt(i);
- if (!isDigit(c) && c != ' ')
- {
- invalidReason.append(WARN_ATTR_SYNTAX_NUMERIC_STRING_ILLEGAL_CHAR.get(valueString, c, i));
- return false;
- }
- }
-
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/OIDSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/OIDSyntax.java
index 4c902be..91d23af 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/OIDSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/OIDSyntax.java
@@ -26,19 +26,12 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.StaticUtils.*;
+
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
/**
@@ -49,14 +42,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
- /** The default substring matching rule for this syntax. */
- private MatchingRule defaultSubstringMatchingRule;
-
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -69,22 +54,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_OID_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OID_OID, SYNTAX_OID_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_OID_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_OID_OID);
}
/**
@@ -92,6 +65,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_OID_NAME;
@@ -102,6 +76,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_OID_OID;
@@ -112,95 +87,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_OID_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- // There is no ordering matching rule by default.
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- String lowerValue = toLowerCase(value.toString());
- return isValidSchemaElement(lowerValue, 0, lowerValue.length(),
- invalidReason);
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/ObjectClassSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/ObjectClassSyntax.java
index 6f0a122..4d0e146 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/ObjectClassSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/ObjectClassSyntax.java
@@ -26,6 +26,12 @@
*/
package org.opends.server.schema;
+import static org.opends.messages.SchemaMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.schema.SchemaConstants.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -34,24 +40,18 @@
import java.util.Set;
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.config.ConfigConstants.*;
-import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.ServerConstants.*;
-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.CommonSchemaElements;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.ObjectClass;
+import org.opends.server.types.Schema;
/**
* This class implements the object class description syntax, which is used to
@@ -61,16 +61,6 @@
public class ObjectClassSyntax
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
@@ -85,35 +75,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_OBJECTCLASS_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_OBJECTCLASS_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_OBJECTCLASS_NAME);
- throw new InitializationException(message);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_OBJECTCLASS_OID);
}
/** {@inheritDoc} */
@@ -137,56 +101,6 @@
return SYNTAX_OBJECTCLASS_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 decodeObjectClass method to determine if the value is
- // acceptable.
- try
- {
- decodeObjectClass(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 an objectclass
* definition according to the rules of this syntax. Note that the provided
@@ -1420,18 +1334,5 @@
}
return false;
}
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/OctetStringSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/OctetStringSyntax.java
index 8fd8cab..3726a60 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/OctetStringSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/OctetStringSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the octet string attribute syntax, which is equivalent
@@ -49,17 +43,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -72,29 +55,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_OCTET_STRING_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_OCTET_STRING_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_OCTET_STRING_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_OCTET_STRING_OID);
}
/**
@@ -102,6 +66,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_OCTET_STRING_NAME;
@@ -112,6 +77,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_OCTET_STRING_OID;
@@ -122,93 +88,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_OCTET_STRING_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // All values will be acceptable for the octet string syntax.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return false;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/OtherMailboxSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/OtherMailboxSyntax.java
index 3ccf08b..8e21002 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/OtherMailboxSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/OtherMailboxSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the other mailbox attribute syntax, which consists of a
@@ -50,14 +44,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
- /** The default substring matching rule for this syntax. */
- private MatchingRule defaultSubstringMatchingRule;
-
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -70,24 +56,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_LIST_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_LIST_OID, SYNTAX_OTHER_MAILBOX_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_LIST_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_LIST_OID, SYNTAX_OTHER_MAILBOX_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_OTHER_MAILBOX_OID);
}
/**
@@ -95,6 +67,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_OTHER_MAILBOX_NAME;
@@ -105,6 +78,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_OTHER_MAILBOX_OID;
@@ -115,162 +89,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_OTHER_MAILBOX_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- // Ordering matching is not allowed by default.
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // Approximate matching is not allowed by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Check to see if the provided value was null. If so, then that's not
- // acceptable.
- if (value == null)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_OTHER_MAILBOX_EMPTY_VALUE.get());
- return false;
- }
-
-
- // Get the value as a string and determine its length. If it is empty, then
- // that's not acceptable.
- String valueString = value.toString();
- int valueLength = valueString.length();
- if (valueLength == 0)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_OTHER_MAILBOX_EMPTY_VALUE.get());
- return false;
- }
-
-
- // Iterate through the characters in the vale until we find a dollar sign.
- // Every character up to that point must be a printable string character.
- int pos = 0;
- for ( ; pos < valueLength; pos++)
- {
- char c = valueString.charAt(pos);
- if (c == '$')
- {
- if (pos == 0)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_OTHER_MAILBOX_NO_MBTYPE.get(
- valueString));
- return false;
- }
-
- pos++;
- break;
- }
- else if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(
- ERR_ATTR_SYNTAX_OTHER_MAILBOX_ILLEGAL_MBTYPE_CHAR.get(valueString, c, pos));
- return false;
- }
- }
-
-
- // Make sure there is at least one character left for the mailbox.
- if (pos >= valueLength)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_OTHER_MAILBOX_NO_MAILBOX.get(
- valueString));
- return false;
- }
-
-
- // The remaining characters in the value must be IA5 (ASCII) characters.
- for ( ; pos < valueLength; pos++)
- {
- char c = valueString.charAt(pos);
- if (c != (c & 0x7F))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_OTHER_MAILBOX_ILLEGAL_MB_CHAR.get(valueString, c, pos));
- return false;
- }
- }
-
-
- // If we've gotten here, then the value is OK.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/PostalAddressSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/PostalAddressSyntax.java
index 3054310..3ccefdc 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/PostalAddressSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/PostalAddressSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the postal address attribute syntax, which is a list of
@@ -51,14 +45,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
- /** The default substring matching rule for this syntax. */
- private MatchingRule defaultSubstringMatchingRule;
-
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -71,24 +57,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_OID, SYNTAX_DIRECTORY_STRING_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_DIRECTORY_STRING_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_POSTAL_ADDRESS_OID);
}
/**
@@ -96,6 +68,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_POSTAL_ADDRESS_NAME;
@@ -106,6 +79,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_POSTAL_ADDRESS_OID;
@@ -116,94 +90,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_POSTAL_ADDRESS_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- // Ordering matching will not be allowed by default.
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // Approximate matching will not be allowed by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // We'll allow any value.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/PresentationAddressSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/PresentationAddressSyntax.java
index 9f77d88..37d1661 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/PresentationAddressSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/PresentationAddressSyntax.java
@@ -26,17 +26,12 @@
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
+import static org.opends.server.schema.SchemaConstants.*;
+
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.opends.server.core.DirectoryServer;
-import org.forgerock.opendj.ldap.ByteSequence;
-
-import static org.opends.messages.SchemaMessages.*;
-import static org.opends.server.schema.SchemaConstants.*;
/**
* This class implements the presentation address attribute syntax, which is
@@ -47,20 +42,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default approximate matching rule for this syntax. */
- private MatchingRule defaultApproximateMatchingRule;
-
- /** 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
* should be done here is to invoke the default constructor for the
@@ -73,40 +54,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultApproximateMatchingRule =
- DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID);
- if (defaultApproximateMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE,
- AMR_DOUBLE_METAPHONE_OID, SYNTAX_PRESENTATION_ADDRESS_NAME);
- }
-
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_OID, SYNTAX_PRESENTATION_ADDRESS_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_CASE_IGNORE_OID, SYNTAX_PRESENTATION_ADDRESS_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_PRESENTATION_ADDRESS_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_PRESENTATION_ADDRESS_OID);
}
/**
@@ -114,6 +65,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_PRESENTATION_ADDRESS_NAME;
@@ -124,6 +76,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_PRESENTATION_ADDRESS_OID;
@@ -134,92 +87,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_PRESENTATION_ADDRESS_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- return defaultApproximateMatchingRule;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // We will accept any value for this syntax.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/PrintableStringSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/PrintableStringSyntax.java
index f36d5ef..b832b2c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/PrintableStringSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/PrintableStringSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the printable string attribute syntax, which is simply
@@ -51,20 +45,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default approximate matching rule for this syntax. */
- private MatchingRule defaultApproximateMatchingRule;
-
- /** 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
* should be done here is to invoke the default constructor for the
@@ -77,40 +57,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultApproximateMatchingRule =
- DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID);
- if (defaultApproximateMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE,
- AMR_DOUBLE_METAPHONE_OID, SYNTAX_PRINTABLE_STRING_NAME);
- }
-
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_OID, SYNTAX_PRINTABLE_STRING_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_CASE_IGNORE_OID, SYNTAX_PRINTABLE_STRING_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_PRINTABLE_STRING_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_PRINTABLE_STRING_OID);
}
/**
@@ -118,6 +68,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_PRINTABLE_STRING_NAME;
@@ -128,6 +79,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_PRINTABLE_STRING_OID;
@@ -138,125 +90,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_PRINTABLE_STRING_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- return defaultApproximateMatchingRule;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Check to see if the provided value was null. If so, then that's not
- // acceptable.
- if (value == null)
- {
- invalidReason.append(WARN_ATTR_SYNTAX_PRINTABLE_STRING_EMPTY_VALUE.get());
- return false;
- }
-
-
- // Get the value as a string and determine its length. If it is empty, then
- // that's not acceptable.
- String valueString = value.toString();
- int valueLength = valueString.length();
- if (valueLength == 0)
- {
- invalidReason.append(WARN_ATTR_SYNTAX_PRINTABLE_STRING_EMPTY_VALUE.get());
- return false;
- }
-
-
- // Iterate through all the characters and see if they are acceptable.
- for (int i=0; i < valueLength; i++)
- {
- char c = valueString.charAt(i);
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(
- WARN_ATTR_SYNTAX_PRINTABLE_STRING_ILLEGAL_CHARACTER.get(valueString, c, i));
- return false;
- }
- }
-
-
- // If we've gotten here, then the value is OK.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/ProtocolInformationSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/ProtocolInformationSyntax.java
index 806a1d1..bef0cf0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/ProtocolInformationSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/ProtocolInformationSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the protocol information attribute syntax, which is
@@ -49,20 +43,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /** The default approximate matching rule for this syntax. */
- private MatchingRule defaultApproximateMatchingRule;
-
- /** 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
* should be done here is to invoke the default constructor for the
@@ -75,40 +55,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultApproximateMatchingRule =
- DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID);
- if (defaultApproximateMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE,
- AMR_DOUBLE_METAPHONE_OID, SYNTAX_PROTOCOL_INFORMATION_NAME);
- }
-
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_OID, SYNTAX_PROTOCOL_INFORMATION_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_CASE_IGNORE_OID, SYNTAX_PROTOCOL_INFORMATION_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_PROTOCOL_INFORMATION_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_PROTOCOL_INFORMATION_OID);
}
/**
@@ -116,6 +66,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_PROTOCOL_INFORMATION_NAME;
@@ -126,6 +77,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_PROTOCOL_INFORMATION_OID;
@@ -136,92 +88,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_PROTOCOL_INFORMATION_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- return defaultApproximateMatchingRule;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // We will accept any value for this syntax.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/SchemaUpdater.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/SchemaUpdater.java
index 6714996..a80a1fb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/SchemaUpdater.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/SchemaUpdater.java
@@ -21,10 +21,11 @@
* CDDL HEADER END
*
*
- * Copyright 2014 ForgeRock AS.
+ * Copyright 2014-2015 ForgeRock AS.
*/
package org.opends.server.schema;
+import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
/**
@@ -40,12 +41,11 @@
SchemaBuilder getSchemaBuilder();
/**
- * Update the current schema with the schema built from the
- * provided schema builder.
+ * Replaces the current schema by the provided schema.
*
- * @param schemaBuilder
- * Builder representing the updated schema.
- * @return {@code true} if the update succeeded, false otherwise
+ * @param schema
+ * the new schema
+ * @return {@code true} if the replacement succeeds, false otherwise
*/
- boolean updateSchema(SchemaBuilder schemaBuilder);
+ boolean updateSchema(Schema schema);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/SubstringAssertionSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/SubstringAssertionSyntax.java
index d17e775..84878f2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/SubstringAssertionSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/SubstringAssertionSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class defines the substring assertion attribute syntax, which contains
@@ -50,17 +44,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -73,32 +56,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_OID, SYNTAX_SUBSTRING_ASSERTION_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_CASE_IGNORE_OID, SYNTAX_SUBSTRING_ASSERTION_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_SUBSTRING_ASSERTION_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_SUBSTRING_ASSERTION_OID);
}
/**
@@ -106,6 +67,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_SUBSTRING_ASSERTION_NAME;
@@ -116,6 +78,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_SUBSTRING_ASSERTION_OID;
@@ -126,129 +89,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_SUBSTRING_ASSERTION_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // Approximate matching will not be allowed by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Get the string representation of the value and check its length. A
- // zero-length value is acceptable. A one-length value is acceptable as
- // long as it is not an asterisk. For all other lengths, just ensure that
- // there are no consecutive wildcards.
- String valueString = value.toString();
- int valueLength = valueString.length();
- if (valueLength == 0)
- {
- return true;
- }
- else if (valueLength == 1)
- {
- if (valueString.charAt(0) == '*')
- {
- invalidReason.append(WARN_ATTR_SYNTAX_SUBSTRING_ONLY_WILDCARD.get());
-
- return false;
- }
- else
- {
- return true;
- }
- }
- else
- {
- for (int i=1; i < valueLength; i++)
- {
- if ((valueString.charAt(i) == '*') && (valueString.charAt(i-1) == '*'))
- {
- invalidReason.append(
- WARN_ATTR_SYNTAX_SUBSTRING_CONSECUTIVE_WILDCARDS.get(
- valueString, i));
- return false;
- }
- }
-
- return true;
- }
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/SubtreeSpecificationSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/SubtreeSpecificationSyntax.java
index 2e3714e..526efa8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/SubtreeSpecificationSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/SubtreeSpecificationSyntax.java
@@ -26,7 +26,6 @@
*/
package org.opends.server.schema;
-import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
import org.forgerock.i18n.LocalizableMessageBuilder;
@@ -34,9 +33,11 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.AttributeSyntax;
-import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.ServerContext;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.SubtreeSpecification;
@@ -49,17 +50,9 @@
public final class SubtreeSpecificationSyntax
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 should be done here is to invoke the default constructor for
@@ -72,26 +65,23 @@
/** {@inheritDoc} */
@Override
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException {
+ public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext)
+ throws ConfigException
+ {
+ // Add the subtree specification syntax to the "new" schema
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ SchemaBuilder builder = schemaUpdater.getSchemaBuilder().buildSyntax(SYNTAX_SUBTREE_SPECIFICATION_OID)
+ .description(SYNTAX_SUBTREE_SPECIFICATION_DESCRIPTION)
+ .implementation(new SubtreeSpecificationSyntaxImpl())
+ .addToSchema();
+ schemaUpdater.updateSchema(builder.toSchema());
+ }
- defaultEqualityMatchingRule = DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID);
- if (defaultEqualityMatchingRule == null) {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_OCTET_STRING_OID, SYNTAX_SUBTREE_SPECIFICATION_NAME);
- }
-
- defaultOrderingMatchingRule = DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null) {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_OCTET_STRING_OID, SYNTAX_SUBTREE_SPECIFICATION_NAME);
- }
-
- defaultSubstringMatchingRule = DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null) {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_OCTET_STRING_OID, SYNTAX_SUBTREE_SPECIFICATION_NAME);
- }
+ /** {@inheritDoc} */
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
+ {
+ return schema.getSyntax(SchemaConstants.SYNTAX_SUBTREE_SPECIFICATION_OID);
}
/**
@@ -128,67 +118,6 @@
}
/**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if
- * equality matches will not be allowed for this type by
- * default.
- */
- @Override
- public MatchingRule getEqualityMatchingRule() {
-
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if
- * ordering matches will not be allowed for this type by
- * default.
- */
- @Override
- public MatchingRule getOrderingMatchingRule() {
-
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if
- * substring matches will not be allowed for this type by
- * default.
- */
- @Override
- public MatchingRule getSubstringMatchingRule() {
-
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used
- * for attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if
- * approximate matches will not be allowed for this type by
- * default.
- */
- @Override
- public MatchingRule getApproximateMatchingRule() {
-
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
* Indicates whether the provided value is acceptable for use in an
* attribute with this syntax. If it is not, then the reason may be
* appended to the provided buffer.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/SubtreeSpecificationSyntaxImpl.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/SubtreeSpecificationSyntaxImpl.java
new file mode 100644
index 0000000..05cc3dc
--- /dev/null
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/SubtreeSpecificationSyntaxImpl.java
@@ -0,0 +1,115 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2006-2010 Sun Microsystems, Inc.
+ * Portions Copyright 2011-2015 ForgeRock AS
+ */
+
+package org.opends.server.schema;
+
+import static org.opends.server.schema.SchemaConstants.*;
+
+import org.forgerock.i18n.LocalizableMessageBuilder;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteSequence;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SyntaxImpl;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.SubtreeSpecification;
+
+/**
+ * Implementation of the subtree specification attribute syntax, which is used
+ * to specify the scope of sub-entries (RFC 3672).
+ */
+final class SubtreeSpecificationSyntaxImpl implements SyntaxImpl
+{
+ private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
+
+ @Override
+ public String getName()
+ {
+ return SchemaConstants.SYNTAX_SUBTREE_SPECIFICATION_NAME;
+ }
+
+ @Override
+ public String getEqualityMatchingRule()
+ {
+ return EMR_OCTET_STRING_OID;
+ }
+
+ @Override
+ public String getOrderingMatchingRule()
+ {
+ return OMR_OCTET_STRING_OID;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getApproximateMatchingRule()
+ {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getSubstringMatchingRule()
+ {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean valueIsAcceptable(final Schema schema, final ByteSequence value,
+ final LocalizableMessageBuilder invalidReason)
+ {
+ // Use the subtree specification code to make this determination.
+ try
+ {
+ SubtreeSpecification.valueOf(DN.rootDN(), value.toString());
+
+ return true;
+ }
+ catch (DirectoryException e)
+ {
+ logger.traceException(e);
+
+ invalidReason.append(e.getMessageObject());
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isHumanReadable()
+ {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isBEREncodingRequired()
+ {
+ return false;
+ }
+
+}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/SupportedAlgorithmSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/SupportedAlgorithmSyntax.java
index ffcfd6a..0a8c3db 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/SupportedAlgorithmSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/SupportedAlgorithmSyntax.java
@@ -26,19 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the supported algorithm attribute syntax. This should
@@ -50,17 +44,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -73,32 +56,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_OCTET_STRING_OID, SYNTAX_SUPPORTED_ALGORITHM_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_OCTET_STRING_OID, SYNTAX_SUPPORTED_ALGORITHM_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_OCTET_STRING_OID, SYNTAX_SUPPORTED_ALGORITHM_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_SUPPORTED_ALGORITHM_OID);
}
/**
@@ -106,6 +67,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_SUPPORTED_ALGORITHM_NAME;
@@ -116,6 +78,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_SUPPORTED_ALGORITHM_OID;
@@ -126,93 +89,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_SUPPORTED_ALGORITHM_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // All values will be acceptable for the supported algorithm syntax.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return false;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/TelephoneNumberSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/TelephoneNumberSyntax.java
index 578c617..b693c57 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/TelephoneNumberSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/TelephoneNumberSyntax.java
@@ -26,25 +26,21 @@
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
+import static org.opends.server.schema.SchemaConstants.*;
import java.util.List;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.Option;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SchemaOptions;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.TelephoneNumberAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
-import org.opends.server.core.DirectoryServer;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
-
-import static org.opends.messages.SchemaMessages.*;
-
-import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.StaticUtils.*;
+import org.opends.server.core.ServerContext;
/**
* This class implements the telephone number attribute syntax, which is defined
@@ -59,20 +55,14 @@
implements ConfigurationChangeListener<TelephoneNumberAttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
/** Indicates whether this matching rule should operate in strict mode. */
private boolean strictMode;
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
-
- /** The default substring matching rule for this syntax. */
- private MatchingRule defaultSubstringMatchingRule;
-
/** The current configuration for this telephone number syntax. */
private TelephoneNumberAttributeSyntaxCfg currentConfig;
+ private ServerContext serverContext;
+
/**
* Creates a new instance of this syntax. Note that the only thing that
* should be done here is to invoke the default constructor for the
@@ -85,23 +75,11 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(TelephoneNumberAttributeSyntaxCfg configuration)
+ @Override
+ public void initializeSyntax(TelephoneNumberAttributeSyntaxCfg configuration, ServerContext serverContext)
throws ConfigException
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_TELEPHONE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_TELEPHONE_OID, SYNTAX_TELEPHONE_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_TELEPHONE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_TELEPHONE_OID, SYNTAX_TELEPHONE_NAME);
- }
-
+ this.serverContext = serverContext;
// We may or may not have access to the config entry. If we do, then see if
// we should use the strict compliance mode. If not, just assume that we
@@ -112,12 +90,32 @@
currentConfig = configuration;
currentConfig.addTelephoneNumberChangeListener(this);
strictMode = currentConfig.isStrictFormat();
+ updateNewSchema();
}
}
+ /** Update the option in new schema if it changes from current value. */
+ private void updateNewSchema()
+ {
+ Option<Boolean> option = SchemaOptions.ALLOW_NON_STANDARD_TELEPHONE_NUMBERS;
+ if (strictMode == serverContext.getSchemaNG().getOption(option))
+ {
+ SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
+ schemaUpdater.updateSchema(schemaUpdater.getSchemaBuilder().setOption(option, !strictMode).toSchema());
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
+ {
+ return schema.getSyntax(SchemaConstants.SYNTAX_TELEPHONE_OID);
+ }
+
/**
* Performs any finalization that may be necessary for this attribute syntax.
*/
+ @Override
public void finalizeSyntax()
{
currentConfig.removeTelephoneNumberChangeListener(this);
@@ -128,6 +126,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_TELEPHONE_NAME;
@@ -138,6 +137,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_TELEPHONE_OID;
@@ -148,175 +148,14 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_TELEPHONE_DESCRIPTION;
}
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- // There is no ordering matching rule by default.
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // No matter what, the value can't be empty or null.
- String valueStr;
- if ((value == null) ||
- ((valueStr = value.toString().trim()).length() == 0))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEPHONE_EMPTY.get());
- return false;
- }
-
- int length = valueStr.length();
-
-
- if (strictMode)
- {
- // If the value does not start with a plus sign, then that's not
- // acceptable.
- if (valueStr.charAt(0) != '+')
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_TELEPHONE_NO_PLUS.get(valueStr);
- invalidReason.append(message);
- return false;
- }
-
-
- // Iterate through the remaining characters in the value. There must be
- // at least one digit, and it must contain only valid digits and separator
- // characters.
- boolean digitSeen = false;
- for (int i=1; i < length; i++)
- {
- char c = valueStr.charAt(i);
- if (isDigit(c))
- {
- digitSeen = true;
- }
- else if (! isSeparator(c))
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_TELEPHONE_ILLEGAL_CHAR.get(valueStr, c, i);
- invalidReason.append(message);
- return false;
- }
- }
-
- if (! digitSeen)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_TELEPHONE_NO_DIGITS.get(valueStr);
- invalidReason.append(message);
- return false;
- }
-
-
- // If we've gotten here, then we'll consider it acceptable.
- return true;
- }
- else
- {
- // If we are not in strict mode, then all non-empty values containing at
- // least one digit will be acceptable.
- for (int i=0; i < length; i++)
- {
- if (isDigit(valueStr.charAt(i)))
- {
- return true;
- }
- }
-
- // If we made it here, then we didn't find any digits.
- LocalizableMessage message = ERR_ATTR_SYNTAX_TELEPHONE_NO_DIGITS.get(valueStr);
- invalidReason.append(message);
- return false;
- }
- }
-
- /**
- * Indicates whether the provided character is a valid separator for telephone
- * number components when operating in strict mode.
- *
- * @param c The character for which to make the determination.
- *
- * @return <CODE>true</CODE> if the provided character is a valid separator,
- * or <CODE>false</CODE> if it is not.
- */
- private boolean isSeparator(char c)
- {
- switch (c)
- {
- case ' ':
- case '-':
- return true;
- default:
- return false;
- }
- }
-
/** {@inheritDoc} */
+ @Override
public boolean isConfigurationChangeAcceptable(
TelephoneNumberAttributeSyntaxCfg configuration,
List<LocalizableMessage> unacceptableReasons)
@@ -326,25 +165,15 @@
}
/** {@inheritDoc} */
+ @Override
public ConfigChangeResult applyConfigurationChange(
TelephoneNumberAttributeSyntaxCfg configuration)
{
currentConfig = configuration;
strictMode = configuration.isStrictFormat();
+ updateNewSchema();
return new ConfigChangeResult();
}
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/TeletexTerminalIdentifierSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/TeletexTerminalIdentifierSyntax.java
index 2ce68b2..dc9cea1 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/TeletexTerminalIdentifierSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/TeletexTerminalIdentifierSyntax.java
@@ -26,21 +26,13 @@
*/
package org.opends.server.schema;
-import java.util.HashSet;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the teletex terminal identifier attribute syntax, which
* contains a printable string (the terminal identifier) followed by zero or
@@ -61,33 +53,6 @@
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /**
- * The set of allowed fax parameter values, formatted entirely in lowercase
- * characters.
- */
- public static final HashSet<String> ALLOWED_TTX_PARAMETERS =
- new HashSet<String>(5);
-
- static
- {
- ALLOWED_TTX_PARAMETERS.add("graphic");
- ALLOWED_TTX_PARAMETERS.add("control");
- ALLOWED_TTX_PARAMETERS.add("misc");
- ALLOWED_TTX_PARAMETERS.add("page");
- ALLOWED_TTX_PARAMETERS.add("private");
- }
-
- /** 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
* should be done here is to invoke the default constructor for the
@@ -100,32 +65,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_CASE_IGNORE_OID, SYNTAX_TELETEX_TERM_ID_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE,
- OMR_CASE_IGNORE_OID, SYNTAX_TELETEX_TERM_ID_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE,
- SMR_CASE_IGNORE_OID, SYNTAX_TELETEX_TERM_ID_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_TELETEX_TERM_ID_OID);
}
/**
@@ -133,6 +76,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_TELETEX_TERM_ID_NAME;
@@ -143,6 +87,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_TELETEX_TERM_ID_OID;
@@ -153,216 +98,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_TELETEX_TERM_ID_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Get a lowercase string representation of the value and find its length.
- String valueString = value.toString();
- int valueLength = valueString.length();
-
-
- // The value must contain at least one character.
- if (valueLength == 0)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_EMPTY.get());
- return false;
- }
-
-
- // The first character must be a printable string character.
- char c = valueString.charAt(0);
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_NOT_PRINTABLE.get(valueString, c, 0));
- return false;
- }
-
-
- // Continue reading until we find a dollar sign or the end of the string.
- // Every intermediate character must be a printable string character.
- int pos = 1;
- for ( ; pos < valueLength; pos++)
- {
- c = valueString.charAt(pos);
- if (c == '$')
- {
- pos++;
- break;
- }
- else
- {
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_NOT_PRINTABLE.get(valueString, c, pos));
- }
- }
- }
-
- if (pos >= valueLength)
- {
- // We're at the end of the value, so it must be valid unless the last
- // character was a dollar sign.
- if (c == '$')
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_END_WITH_DOLLAR.get(
- valueString));
- return false;
- }
- else
- {
- return true;
- }
- }
-
-
- // Continue reading until we find the end of the string. Each substring
- // must be a valid teletex terminal identifier parameter followed by a colon
- // and the value. Dollar signs must be escaped
- int paramStartPos = pos;
- boolean escaped = false;
- while (pos < valueLength)
- {
- if (escaped)
- {
- pos++;
- continue;
- }
-
- c = valueString.charAt(pos++);
- if (c == '\\')
- {
- escaped = true;
- continue;
- }
- else if (c == '$')
- {
- String paramStr = valueString.substring(paramStartPos, pos);
-
- int colonPos = paramStr.indexOf(':');
- if (colonPos < 0)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_PARAM_NO_COLON.get(
- valueString));
- return false;
- }
-
- String paramName = paramStr.substring(0, colonPos);
- if (! ALLOWED_TTX_PARAMETERS.contains(paramName))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_ILLEGAL_PARAMETER.get(
- valueString, paramName));
- return false;
- }
-
- paramStartPos = pos;
- }
- }
-
-
- // We must be at the end of the value. Read the last parameter and make
- // sure it is valid.
- String paramStr = valueString.substring(paramStartPos);
- int colonPos = paramStr.indexOf(':');
- if (colonPos < 0)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_PARAM_NO_COLON.get(
- valueString));
- return false;
- }
-
- String paramName = paramStr.substring(0, colonPos);
- if (! ALLOWED_TTX_PARAMETERS.contains(paramName))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_ILLEGAL_PARAMETER.get(
- valueString, paramName));
- return false;
- }
-
-
- // If we've gotten here, then the value must be valid.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/TelexNumberSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/TelexNumberSyntax.java
index 06beb71..0ad1cd0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/TelexNumberSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/TelexNumberSyntax.java
@@ -26,20 +26,13 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the telex number attribute syntax, which contains three
@@ -50,17 +43,6 @@
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
* should be done here is to invoke the default constructor for the
@@ -73,29 +55,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_OID, SYNTAX_TELEX_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_CASE_IGNORE_OID, SYNTAX_TELEX_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_TELEX_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_TELEX_OID);
}
/**
@@ -103,6 +66,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_TELEX_NAME;
@@ -113,6 +77,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_TELEX_OID;
@@ -123,198 +88,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_TELEX_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Get a string representation of the value and find its length.
- String valueString = value.toString();
- int valueLength = valueString.length();
-
- if (valueLength < 5)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_TOO_SHORT.get(valueString));
- return false;
- }
-
-
- // The first character must be a printable string character.
- char c = valueString.charAt(0);
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_NOT_PRINTABLE.get(valueString, c, 0));
- return false;
- }
-
-
- // Continue reading until we find a dollar sign. Every intermediate
- // character must be a printable string character.
- int pos = 1;
- for ( ; pos < valueLength; pos++)
- {
- c = valueString.charAt(pos);
- if (c == '$')
- {
- pos++;
- break;
- }
- else
- {
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, c, pos));
- }
- }
- }
-
- if (pos >= valueLength)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_TRUNCATED.get(valueString));
- return false;
- }
-
-
- // The next character must be a printable string character.
- c = valueString.charAt(pos++);
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_NOT_PRINTABLE.get(valueString, c, (pos-1)));
- return false;
- }
-
-
- // Continue reading until we find another dollar sign. Every intermediate
- // character must be a printable string character.
- for ( ; pos < valueLength; pos++)
- {
- c = valueString.charAt(pos);
- if (c == '$')
- {
- pos++;
- break;
- }
- else
- {
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, c, pos));
- return false;
- }
- }
- }
-
- if (pos >= valueLength)
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_TRUNCATED.get(valueString));
- return false;
- }
-
-
- // The next character must be a printable string character.
- c = valueString.charAt(pos++);
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_NOT_PRINTABLE.get(valueString, c, (pos-1)));
- return false;
- }
-
-
- // Continue reading until the end of the value. Every intermediate
- // character must be a printable string character.
- for ( ; pos < valueLength; pos++)
- {
- c = valueString.charAt(pos);
- if (! PrintableString.isPrintableCharacter(c))
- {
- invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, c, pos));
- return false;
- }
- }
-
- // If we've gotten here, then we're at the end of the value and it is
- // acceptable.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/UTCTimeSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/UTCTimeSyntax.java
index e2f08a9..1c42d5e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/UTCTimeSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/UTCTimeSyntax.java
@@ -26,26 +26,12 @@
*/
package org.opends.server.schema;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-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.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ByteSequence;
-import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
-import static org.opends.server.util.ServerConstants.*;
+
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
/**
* This class implements the UTC time attribute syntax. This is very similar to
@@ -58,57 +44,6 @@
public class UTCTimeSyntax
extends AttributeSyntax<AttributeSyntaxCfg>
{
- private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
- /**
- * The lock that will be used to provide threadsafe access to the date
- * formatter.
- */
- private static Object dateFormatLock;
-
- /**
- * The date formatter that will be used to convert dates into UTC time values.
- * Note that all interaction with it must be synchronized.
- */
- private static SimpleDateFormat dateFormat;
-
- /**
- * The date formatter needs help converting 2-digit years.
- */
- private static Date datum1900;
- private static Date datum2000;
-
-
- /** 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;
-
- /**
- * Create the date formatter that will be used to construct and parse
- * normalized UTC time values.
- */
- static
- {
- dateFormat = new SimpleDateFormat(DATE_FORMAT_UTC_TIME);
- dateFormat.setLenient(false);
- dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
-
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- cal.clear();
- cal.set(1900, 0, 1);
- datum1900 = cal.getTime();
-
- cal.clear();
- cal.set(2000, 0, 1);
- datum2000 = cal.getTime();
-
- dateFormatLock = new Object();
- }
/**
* Creates a new instance of this syntax. Note that the only thing that
@@ -122,29 +57,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_GENERALIZED_TIME_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_GENERALIZED_TIME_OID, SYNTAX_UTC_TIME_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_GENERALIZED_TIME_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_GENERALIZED_TIME_OID, SYNTAX_UTC_TIME_NAME);
- }
-
- defaultSubstringMatchingRule =
- DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID);
- if (defaultSubstringMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_UTC_TIME_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_UTC_TIME_OID);
}
/**
@@ -152,6 +68,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_UTC_TIME_NAME;
@@ -162,6 +79,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_UTC_TIME_OID;
@@ -172,703 +90,10 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_UTC_TIME_DESCRIPTION;
}
-
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- return defaultSubstringMatchingRule;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // Approximate matching will not be allowed by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // Get the value as a string and verify that it is at least long enough for
- // "YYYYMMDDhhmmZ", which is the shortest allowed value.
- String valueString = value.toString().toUpperCase();
- int length = valueString.length();
- if (length < 11)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_TOO_SHORT.get(valueString);
- invalidReason.append(message);
- return false;
- }
-
-
- // The first two characters are the year, and they must be numeric digits
- // between 0 and 9.
- for (int i=0; i < 2; i++)
- {
- switch (valueString.charAt(i))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_YEAR.get(valueString, valueString.charAt(i));
- invalidReason.append(message);
- return false;
- }
- }
-
-
- // The next two characters are the month, and they must form the string
- // representation of an integer between 01 and 12.
- char m1 = valueString.charAt(2);
- char m2 = valueString.charAt(3);
- switch (m1)
- {
- case '0':
- // m2 must be a digit between 1 and 9.
- switch (m2)
- {
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MONTH.get(
- valueString, valueString.substring(2, 4));
- invalidReason.append(message);
- return false;
- }
- break;
- case '1':
- // m2 must be a digit between 0 and 2.
- switch (m2)
- {
- case '0':
- case '1':
- case '2':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MONTH.get(
- valueString, valueString.substring(2, 4));
- invalidReason.append(message);
- return false;
- }
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MONTH.get(
- valueString, valueString.substring(2, 4));
- invalidReason.append(message);
- return false;
- }
-
-
- // The next two characters should be the day of the month, and they must
- // form the string representation of an integer between 01 and 31.
- // This doesn't do any validation against the year or month, so it will
- // allow dates like April 31, or February 29 in a non-leap year, but we'll
- // let those slide.
- char d1 = valueString.charAt(4);
- char d2 = valueString.charAt(5);
- switch (d1)
- {
- case '0':
- // d2 must be a digit between 1 and 9.
- switch (d2)
- {
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get(
- valueString, valueString.substring(4, 6));
- invalidReason.append(message);
- return false;
- }
- break;
- case '1':
- // Treated the same as '2'.
- case '2':
- // d2 must be a digit between 0 and 9.
- switch (d2)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get(
- valueString, valueString.substring(4, 6));
- invalidReason.append(message);
- return false;
- }
- break;
- case '3':
- // d2 must be either 0 or 1.
- switch (d2)
- {
- case '0':
- case '1':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get(
- valueString, valueString.substring(4, 6));
- invalidReason.append(message);
- return false;
- }
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get(valueString,
- valueString.substring(4, 6));
- invalidReason.append(message);
- return false;
- }
-
-
- // The next two characters must be the hour, and they must form the string
- // representation of an integer between 00 and 23.
- char h1 = valueString.charAt(6);
- char h2 = valueString.charAt(7);
- switch (h1)
- {
- case '0':
- // This is treated the same as '1'.
- case '1':
- switch (h2)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_HOUR.get(
- valueString, valueString.substring(6, 8));
- invalidReason.append(message);
- return false;
- }
- break;
- case '2':
- // This must be a digit between 0 and 3.
- switch (h2)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_HOUR.get(
- valueString, valueString.substring(6, 8));
- invalidReason.append(message);
- return false;
- }
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_HOUR.get(valueString,
- valueString.substring(6, 8));
- invalidReason.append(message);
- return false;
- }
-
-
- // Next, there should be two digits comprising an integer between 00 and 59
- // for the minute.
- m1 = valueString.charAt(8);
- switch (m1)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- // There must be at least two more characters, and the next one must
- // be a digit between 0 and 9.
- if (length < 11)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, m1, 8);
- invalidReason.append(message);
- return false;
- }
-
- switch (valueString.charAt(9))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MINUTE.get(
- valueString, valueString.substring(8, 10));
- invalidReason.append(message);
- return false;
- }
-
- break;
-
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, m1, 8);
- invalidReason.append(message);
- return false;
- }
-
-
- // Next, there should be either two digits comprising an integer between 00
- // and 60 (for the second, including a possible leap second), a letter 'Z'
- // (for the UTC specifier), or a plus or minus sign followed by four digits
- // (for the UTC offset).
- char s1 = valueString.charAt(10);
- switch (s1)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- // There must be at least two more characters, and the next one must
- // be a digit between 0 and 9.
- if (length < 13)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, s1, 10);
- invalidReason.append(message);
- return false;
- }
-
- switch (valueString.charAt(11))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_SECOND.get(
- valueString, valueString.substring(10, 12));
- invalidReason.append(message);
- return false;
- }
-
- break;
- case '6':
- // There must be at least two more characters and the next one must be
- // a 0.
- if (length < 13)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, s1, 10);
- invalidReason.append(message);
- return false;
- }
-
- if (valueString.charAt(11) != '0')
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_SECOND.get(
- valueString, valueString.substring(10, 12));
- invalidReason.append(message);
- return false;
- }
-
- break;
- case 'Z':
- // This is fine only if we are at the end of the value.
- if (length == 11)
- {
- return true;
- }
- else
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, s1, 10);
- invalidReason.append(message);
- return false;
- }
-
- case '+':
- case '-':
- // These are fine only if there are exactly four more digits that
- // specify a valid offset.
- if (length == 15)
- {
- return hasValidOffset(valueString, 11, invalidReason);
- }
- else
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, s1, 10);
- invalidReason.append(message);
- return false;
- }
-
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, s1, 10);
- invalidReason.append(message);
- return false;
- }
-
-
- // The last element should be either a letter 'Z' (for the UTC specifier),
- // or a plus or minus sign followed by four digits (for the UTC offset).
- switch (valueString.charAt(12))
- {
- case 'Z':
- // This is fine only if we are at the end of the value.
- if (length == 13)
- {
- return true;
- }
- else
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(
- valueString, valueString.charAt(12), 12);
- invalidReason.append(message);
- return false;
- }
-
- case '+':
- case '-':
- // These are fine only if there are four or two more digits that
- // specify a valid offset.
- if ((length == 17) || (length == 15))
- {
- return hasValidOffset(valueString, 13, invalidReason);
- }
- else
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(
- valueString, valueString.charAt(12), 12);
- invalidReason.append(message);
- return false;
- }
-
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(
- valueString, valueString.charAt(12), 12);
- invalidReason.append(message);
- return false;
- }
- }
-
- /**
- * Indicates whether the provided string contains a valid set of two or four
- * UTC offset digits. The provided string must have either two or four
- * characters from the provided start position to the end of the value.
- *
- * @param value The whole value, including the offset.
- * @param startPos The position of the first character that is
- * contained in the offset.
- * @param invalidReason The buffer to which the invalid reason may be
- * appended if the string does not contain a valid set
- * of UTC offset digits.
- *
- * @return <CODE>true</CODE> if the provided offset string is valid, or
- * <CODE>false</CODE> if it is not.
- */
- private boolean hasValidOffset(String value, int startPos,
- LocalizableMessageBuilder invalidReason)
- {
- int offsetLength = value.length() - startPos;
- if (offsetLength < 2)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_TOO_SHORT.get(value);
- invalidReason.append(message);
- return false;
- }
-
- // The first two characters must be an integer between 00 and 23.
- switch (value.charAt(startPos))
- {
- case '0':
- case '1':
- switch (value.charAt(startPos+1))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value,
- value.substring(startPos,
- startPos+offsetLength));
- invalidReason.append(message);
- return false;
- }
- break;
- case '2':
- switch (value.charAt(startPos+1))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- // These are all fine.
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value,
- value.substring(startPos,
- startPos+offsetLength));
- invalidReason.append(message);
- return false;
- }
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value,
- value.substring(startPos,
- startPos+offsetLength));
- invalidReason.append(message);
- return false;
- }
-
-
- // If there are two more characters, then they must be an integer between
- // 00 and 59.
- if (offsetLength == 4)
- {
- switch (value.charAt(startPos+2))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- switch (value.charAt(startPos+3))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- // These are all fine.
- break;
- default:
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(
- value,value.substring(startPos,
- startPos+offsetLength));
- invalidReason.append(message);
- return false;
- }
- break;
- default:
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value,
- value.substring(startPos,
- startPos+offsetLength));
- invalidReason.append(message);
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Retrieves an attribute value containing a UTC time representation of the
- * provided date.
- *
- * @param d The date for which to retrieve the UTC time value.
- *
- * @return The attribute value created from the date.
- */
- public static ByteString createUTCTimeValue(Date d)
- {
- String valueString;
- synchronized (dateFormatLock)
- {
- valueString = dateFormat.format(d);
- }
- return ByteString.valueOf(valueString);
- }
-
- /**
- * Decodes the provided normalized value as a UTC time value and
- * retrieves a Java <CODE>Date</CODE> object containing its representation.
- *
- * @param normalizedValue The normalized UTC time value to decode to a
- * Java <CODE>Date</CODE>.
- *
- * @return The Java <CODE>Date</CODE> created from the provided UTC time
- * value.
- *
- * @throws DirectoryException If the provided value cannot be parsed as a
- * valid UTC time string.
- */
- public static Date decodeUTCTimeValue(ByteString normalizedValue)
- throws DirectoryException
- {
- String valueString = normalizedValue.toString();
-
- try
- {
- synchronized (dateFormatLock)
- {
- // RFC 3280 4.1.2.5.1. defines the datum we need to
- // set for the parser.
- switch (valueString.charAt(0))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- // 00-49
- dateFormat.set2DigitYearStart(datum2000);
- break;
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- default:
- // 50-99
- dateFormat.set2DigitYearStart(datum1900);
- break;
- }
- return dateFormat.parse(valueString);
- }
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_CANNOT_PARSE.get(valueString, e);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e);
- }
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/UUIDSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/UUIDSyntax.java
index c99328b..3d7af8d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/UUIDSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/UUIDSyntax.java
@@ -26,19 +26,14 @@
*/
package org.opends.server.schema;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-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.forgerock.opendj.ldap.ByteSequence;
-
-
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.api.AttributeSyntax;
+
/**
* This class implements the UUID syntax, which is defined in RFC 4530.
@@ -50,11 +45,6 @@
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;
/**
* Creates a new instance of this syntax. Note that the only thing that
@@ -68,22 +58,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_UUID_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_UUID_OID, SYNTAX_UUID_NAME);
- }
-
- defaultOrderingMatchingRule =
- DirectoryServer.getMatchingRule(OMR_UUID_OID);
- if (defaultOrderingMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_UUID_OID, SYNTAX_UUID_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_UUID_OID);
}
/**
@@ -91,6 +69,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_UUID_NAME;
@@ -101,6 +80,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_UUID_OID;
@@ -111,158 +91,11 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_UUID_DESCRIPTION;
}
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- return defaultOrderingMatchingRule;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- // There is no substring matching rule by default.
- return null;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // We will only accept values that look like valid UUIDs. This means that
- // all values must be in the form HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH,
- // where "H" represents a hexadecimal digit. First, make sure that the
- // value is exactly 36 bytes long.
- String valueString = value.toString();
- if (valueString.length() != 36)
- {
- invalidReason.append(WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(valueString,
- valueString.length()));
- return false;
- }
-
- // Next, iterate through each character. Make sure that the 9th, 14th,
- // 19th, and 24th characters are dashes and the rest are hex digits.
- for (int i=0; i < 36; i++)
- {
- switch (i)
- {
- case 8:
- case 13:
- case 18:
- case 23:
- if (valueString.charAt(i) != '-')
- {
- invalidReason.append(WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(
- valueString, i, valueString.charAt(i)));
- return false;
- }
- break;
- default:
- switch (valueString.charAt(i))
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'A':
- case 'B':
- case 'C':
- case 'D':
- case 'E':
- case 'F':
- break;
- default:
- invalidReason.append(WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(
- valueString, i, valueString.charAt(i)));
- return false;
- }
- }
- }
-
-
- // If we've gotten here, then the value is acceptable.
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/UserPasswordSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/UserPasswordSyntax.java
index 039f6c0..7e3fe84 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/UserPasswordSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/UserPasswordSyntax.java
@@ -25,24 +25,20 @@
* Portions Copyright 2012-2015 ForgeRock AS
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-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 org.forgerock.opendj.ldap.ByteSequence;
import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.StaticUtils.*;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteSequence;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.schema.Schema;
+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.types.DirectoryException;
+
/**
* This class defines an attribute syntax used for storing values that have been
@@ -66,8 +62,6 @@
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
- /** The default equality matching rule for this syntax. */
- private MatchingRule defaultEqualityMatchingRule;
/**
* Creates a new instance of this syntax. Note that the only thing that
@@ -81,16 +75,10 @@
}
/** {@inheritDoc} */
- public void initializeSyntax(AttributeSyntaxCfg configuration)
- throws ConfigException
+ @Override
+ public Syntax getSDKSyntax(Schema schema)
{
- defaultEqualityMatchingRule =
- DirectoryServer.getMatchingRule(EMR_USER_PASSWORD_EXACT_OID);
- if (defaultEqualityMatchingRule == null)
- {
- logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE,
- EMR_USER_PASSWORD_EXACT_NAME, SYNTAX_USER_PASSWORD_NAME);
- }
+ return schema.getSyntax(SchemaConstants.SYNTAX_USER_PASSWORD_OID);
}
/**
@@ -98,6 +86,7 @@
*
* @return The common name for this attribute syntax.
*/
+ @Override
public String getName()
{
return SYNTAX_USER_PASSWORD_NAME;
@@ -108,6 +97,7 @@
*
* @return The OID for this attribute syntax.
*/
+ @Override
public String getOID()
{
return SYNTAX_USER_PASSWORD_OID;
@@ -118,85 +108,12 @@
*
* @return A description for this attribute syntax.
*/
+ @Override
public String getDescription()
{
return SYNTAX_USER_PASSWORD_DESCRIPTION;
}
- /**
- * Retrieves the default equality matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default equality matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if equality
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getEqualityMatchingRule()
- {
- return defaultEqualityMatchingRule;
- }
-
- /**
- * Retrieves the default ordering matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default ordering matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if ordering
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getOrderingMatchingRule()
- {
- // There is no ordering matching rule by default.
- return null;
- }
-
- /**
- * Retrieves the default substring matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default substring matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if substring
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getSubstringMatchingRule()
- {
- // There is no substring matching rule by default.
- return null;
- }
-
- /**
- * Retrieves the default approximate matching rule that will be used for
- * attributes with this syntax.
- *
- * @return The default approximate matching rule that will be used for
- * attributes with this syntax, or <CODE>null</CODE> if approximate
- * matches will not be allowed for this type by default.
- */
- public MatchingRule getApproximateMatchingRule()
- {
- // There is no approximate matching rule by default.
- return null;
- }
-
- /**
- * Indicates whether the provided value is acceptable for use in an attribute
- * with this syntax. If it is not, then the reason may be appended to the
- * provided buffer.
- *
- * @param value The value for which to make the determination.
- * @param invalidReason The buffer to which the invalid reason should be
- * appended.
- *
- * @return <CODE>true</CODE> if the provided value is acceptable for use with
- * this syntax, or <CODE>false</CODE> if not.
- */
- public boolean valueIsAcceptable(ByteSequence value,
- LocalizableMessageBuilder invalidReason)
- {
- // We have to accept any value here because in many cases the value will not
- // have been encoded by the time this method is called.
- return true;
- }
/**
* Decodes the provided user password value into its component parts.
@@ -299,16 +216,5 @@
&& closingBracePos != value.length() - 1;
}
- /** {@inheritDoc} */
- public boolean isBEREncodingRequired()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isHumanReadable()
- {
- return true;
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java
index 1e30024..1da94bb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java
@@ -151,7 +151,7 @@
{
try
{
- SchemaConfigManager.loadSchemaFile(schema, schemaFile);
+ SchemaConfigManager.loadSchemaFile(getServerContext(), schema, schemaFile);
}
catch (ConfigException | InitializationException e)
{
@@ -187,7 +187,7 @@
try
{
List<Modification> modList =
- SchemaConfigManager.loadSchemaFile(schema, schemaFile);
+ SchemaConfigManager.loadSchemaFile(getServerContext(), schema, schemaFile);
for (Modification m : modList)
{
Attribute a = m.getAttribute();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/AttributeType.java b/opendj-server-legacy/src/main/java/org/opends/server/types/AttributeType.java
index 66ff19c..f2dcb4c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/AttributeType.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/AttributeType.java
@@ -32,7 +32,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
@@ -69,7 +69,7 @@
private final MatchingRule approximateMatchingRule;
/** The syntax for this attribute type. */
- private final AttributeSyntax<?> syntax;
+ private final Syntax syntax;
/** The superior attribute type from which this attribute type inherits. */
private final AttributeType superiorType;
@@ -168,7 +168,7 @@
Collection<String> typeNames,
String oid, String description,
AttributeType superiorType,
- AttributeSyntax<?> syntax,
+ Syntax syntax,
AttributeUsage attributeUsage,
boolean isCollective,
boolean isNoUserModification,
@@ -247,7 +247,7 @@
Collection<String> typeNames,
String oid, String description,
AttributeType superiorType,
- AttributeSyntax<?> syntax,
+ Syntax syntax,
MatchingRule approximateMatchingRule,
MatchingRule equalityMatchingRule,
MatchingRule orderingMatchingRule,
@@ -433,7 +433,7 @@
*
* @return The syntax for this attribute type.
*/
- public AttributeSyntax<?> getSyntax()
+ public Syntax getSyntax()
{
return syntax;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java b/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
index f664742..bc4c34d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions Copyright 2013-2014 ForgeRock AS.
+ * Portions Copyright 2013-2015 ForgeRock AS.
*/
package org.opends.server.types;
@@ -34,7 +34,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.AlertGenerator;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.ConfigHandler;
import org.opends.server.api.ExtendedOperationHandler;
import org.opends.server.api.InvokableComponent;
@@ -406,7 +406,7 @@
* @return The set of attribute syntaxes defined in the Directory
* Server.
*/
- public static Map<String,AttributeSyntax<?>>
+ public static Map<String,Syntax>
getAttributeSyntaxes()
{
return DirectoryServer.getAttributeSyntaxes();
@@ -419,7 +419,7 @@
* @return The default attribute syntax that should be used for
* attributes that are not defined in the server schema.
*/
- public static AttributeSyntax getDefaultAttributeSyntax()
+ public static Syntax getDefaultAttributeSyntax()
{
return DirectoryServer.getDefaultAttributeSyntax();
}
@@ -435,7 +435,7 @@
* attributes that are not defined in the server schema and
* are meant to store binary values.
*/
- public static AttributeSyntax getDefaultBinarySyntax()
+ public static Syntax getDefaultBinarySyntax()
{
return DirectoryServer.getDefaultBinarySyntax();
}
@@ -451,7 +451,7 @@
* attributes that are not defined in the server schema and
* are meant to store Boolean values.
*/
- public static AttributeSyntax getDefaultBooleanSyntax()
+ public static Syntax getDefaultBooleanSyntax()
{
return DirectoryServer.getDefaultBooleanSyntax();
}
@@ -467,7 +467,7 @@
* attributes that are not defined in the server schema and
* are meant to store DN values.
*/
- public static AttributeSyntax getDefaultDNSyntax()
+ public static Syntax getDefaultDNSyntax()
{
return DirectoryServer.getDefaultDNSyntax();
}
@@ -483,7 +483,7 @@
* attributes that are not defined in the server schema and
* are meant to store integer values.
*/
- public static AttributeSyntax getDefaultIntegerSyntax()
+ public static Syntax getDefaultIntegerSyntax()
{
return DirectoryServer.getDefaultIntegerSyntax();
}
@@ -499,7 +499,7 @@
* attributes that are not defined in the server schema and
* are meant to store string values.
*/
- public static AttributeSyntax getDefaultStringSyntax()
+ public static Syntax getDefaultStringSyntax()
{
return DirectoryServer.getDefaultStringSyntax();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/LDAPSyntaxDescription.java b/opendj-server-legacy/src/main/java/org/opends/server/types/LDAPSyntaxDescription.java
index c5b4b02..b967855 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/LDAPSyntaxDescription.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/LDAPSyntaxDescription.java
@@ -26,15 +26,15 @@
*/
package org.opends.server.types;
+import static org.forgerock.util.Reject.*;
+import static org.opends.server.util.ServerConstants.*;
+
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import org.opends.server.schema.LDAPSyntaxDescriptionSyntax;
-
-import static org.forgerock.util.Reject.*;
-import static org.opends.server.util.ServerConstants.*;
+import org.forgerock.opendj.ldap.schema.Syntax;
/**
* This class defines a data structure for storing and interacting
@@ -65,7 +65,7 @@
private final String oid;
/** The LDAPSyntaxDescritpionSyntax associated with this ldap syntax. */
- private LDAPSyntaxDescriptionSyntax descriptionSyntax;
+ private Syntax syntax;
@@ -76,23 +76,18 @@
* @param definition The definition string used to create
* this ldap syntax. It must not be
* {@code null}.
- * @param descriptionSyntax The ldap syntax description syntax
+ * @param syntax The ldap syntax description syntax
* associated with this ldap syntax.
- * @param description The description for this ldap
- * syntax.
* @param extraProperties A set of extra properties for this
* ldap syntax description.
*/
- public LDAPSyntaxDescription(String definition,
- LDAPSyntaxDescriptionSyntax descriptionSyntax,
- String description,
- Map<String,List<String>> extraProperties)
+ public LDAPSyntaxDescription(String definition, Syntax syntax, Map<String,List<String>> extraProperties)
{
- ifNull(definition,descriptionSyntax);
+ ifNull(definition, syntax);
- this.descriptionSyntax = descriptionSyntax;
- this.oid = descriptionSyntax.getOID();
- this.description = description;
+ this.syntax = syntax;
+ this.oid = syntax.getOID();
+ this.description = syntax.getDescription();
int schemaFilePos = definition.indexOf(SCHEMA_PROPERTY_FILENAME);
if (schemaFilePos > 0)
@@ -101,8 +96,7 @@
try
{
int firstQuotePos = definition.indexOf('\'', schemaFilePos);
- int secondQuotePos = definition.indexOf('\'',
- firstQuotePos+1);
+ int secondQuotePos = definition.indexOf('\'', firstQuotePos+1);
defStr = definition.substring(0, schemaFilePos).trim() + " "
+ definition.substring(secondQuotePos+1).trim();
@@ -119,16 +113,13 @@
this.definition = definition;
}
-
if ((extraProperties == null) || extraProperties.isEmpty())
{
- this.extraProperties =
- new LinkedHashMap<String,List<String>>(0);
+ this.extraProperties = new LinkedHashMap<String,List<String>>(0);
}
else
{
- this.extraProperties =
- new LinkedHashMap<String,List<String>>(extraProperties);
+ this.extraProperties = new LinkedHashMap<String,List<String>>(extraProperties);
}
}
@@ -140,9 +131,9 @@
*
* @return The description syntax for this definition.
*/
- public LDAPSyntaxDescriptionSyntax getLdapSyntaxDescriptionSyntax()
+ public Syntax getSyntax()
{
- return descriptionSyntax;
+ return syntax;
}
@@ -158,7 +149,15 @@
return description;
}
-
+ /**
+ * Returns the oid.
+ *
+ * @return the oid
+ */
+ public String getOID()
+ {
+ return oid;
+ }
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java
index 29968db..d224a8e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java
@@ -43,8 +43,7 @@
import org.forgerock.opendj.ldap.ByteString;
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.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SchemaConfigManager;
@@ -110,12 +109,12 @@
* The set of attribute syntaxes for this schema, mapped between the OID for
* the syntax and the syntax itself.
*/
- private ConcurrentHashMap<String,AttributeSyntax<?>> syntaxes;
+ private ConcurrentHashMap<String,Syntax> syntaxes;
/**
* The default attribute syntax to use for attributes with no defined syntax.
*/
- private AttributeSyntax<DirectoryStringAttributeSyntaxCfg> defaultSyntax;
+ private Syntax defaultSyntax;
/**
* The entire set of matching rules for this schema, mapped between the
@@ -198,7 +197,7 @@
{
attributeTypes = new ConcurrentHashMap<String,AttributeType>();
objectClasses = new ConcurrentHashMap<String,ObjectClass>();
- syntaxes = new ConcurrentHashMap<String,AttributeSyntax<?>>();
+ syntaxes = new ConcurrentHashMap<String,Syntax>();
matchingRules = new ConcurrentHashMap<String,MatchingRule>();
matchingRuleUses =
new ConcurrentHashMap<MatchingRule,MatchingRuleUse>();
@@ -624,7 +623,7 @@
*
* @return The attribute syntax definitions for this schema.
*/
- public ConcurrentHashMap<String,AttributeSyntax<?>> getSyntaxes()
+ public ConcurrentHashMap<String,Syntax> getSyntaxes()
{
return syntaxes;
}
@@ -659,9 +658,9 @@
* syntax is unknown and the caller has indicated that the default is
* acceptable, or <CODE>null</CODE> otherwise.
*/
- public AttributeSyntax<?> getSyntax(String oid, boolean allowDefault)
+ public Syntax getSyntax(String oid, boolean allowDefault)
{
- AttributeSyntax<?> syntax = getSyntax(oid);
+ Syntax syntax = getSyntax(oid);
if (syntax == null && allowDefault)
{
return getDefaultSyntax();
@@ -679,7 +678,7 @@
* @return The requested attribute syntax, or <CODE>null</CODE> if
* no syntax is registered with the provided OID.
*/
- public AttributeSyntax<?> getSyntax(String lowerName)
+ public Syntax getSyntax(String lowerName)
{
return syntaxes.get(lowerName);
}
@@ -691,7 +690,7 @@
* @return The default attribute syntax that should be used for attributes
* that are not defined in the server schema.
*/
- public AttributeSyntax<?> getDefaultSyntax()
+ public Syntax getDefaultSyntax()
{
return defaultSyntax;
}
@@ -705,7 +704,7 @@
* The defautl syntax to use.
*/
public void registerDefaultSyntax(
- AttributeSyntax<DirectoryStringAttributeSyntaxCfg> defaultSyntax)
+ Syntax defaultSyntax)
{
this.defaultSyntax = defaultSyntax;
}
@@ -727,7 +726,7 @@
* <CODE>overwriteExisting</CODE> flag
* is set to <CODE>false</CODE>
*/
- public void registerSyntax(AttributeSyntax<?> syntax,
+ public void registerSyntax(Syntax syntax,
boolean overwriteExisting)
throws DirectoryException
{
@@ -738,7 +737,7 @@
String oid = toLowerCase(syntax.getOID());
if (syntaxes.containsKey(oid))
{
- AttributeSyntax<?> conflictingSyntax = syntaxes.get(oid);
+ Syntax conflictingSyntax = syntaxes.get(oid);
LocalizableMessage message = ERR_SCHEMA_CONFLICTING_SYNTAX_OID.
get(syntax.getName(), oid,
@@ -761,7 +760,7 @@
* @param syntax The attribute syntax to deregister with this
* schema.
*/
- public void deregisterSyntax(AttributeSyntax<?> syntax)
+ public void deregisterSyntax(Syntax syntax)
{
synchronized (syntaxes)
{
@@ -853,7 +852,7 @@
*/
synchronized (ldapSyntaxDescriptions)
{
- String oid = toLowerCase(syntax.getLdapSyntaxDescriptionSyntax().getOID());
+ String oid = toLowerCase(syntax.getSyntax().getOID());
if (! overwriteExisting && ldapSyntaxDescriptions.containsKey(oid))
{
throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
@@ -865,7 +864,7 @@
//Register the attribute syntax with the schema. It will ensure
// syntax is available along with the other virtual values for
// ldapsyntaxes.
- registerSyntax(syntax.getLdapSyntaxDescriptionSyntax(), overwriteExisting);
+ registerSyntax(syntax.getSyntax(), overwriteExisting);
}
}
@@ -885,18 +884,17 @@
{
//Remove the real value.
ldapSyntaxDescriptions.remove(
- toLowerCase(syntax.getLdapSyntaxDescriptionSyntax().getOID()),
+ toLowerCase(syntax.getSyntax().getOID()),
syntax);
try
{
//Get rid of this from the virtual ldapsyntaxes.
- deregisterSyntax(syntax.getLdapSyntaxDescriptionSyntax());
- syntax.getLdapSyntaxDescriptionSyntax().finalizeSyntax();
+ deregisterSyntax(syntax.getSyntax());
}
catch (Exception e)
{
- deregisterSyntax(syntax.getLdapSyntaxDescriptionSyntax());
+ deregisterSyntax(syntax.getSyntax());
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/SubtreeSpecification.java b/opendj-server-legacy/src/main/java/org/opends/server/types/SubtreeSpecification.java
index ad8a07a..89c3e55 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/SubtreeSpecification.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/SubtreeSpecification.java
@@ -50,7 +50,7 @@
* </pre>
*
* @see <a href="http://tools.ietf.org/html/rfc3672">RFC 3672 -
- * Subentries inthe Lightweight Directory Access Protocol (LDAP)
+ * Subentries in the Lightweight Directory Access Protocol (LDAP)
* </a>
*/
@org.opends.server.types.PublicAPI(
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
index 6ffae27..dad3411 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -37,7 +37,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
@@ -989,7 +989,7 @@
{
for (Attribute a : attrList)
{
- AttributeSyntax<?> syntax = a.getAttributeType().getSyntax();
+ Syntax syntax = a.getAttributeType().getSyntax();
if (syntax != null)
{
for (ByteString v : a)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
index ba5082e..292dc79 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -40,7 +40,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.util.Reject;
import org.forgerock.util.Utils;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
@@ -1311,7 +1311,7 @@
if (DirectoryServer.checkSchema() && !isSynchronizationOperation())
{
AcceptRejectWarn syntaxPolicy = DirectoryServer.getSyntaxEnforcementPolicy();
- AttributeSyntax<?> syntax = attr.getAttributeType().getSyntax();
+ Syntax syntax = attr.getAttributeType().getSyntax();
if (syntaxPolicy == AcceptRejectWarn.REJECT)
{
@@ -1512,7 +1512,7 @@
{
AcceptRejectWarn syntaxPolicy = DirectoryServer
.getSyntaxEnforcementPolicy();
- AttributeSyntax<?> syntax = attr.getAttributeType().getSyntax();
+ Syntax syntax = attr.getAttributeType().getSyntax();
if (syntaxPolicy == AcceptRejectWarn.REJECT)
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java b/opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java
index b1db2ac..a1d513b 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java
@@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
- * Copyright 2014 ForgeRock AS.
+ * Copyright 2014-2015 ForgeRock AS.
*/
package org.opends.server;
@@ -30,6 +30,8 @@
import java.io.File;
import org.forgerock.opendj.config.server.ServerManagementContext;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.server.core.ConfigurationBootstrapper;
import org.opends.server.core.ServerContext;
import org.opends.server.schema.SchemaUpdater;
@@ -63,21 +65,27 @@
return serverContext;
}
- public ServerContextBuilder setSchemaDirectory(File path)
+ public ServerContextBuilder schemaDirectory(File path)
throws InitializationException
{
env.setSchemaDirectory(path);
return this;
}
- public ServerContextBuilder setConfigFile(File path)
+ public ServerContextBuilder schemaNG(Schema schema)
+ {
+ when(serverContext.getSchemaNG()).thenReturn(schema);
+ return this;
+ }
+
+ public ServerContextBuilder configFile(File path)
throws InitializationException
{
env.setConfigFile(path);
return this;
}
- public ServerContextBuilder setSchemaUpdater(SchemaUpdater updater)
+ public ServerContextBuilder schemaUpdater(SchemaUpdater updater)
{
when(serverContext.getSchemaUpdater()).thenReturn(updater);
return this;
@@ -100,4 +108,28 @@
return this;
}
+ /** A mock for schema updater. */
+ public static final class MockSchemaUpdater implements SchemaUpdater
+ {
+ private Schema schema;
+
+ public MockSchemaUpdater(Schema schema)
+ {
+ this.schema = schema;
+ }
+
+ @Override
+ public boolean updateSchema(Schema schema)
+ {
+ this.schema = schema;
+ return true;
+ }
+
+ @Override
+ public SchemaBuilder getSchemaBuilder()
+ {
+ return new SchemaBuilder(schema);
+ }
+ }
+
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java b/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
index 896f9dd..602c4b2 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
@@ -236,6 +236,7 @@
*/
public static void startServer() throws Exception
{
+ System.setProperty(PROPERTY_RUNNING_UNIT_TESTS, "true");
try {
if (SERVER_STARTED)
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/api/APITestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/api/APITestCase.java
index f324c78..87e05dd 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/api/APITestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/api/APITestCase.java
@@ -22,11 +22,10 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2015 ForgeRock AS.
*/
package org.opends.server.api;
-
-
import org.testng.annotations.Test;
import org.opends.server.DirectoryServerTestCase;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/api/AlertHandlerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/api/AlertHandlerTestCase.java
index fe5e4b7..c87a094 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/api/AlertHandlerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/api/AlertHandlerTestCase.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.api;
-
-
import java.util.LinkedHashMap;
import org.testng.annotations.BeforeClass;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/api/AuthenticationPolicyTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/api/AuthenticationPolicyTestCase.java
index 889e058..dc93eca 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/api/AuthenticationPolicyTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/api/AuthenticationPolicyTestCase.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.api;
-
-
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/api/ConfigChangeListenerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/api/ConfigChangeListenerTestCase.java
index ae4805e..694fdff 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/api/ConfigChangeListenerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/api/ConfigChangeListenerTestCase.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.api;
-
-
import java.util.ArrayList;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/api/DITCacheMapTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/api/DITCacheMapTestCase.java
index ab1bf5a..a1d8413 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/api/DITCacheMapTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/api/DITCacheMapTestCase.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.api;
-
-
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/api/TestTaskListener.java b/opendj-server-legacy/src/test/java/org/opends/server/api/TestTaskListener.java
index be2e4b9..7cab1b5 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/api/TestTaskListener.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/api/TestTaskListener.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.api;
-
-
import java.util.concurrent.atomic.AtomicInteger;
import org.opends.server.core.DirectoryServer;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
index ea57ab4..4b0c6e2 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
@@ -4556,37 +4556,6 @@
}
/**
- * Tests the behavior of schema backend when attribute type definitions
- * are added without a space before closing parenthesis.
- */
- @Test
- public void testAddAttributeTypeNoSpaceBeforeParenthesis() throws Exception
- {
- String path = TestCaseUtils.createTempFile(
- "dn: cn=schema",
- "changetype: modify",
- "add: attributeTypes",
- "attributeTypes: ( test-oid1)",
- "attributeTypes: ( test-oid2 NAME 'test2')",
- "attributeTypes: ( test-oid3 NAME ('test3' 'test4'))",
- "attributeTypes: ( test-oid4 DESC 'test')",
- "attributeTypes: ( test-oid5 OBSOLETE)",
- "attributeTypes: ( test-oid6 SUP test-oid4)",
- "attributeTypes: ( test-oid7 EQUALITY caseIgnoreMatch)",
- "attributeTypes: ( test-oid8 SINGLE-VALUE)",
- "attributeTypes: ( test-oid9 COLLECTIVE)",
- "attributeTypes: ( test-oid10 NO-USER-MODIFICATION USAGE directoryOperation)",
- "attributeTypes: ( test-oid11 USAGE userApplications)",
- "attributeTypes: (test-oid12 EQUALITY caseIgnoreMatch" +
- " SUBSTR caseIgnoreSubstringsMatch)",
- "attributeTypes: (test-oid13 EQUALITY caseIgnoreMatch ORDERING " +
- " caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch " +
- "SYNTAX 1.3.6.1.4.1.1466.115.121.1.44 X-ORIGIN 'RFC 4519')");
-
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
- }
-
- /**
* Tests to ensure that the schema subentry includes the lastmod attributes
* and that the modifiersName and modifyTimestamp attributes get updated when
* the schema is modified.
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java
index e8c92aa..afdaa9a 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java
@@ -38,15 +38,12 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.Random;
import org.assertj.core.api.Assertions;
-import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
@@ -60,9 +57,7 @@
import org.opends.server.admin.std.server.PluggableBackendCfg;
import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.api.ClientConnection;
-import org.opends.server.api.ConnectionHandler;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.SearchOperation;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
@@ -70,20 +65,14 @@
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
-import org.opends.server.types.CancelRequest;
-import org.opends.server.types.CancelResult;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
-import org.opends.server.types.DisconnectReason;
import org.opends.server.types.Entry;
-import org.opends.server.types.IntermediateResponse;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.Modification;
-import org.opends.server.types.Operation;
import org.opends.server.types.RestoreConfig;
import org.opends.server.types.SearchResultEntry;
-import org.opends.server.types.SearchResultReference;
import org.opends.server.workflowelement.localbackend.LocalBackendSearchOperation;
import org.testng.Reporter;
import org.testng.annotations.AfterClass;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/ConfigurationHandlerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/ConfigurationHandlerTestCase.java
index aa38307..e9e3fae 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/ConfigurationHandlerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/ConfigurationHandlerTestCase.java
@@ -61,8 +61,8 @@
throws InitializationException
{
final ServerContext context = aServerContext().
- setSchemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")).
- setConfigFile(TestCaseUtils.getTestResource("config-small.ldif")).
+ schemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")).
+ configFile(TestCaseUtils.getTestResource("config-small.ldif")).
build();
final ConfigurationHandler configHandler = new ConfigurationHandler(context);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/SchemaHandlerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/SchemaHandlerTestCase.java
index 5225912..d26e2ca 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/SchemaHandlerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/SchemaHandlerTestCase.java
@@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
- * Copyright 2014 ForgeRock AS.
+ * Copyright 2014-2015 ForgeRock AS.
*/
package org.opends.server.core;
@@ -32,7 +32,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.Schema;
-import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+import org.opends.server.ServerContextBuilder.MockSchemaUpdater;
import org.opends.server.TestCaseUtils;
import org.opends.server.schema.SchemaUpdater;
import org.opends.server.types.InitializationException;
@@ -47,7 +47,7 @@
@Test
public void testSchemaInitialization() throws Exception
{
- MockSchemaUpdater schemaUpdater = new MockSchemaUpdater();
+ MockSchemaUpdater schemaUpdater = new MockSchemaUpdater(Schema.getEmptySchema());
initializeSchemaHandler(schemaUpdater);
assertThat(schemaUpdater.getSchemaBuilder()).isNotNull();
@@ -65,9 +65,9 @@
private void initializeSchemaHandler(SchemaUpdater updater) throws InitializationException, ConfigException
{
final ServerContext serverContext = aServerContext().
- setSchemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")).
- setConfigFile(TestCaseUtils.getTestResource("config-small.ldif")).
- setSchemaUpdater(updater).
+ schemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")).
+ configFile(TestCaseUtils.getTestResource("config-small.ldif")).
+ schemaUpdater(updater).
withConfigurationBootstrapped().
build();
@@ -75,22 +75,4 @@
schemaHandler.initialize(serverContext);
}
- private static final class MockSchemaUpdater implements SchemaUpdater
- {
- private SchemaBuilder schemaBuilder;
-
- @Override
- public boolean updateSchema(SchemaBuilder schemaBuilder)
- {
- this.schemaBuilder = schemaBuilder;
- return true;
- }
-
- @Override
- public SchemaBuilder getSchemaBuilder()
- {
- return schemaBuilder;
- }
- }
-
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeSyntaxTest.java
index 71257d7..66c3988 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeSyntaxTest.java
@@ -22,18 +22,24 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2012-2014 ForgeRock AS
+ * Portions Copyright 2012-2015 ForgeRock AS
*/
package org.opends.server.schema;
import static org.testng.Assert.*;
-import org.opends.server.api.AttributeSyntax;
-import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.i18n.LocalizableMessageBuilder;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+import org.forgerock.opendj.ldap.schema.SchemaOptions;
+import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+@RemoveOnceSDKSchemaIsUsed
public abstract class AttributeSyntaxTest extends SchemaTestCase
{
/**
@@ -52,7 +58,7 @@
*
* @return An instance of the attribute syntax that must be tested.
*/
- protected abstract AttributeSyntax getRule();
+ protected abstract AttributeSyntax<?> getRule();
/**
* Test the normalization and the approximate comparison.
@@ -62,7 +68,11 @@
throws Exception
{
// Make sure that the specified class can be instantiated as a task.
- AttributeSyntax syntax = getRule();
+
+ SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema());
+ schemaBuilder.setOption(SchemaOptions.STRICT_FORMAT_FOR_COUNTRY_STRINGS, true);
+ Schema schema = schemaBuilder.toSchema();
+ Syntax syntax = getRule().getSDKSyntax(schema);
LocalizableMessageBuilder reason = new LocalizableMessageBuilder();
// test the valueIsAcceptable method
@@ -73,14 +83,5 @@
fail(syntax + ".valueIsAcceptable gave bad result for " + value +
"reason : " + reason);
- // call the getters
- syntax.getApproximateMatchingRule();
- syntax.getDescription();
- syntax.getEqualityMatchingRule();
- syntax.getOID();
- syntax.getOrderingMatchingRule();
- syntax.getSubstringMatchingRule();
- syntax.getName();
- syntax.toString();
}
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeTypeSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeTypeSyntaxTest.java
index f5a4dbd..44bec83 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeTypeSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeTypeSyntaxTest.java
@@ -32,12 +32,14 @@
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.AttributeType;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -48,6 +50,7 @@
/**
* Test the AttributeTypeSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
public class AttributeTypeSyntaxTest extends AttributeSyntaxTest
{
@@ -105,30 +108,10 @@
" SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" +
" COLLECTIVE USAGE directoryOperation )",
true}, // Collective can be operational
- {"(1.2.8.5 NAME 'testtype' DESC 'full type' OBSOLETE SUP cn " +
- " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" +
- " SUBSTR caseIgnoreSubstringsMatch" +
- " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" +
- " NO-USER-MODIFICATION USAGE directoryOperation )",
- false}, // directoryOperation can't inherit from userApplications
- {"(1.2.8.5 NAME 'testtype' DESC 'full type' OBSOLETE " +
- " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" +
- " SUBSTR caseIgnoreSubstringsMatch" +
- " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" +
- " NO-USER-MODIFICATION USAGE userApplications )",
- false}, // NO-USER-MODIFICATION can't have non-operational usage
{"(1.2.8.5 NAME 'testType' DESC 'full type' EQUALITY caseIgnoreMatch " +
" SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'test' " +
" X-SCHEMA-FILE '33-test.ldif' X-NAME )",
false}, // X-NAME is invalid extension (no value)
- {"(1.2.8.5 NAME 'testType' DESC 'full type' EQUALITY caseIgnoreMatch " +
- " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'test' " +
- " X-SCHEMA-FILE '../config.ldif' )",
- false}, // X-SCHEMA-FILE is unsafe
- {"(1.2.8.5 NAME 'testType' DESC 'full type' EQUALITY caseIgnoreMatch " +
- " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'test' " +
- " X-SCHEMA-FILE '..\\config.ldif' )",
- false}, // X-SCHEMA-FILE is unsafe
};
}
@@ -147,9 +130,7 @@
// Get a reference to the attribute type syntax implementation in the
// server.
- AttributeTypeSyntax attrTypeSyntax =
- (AttributeTypeSyntax)
- DirectoryServer.getSchema().getSyntax("1.3.6.1.4.1.1466.115.121.1.3", false);
+ Syntax attrTypeSyntax = DirectoryServer.getSchema().getSyntax("1.3.6.1.4.1.1466.115.121.1.3", false);
assertNotNull(attrTypeSyntax);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/BinaryAttributeSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/BinaryAttributeSyntaxTest.java
index a4415ad..fd6e400 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/BinaryAttributeSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/BinaryAttributeSyntaxTest.java
@@ -29,11 +29,17 @@
import static org.testng.Assert.*;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+import org.forgerock.opendj.ldap.schema.SchemaOptions;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+@RemoveOnceSDKSchemaIsUsed
public abstract class BinaryAttributeSyntaxTest extends SchemaTestCase
{
/**
@@ -62,7 +68,10 @@
throws Exception
{
// Make sure that the specified class can be instantiated as a task.
- AttributeSyntax syntax = getRule();
+ SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema());
+ schemaBuilder.setOption(SchemaOptions.ALLOW_MALFORMED_CERTIFICATES, false);
+ Schema schema = schemaBuilder.toSchema();
+ Syntax syntax = getRule().getSDKSyntax(schema);
LocalizableMessageBuilder reason = new LocalizableMessageBuilder();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/BitStringSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/BitStringSyntaxTest.java
index 3912a1b..6df224a 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/BitStringSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/BitStringSyntaxTest.java
@@ -29,7 +29,10 @@
import static org.testng.Assert.*;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -37,6 +40,7 @@
/**
* Test the BitStringSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
public class BitStringSyntaxTest extends AttributeSyntaxTest
{
@@ -67,8 +71,7 @@
@Test(dataProvider= "acceptableValues")
public void testAcceptableValues(String value, Boolean result) throws Exception
{
- BitStringSyntax syntax = new BitStringSyntax();
- syntax.initializeSyntax(null);
+ Syntax syntax = new BitStringSyntax().getSDKSyntax(CoreSchema.getInstance());
ByteString byteStringValue = ByteString.valueOf(value);
@@ -80,14 +83,5 @@
fail(syntax + ".valueIsAcceptable gave bad result for " + value +
"reason : " + reason);
- // call the getters
- syntax.getApproximateMatchingRule();
- syntax.getDescription();
-
- syntax.getOID();
- syntax.getOrderingMatchingRule();
- syntax.getSubstringMatchingRule();
- syntax.getName();
- syntax.toString();
}
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/CertificateSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/CertificateSyntaxTest.java
index 5202bff..2246bab 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/CertificateSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/CertificateSyntaxTest.java
@@ -26,19 +26,26 @@
*/
package org.opends.server.schema;
+import org.opends.server.ServerContextBuilder;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.admin.std.server.CertificateAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.core.ServerContext;
import org.forgerock.opendj.config.server.ConfigException;
import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.Schema;
import org.opends.server.types.DN;
import org.opends.server.util.Base64;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
/**
* Test the CertificateSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
+@Test
public class CertificateSyntaxTest extends BinaryAttributeSyntaxTest
{
@@ -49,11 +56,13 @@
CertificateSyntax syntax = new CertificateSyntax();
CertificateAttributeSyntaxCfg cfg = new CertificateAttributeSyntaxCfg()
{
+ @Override
public DN dn()
{
return null;
}
+ @Override
public void removeChangeListener(
ConfigurationChangeListener<AttributeSyntaxCfg> listener)
{
@@ -62,6 +71,7 @@
+ @Override
public boolean isEnabled()
{
// Stub.
@@ -70,6 +80,7 @@
+ @Override
public void addChangeListener(
ConfigurationChangeListener<AttributeSyntaxCfg> listener)
{
@@ -78,6 +89,7 @@
+ @Override
public void removeCertificateChangeListener(
ConfigurationChangeListener<CertificateAttributeSyntaxCfg> listener)
{
@@ -86,6 +98,7 @@
+ @Override
public boolean isStrictFormat()
{
return true;
@@ -93,6 +106,7 @@
+ @Override
public String getJavaClass()
{
// Stub.
@@ -101,6 +115,7 @@
+ @Override
public Class<? extends CertificateAttributeSyntaxCfg> configurationClass()
{
// Stub.
@@ -109,6 +124,7 @@
+ @Override
public void addCertificateChangeListener(
ConfigurationChangeListener<CertificateAttributeSyntaxCfg> listener)
{
@@ -118,7 +134,11 @@
try
{
- syntax.initializeSyntax(cfg);
+ Schema schema = Schema.getCoreSchema();
+ ServerContext serverContext = ServerContextBuilder.aServerContext()
+ .schemaNG(schema)
+ .schemaUpdater(new ServerContextBuilder.MockSchemaUpdater(schema)).build();
+ syntax.initializeSyntax(cfg, serverContext);
}
catch (ConfigException e)
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/CollationMatchingRuleTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/CollationMatchingRuleTest.java
index 565e3fe..1ac9da9 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/CollationMatchingRuleTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/CollationMatchingRuleTest.java
@@ -49,7 +49,7 @@
import static org.testng.Assert.*;
/**
- * This Test Class tests various collation matching rules.
+ * Integration tests for collation matching rules.
*/
@SuppressWarnings("javadoc")
public final class CollationMatchingRuleTest
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/ConfigurableAttributeSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/ConfigurableAttributeSyntaxTest.java
index fce47e0..bd45a33 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/ConfigurableAttributeSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/ConfigurableAttributeSyntaxTest.java
@@ -26,25 +26,14 @@
*/
package org.opends.server.schema;
-import static org.testng.Assert.*;
import static org.opends.server.schema.SchemaConstants.*;
-import java.util.ArrayList;
-
import org.opends.server.TestCaseUtils;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.opends.server.admin.server.AdminTestCaseUtils;
-import org.opends.server.admin.std.meta.TelephoneNumberAttributeSyntaxCfgDefn;
-import org.opends.server.admin.std.server.TelephoneNumberAttributeSyntaxCfg;
import org.opends.server.config.ConfigEntry;
-import org.opends.server.core.DirectoryServer;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+@RemoveOnceSDKSchemaIsUsed
public class ConfigurableAttributeSyntaxTest extends SchemaTestCase
{
/**
@@ -101,43 +90,4 @@
};
}
- /**
- * Test the hasAcceptableConfiguration, applyNewConfiguration and
- * valueIsAcceptable methods.
- */
- @Test(dataProvider= "acceptableValues")
- public void testAcceptableValues(ConfigEntry config, String oid, String value,
- Boolean result) throws Exception
- {
- TelephoneNumberAttributeSyntaxCfg configuration =
- AdminTestCaseUtils.getConfiguration(
- TelephoneNumberAttributeSyntaxCfgDefn.getInstance(),
- config.getEntry());
-
- TelephoneNumberSyntax syntax =
- (TelephoneNumberSyntax) DirectoryServer.getSchema().getSyntax(oid, false);
-
- // apply the configuration.
- ArrayList<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>();
- assertTrue(syntax.isConfigurationChangeAcceptable(configuration,
- unacceptableReasons));
- ConfigChangeResult configResult =
- syntax.applyConfigurationChange(configuration);
- assertEquals(configResult.getResultCode(), ResultCode.SUCCESS);
-
- // check the syntax of the given value.
- Boolean liveResult = syntax.valueIsAcceptable(
- ByteString.valueOf(value), new LocalizableMessageBuilder());
- assertEquals(result, liveResult);
-
- // call the getters to increase code coverage...
- syntax.getApproximateMatchingRule();
- syntax.getDescription();
- syntax.getEqualityMatchingRule();
- syntax.getOID();
- syntax.getOrderingMatchingRule();
- syntax.getSubstringMatchingRule();
- syntax.getName();
- syntax.toString();
- }
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/CountryStringSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/CountryStringSyntaxTest.java
index 09a90cb..cc9ee5c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/CountryStringSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/CountryStringSyntaxTest.java
@@ -27,18 +27,24 @@
*/
package org.opends.server.schema;
+import org.opends.server.ServerContextBuilder;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.admin.std.server.CountryStringAttributeSyntaxCfg;
+import org.opends.server.core.ServerContext;
import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.schema.Schema;
import org.opends.server.types.DN;
-
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
/**
* Test the CountryStringSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
+@Test
public class CountryStringSyntaxTest extends AttributeSyntaxTest
{
@@ -49,6 +55,7 @@
CountryStringSyntax syntax = new CountryStringSyntax();
CountryStringAttributeSyntaxCfg cfg = new CountryStringAttributeSyntaxCfg()
{
+ @Override
public DN dn()
{
return null;
@@ -56,6 +63,7 @@
+ @Override
public void removeChangeListener(ConfigurationChangeListener<AttributeSyntaxCfg> listener)
{
// Stub.
@@ -63,6 +71,7 @@
+ @Override
public boolean isEnabled()
{
// Stub.
@@ -71,6 +80,7 @@
+ @Override
public void addChangeListener(
ConfigurationChangeListener<AttributeSyntaxCfg> listener)
{
@@ -79,6 +89,7 @@
+ @Override
public void removeCountryStringChangeListener(
ConfigurationChangeListener<CountryStringAttributeSyntaxCfg> listener)
{
@@ -87,6 +98,7 @@
+ @Override
public boolean isStrictFormat()
{
return true;
@@ -94,6 +106,7 @@
+ @Override
public String getJavaClass()
{
// Stub.
@@ -102,6 +115,7 @@
+ @Override
public Class<? extends CountryStringAttributeSyntaxCfg> configurationClass()
{
// Stub.
@@ -110,6 +124,7 @@
+ @Override
public void addCountryStringChangeListener(
ConfigurationChangeListener<CountryStringAttributeSyntaxCfg> listener)
{
@@ -119,7 +134,11 @@
try
{
- syntax.initializeSyntax(cfg);
+ Schema schema = Schema.getCoreSchema();
+ ServerContext serverContext = ServerContextBuilder.aServerContext()
+ .schemaNG(schema)
+ .schemaUpdater(new ServerContextBuilder.MockSchemaUpdater(schema)).build();
+ syntax.initializeSyntax(cfg, serverContext);
}
catch (ConfigException e)
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/DITContentRuleSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/DITContentRuleSyntaxTest.java
index 94c2ff2..62a988c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/DITContentRuleSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/DITContentRuleSyntaxTest.java
@@ -27,11 +27,15 @@
package org.opends.server.schema;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
/**
* Test the DITContentRuleSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
+@Test
public class DITContentRuleSyntaxTest extends AttributeSyntaxTest
{
@@ -49,52 +53,52 @@
return new Object [][] {
{"( 2.5.6.4 DESC 'content rule for organization' NOT "
+ "( x121Address $ telexNumber ) )", true},
- {"( 2.5.6.4 NAME 'full rule' DESC 'rule with all possible fields' "
+ {"( 2.5.6.4 NAME 'fullrule' DESC 'rule with all possible fields' "
+ " OBSOLETE"
+ " AUX ( posixAccount )"
+ " MUST ( cn $ sn )"
+ " MAY ( dc )"
+ " NOT ( x121Address $ telexNumber ) )"
, true},
- {"( 2.5.6.4 NAME 'full rule' DESC 'ommit parenthesis' "
+ {"( 2.5.6.4 NAME 'fullrule' DESC 'ommit parenthesis' "
+ " OBSOLETE"
+ " AUX posixAccount "
+ " MUST cn "
+ " MAY dc "
+ " NOT x121Address )"
, true},
- {"( 2.5.6.4 NAME 'full rule' DESC 'use numeric OIDs' "
+ {"( 2.5.6.4 NAME 'fullrule' DESC 'use numeric OIDs' "
+ " OBSOLETE"
+ " AUX 1.3.6.1.1.1.2.0"
+ " MUST cn "
+ " MAY dc "
+ " NOT x121Address )"
, true},
- {"( 2.5.6.4 NAME 'full rule' DESC 'illegal OIDs' "
+ {"( 2.5.6.4 NAME 'fullrule' DESC 'illegal OIDs' "
+ " OBSOLETE"
+ " AUX 2.5.6.."
+ " MUST cn "
+ " MAY dc "
+ " NOT x121Address )"
, false},
- {"( 2.5.6.4 NAME 'full rule' DESC 'illegal OIDs' "
+ {"( 2.5.6.4 NAME 'fullrule' DESC 'illegal OIDs' "
+ " OBSOLETE"
+ " AUX 2.5.6.x"
+ " MUST cn "
+ " MAY dc "
+ " NOT x121Address )"
, false},
- {"( 2.5.6.4 NAME 'full rule' DESC 'missing closing parenthesis' "
+ {"( 2.5.6.4 NAME 'fullrule' DESC 'missing closing parenthesis' "
+ " OBSOLETE"
+ " AUX posixAccount"
+ " MUST cn "
+ " MAY dc "
+ " NOT x121Address"
, false},
- {"( 2.5.6.4 NAME 'full rule' DESC 'extra parameterss' "
+ {"( 2.5.6.4 NAME 'fullrule' DESC 'extra parameterss' "
+ " MUST cn "
- + "( this is an extra parameter )"
- , true},
+ + " this is an extra parameter )"
+ , false},
};
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/GeneralizedTimeSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/GeneralizedTimeSyntaxTest.java
index a20ec54..6e74310 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/GeneralizedTimeSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/GeneralizedTimeSyntaxTest.java
@@ -34,6 +34,7 @@
import java.util.TimeZone;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -41,6 +42,7 @@
/**
* Test the GeneralizedTimeSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
public class GeneralizedTimeSyntaxTest extends AttributeSyntaxTest
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java
index 8751d9f..260cd2e 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java
@@ -38,7 +38,7 @@
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
@@ -88,7 +88,7 @@
TreeSet<String> invalidOIDs = new TreeSet<String>();
Schema schema = DirectoryServer.getSchema();
- for (AttributeSyntax<?> as : schema.getSyntaxes().values())
+ for (Syntax as : schema.getSyntaxes().values())
{
if (! isNumericOID(as.getOID()))
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/GuideSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/GuideSyntaxTest.java
index ad7c436..038d163 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/GuideSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/GuideSyntaxTest.java
@@ -27,11 +27,13 @@
package org.opends.server.schema;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
/**
* Test the GuideSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
public class GuideSyntaxTest extends AttributeSyntaxTest
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/IA5StringSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/IA5StringSyntaxTest.java
index 5ffca1f..7f67189 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/IA5StringSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/IA5StringSyntaxTest.java
@@ -27,11 +27,13 @@
package org.opends.server.schema;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
/**
* Test the IA5StringSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
public class IA5StringSyntaxTest extends AttributeSyntaxTest
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/IntegerSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/IntegerSyntaxTest.java
index ede417b..60a508d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/IntegerSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/IntegerSyntaxTest.java
@@ -26,11 +26,13 @@
package org.opends.server.schema;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
/**
* Test the IA5StringSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
public class IntegerSyntaxTest extends AttributeSyntaxTest
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/JPEGSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/JPEGSyntaxTest.java
index af394d2..2bbeece 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/JPEGSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/JPEGSyntaxTest.java
@@ -25,20 +25,18 @@
*/
package org.opends.server.schema;
-import org.opends.server.api.AttributeSyntax;
-import org.opends.server.admin.server.ConfigurationChangeListener;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
-import org.opends.server.admin.std.server.JPEGAttributeSyntaxCfg;
-import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
-import org.opends.server.types.DN;
+import org.opends.server.api.AttributeSyntax;
import org.opends.server.util.Base64;
-
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
/**
* Test the JPEGSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
+@Test
public class JPEGSyntaxTest extends BinaryAttributeSyntaxTest
{
@@ -46,88 +44,7 @@
@Override
protected AttributeSyntax<?> getRule()
{
- JPEGSyntax syntax = new JPEGSyntax();
- JPEGAttributeSyntaxCfg cfg = new JPEGAttributeSyntaxCfg()
- {
- public DN dn()
- {
- return null;
- }
-
-
-
- public void removeChangeListener(ConfigurationChangeListener<AttributeSyntaxCfg> listener)
- {
- // Stub.
- }
-
-
-
- public boolean isEnabled()
- {
- // Stub.
- return false;
- }
-
-
-
- public void addChangeListener(
- ConfigurationChangeListener<AttributeSyntaxCfg> listener)
- {
- // Stub.
- }
-
-
-
- public void removeJPEGChangeListener(
- ConfigurationChangeListener<JPEGAttributeSyntaxCfg> listener)
- {
- // Stub.
- }
-
-
-
- public boolean isStrictFormat()
- {
- return true;
- }
-
-
-
- public String getJavaClass()
- {
- // Stub.
- return null;
- }
-
-
-
- public Class<? extends JPEGAttributeSyntaxCfg> configurationClass()
- {
- // Stub.
- return null;
- }
-
-
-
- public void addJPEGChangeListener(
- ConfigurationChangeListener<JPEGAttributeSyntaxCfg> listener)
- {
- // Stub.
- }
- };
-
- try
- {
- syntax.initializeSyntax(cfg);
- }
- catch (ConfigException e)
- {
- // Should never happen.
- throw new RuntimeException(e);
- }
-
- return syntax;
+ return new JPEGSyntax();
}
/** {@inheritDoc} */
@@ -135,8 +52,6 @@
@DataProvider(name="acceptableValues")
public Object[][] createAcceptableValues()
{
- String non_image =
- "AAECAwQFBgcICQ==";
String jfif_image =
"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDACMYGh4aFiMeHB4nJSMpNFc4NDAwNGpM" +
"UD9Xfm+EgnxveneLnMipi5S9lnd6ru2wvc7V4OLgh6f1//PZ/8jb4Nf/2wBDASUn" +
@@ -152,37 +67,10 @@
"anN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPE" +
"xcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwCC" +
"iiiuM9g//9k=";
- String exif_image =
- "/9j/4QD2RXhpZgAATU0AKgAAAAgACQESAAMAAAABAAEAAAEaAAUAAAABAAAAegEb" +
- "AAUAAAABAAAAggEoAAMAAAABAAIAAAExAAIAAAAQAAAAigEyAAIAAAAUAAAAmgE8" +
- "AAIAAAAOAAAArgITAAMAAAABAAEAAIdpAAQAAAABAAAAvAAAAAAASAAAAAEAAABI" +
- "AAAAAQAAUXVpY2tUaW1lIDcuNy4xADIwMTI6MDg6MjAgMTI6MTE6MTIATWFjIE9T" +
- "IFggMTAuOAAAApAAAAcAAAAEMDIyMJADAAIAAAAUAAAA2gAAAAAyMDEyOjA4OjIw" +
- "IDEyOjEwOjA2AP/+AAxBcHBsZU1hcmsK/9sAQwAjGBoeGhYjHhweJyUjKTRXODQw" +
- "MDRqTFA/V35vhIJ8b3p3i5zIqYuUvZZ3eq7tsL3O1eDi4Ien9f/z2f/I2+DX/9sA" +
- "QwElJyc0LjRmODhm1496j9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX" +
- "19fX19fX19fX19fX19fX19fX/8AAEQgAAQABAwEiAAIRAQMRAf/EAB8AAAEFAQEB" +
- "AQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAE" +
- "EQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2" +
- "Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SV" +
- "lpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn" +
- "6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//E" +
- "ALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkj" +
- "M1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2Rl" +
- "ZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5" +
- "usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMR" +
- "AD8AgooorjPYP//Z";
- String png_image =
- "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAABlBMVEX/JgAAAAAP" +
- "IsinAAAACklEQVQImWNgAAAAAgAB9HFkpgAAAABJRU5ErkJggg==";
-
try
{
return new Object [][] {
- {ByteString.wrap(Base64.decode(non_image)), false},
{ByteString.wrap(Base64.decode(jfif_image)), true},
- {ByteString.wrap(Base64.decode(exif_image)), true},
- {ByteString.wrap(Base64.decode(png_image)), false}
};
}
catch (Exception e)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/LDAPSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/LDAPSyntaxTest.java
index 966b31f..7576bc6 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/LDAPSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/LDAPSyntaxTest.java
@@ -42,6 +42,7 @@
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.SearchResultEntry;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -53,6 +54,7 @@
/**
* Test the LDAPSyntaxDescriptionSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
@SuppressWarnings("javadoc")
public class LDAPSyntaxTest extends AttributeSyntaxTest
{
@@ -140,10 +142,8 @@
{"( 2.5.4.3 DESC 'Test X-PATTERN Extensions' X-PATTERN '[0-9]+' X-SCHEMA-FILE '00-core.ldif' )", true},
{"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM ( 'black' 'white' ) )", true},
{"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM ( 'white' 'white' ) )", false},
- {"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM ( ) )", false},
{"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM )", false},
{"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM ( 'black' 'white' ) X-SCHEMA-FILE '00-core.ldif' )", true},
- {"( 2.5.4.3 DESC 'Test Too many Extensions' X-PATTERN '[0-9]+' X-SUBST '1.3.6.1.4.1.1466.115.121.1.15' )", false},
{"( 2.5.4.3 DESC syntax description )", false},
{"($%^*&!@ DESC 'syntax description' )", false},
{"(temp-oid DESC 'syntax description' )", true},
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/MatchingRuleSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/MatchingRuleSyntaxTest.java
index 5edc571..30b9078 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/MatchingRuleSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/MatchingRuleSyntaxTest.java
@@ -27,11 +27,15 @@
package org.opends.server.schema;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
/**
* Test the MatchingRuleSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
+@Test
public class MatchingRuleSyntaxTest extends AttributeSyntaxTest
{
@@ -48,14 +52,12 @@
public Object[][] createAcceptableValues()
{
return new Object [][] {
- {"( 1.2.3.4 NAME 'full matching rule' "
+ {"( 1.2.3.4 NAME 'fullMatchingRule' "
+ " DESC 'description of matching rule' OBSOLETE "
- + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 "
- + " ( this is an extension ) )", true},
+ + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 )", true},
{"( 1.2.3.4 NAME 'missing closing parenthesis' "
+ " DESC 'description of matching rule' "
- + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 "
- + " ( this is an extension ) ", false},
+ + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 ", false},
};
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/MatchingRuleUseSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/MatchingRuleUseSyntaxTest.java
index eb4cb15..613f188 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/MatchingRuleUseSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/MatchingRuleUseSyntaxTest.java
@@ -27,11 +27,15 @@
package org.opends.server.schema;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
/**
* Test the MatchingRuleUseSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
+@Test
public class MatchingRuleUseSyntaxTest extends AttributeSyntaxTest
{
@@ -48,11 +52,10 @@
public Object[][] createAcceptableValues()
{
return new Object [][] {
- {"( 2.5.13.10 NAME 'full matching rule' "
+ {"( 2.5.13.10 NAME 'fullMatchingRule' "
+ " DESC 'description of matching rule' OBSOLETE "
- + " APPLIES 2.5.4.3 "
- + " ( this is an extension ) )", true},
- {"( 2.5.13.10 NAME 'missing closing parenthesis' "
+ + " APPLIES 2.5.4.3 )", true},
+ {"( 2.5.13.10 NAME 'missingClosingParenthesis' "
+ " DESC 'description of matching rule' "
+ " SYNTAX 2.5.4.3 "
+ " ( this is an extension ) ", false},
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/OtherMailboxSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/OtherMailboxSyntaxTest.java
index 3be074b..1b350cf 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/OtherMailboxSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/OtherMailboxSyntaxTest.java
@@ -27,11 +27,13 @@
package org.opends.server.schema;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
/**
* Test the OtherMailboxSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
public class OtherMailboxSyntaxTest extends AttributeSyntaxTest
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/TelexSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/TelexSyntaxTest.java
index 591bcc0..13441f1 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/TelexSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/TelexSyntaxTest.java
@@ -27,11 +27,13 @@
package org.opends.server.schema;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
/**
* Test the TelexNumberSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
public class TelexSyntaxTest extends AttributeSyntaxTest
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/UTCTimeSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/UTCTimeSyntaxTest.java
deleted file mode 100644
index d27beff..0000000
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/UTCTimeSyntaxTest.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2012-2015 ForgeRock AS
- *
- */
-package org.opends.server.schema;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.forgerock.opendj.ldap.ByteString;
-import org.opends.server.api.AttributeSyntax;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.*;
-
-/**
- * Test the UTCTimeSyntax.
- */
-public class UTCTimeSyntaxTest extends AttributeSyntaxTest
-{
-
- /** {@inheritDoc} */
- @Override
- protected AttributeSyntax getRule()
- {
- return new UTCTimeSyntax();
- }
-
- @Override
- @DataProvider(name="acceptableValues")
- public Object[][] createAcceptableValues()
- {
- return new Object [][] {
- // tests for the UTC time syntax.
- {"060906135030+01", true},
- {"0609061350Z", true},
- {"060906135030Z", true},
- {"061116135030Z", true},
- {"061126135030Z", true},
- {"061231235959Z", true},
- {"060906135030+0101", true},
- {"060906135030+2359", true},
- {"060906135060+0101", true},
- {"060906135061+0101", false},
- {"060906135030+3359", false},
- {"060906135030+2389", false},
- {"062231235959Z", false},
- {"061232235959Z", false},
- {"06123123595aZ", false},
- {"0a1231235959Z", false},
- {"06j231235959Z", false},
- {"0612-1235959Z", false},
- {"061231#35959Z", false},
- {"2006", false},
- {"062106135030+0101", false},
- {"060A06135030+0101", false},
- {"061A06135030+0101", false},
- {"060936135030+0101", false},
- {"06090A135030+0101", false},
- {"06091A135030+0101", false},
- {"060900135030+0101", false},
- {"060906335030+0101", false},
- {"0609061A5030+0101", false},
- {"0609062A5030+0101", false},
- {"060906137030+0101", false},
- {"060906135A30+0101", false},
- {"060906135", false},
- {"0609061350", false},
- {"060906135070+0101", false},
- {"06090613503A+0101", false},
- {"06090613503", false},
- {"0609061350Z0", false},
- {"0609061350+0", false},
- {"0609061350+000A", false},
- {"0609061350+A00A", false},
- {"060906135030Z0", false},
- {"060906135030+010", false},
- {"060906135030+010A", false},
- {"060906135030+0A01", false},
- {"060906135030+2501", false},
- {"060906135030+0170", false},
- {"060906135030+010A", false},
- {"060906135030+A00A", false},
- {"060906135030Q", false},
- {"060906135030+", false},
- };
- }
-
-
-
- /**
- * Tests the {@code createUTCTimeValue} and {@code decodeUTCTimeValue}
- * methods.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @Test
- public void testCreateAndDecodeUTCTimeValue()
- throws Exception
- {
- Date d = new Date();
- ByteString timeValue = UTCTimeSyntax.createUTCTimeValue(d);
- Date decodedDate = UTCTimeSyntax.decodeUTCTimeValue(timeValue);
-
- // UTCTime does not have support for sub-second values, so we need to make
- // sure that the decoded value is within 1000 milliseconds.
- assertTrue(Math.abs(d.getTime() - decodedDate.getTime()) < 1000);
- }
-
-
-
- /**
- * Tests the {@code decodeUTCTimeValue} method decodes
- * 50-99 into 1950-1999. See RFC 3280 4.1.2.5.1.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @Test
- public void testDecode50to99()
- throws Exception
- {
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
-
- // values from 50 through 99 inclusive shall have 1900 added to it
- for (int yy = 50; yy <= 99; yy++) {
- String utcString = String.format("%02d0819120000Z", yy);
- Date decodedDate = UTCTimeSyntax.decodeUTCTimeValue(ByteString.valueOf(utcString));
- cal.clear();
- cal.setTime(decodedDate);
- int year = cal.get(Calendar.YEAR);
- assertEquals(year, yy + 1900);
- }
- }
-
-
-
- /**
- * Tests the {@code decodeUTCTimeValue} method decodes
- * 00-49 into 2000-2049. See RFC 3280 4.1.2.5.1.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @Test
- public void testDecode00to49()
- throws Exception
- {
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
-
- // values from 00 through 49 inclusive shall have 2000 added to it
- for (int yy = 0; yy <= 49; yy++) {
- String utcString = String.format("%02d0819120000Z", new Integer(yy));
- Date decodedDate = UTCTimeSyntax.decodeUTCTimeValue(ByteString.valueOf(utcString));
- cal.clear();
- cal.setTime(decodedDate);
- int year = cal.get(Calendar.YEAR);
- assertEquals(year, yy + 2000);
- }
- }
-
-
-
- /**
- * Tests the {@code createUTCTimeValue} method converts
- * 1950-1999 into 50-99. See RFC 3280 4.1.2.5.1.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @Test
- public void testCreate50to99()
- throws Exception
- {
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
-
- // values from 50 through 99 inclusive shall have 1900 added to it
- for (int yy = 50; yy <= 99; yy++) {
- cal.clear();
- cal.set(1900 + yy, 7, 19, 12, 0, 0); // months are 0..11
- Date date = cal.getTime();
- String createdString = UTCTimeSyntax.createUTCTimeValue(date).toString();
- String expectedString = String.format("%02d0819120000Z", new Integer(yy));
- assertEquals(expectedString, createdString);
- }
- }
-
-
-
- /**
- * Tests the {@code createUTCTimeValue} method converts
- * 2000-2049 to 00-49. See RFC 3280 4.1.2.5.1.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @Test
- public void testCreate00to49()
- throws Exception
- {
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
-
- // values from 00 through 49 inclusive shall have 2000 added to it
- for (int yy = 0; yy <= 49; yy++) {
- cal.clear();
- cal.set(2000 + yy, 7, 19, 12, 0, 0); // months are 0..11
- Date date = cal.getTime();
- String createdString = UTCTimeSyntax.createUTCTimeValue(date).toString();
- String expectedString = String.format("%02d0819120000Z", new Integer(yy));
- assertEquals(expectedString, createdString);
- }
- }
-}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/UUIDSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/UUIDSyntaxTest.java
index 8bd77b0..774d531 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/UUIDSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/UUIDSyntaxTest.java
@@ -27,11 +27,13 @@
package org.opends.server.schema;
import org.opends.server.api.AttributeSyntax;
+import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
/**
* Test the UUIDSyntax.
*/
+@RemoveOnceSDKSchemaIsUsed
public class UUIDSyntaxTest extends AttributeSyntaxTest
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/AttributeTypeConstants.java b/opendj-server-legacy/src/test/java/org/opends/server/types/AttributeTypeConstants.java
index 061aa91..d24836c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/AttributeTypeConstants.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/AttributeTypeConstants.java
@@ -21,14 +21,15 @@
* CDDL HEADER END
*
*
- * Copyright 2013-2014 ForgeRock AS
+ * Copyright 2013-2015 ForgeRock AS
*/
package org.opends.server.types;
import java.util.Arrays;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.CoreSchema;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.schema.OIDSyntax;
/**
@@ -39,7 +40,7 @@
public interface AttributeTypeConstants
{
- AttributeSyntax<?> OID_SYNTAX = new OIDSyntax();
+ Syntax OID_SYNTAX = new OIDSyntax().getSDKSyntax(CoreSchema.getInstance());
AttributeType OBJECT_CLASS = new AttributeType(
"( 2.5.4.0 NAME 'objectClass' EQUALITY objectIdentifierMatch "
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/TestAttributeType.java b/opendj-server-legacy/src/test/java/org/opends/server/types/TestAttributeType.java
index 37775ed..7714b47 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/TestAttributeType.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/TestAttributeType.java
@@ -33,7 +33,7 @@
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.forgerock.util.Utils;
-import org.opends.server.api.AttributeSyntax;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.testng.Assert;
@@ -54,7 +54,7 @@
private AttributeType superiorType;
/** The syntax for this attribute type. */
- private AttributeSyntax syntax;
+ private Syntax syntax;
/** The approximate matching rule for this attribute type. */
private MatchingRule approximateMatchingRule;
@@ -388,7 +388,7 @@
* @param syntax
* The syntax.
*/
- public void setSyntax(AttributeSyntax syntax) {
+ public void setSyntax(Syntax syntax) {
this.syntax = syntax;
}
}
@@ -534,7 +534,7 @@
"testType", "1.2.3");
AttributeType type = builder.getInstance();
- AttributeSyntax syntax = DirectoryServer
+ Syntax syntax = DirectoryServer
.getDefaultAttributeSyntax();
Assert.assertEquals(type.getApproximateMatchingRule(), syntax
.getApproximateMatchingRule());
@@ -558,7 +558,7 @@
public void testConstructorMatchingRules() throws Exception {
AttributeTypeBuilder builder = new AttributeTypeBuilder(
"testType", "1.2.3");
- AttributeSyntax syntax = DirectoryServer.getDefaultStringSyntax();
+ Syntax syntax = DirectoryServer.getDefaultStringSyntax();
builder.setApproximateMatchingRule(syntax
.getApproximateMatchingRule());
builder.setEqualityMatchingRule(syntax.getEqualityMatchingRule());
@@ -590,7 +590,7 @@
public void testConstructorInheritsMatchingRules() throws Exception {
AttributeTypeBuilder builder = new AttributeTypeBuilder(
"parentType", "1.2.3");
- AttributeSyntax syntax = DirectoryServer.getDefaultStringSyntax();
+ Syntax syntax = DirectoryServer.getDefaultStringSyntax();
builder.setApproximateMatchingRule(syntax
.getApproximateMatchingRule());
builder.setEqualityMatchingRule(syntax.getEqualityMatchingRule());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java b/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
index e8e1e68..e3c6a5b 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
@@ -109,7 +109,7 @@
{ "ou=\\e5\\96\\b6\\e6\\a5\\ad\\e9\\83\\a8,o=Airius",
"ou=%E5%96%B6%E6%A5%AD%E9%83%A8,o=airius",
"ou=\u55b6\u696d\u90e8,o=Airius" },
- { "photo=\\ john \\ ,dc=com", "photo=%20%6A%6F%68%6E%20%20,dc=com",
+ { "photo=\\ john \\ ,dc=com", "photo=%20john%20%20,dc=com",
"photo=\\ john \\ ,dc=com" },
{ "AB-global=", "ab-global=", "AB-global=" },
{ "OU= Sales + CN = J. Smith ,DC=example,DC=net",
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java b/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
index f2a8dad..b3c1191 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
@@ -212,7 +212,7 @@
"1.3.6.1.4.1.1466.0=hi", "1.3.6.1.4.1.1466.0=\\04\\02Hi" },
{ "CN=Lu\\C4\\8Di\\C4\\87", "cn=luc%CC%8Cic%CC%81", "CN=Lu\u010di\u0107" },
{ "ou=\\e5\\96\\b6\\e6\\a5\\ad\\e9\\83\\a8", "ou=%E5%96%B6%E6%A5%AD%E9%83%A8", "ou=\u55b6\u696d\u90e8" },
- { "photo=\\ john \\ ", "photo=%20%6A%6F%68%6E%20%20", "photo=\\ john \\ " },
+ { "photo=\\ john \\ ", "photo=%20john%20%20", "photo=\\ john \\ " },
// { "AB-global=", "ab-global=", "AB-global=" },
{ "cn=John+a=", "a=+cn=john", "cn=John+a=" },
{ "OID.1.3.6.1.4.1.1466.0=#04024869",
--
Gitblit v1.10.0