From ab8845f3c17fd0313ac8a705a71b28a3ed21a2c4 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 06 Jun 2016 18:40:37 +0000
Subject: [PATCH] OPENDJ-3037 Remove LDAPSyntaxDescription class
---
/dev/null | 241 -----------
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java | 30
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java | 70 ++-
opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java | 135 -----
opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java | 49 --
opendj-server-legacy/src/main/java/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java | 735 -----------------------------------
6 files changed, 80 insertions(+), 1,180 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java
index fc56b84..8cf8166 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java
@@ -16,6 +16,8 @@
*/
package org.opends.guitools.controlpanel.util;
+import static org.forgerock.opendj.ldap.schema.Schema.*;
+
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@@ -59,9 +61,10 @@
{
matchingRulesToKeep.clear();
syntaxesToKeep.clear();
- matchingRulesToKeep.addAll(org.forgerock.opendj.ldap.schema.Schema.getCoreSchema().getMatchingRules());
- syntaxesToKeep.addAll(org.forgerock.opendj.ldap.schema.Schema.getCoreSchema().getSyntaxes());
+ matchingRulesToKeep.addAll(getCoreSchema().getMatchingRules());
+ syntaxesToKeep.addAll(getCoreSchema().getSyntaxes());
}
+
/**
* Reads the schema.
*
@@ -154,7 +157,7 @@
final Set<Object> remainingAttrs = new HashSet<>(csr.getAttributeValues(schemaAttr));
if (schemaAttr.equals(ConfigConstants.ATTR_LDAP_SYNTAXES_LC))
{
- registerSchemaLdapSyntaxDefinitions(remainingAttrs);
+ registerSyntaxDefinitions(remainingAttrs);
return;
}
@@ -164,17 +167,16 @@
final Set<Object> registered = new HashSet<>();
for (final Object definition : remainingAttrs)
{
- final ByteStringBuilder sb = new ByteStringBuilder();
- sb.appendObject(definition);
+ final String definitionStr = toString(definition);
try
{
switch (schemaAttr)
{
case ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC:
- schema.registerAttributeType(sb.toString(), null, true);
+ schema.registerAttributeType(definitionStr, null, true);
break;
case ConfigConstants.ATTR_OBJECTCLASSES_LC:
- schema.registerObjectClass(sb.toString(), null, true);
+ schema.registerObjectClass(definitionStr, null, true);
break;
}
registered.add(definition);
@@ -192,17 +194,16 @@
}
}
- private void registerSchemaLdapSyntaxDefinitions(Set<Object> remainingAttrs) throws DirectoryException
+ private void registerSyntaxDefinitions(Set<Object> definitions) throws DirectoryException
{
- for (final Object definition : remainingAttrs)
+ for (final Object definition : definitions)
{
- final ByteStringBuilder sb = new ByteStringBuilder();
- sb.appendObject(definition);
+ final String definitionStr = toString(definition);
if (definition.toString().contains(SchemaConstants.OID_OPENDS_SERVER_BASE))
{
try
{
- schema.registerLdapSyntaxDescription(sb.toString(), true);
+ schema.registerSyntax(definitionStr, true);
}
catch (DirectoryException e)
{
@@ -216,6 +217,11 @@
}
}
+ private String toString(final Object definition)
+ {
+ return new ByteStringBuilder().appendObject(definition).toString();
+ }
+
/**
* Returns the schema that was read.
*
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 b16283a..f80407b 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
@@ -69,6 +69,7 @@
import org.forgerock.opendj.ldap.schema.NameForm;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.forgerock.opendj.ldap.schema.SchemaElement;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.server.config.server.SchemaBackendCfg;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.Backend;
@@ -94,7 +95,6 @@
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.IndexType;
import org.opends.server.types.InitializationException;
-import org.opends.server.types.LDAPSyntaxDescription;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.LDIFImportResult;
@@ -316,8 +316,8 @@
Set<String> newDCRs = new LinkedHashSet<>();
Set<String> newDSRs = new LinkedHashSet<>();
Set<String> newMRUs = new LinkedHashSet<>();
- Set<String> newLSDs = new LinkedHashSet<>();
- Schema.genConcatenatedSchema(newATs, newOCs, newNFs, newDCRs, newDSRs, newMRUs,newLSDs);
+ Set<String> newLSs = new LinkedHashSet<>();
+ Schema.genConcatenatedSchema(newATs, newOCs, newNFs, newDCRs, newDSRs, newMRUs, newLSs);
// Next, generate lists of elements from the previous concatenated schema.
// If there isn't a previous concatenated schema, then use the base
@@ -365,9 +365,9 @@
Set<String> oldDCRs = new LinkedHashSet<>();
Set<String> oldDSRs = new LinkedHashSet<>();
Set<String> oldMRUs = new LinkedHashSet<>();
- Set<String> oldLSDs = new LinkedHashSet<>();
+ Set<String> oldLSs = new LinkedHashSet<>();
Schema.readConcatenatedSchema(concatFilePath, oldATs, oldOCs, oldNFs,
- oldDCRs, oldDSRs, oldMRUs,oldLSDs);
+ oldDCRs, oldDSRs, oldMRUs,oldLSs);
// Create a list of modifications and add any differences between the old
// and new schema into them.
@@ -378,7 +378,7 @@
Schema.compareConcatenatedSchema(oldDCRs, newDCRs, ditContentRulesType, mods);
Schema.compareConcatenatedSchema(oldDSRs, newDSRs, ditStructureRulesType, mods);
Schema.compareConcatenatedSchema(oldMRUs, newMRUs, matchingRuleUsesType, mods);
- Schema.compareConcatenatedSchema(oldLSDs, newLSDs, ldapSyntaxesType, mods);
+ Schema.compareConcatenatedSchema(oldLSs, newLSs, ldapSyntaxesType, mods);
if (! mods.isEmpty())
{
// TODO : Raise an alert notification.
@@ -2118,28 +2118,27 @@
throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
}
- LDAPSyntaxDescription existingLSD = schema.getLdapSyntaxDescription(oid);
- // If there is no existing lsd, then we're adding a new ldapsyntax.
+ Syntax existingLS = schema.getSyntax(oid);
+ // If there is no existing ldapsyntax, then we're adding a new one.
// Otherwise, we're replacing an existing one.
- if (existingLSD == null)
+ if (existingLS == null)
{
String def = Schema.addSchemaFileToElementDefinitionIfAbsent(definition, FILE_USER_SCHEMA_ELEMENTS);
- schema.registerLdapSyntaxDescription(def, false);
+ schema.registerSyntax(def, false);
- String schemaFile = getSchemaFile(schema.getLdapSyntaxDescription(oid));
- modifiedSchemaFiles.add(schemaFile);
+ modifiedSchemaFiles.add(getSchemaFile(schema.getSyntax(oid)));
}
else
{
- schema.deregisterLdapSyntaxDescription(existingLSD);
+ schema.deregisterSyntax(existingLS);
- String oldSchemaFile = getSchemaFile(existingLSD);
+ String oldSchemaFile = getSchemaFile(existingLS);
String schemaFile = oldSchemaFile != null && oldSchemaFile.length() > 0 ?
oldSchemaFile : FILE_USER_SCHEMA_ELEMENTS;
String def = Schema.addSchemaFileToElementDefinitionIfAbsent(definition, schemaFile);
- schema.registerLdapSyntaxDescription(def, false);
+ schema.registerSyntax(def, false);
- String newSchemaFile = getSchemaFile(schema.getLdapSyntaxDescription(oid));
+ String newSchemaFile = getSchemaFile(schema.getSyntax(oid));
addIfNotNull(modifiedSchemaFiles, oldSchemaFile);
addIfNotNull(modifiedSchemaFiles, newSchemaFile);
}
@@ -2157,16 +2156,16 @@
*/
String oid = Schema.parseOID(definition, ERR_PARSING_LDAP_SYNTAX_OID);
- LDAPSyntaxDescription removeLSD = schema.getLdapSyntaxDescription(oid);
- if (removeLSD == null)
+ Syntax removeLS = schema.getSyntax(oid);
+ if (removeLS == null)
{
LocalizableMessage message =
ERR_SCHEMA_MODIFY_REMOVE_NO_SUCH_LSD.get(oid);
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
- schema.deregisterLdapSyntaxDescription(removeLSD);
- addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeLSD));
+ schema.deregisterSyntax(removeLS);
+ addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeLS));
}
/**
@@ -2223,7 +2222,7 @@
* this only for the real part of the ldapsyntaxes attribute. The real part
* is read and write to/from the schema files.
*/
- Set<ByteString> values = getValuesForSchemaFile(schema.getLdapSyntaxDescriptions(), schemaFile);
+ Set<ByteString> values = getValuesForSchemaFile(getCustomSyntaxes(schema), schemaFile);
addAttribute(schemaEntry, ldapSyntaxesType, values);
// Add all of the appropriate attribute types to the schema entry. We need
@@ -2283,6 +2282,35 @@
return tempFile;
}
+ /**
+ * Returns custom syntaxes defined by OpenDJ configuration or by users.
+ * <p>
+ * These are non-standard syntaxes.
+ *
+ * @param schema
+ * the schema where to extract custom syntaxes from
+ * @return custom, non-standard syntaxes
+ */
+ private Collection<Syntax> getCustomSyntaxes(Schema schema)
+ {
+ List<Syntax> results = new ArrayList<>();
+ for (Syntax syntax : schema.getSyntaxes())
+ {
+ for (String propertyName : syntax.getExtraProperties().keySet())
+ {
+ if ("x-subst".equalsIgnoreCase(propertyName)
+ || "x-pattern".equalsIgnoreCase(propertyName)
+ || "x-enum".equalsIgnoreCase(propertyName)
+ || "x-schema-file".equalsIgnoreCase(propertyName))
+ {
+ results.add(syntax);
+ break;
+ }
+ }
+ }
+ return results;
+ }
+
private Set<ByteString> getValuesForSchemaFile(Collection<? extends SchemaElement> schemaElements, String schemaFile)
{
Set<ByteString> values = new LinkedHashSet<>();
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 00afecd..fb2c6fd 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
@@ -27,7 +27,6 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
@@ -367,9 +366,6 @@
final Entry entry = readSchemaEntryFromFile(schemaFile, failOnError);
if (entry != null)
{
- List<Attribute> ldapSyntaxList = entry.getAttribute(CoreSchema.getLDAPSyntaxesAttributeType());
- parseLdapSyntaxesDefinitions(schema, schemaFile, failOnError, ldapSyntaxList);
-
updateSchemaWithEntry(schema, schemaFile, failOnError, entry);
}
return entry;
@@ -513,51 +509,6 @@
return mods;
}
- /** Parse the ldapsyntaxes definitions if there are any. */
- private static void parseLdapSyntaxesDefinitions(Schema schema,
- String schemaFile, boolean failOnError, List<Attribute> ldapSyntaxList)
- throws ConfigException
- {
- for (Attribute a : ldapSyntaxList)
- {
- for (ByteString v : a)
- {
- final String definition = Schema.addSchemaFileToElementDefinitionIfAbsent(v.toString(), schemaFile);
- try
- {
- schema.registerLdapSyntaxDescription(definition, failOnError);
- }
- catch (DirectoryException de)
- {
- logger.traceException(de);
-
- if (de.getResultCode().equals(ResultCode.CONSTRAINT_VIOLATION))
- {
- // Register it with the schema. We will allow duplicates, with the
- // later definition overriding any earlier definition, but we want
- // to trap them and log a warning.
- logger.warn(WARN_CONFIG_SCHEMA_CONFLICTING_LDAP_SYNTAX, schemaFile, de.getMessageObject());
- try
- {
- schema.registerLdapSyntaxDescription(definition, true);
- }
- catch (Exception e)
- {
- // This should never happen.
- logger.traceException(e);
- }
- }
- else
- {
- LocalizableMessage message =
- WARN_CONFIG_SCHEMA_CANNOT_PARSE_LDAP_SYNTAX.get(schemaFile, de.getMessageObject());
- reportError(failOnError, de, message);
- }
- }
- }
- }
- }
-
private static void reportError(boolean failOnError, Exception e,
LocalizableMessage message) throws ConfigException
{
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 7925966..c8d2c6d 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
@@ -16,31 +16,11 @@
*/
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.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
-import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.server.config.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.CommonSchemaElements;
-import org.opends.server.types.DirectoryException;
-import org.opends.server.types.LDAPSyntaxDescription;
-import org.opends.server.types.Schema;
/**
* This class defines the LDAP syntax description syntax, which is used to
@@ -50,17 +30,6 @@
public class LDAPSyntaxDescriptionSyntax
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,731 +41,27 @@
super();
}
- /** {@inheritDoc} */
@Override
public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema)
{
return schema.getSyntax(SchemaConstants.SYNTAX_LDAP_SYNTAX_OID);
}
- /**
- * Retrieves the common name for this attribute syntax.
- *
- * @return The common name for this attribute syntax.
- */
@Override
public String getName()
{
return SYNTAX_LDAP_SYNTAX_NAME;
}
- /**
- * Retrieves the OID for this attribute syntax.
- *
- * @return The OID for this attribute syntax.
- */
@Override
public String getOID()
{
return SYNTAX_LDAP_SYNTAX_OID;
}
- /**
- * Retrieves a description for this attribute syntax.
- *
- * @return A description for this attribute syntax.
- */
@Override
public String getDescription()
{
return SYNTAX_LDAP_SYNTAX_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;
- }
-
- /**
- * Decodes the contents of the provided byte sequence as an ldap syntax
- * definition according to the rules of this syntax. Note that the provided
- * byte sequence value does not need to be normalized (and in fact, it should
- * not be in order to allow the desired capitalization to be preserved).
- *
- * @param value The byte sequence containing the value
- * to decode (it does not need to be
- * normalized).
- * @param schema The schema to use to resolve references to
- * other schema elements.
- * @param allowUnknownElements Indicates whether to allow values that are
- * not defined in the server schema. This
- * 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, boolean forDelete)
- throws DirectoryException
- {
- // Get string representations of the provided value using the provided form.
- String valueStr = value.toString();
-
- // 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.
-
- LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_EMPTY_VALUE.get();
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
-
-
- // The next character must be an open parenthesis. If it is not, then that
- // is an error.
- char c = valueStr.charAt(pos++);
- if (c != '(')
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_LDAPSYNTAX_EXPECTED_OPEN_PARENTHESIS.get(valueStr, pos-1, c);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
-
-
- // 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.
- LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_TRUNCATED_VALUE.get(
- valueStr);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
-
- int oidStartPos = pos;
- 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)) != ' ')
- && (c = valueStr.charAt(pos)) != ')')
- {
- if (c == '.')
- {
- if (lastWasPeriod)
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_LDAPSYNTAX_DOUBLE_PERIOD_IN_NUMERIC_OID.get(valueStr, pos-1);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
- lastWasPeriod = true;
- }
- else if (! isDigit(c))
- {
- // This must have been an illegal character.
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_LDAPSYNTAX_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos-1);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
- else
- {
- lastWasPeriod = false;
- }
- pos++;
- }
- }
- 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)) != ' ')
- && (c=valueStr.charAt(pos))!=')')
- {
- if (isAlpha(c) || isDigit(c) || c == '-' ||
- (c == '_' && DirectoryServer.allowAttributeNameExceptions()))
- {
- // This is fine. It is an acceptable character.
- pos++;
- }
- else
- {
- // This must have been an illegal character.
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_LDAPSYNTAX_ILLEGAL_CHAR_IN_STRING_OID.
- get(valueStr, c, pos-1);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
- }
- }
-
- // If we're at the end of the value, then it isn't a valid attribute type
- // description. Otherwise, parse out the OID.
- String oid;
- if (pos >= length)
- {
- LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_TRUNCATED_VALUE.get(
- valueStr);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
- oid = toLowerCase(valueStr.substring(oidStartPos, pos));
-
- // 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.
- LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_TRUNCATED_VALUE.get(
- valueStr);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- message);
- }
-
- // 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.
- String description = null;
- Syntax syntax = null;
- HashMap<String,List<String>> extraProperties = new LinkedHashMap<>();
- boolean hasXSyntaxToken = false;
-
- while (true)
- {
- StringBuilder tokenNameBuffer = new StringBuilder();
- pos = readTokenName(valueStr, tokenNameBuffer, pos);
- 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)
- {
- LocalizableMessage message =
- ERR_ATTR_SYNTAX_LDAPSYNTAX_UNEXPECTED_CLOSE_PARENTHESIS.get(valueStr, pos-1);
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
- break;
- }
- else if (lowerTokenName.equals("desc"))
- {
- // This specifies the description for the attribute type. It is an
- // arbitrary string of characters enclosed in single quotes.
- StringBuilder descriptionBuffer = new StringBuilder();
- pos = readQuotedString(valueStr, descriptionBuffer, pos);
- description = descriptionBuffer.toString();
- }
- else
- {
- SchemaBuilder schemaBuilder = new SchemaBuilder(schema.getSchemaNG());
-
- 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<>();
- 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.valueOfUtf8(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<>();
- 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)
- {
- // 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.getOID(), extraProperties);
- }
-
- /**
- * Reads the next token name from the attribute syntax definition, skipping
- * over any leading or trailing spaces, and appends it to the provided buffer.
- *
- * @param valueStr The string representation of the attribute syntax
- * 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_LDAPSYNTAX_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 attribute type
- * 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_LDAPSYNTAX_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_LDAPSYNTAX_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_LDAPSYNTAX_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 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,
- List<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_LDAPSYNTAX_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_LDAPSYNTAX_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_LDAPSYNTAX_EXTENSION_INVALID_CHARACTER.get(
- valueStr, 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_LDAPSYNTAX_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_LDAPSYNTAX_TRUNCATED_VALUE.get(valueStr);
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
- }
-
- return startPos;
- }
}
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
deleted file mode 100644
index 42076f6..0000000
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/LDAPSyntaxDescription.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2009 Sun Microsystems, Inc.
- * Portions Copyright 2013-2016 ForgeRock AS.
- */
-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.forgerock.opendj.ldap.schema.SchemaElement;
-
-/**
- * This class defines a data structure for storing and interacting
- * with an ldap syntax, which defines the custom ldap syntaxes.
- */
-@org.opends.server.types.PublicAPI(
- stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
- mayInstantiate=false,
- mayExtend=false,
- mayInvoke=true)
-
-public final class LDAPSyntaxDescription implements SchemaElement
-{
- /**
- * The set of additional name-value pairs associated with this ldap
- * syntax definition.
- */
- private final Map<String,List<String>> extraProperties;
-
- /** The definition string used to create this ldap syntax description. */
- private final String definition;
-
- /** The OID of the enclosed ldap syntax description. */
- private final String oid;
-
- /**
- * Creates a new ldap syntax definition with the provided information.
- *
- * @param definition
- * The definition string used to create this ldap syntax. It must not be {@code null}.
- * @param oid
- * oid of the syntax
- * @param extraProperties
- * A set of extra properties for this ldap syntax description.
- */
- public LDAPSyntaxDescription(String definition, String oid, Map<String,List<String>> extraProperties)
- {
- ifNull(definition, oid);
-
- this.oid = oid;
-
- int schemaFilePos = definition.indexOf(SCHEMA_PROPERTY_FILENAME);
- if (schemaFilePos > 0)
- {
- String defStr;
- try
- {
- int firstQuotePos = definition.indexOf('\'', schemaFilePos);
- int secondQuotePos = definition.indexOf('\'', firstQuotePos+1);
-
- defStr = definition.substring(0, schemaFilePos).trim() + " "
- + definition.substring(secondQuotePos+1).trim();
- }
- catch (Exception e)
- {
- defStr = definition;
- }
-
- this.definition = defStr;
- }
- else
- {
- this.definition = definition;
- }
-
- if (extraProperties == null || extraProperties.isEmpty())
- {
- this.extraProperties = new LinkedHashMap<>(0);
- }
- else
- {
- this.extraProperties = new LinkedHashMap<>(extraProperties);
- }
- }
-
- /**
- * Returns the oid.
- *
- * @return the oid
- */
- public String getOID()
- {
- return oid;
- }
-
-
- /**
- * Retrieves a mapping between the names of any extra non-standard
- * properties that may be associated with this ldap syntax
- * description and the value for that property.
- *
- * @return A mapping between the names of any extra non-standard
- * properties that may be associated with this ldap syntax
- * description and the value for that property.
- */
- @Override
- public Map<String,List<String>> getExtraProperties()
- {
- return extraProperties;
- }
-
-
-
- /**
- * Retrieves the value of the specified "extra" property for this
- * ldap syntax description.
- *
- * @param propertyName The name of the "extra" property for which
- * to retrieve the value.
- *
- * @return The value of the specified "extra" property for this
- * ldap syntax description, or {@code null} if no such
- * property is defined.
- */
- public List<String> getExtraProperty(String propertyName)
- {
- return extraProperties.get(propertyName);
- }
-
-
-
- /**
- * Specifies the provided "extra" property for this ldap syntax
- * description.
- *
- * @param name The name for the "extra" property. It must not
- * be {@code null}.
- * @param values The set of value for the "extra" property, or
- * {@code null} if the property is to be removed.
- */
- public void setExtraProperty(String name, List<String> values)
- {
- ifNull(name);
-
- if (values == null || values.isEmpty())
- {
- extraProperties.remove(name);
- }
- else
- {
- LinkedList<String> valuesCopy = new LinkedList<>(values);
- extraProperties.put(name, valuesCopy);
- }
- }
-
-
-
- /**
- * Indicates whether the provided object is equal to this ldap
- * syntax. The object will be considered equal if it is a ldap
- * syntax with the same OID as the current ldap syntax description.
- *
- * @param o The object for which to make the determination.
- *
- * @return {@code true} if the provided object is equal to this
- * ldap syntax description, or {@code true} if not.
- */
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (!(o instanceof LDAPSyntaxDescription))
- {
- return false;
- }
- return oid.equals(((LDAPSyntaxDescription) o).oid);
- }
-
-
-
- /**
- * Retrieves the hash code for this ldap syntax description. It
- * will be based on the sum of the bytes of the OID.
- *
- * @return The hash code for this ldap syntax description.
- */
- @Override
- public int hashCode()
- {
- int oidLength = oid.length();
- int hashCode = 0;
- for (int i=0; i < oidLength; i++)
- {
- hashCode += oid.charAt(i);
- }
-
- return hashCode;
- }
-
-
-
- /**
- * Retrieves the string representation of this ldap syntax
- * description in the form specified in RFC 2252.
- *
- * @return The string representation of this ldap syntax in the
- * form specified in RFC 2252.
- */
- @Override
- public String toString()
- {
- return definition;
- }
-
- @Override
- public String getDescription()
- {
- return "";
- }
-
-}
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 6dfacbb..d02a95a 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
@@ -35,7 +35,6 @@
import java.io.IOException;
import java.text.ParseException;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -43,7 +42,6 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -98,13 +96,6 @@
{
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
- /**
- * The set of ldap syntax descriptions for this schema, mapped the OID and the
- * ldap syntax description itself.
- */
- private ConcurrentHashMap<String,LDAPSyntaxDescription>
- ldapSyntaxDescriptions;
-
/** The oldest modification timestamp for any schema configuration file. */
private long oldestModificationTime;
/** The youngest modification timestamp for any schema configuration file. */
@@ -146,8 +137,6 @@
.toSchema();
switchSchema(newSchemaNG);
- ldapSyntaxDescriptions = new ConcurrentHashMap<String,LDAPSyntaxDescription>();
-
oldestModificationTime = System.currentTimeMillis();
youngestModificationTime = oldestModificationTime;
}
@@ -869,7 +858,19 @@
}
}
- private void registerSyntax(final String definition, final boolean overwriteExisting) throws DirectoryException
+ /**
+ * Registers the provided syntax definition with this schema.
+ *
+ * @param definition
+ * The definition to register with this schema.
+ * @param overwriteExisting
+ * Indicates whether to overwrite an existing mapping if there are any conflicts (i.e.,
+ * another attribute syntax with the same OID).
+ * @throws DirectoryException
+ * If a conflict is encountered and the <CODE>overwriteExisting</CODE> flag is set to
+ * {@code false}
+ */
+ public void registerSyntax(final String definition, final boolean overwriteExisting) throws DirectoryException
{
exclusiveLock.lock();
try
@@ -917,107 +918,6 @@
}
}
-
-
- /**
- * Retrieves the ldap syntax definitions for this schema.
- *
- * @return The ldap syntax definitions for this schema.
- */
- public Collection<LDAPSyntaxDescription> getLdapSyntaxDescriptions()
- {
- return Collections.unmodifiableCollection(ldapSyntaxDescriptions.values());
- }
-
- /**
- * Retrieves the ldap syntax definition with the OID.
- *
- * @param nameOrOid
- * The OID of the ldap syntax to retrieve.
- * @return The requested ldap syntax, or {@code null} if no syntax is registered with the provided
- * OID.
- */
- public LDAPSyntaxDescription getLdapSyntaxDescription(String nameOrOid)
- {
- return ldapSyntaxDescriptions.get(nameOrOid);
- }
-
- /**
- * Registers the provided ldap syntax description with this schema.
- *
- * @param definition
- * The ldap syntax definition to register with this schema.
- * @param overwriteExisting
- * Indicates whether to overwrite an existing mapping if there are any conflicts (i.e.,
- * another ldap syntax with the same OID).
- * @throws DirectoryException
- * If a conflict is encountered and <CODE>overwriteExisting</CODE> flag is set to
- * {@code false}
- */
- public void registerLdapSyntaxDescription(String definition, boolean overwriteExisting)
- throws DirectoryException
- {
- /**
- * ldapsyntaxes is part real and part virtual. For any
- * ldapsyntaxes attribute this is real, an LDAPSyntaxDescription
- * object is created and stored with the schema. Also, the
- * associated LDAPSyntaxDescriptionSyntax is added into the
- * virtual syntax set to make this available through virtual
- * ldapsyntaxes attribute.
- */
- exclusiveLock.lock();
- try
- {
- String oid = parseAttributeTypeOID(definition);
- if (! overwriteExisting && ldapSyntaxDescriptions.containsKey(oid))
- {
- throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
- ERR_SCHEMA_MODIFY_MULTIPLE_CONFLICTS_FOR_ADD_LDAP_SYNTAX.get(oid));
- }
-
- // Register the syntax with the schema.
- // It will ensure syntax is available along with the other virtual values for ldapsyntaxes.
- registerSyntax(definition, overwriteExisting);
-
- Syntax syntax = schemaNG.getSyntax(oid);
- LDAPSyntaxDescription syntaxDesc = new LDAPSyntaxDescription(definition, oid, syntax.getExtraProperties());
- ldapSyntaxDescriptions.put(oid, syntaxDesc);
- }
- finally
- {
- exclusiveLock.unlock();
- }
- }
-
-
-
- /**
- * Deregisters the provided ldap syntax description with this schema.
- *
- * @param syntaxDesc
- * The ldap syntax to deregister with this schema.
- * @throws DirectoryException
- * If the LDAP syntax is referenced by another schema element.
- */
- public void deregisterLdapSyntaxDescription(LDAPSyntaxDescription syntaxDesc) throws DirectoryException
- {
- exclusiveLock.lock();
- try
- {
- // Remove the real value.
- ldapSyntaxDescriptions.remove(toLowerCase(syntaxDesc.getOID()), syntaxDesc);
-
- // Get rid of this from the virtual ldapsyntaxes.
- deregisterSyntax(getSyntax(syntaxDesc.getOID()));
- }
- finally
- {
- exclusiveLock.unlock();
- }
- }
-
-
-
/**
* Retrieves all matching rule definitions for this schema.
*
@@ -1028,8 +928,6 @@
return schemaNG.getMatchingRules();
}
-
-
/**
* Indicates whether this schema definition includes a matching rule with the provided name or
* OID.
@@ -1674,7 +1572,6 @@
throw new RuntimeException(unexpected);
}
- dupSchema.ldapSyntaxDescriptions.putAll(ldapSyntaxDescriptions);
dupSchema.oldestModificationTime = oldestModificationTime;
dupSchema.youngestModificationTime = youngestModificationTime;
if (extraAttributes != null)
@@ -2107,12 +2004,6 @@
extraAttributes.clear();
extraAttributes = null;
}
-
- if(ldapSyntaxDescriptions != null)
- {
- ldapSyntaxDescriptions.clear();
- ldapSyntaxDescriptions = null;
- }
}
/**
--
Gitblit v1.10.0