mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
10.36.2013 01a60aa97ce21b185d574a090fcd04752ea417f0
DirectoryServer.java:
In bootstrapAttributeSyntaxes(), extracted method initAndRegister() to remove duplicated code.

*.java:
Replaced collection concrete classes with interfaces.
3 files modified
730 ■■■■■ changed files
opends/src/server/org/opends/server/backends/SchemaBackend.java 173 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/DirectoryServer.java 303 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/Schema.java 254 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/SchemaBackend.java
@@ -127,91 +127,115 @@
  // The set of user-defined attributes that will be included in the schema
  // entry.
  /**
   * The set of user-defined attributes that will be included in the schema
   * entry.
   */
  private ArrayList<Attribute> userDefinedAttributes;
  // The attribute type that will be used to include the defined attribute
  // types.
  /**
   * The attribute type that will be used to include the defined attribute
   * types.
   */
  private AttributeType attributeTypesType;
  // The attribute type that will be used to hold the schema creation timestamp.
  /**
   * The attribute type that will be used to hold the schema creation timestamp.
   */
  private AttributeType createTimestampType;
  // The attribute type that will be used to hold the schema creator's name.
  /** The attribute type that will be used to hold the schema creator's name. */
  private AttributeType creatorsNameType;
  // The attribute type that will be used to include the defined DIT content
  // rules.
  /**
   * The attribute type that will be used to include the defined DIT content
   * rules.
   */
  private AttributeType ditContentRulesType;
  // The attribute type that will be used to include the defined DIT structure
  // rules.
  /**
   * The attribute type that will be used to include the defined DIT structure
   * rules.
   */
  private AttributeType ditStructureRulesType;
  // The attribute type that will be used to include the defined attribute
  // syntaxes.
  /**
   * The attribute type that will be used to include the defined attribute
   * syntaxes.
   */
  private AttributeType ldapSyntaxesType;
  // The attribute type that will be used to include the defined matching rules.
  /**
   * The attribute type that will be used to include the defined matching rules.
   */
  private AttributeType matchingRulesType;
  // The attribute type that will be used to include the defined matching rule
  // uses.
  /**
   * The attribute type that will be used to include the defined matching rule
   * uses.
   */
  private AttributeType matchingRuleUsesType;
  // The attribute that will be used to hold the schema modifier's name.
  /** The attribute that will be used to hold the schema modifier's name. */
  private AttributeType modifiersNameType;
  // The attribute type that will be used to hold the schema modification
  // timestamp.
  /**
   * The attribute type that will be used to hold the schema modification
   * timestamp.
   */
  private AttributeType modifyTimestampType;
  // The attribute type that will be used to include the defined object classes.
  /**
   * The attribute type that will be used to include the defined object classes.
   */
  private AttributeType objectClassesType;
  // The attribute type that will be used to include the defined name forms.
  /** The attribute type that will be used to include the defined name forms. */
  private AttributeType nameFormsType;
  // The value containing DN of the user we'll say created the configuration.
  /** The value containing DN of the user we'll say created the configuration. */
  private AttributeValue creatorsName;
  // The value containing the DN of the last user to modify the configuration.
  /** The value containing the DN of the last user to modify the configuration. */
  private AttributeValue modifiersName;
  // The timestamp that will be used for the schema creation time.
  /** The timestamp that will be used for the schema creation time. */
  private AttributeValue createTimestamp;
  // The timestamp that will be used for the latest schema modification time.
  /** The timestamp that will be used for the latest schema modification time. */
  private AttributeValue modifyTimestamp;
  // Indicates whether the attributes of the schema entry should always be
  // treated as user attributes even if they are defined as operational.
  /**
   * Indicates whether the attributes of the schema entry should always be
   * treated as user attributes even if they are defined as operational.
   */
  private boolean showAllAttributes;
  // The DN of the configuration entry for this backend.
  /** The DN of the configuration entry for this backend. */
  private DN configEntryDN;
  // The current configuration state.
  /** The current configuration state. */
  private SchemaBackendCfg currentConfig;
  // The set of base DNs for this backend.
  /** The set of base DNs for this backend. */
  private DN[] baseDNs;
  // The set of objectclasses that will be used in the schema entry.
  /** The set of objectclasses that will be used in the schema entry. */
  private HashMap<ObjectClass,String> schemaObjectClasses;
  // The set of supported controls for this backend.
  private HashSet<String> supportedControls;
  /** The set of supported controls for this backend. */
  private Set<String> supportedControls;
  // The set of supported features for this backend.
  private HashSet<String> supportedFeatures;
  /** The set of supported features for this backend. */
  private Set<String> supportedFeatures;
  // The time that the schema was last modified.
  /** The time that the schema was last modified. */
  private long modifyTime;
  //Regular expression used to strip minimum upper bound value from
  //syntax Attribute Type Description. The value looks like: {count}.
  /**
   * Regular expression used to strip minimum upper bound value from syntax
   * Attribute Type Description. The value looks like: {count}.
   */
  private String stripMinUpperBoundRegEx = "\\{\\d+\\}";
@@ -386,13 +410,13 @@
    try
    {
      // First, generate lists of elements from the current schema.
      LinkedHashSet<String> newATs  = new LinkedHashSet<String>();
      LinkedHashSet<String> newOCs  = new LinkedHashSet<String>();
      LinkedHashSet<String> newNFs  = new LinkedHashSet<String>();
      LinkedHashSet<String> newDCRs = new LinkedHashSet<String>();
      LinkedHashSet<String> newDSRs = new LinkedHashSet<String>();
      LinkedHashSet<String> newMRUs = new LinkedHashSet<String>();
      LinkedHashSet<String> newLSDs = new LinkedHashSet<String>();
      Set<String> newATs  = new LinkedHashSet<String>();
      Set<String> newOCs  = new LinkedHashSet<String>();
      Set<String> newNFs  = new LinkedHashSet<String>();
      Set<String> newDCRs = new LinkedHashSet<String>();
      Set<String> newDSRs = new LinkedHashSet<String>();
      Set<String> newMRUs = new LinkedHashSet<String>();
      Set<String> newLSDs = new LinkedHashSet<String>();
      Schema.genConcatenatedSchema(newATs, newOCs, newNFs, newDCRs, newDSRs,
                                   newMRUs,newLSDs);
@@ -439,19 +463,19 @@
        }
      }
      LinkedHashSet<String> oldATs  = new LinkedHashSet<String>();
      LinkedHashSet<String> oldOCs  = new LinkedHashSet<String>();
      LinkedHashSet<String> oldNFs  = new LinkedHashSet<String>();
      LinkedHashSet<String> oldDCRs = new LinkedHashSet<String>();
      LinkedHashSet<String> oldDSRs = new LinkedHashSet<String>();
      LinkedHashSet<String> oldMRUs = new LinkedHashSet<String>();
      LinkedHashSet<String> oldLSDs = new LinkedHashSet<String>();
      Set<String> oldATs  = new LinkedHashSet<String>();
      Set<String> oldOCs  = new LinkedHashSet<String>();
      Set<String> oldNFs  = new LinkedHashSet<String>();
      Set<String> oldDCRs = new LinkedHashSet<String>();
      Set<String> oldDSRs = new LinkedHashSet<String>();
      Set<String> oldMRUs = new LinkedHashSet<String>();
      Set<String> oldLSDs = new LinkedHashSet<String>();
      Schema.readConcatenatedSchema(concatFilePath, oldATs, oldOCs, oldNFs,
                                    oldDCRs, oldDSRs, oldMRUs,oldLSDs);
      // Create a list of modifications and add any differences between the old
      // and new schema into them.
      LinkedList<Modification> mods = new LinkedList<Modification>();
      List<Modification> mods = new LinkedList<Modification>();
      Schema.compareConcatenatedSchema(oldATs, newATs, attributeTypesType,
                                       mods);
      Schema.compareConcatenatedSchema(oldOCs, newOCs, objectClassesType, mods);
@@ -681,10 +705,10 @@
  private Entry getSchemaEntry(DN entryDN, boolean includeSchemaFile,
                                          boolean ignoreShowAllOption)
  {
    LinkedHashMap<AttributeType, List<Attribute>> userAttrs =
    Map<AttributeType, List<Attribute>> userAttrs =
      new LinkedHashMap<AttributeType, List<Attribute>>();
    LinkedHashMap<AttributeType, List<Attribute>> operationalAttrs =
    Map<AttributeType, List<Attribute>> operationalAttrs =
      new LinkedHashMap<AttributeType, List<Attribute>>();
    // Add the RDN attribute(s) for the provided entry.
@@ -714,14 +738,13 @@
    Schema schema = DirectoryServer.getSchema();
    // Add the "attributeTypes" attribute.
    LinkedHashSet<AttributeValue> valueSet = DirectoryServer
        .getAttributeTypeSet();
    Set<AttributeValue> valueSet = DirectoryServer.getAttributeTypeSet();
    // Add the file name to the description of the attribute type if
    // this was requested by the caller.
    if (includeSchemaFile)
    {
      LinkedHashSet<AttributeValue> newValueSet =
      Set<AttributeValue> newValueSet =
        new LinkedHashSet<AttributeValue>(valueSet.size());
      for (AttributeValue value : valueSet)
@@ -796,7 +819,7 @@
    // the caller.
    if (includeSchemaFile)
    {
      LinkedHashSet<AttributeValue> newValueSet =
      Set<AttributeValue> newValueSet =
        new LinkedHashSet<AttributeValue>(valueSet.size());
      for (AttributeValue value : valueSet)
@@ -3434,7 +3457,7 @@
   */
  private Entry createEmptySchemaEntry()
  {
    LinkedHashMap<ObjectClass,String> objectClasses =
    Map<ObjectClass,String> objectClasses =
         new LinkedHashMap<ObjectClass,String>();
    objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP);
    objectClasses.put(DirectoryServer.getObjectClass(OC_LDAP_SUBENTRY_LC, true),
@@ -3442,10 +3465,10 @@
    objectClasses.put(DirectoryServer.getObjectClass(OC_SUBSCHEMA, true),
                      OC_SUBSCHEMA);
    LinkedHashMap<AttributeType,List<Attribute>> userAttributes =
    Map<AttributeType,List<Attribute>> userAttributes =
         new LinkedHashMap<AttributeType,List<Attribute>>();
    LinkedHashMap<AttributeType,List<Attribute>> operationalAttributes =
    Map<AttributeType,List<Attribute>> operationalAttributes =
         new LinkedHashMap<AttributeType,List<Attribute>>();
    DN  dn  = DirectoryServer.getSchemaDN();
@@ -3453,7 +3476,7 @@
    for (int i=0; i < rdn.getNumValues(); i++)
    {
      AttributeType type = rdn.getAttributeType(i);
      LinkedList<Attribute> attrList = new LinkedList<Attribute>();
      List<Attribute> attrList = new LinkedList<Attribute>();
      attrList.add(Attributes.create(type, rdn.getAttributeValue(i)));
      if (type.isOperational())
      {
@@ -3499,7 +3522,7 @@
     * this only for the real part of the ldapsyntaxes attribute. The real part
     * is read and write to/from the schema files.
     */
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>();
    Set<AttributeValue> values = new LinkedHashSet<AttributeValue>();
    for (LDAPSyntaxDescription ldapSyntax :
                                   schema.getLdapSyntaxDescriptions().values())
    {
@@ -3522,7 +3545,7 @@
    // Add all of the appropriate attribute types to the schema entry.  We need
    // to be careful of the ordering to ensure that any superior types in the
    // same file are written before the subordinate types.
    HashSet<AttributeType> addedTypes = new HashSet<AttributeType>();
    Set<AttributeType> addedTypes = new HashSet<AttributeType>();
    values = new LinkedHashSet<AttributeValue>();
    for (AttributeType at : schema.getAttributeTypes().values())
    {
@@ -3545,7 +3568,7 @@
    // Add all of the appropriate objectclasses to the schema entry.  We need
    // to be careful of the ordering to ensure that any superior classes in the
    // same file are written before the subordinate classes.
    HashSet<ObjectClass> addedClasses = new HashSet<ObjectClass>();
    Set<ObjectClass> addedClasses = new HashSet<ObjectClass>();
    values = new LinkedHashSet<AttributeValue>();
    for (ObjectClass oc : schema.getObjectClasses().values())
    {
@@ -3618,7 +3641,7 @@
    // Add all of the appropriate DIT structure rules to the schema entry.  We
    // need to be careful of the ordering to ensure that any superior rules in
    // the same file are written before the subordinate rules.
    HashSet<DITStructureRule> addedDSRs = new HashSet<DITStructureRule>();
    Set<DITStructureRule> addedDSRs = new HashSet<DITStructureRule>();
    values = new LinkedHashSet<AttributeValue>();
    for (DITStructureRule dsr : schema.getDITStructureRulesByID().values())
    {
@@ -3705,8 +3728,8 @@
   */
  private void addAttrTypeToSchemaFile(Schema schema, String schemaFile,
                                       AttributeType attributeType,
                                       LinkedHashSet<AttributeValue> values,
                                       HashSet<AttributeType> addedTypes,
                                       Set<AttributeValue> values,
                                       Set<AttributeType> addedTypes,
                                       int depth)
          throws DirectoryException
  {
@@ -3756,8 +3779,8 @@
   */
  private void addObjectClassToSchemaFile(Schema schema, String schemaFile,
                                          ObjectClass objectClass,
                                          LinkedHashSet<AttributeValue> values,
                                          HashSet<ObjectClass> addedClasses,
                                          Set<AttributeValue> values,
                                          Set<ObjectClass> addedClasses,
                                          int depth)
          throws DirectoryException
  {
@@ -3808,8 +3831,8 @@
   */
  private void addDITStructureRuleToSchemaFile(Schema schema, String schemaFile,
                    DITStructureRule ditStructureRule,
                    LinkedHashSet<AttributeValue> values,
                    HashSet<DITStructureRule> addedDSRs, int depth)
                    Set<AttributeValue> values,
                    Set<DITStructureRule> addedDSRs, int depth)
          throws DirectoryException
  {
    if (depth > 20)
@@ -4240,7 +4263,7 @@
   * {@inheritDoc}
   */
  @Override()
  public HashSet<String> getSupportedControls()
  public Set<String> getSupportedControls()
  {
    return supportedControls;
  }
@@ -4251,7 +4274,7 @@
   * {@inheritDoc}
   */
  @Override()
  public HashSet<String> getSupportedFeatures()
  public Set<String> getSupportedFeatures()
  {
    return supportedFeatures;
  }
@@ -5781,7 +5804,7 @@
      // deleteBaseDNs will contain the set of DNs that should no longer be used
      // and should be deregistered from the server, and the newBaseDNs set will
      // just contain the set of DNs to add.
      HashSet<DN> deleteBaseDNs = new HashSet<DN>(baseDNs.length);
      Set<DN> deleteBaseDNs = new HashSet<DN>(baseDNs.length);
      for (DN baseDN : baseDNs)
      {
        if (! newBaseDNs.remove(baseDN))
opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -398,10 +398,10 @@
  private ConcurrentHashMap<String,SASLMechanismHandler> saslMechanismHandlers;
  /** The connection handler configuration manager for the Directory Server. */
  private ConnectionHandlerConfigManager connectionHandlerConfigManager = null;
  private ConnectionHandlerConfigManager connectionHandlerConfigManager;
  /** The set of alert handlers registered with the Directory Server. */
  private CopyOnWriteArrayList<AlertHandler> alertHandlers;
  private List<AlertHandler> alertHandlers;
  /** The set of backup task listeners registered with the Directory Server. */
  private CopyOnWriteArrayList<BackupTaskListener> backupTaskListeners;
@@ -410,11 +410,11 @@
   * The set of change notification listeners registered with the Directory
   * Server.
   */
  private CopyOnWriteArrayList<ChangeNotificationListener>
  private List<ChangeNotificationListener>
               changeNotificationListeners;
  /** The set of connection handlers registered with the Directory Server. */
  private CopyOnWriteArrayList<ConnectionHandler> connectionHandlers;
  private List<ConnectionHandler> connectionHandlers;
  /** The set of export task listeners registered with the Directory Server. */
  private CopyOnWriteArrayList<ExportTaskListener> exportTaskListeners;
@@ -429,35 +429,34 @@
   * The set of initialization completed listeners that have been registered
   * with the Directory Server.
   */
  private CopyOnWriteArrayList<InitializationCompletedListener>
  private List<InitializationCompletedListener>
          initializationCompletedListeners;
  /**
   * The set of shutdown listeners that have been registered with the Directory
   * Server.
   */
  private CopyOnWriteArrayList<ServerShutdownListener> shutdownListeners;
  private List<ServerShutdownListener> shutdownListeners;
  /**
   * The set of synchronization providers that have been registered with the
   * Directory Server.
   */
  private
    CopyOnWriteArrayList<SynchronizationProvider<SynchronizationProviderCfg>>
  private List<SynchronizationProvider<SynchronizationProviderCfg>>
               synchronizationProviders;
  /** The set of virtual attributes defined in the server. */
  private CopyOnWriteArrayList<VirtualAttributeRule> virtualAttributes;
  private List<VirtualAttributeRule> virtualAttributes;
  /**
   * The set of backend initialization listeners registered with the Directory
   * Server.
   */
  private CopyOnWriteArraySet<BackendInitializationListener>
  private Set<BackendInitializationListener>
               backendInitializationListeners;
  /** The set of root DNs registered with the Directory Server. */
  private CopyOnWriteArraySet<DN> rootDNs;
  private Set<DN> rootDNs;
  /** The core configuration manager for the Directory Server. */
  private CoreConfigManager coreConfigManager;
@@ -548,7 +547,7 @@
  private ExtensionConfigManager extensionConfigManager;
  /** The set of connections that are currently established. */
  private LinkedHashSet<ClientConnection> establishedConnections;
  private Set<ClientConnection> establishedConnections;
  /** The sets of mail server properties. */
  private List<Properties> mailServerPropertySets;
@@ -1623,9 +1622,26 @@
   */
  private void bootstrapAttributeSyntaxes()
  {
    initAndRegister(new AttributeTypeSyntax());
    defaultBinarySyntax = initAndRegister(new BinarySyntax());
    defaultBooleanSyntax = initAndRegister(new BooleanSyntax());
    defaultStringSyntax = initAndRegister(new DirectoryStringSyntax());
    defaultSyntax = defaultStringSyntax;
    defaultDNSyntax = initAndRegister(new DistinguishedNameSyntax());
    initAndRegister(new IA5StringSyntax());
    defaultIntegerSyntax = initAndRegister(new IntegerSyntax());
    initAndRegister(new GeneralizedTimeSyntax());
    initAndRegister(new ObjectClassSyntax());
    initAndRegister(new OIDSyntax());
    initAndRegister(new TelephoneNumberSyntax());
  }
  private <T extends AttributeSyntaxCfg> AttributeSyntax<T> initAndRegister(
      AttributeSyntax<T> syntax)
  {
    try
    {
      AttributeTypeSyntax syntax = new AttributeTypeSyntax();
      syntax.initializeSyntax(null);
      registerAttributeSyntax(syntax, true);
    }
@@ -1636,205 +1652,10 @@
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.get(
          AttributeTypeSyntax.class.getName(), stackTraceToSingleLineString(e));
      logError(message);
      logError(ERR_CANNOT_BOOTSTRAP_SYNTAX.get(syntax.getClass().getName(),
          stackTraceToSingleLineString(e)));
    }
    try
    {
      defaultBinarySyntax = new BinarySyntax();
      defaultBinarySyntax.initializeSyntax(null);
      registerAttributeSyntax(defaultBinarySyntax, true);
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.get(
          BinarySyntax.class.getName(), stackTraceToSingleLineString(e));
      logError(message);
    }
    try
    {
      defaultBooleanSyntax = new BooleanSyntax();
      defaultBooleanSyntax.initializeSyntax(null);
      registerAttributeSyntax(defaultBooleanSyntax, true);
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.get(
          BooleanSyntax.class.getName(), stackTraceToSingleLineString(e));
      logError(message);
    }
    try
    {
      defaultStringSyntax = new DirectoryStringSyntax();
      defaultStringSyntax.initializeSyntax(null);
      registerAttributeSyntax(defaultStringSyntax, true);
      defaultSyntax = defaultStringSyntax;
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.
          get(DirectoryStringSyntax.class.getName(),
              stackTraceToSingleLineString(e));
      logError(message);
    }
    try
    {
      defaultDNSyntax = new DistinguishedNameSyntax();
      defaultDNSyntax.initializeSyntax(null);
      registerAttributeSyntax(defaultDNSyntax, true);
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.
          get(DistinguishedNameSyntax.class.getName(),
              stackTraceToSingleLineString(e));
      logError(message);
    }
    try
    {
      IA5StringSyntax syntax = new IA5StringSyntax();
      syntax.initializeSyntax(null);
      registerAttributeSyntax(syntax, true);
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.get(
          IA5StringSyntax.class.getName(), stackTraceToSingleLineString(e));
      logError(message);
    }
    try
    {
      defaultIntegerSyntax = new IntegerSyntax();
      defaultIntegerSyntax.initializeSyntax(null);
      registerAttributeSyntax(defaultIntegerSyntax, true);
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.get(
          IntegerSyntax.class.getName(), stackTraceToSingleLineString(e));
      logError(message);
    }
    try
    {
      GeneralizedTimeSyntax syntax = new GeneralizedTimeSyntax();
      syntax.initializeSyntax(null);
      registerAttributeSyntax(syntax, true);
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.
          get(GeneralizedTimeSyntax.class.getName(),
              stackTraceToSingleLineString(e));
      logError(message);
    }
    try
    {
      ObjectClassSyntax syntax = new ObjectClassSyntax();
      syntax.initializeSyntax(null);
      registerAttributeSyntax(syntax, true);
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.get(
          ObjectClassSyntax.class.getName(), stackTraceToSingleLineString(e));
      logError(message);
    }
    try
    {
      OIDSyntax syntax = new OIDSyntax();
      syntax.initializeSyntax(null);
      registerAttributeSyntax(syntax, true);
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.get(
          OIDSyntax.class.getName(), stackTraceToSingleLineString(e));
      logError(message);
    }
    try
    {
      TelephoneNumberSyntax syntax = new TelephoneNumberSyntax();
      syntax.initializeSyntax(null);
      registerAttributeSyntax(syntax, true);
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      Message message = ERR_CANNOT_BOOTSTRAP_SYNTAX.
          get(TelephoneNumberSyntax.class.getName(),
              stackTraceToSingleLineString(e));
      logError(message);
    }
    return syntax;
  }
@@ -1982,11 +1803,11 @@
    // preserve any configuration add/delete/change listeners that might have
    // been registered with the old configuration (which will primarily be
    // schema elements) so they can be re-registered with the new configuration.
    LinkedHashMap<String,List<ConfigAddListener>> addListeners =
    Map<String, List<ConfigAddListener>> addListeners =
         new LinkedHashMap<String,List<ConfigAddListener>>();
    LinkedHashMap<String,List<ConfigDeleteListener>> deleteListeners =
    Map<String, List<ConfigDeleteListener>> deleteListeners =
         new LinkedHashMap<String,List<ConfigDeleteListener>>();
    LinkedHashMap<String,List<ConfigChangeListener>> changeListeners =
    Map<String, List<ConfigChangeListener>> changeListeners =
         new LinkedHashMap<String,List<ConfigChangeListener>>();
    getChangeListeners(configHandler.getConfigRootEntry(), addListeners,
                       deleteListeners, changeListeners);
@@ -2114,26 +1935,25 @@
   *                          the corresponding configuration entry.
   */
  private void getChangeListeners(ConfigEntry configEntry,
       LinkedHashMap<String,List<ConfigAddListener>> addListeners,
       LinkedHashMap<String,List<ConfigDeleteListener>> deleteListeners,
       LinkedHashMap<String,List<ConfigChangeListener>> changeListeners)
      Map<String, List<ConfigAddListener>> addListeners,
      Map<String, List<ConfigDeleteListener>> deleteListeners,
      Map<String, List<ConfigChangeListener>> changeListeners)
  {
    CopyOnWriteArrayList<ConfigAddListener> cfgAddListeners =
         configEntry.getAddListeners();
    List<ConfigAddListener> cfgAddListeners = configEntry.getAddListeners();
    if ((cfgAddListeners != null) && (cfgAddListeners.size() > 0))
    {
      addListeners.put(configEntry.getDN().toString(), cfgAddListeners);
    }
    CopyOnWriteArrayList<ConfigDeleteListener> cfgDeleteListeners =
         configEntry.getDeleteListeners();
    List<ConfigDeleteListener> cfgDeleteListeners =
        configEntry.getDeleteListeners();
    if ((cfgDeleteListeners != null) && (cfgDeleteListeners.size() > 0))
    {
      deleteListeners.put(configEntry.getDN().toString(), cfgDeleteListeners);
    }
    CopyOnWriteArrayList<ConfigChangeListener> cfgChangeListeners =
         configEntry.getChangeListeners();
    List<ConfigChangeListener> cfgChangeListeners =
        configEntry.getChangeListeners();
    if ((cfgChangeListeners != null) && (cfgChangeListeners.size() > 0))
    {
      changeListeners.put(configEntry.getDN().toString(), cfgChangeListeners);
@@ -3235,7 +3055,7 @@
   * @return  The set of encoded matching rules that have been defined in the
   *          Directory Server.
   */
  public static LinkedHashSet<AttributeValue> getMatchingRuleSet()
  public static Set<AttributeValue> getMatchingRuleSet()
  {
    return directoryServer.schema.getMatchingRuleSet();
  }
@@ -3634,7 +3454,7 @@
   * @return  The set of encoded objectclasses that have been defined in the
   *          Directory Server.
   */
  public static LinkedHashSet<AttributeValue> getObjectClassSet()
  public static Set<AttributeValue> getObjectClassSet()
  {
    return directoryServer.schema.getObjectClassSet();
  }
@@ -3838,7 +3658,7 @@
   * @return  The set of encoded attribute types that have been defined in the
   *          Directory Server.
   */
  public static LinkedHashSet<AttributeValue> getAttributeTypeSet()
  public static Set<AttributeValue> getAttributeTypeSet()
  {
    return directoryServer.schema.getAttributeTypeSet();
  }
@@ -4057,7 +3877,7 @@
   * @return  The set of encoded attribute syntaxes that have been defined in
   *          the Directory Server.
   */
  public static LinkedHashSet<AttributeValue> getAttributeSyntaxSet()
  public static Set<AttributeValue> getAttributeSyntaxSet()
  {
    return directoryServer.schema.getSyntaxSet();
  }
@@ -4238,7 +4058,7 @@
   * @return  The set of encoded matching rule uses that have been defined in
   *          the Directory Server.
   */
  public static LinkedHashSet<AttributeValue> getMatchingRuleUseSet()
  public static Set<AttributeValue> getMatchingRuleUseSet()
  {
    return directoryServer.schema.getMatchingRuleUseSet();
  }
@@ -4318,7 +4138,7 @@
   * @return  The set of encoded DIT content rules that have been defined in the
   *          Directory Server.
   */
  public static LinkedHashSet<AttributeValue> getDITContentRuleSet()
  public static Set<AttributeValue> getDITContentRuleSet()
  {
    return directoryServer.schema.getDITContentRuleSet();
  }
@@ -4397,7 +4217,7 @@
   * @return  The set of encoded DIT structure rules that have been defined in
   *          the Directory Server.
   */
  public static LinkedHashSet<AttributeValue> getDITStructureRuleSet()
  public static Set<AttributeValue> getDITStructureRuleSet()
  {
    return directoryServer.schema.getDITStructureRuleSet();
  }
@@ -4493,7 +4313,7 @@
   * @return  The set of encoded name forms that have been defined in the
   *          Directory Server.
   */
  public static LinkedHashSet<AttributeValue> getNameFormSet()
  public static Set<AttributeValue> getNameFormSet()
  {
    return directoryServer.schema.getNameFormSet();
  }
@@ -4593,8 +4413,8 @@
   */
  public static List<VirtualAttributeRule> getVirtualAttributes(Entry entry)
  {
    LinkedList<VirtualAttributeRule> ruleList =
         new LinkedList<VirtualAttributeRule>();
    List<VirtualAttributeRule> ruleList =
        new LinkedList<VirtualAttributeRule>();
    for (VirtualAttributeRule rule : directoryServer.virtualAttributes)
    {
@@ -4803,7 +4623,7 @@
   * @return  The set of alert handlers that have been registered with the
   *          Directory Server.
   */
  public static CopyOnWriteArrayList<AlertHandler> getAlertHandlers()
  public static List<AlertHandler> getAlertHandlers()
  {
    return directoryServer.alertHandlers;
  }
@@ -5864,7 +5684,7 @@
   *
   * @return  The DNs for the root users configured in the Directory Server.
   */
  public static CopyOnWriteArraySet<DN> getRootDNs()
  public static Set<DN> getRootDNs()
  {
    return directoryServer.rootDNs;
  }
@@ -7173,7 +6993,7 @@
   *
   * @return  The set of connection handlers configured in the Directory Server.
   */
  public static CopyOnWriteArrayList<ConnectionHandler> getConnectionHandlers()
  public static List<ConnectionHandler> getConnectionHandlers()
  {
    return directoryServer.connectionHandlers;
  }
@@ -7238,8 +7058,8 @@
   */
  private void startConnectionHandlers() throws ConfigException
  {
    LinkedHashSet<HostPort> usedListeners = new LinkedHashSet<HostPort>();
    LinkedHashSet<Message> errorMessages = new LinkedHashSet<Message>();
    Set<HostPort> usedListeners = new LinkedHashSet<HostPort>();
    Set<Message> errorMessages = new LinkedHashSet<Message>();
    // Check that the port specified in the connection handlers is
    // available.
    for (ConnectionHandler<?> c : connectionHandlers)
@@ -7475,7 +7295,7 @@
   * @return  The set of change notification listeners registered with the
   *          Directory Server.
   */
  public static CopyOnWriteArrayList<ChangeNotificationListener>
  public static List<ChangeNotificationListener>
                     getChangeNotificationListeners()
  {
    return directoryServer.changeNotificationListeners;
@@ -7522,8 +7342,7 @@
   * @return  The set of synchronization providers that have been registered
   *          with the Directory Server.
   */
  public static
    CopyOnWriteArrayList<SynchronizationProvider<SynchronizationProviderCfg>>
  public static List<SynchronizationProvider<SynchronizationProviderCfg>>
      getSynchronizationProviders()
  {
    return directoryServer.synchronizationProviders;
@@ -9396,7 +9215,7 @@
        // We're not really trying to start, so rebuild the argument list
        // without the "--checkStartability" argument and try again.  Exit with
        // whatever that exits with.
        LinkedList<String> newArgList = new LinkedList<String>();
        List<String> newArgList = new LinkedList<String>();
        for (String arg : args)
        {
          if (! arg.equalsIgnoreCase("--checkstartability"))
opends/src/server/org/opends/server/types/Schema.java
@@ -42,6 +42,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
@@ -99,140 +100,161 @@
  // The matching rule that will be used to normalize schema element
  // definitions.
  /**
   * The matching rule that will be used to normalize schema element
   * definitions.
   */
  private MatchingRule normalizationMatchingRule;
  // The set of subordinate attribute types registered within the
  // server schema.
  /**
   * The set of subordinate attribute types registered within the server schema.
   */
  private ConcurrentHashMap<AttributeType,List<AttributeType>>
               subordinateTypes;
  // The set of attribute type definitions for this schema, mapped
  // between the lowercase names and OID for the definition and the
  // attribute type itself.
  /**
   * The set of attribute type definitions for this schema, mapped between the
   * lowercase names and OID for the definition and the attribute type itself.
   */
  private ConcurrentHashMap<String,AttributeType> attributeTypes;
  // The set of objectclass definitions for this schema, mapped
  // between the lowercase names and OID for the definition and the
  // objectclass itself.
  /**
   * The set of objectclass definitions for this schema, mapped between the
   * lowercase names and OID for the definition and the objectclass itself.
   */
  private ConcurrentHashMap<String,ObjectClass> objectClasses;
  // The set of attribute syntaxes for this schema, mapped between the
  // OID for the syntax and the syntax itself.
  /**
   * The set of attribute syntaxes for this schema, mapped between the OID for
   * the syntax and the syntax itself.
   */
  private ConcurrentHashMap<String,AttributeSyntax<?>> syntaxes;
  // The entire set of matching rules for this schema, mapped between
  // the lowercase names and OID for the definition and the matching
  // rule itself.
  /**
   * The entire set of matching rules for this schema, mapped between the
   * lowercase names and OID for the definition and the matching rule itself.
   */
  private ConcurrentHashMap<String,MatchingRule> matchingRules;
  // The set of approximate matching rules for this schema, mapped
  // between the lowercase names and OID for the definition and the
  // matching rule itself.
  /**
   * The set of approximate matching rules for this schema, mapped between the
   * lowercase names and OID for the definition and the matching rule itself.
   */
  private ConcurrentHashMap<String,ApproximateMatchingRule>
               approximateMatchingRules;
  // The set of equality matching rules for this schema, mapped
  // between the lowercase names and OID for the definition and the
  // matching rule itself.
  /**
   * The set of equality matching rules for this schema, mapped between the
   * lowercase names and OID for the definition and the matching rule itself.
   */
  private ConcurrentHashMap<String,EqualityMatchingRule>
               equalityMatchingRules;
  // The set of ordering matching rules for this schema, mapped
  // between the lowercase names and OID for the definition and the
  // matching rule itself.
  /**
   * The set of ordering matching rules for this schema, mapped between the
   * lowercase names and OID for the definition and the matching rule itself.
   */
  private ConcurrentHashMap<String,OrderingMatchingRule>
               orderingMatchingRules;
  // The set of substring matching rules for this schema, mapped
  // between the lowercase names and OID for the definition and the
  // matching rule itself.
  /**
   * The set of substring matching rules for this schema, mapped between the
   * lowercase names and OID for the definition and the matching rule itself.
   */
  private ConcurrentHashMap<String,SubstringMatchingRule>
               substringMatchingRules;
  // The set of extensible matching rules for this schema, mapped
  // between the lowercase names and OID for the definition and the
  // matching rule itself.
  /**
   * The set of extensible matching rules for this schema, mapped between the
   * lowercase names and OID for the definition and the matching rule itself.
   */
  private ConcurrentHashMap<String,ExtensibleMatchingRule>
               extensibleMatchingRules;
  // The set of matching rule uses for this schema, mapped between the
  // matching rule for the definition and the matching rule use
  // itself.
  /**
   * The set of matching rule uses for this schema, mapped between the matching
   * rule for the definition and the matching rule use itself.
   */
  private ConcurrentHashMap<MatchingRule,MatchingRuleUse>
               matchingRuleUses;
  // The set of DIT content rules for this schema, mapped between the
  // structural objectclass for the definition and the DIT content
  // rule itself.
  /**
   * The set of DIT content rules for this schema, mapped between the structural
   * objectclass for the definition and the DIT content rule itself.
   */
  private ConcurrentHashMap<ObjectClass,DITContentRule>
               ditContentRules;
  // The set of DIT structure rules for this schema, mapped between
  // the name form for the definition and the DIT structure rule
  // itself.
  /**
   * The set of DIT structure rules for this schema, mapped between the name
   * form for the definition and the DIT structure rule itself.
   */
  private ConcurrentHashMap<Integer,DITStructureRule>
               ditStructureRulesByID;
  // The set of DIT structure rules for this schema, mapped between
  // the name form for the definition and the DIT structure rule
  // itself.
  /**
   * The set of DIT structure rules for this schema, mapped between the name
   * form for the definition and the DIT structure rule itself.
   */
  private ConcurrentHashMap<NameForm,DITStructureRule>
               ditStructureRulesByNameForm;
  // The set of name forms for this schema, mapped between the
  // structural objectclass for the definition and the list of name
  // forms
  /**
   * The set of name forms for this schema, mapped between the structural
   * objectclass for the definition and the list of name forms
   */
  private ConcurrentHashMap<ObjectClass,List<NameForm>>
          nameFormsByOC;
  // The set of name forms for this schema, mapped between the
  // names/OID and the name form itself.
  /**
   * The set of name forms for this schema, mapped between the names/OID and the
   * name form itself.
   */
  private ConcurrentHashMap<String,NameForm> nameFormsByName;
  // The set of ldap syntax descriptions for this schema, mapped
  // the OID and the ldap syntax description itself.
  /**
   * The set of ldap syntax descriptions for this schema, mapped the OID and the
   * ldap syntax description itself.
   */
  private ConcurrentHashMap<String,LDAPSyntaxDescription>
          ldapSyntaxDescriptions;
  // The set of pre-encoded attribute syntax representations.
  private LinkedHashSet<AttributeValue> syntaxSet;
  /** The set of pre-encoded attribute syntax representations. */
  private Set<AttributeValue> syntaxSet;
  // The set of pre-encoded attribute type representations.
  private LinkedHashSet<AttributeValue> attributeTypeSet;
  /** The set of pre-encoded attribute type representations. */
  private Set<AttributeValue> attributeTypeSet;
  // The set of pre-encoded DIT content rule representations.
  private LinkedHashSet<AttributeValue> ditContentRuleSet;
  /** The set of pre-encoded DIT content rule representations. */
  private Set<AttributeValue> ditContentRuleSet;
  // The set of pre-encoded DIT structure rule representations.
  private LinkedHashSet<AttributeValue> ditStructureRuleSet;
  /** The set of pre-encoded DIT structure rule representations. */
  private Set<AttributeValue> ditStructureRuleSet;
  // The set of pre-encoded matching rule representations.
  private LinkedHashSet<AttributeValue> matchingRuleSet;
  /** The set of pre-encoded matching rule representations. */
  private Set<AttributeValue> matchingRuleSet;
  // The set of pre-encoded matching rule use representations.
  private LinkedHashSet<AttributeValue> matchingRuleUseSet;
  /** The set of pre-encoded matching rule use representations. */
  private Set<AttributeValue> matchingRuleUseSet;
  // The set of pre-encoded name form representations.
  private LinkedHashSet<AttributeValue> nameFormSet;
  /** The set of pre-encoded name form representations. */
  private Set<AttributeValue> nameFormSet;
  // The set of pre-encoded objectclass representations.
  private LinkedHashSet<AttributeValue> objectClassSet;
  /** The set of pre-encoded objectclass representations. */
  private Set<AttributeValue> objectClassSet;
  // The oldest modification timestamp for any schema configuration
  // file.
  /** The oldest modification timestamp for any schema configuration file. */
  private long oldestModificationTime;
  // The youngest modification timestamp for any schema configuration
  // file.
  /** The youngest modification timestamp for any schema configuration file. */
  private long youngestModificationTime;
  // A set of extra attributes that are not used directly by
  // the schema but may be used by other component to store
  // information in the schema.
  // ex : Replication uses this to store its state and GenerationID.
  /**
   * A set of extra attributes that are not used directly by the schema but may
   * be used by other component to store information in the schema.
   * <p>
   * ex : Replication uses this to store its state and GenerationID.
   */
  private Map<String, Attribute> extraAttributes =
    new HashMap<String, Attribute>();
@@ -313,7 +335,7 @@
   *
   * @return  The set of defined attribute types for this schema.
   */
  public LinkedHashSet<AttributeValue> getAttributeTypeSet()
  public Set<AttributeValue> getAttributeTypeSet()
  {
    return attributeTypeSet;
  }
@@ -612,7 +634,7 @@
   *
   * @return  The set of defined objectclasses for this schema.
   */
  public LinkedHashSet<AttributeValue> getObjectClassSet()
  public Set<AttributeValue> getObjectClassSet()
  {
    return objectClassSet;
  }
@@ -803,7 +825,7 @@
   *
   * @return  The set of defined attribute syntaxes for this schema.
   */
  public LinkedHashSet<AttributeValue> getSyntaxSet()
  public Set<AttributeValue> getSyntaxSet()
  {
    return syntaxSet;
  }
@@ -1097,7 +1119,7 @@
   *
   * @return  The set of defined matching rules for this schema.
   */
  public LinkedHashSet<AttributeValue> getMatchingRuleSet()
  public Set<AttributeValue> getMatchingRuleSet()
  {
    return matchingRuleSet;
  }
@@ -2217,7 +2239,7 @@
   *
   * @return  The set of defined matching rule uses for this schema.
   */
  public LinkedHashSet<AttributeValue> getMatchingRuleUseSet()
  public Set<AttributeValue> getMatchingRuleUseSet()
  {
    return matchingRuleUseSet;
  }
@@ -2378,7 +2400,7 @@
   *
   * @return  The set of defined DIT content rules for this schema.
   */
  public LinkedHashSet<AttributeValue> getDITContentRuleSet()
  public Set<AttributeValue> getDITContentRuleSet()
  {
    return ditContentRuleSet;
  }
@@ -2521,7 +2543,7 @@
   *
   * @return  The set of defined DIT structure rules for this schema.
   */
  public LinkedHashSet<AttributeValue> getDITStructureRuleSet()
  public Set<AttributeValue> getDITStructureRuleSet()
  {
    return ditStructureRuleSet;
  }
@@ -2753,7 +2775,7 @@
   *
   * @return  The set of defined name forms for this schema.
   */
  public LinkedHashSet<AttributeValue> getNameFormSet()
  public Set<AttributeValue> getNameFormSet()
  {
    return nameFormSet;
  }
@@ -3397,19 +3419,13 @@
    String concatFilePath = null;
    try
    {
      LinkedHashSet<String> attributeTypes =
           new LinkedHashSet<String>();
      LinkedHashSet<String> objectClasses =
           new LinkedHashSet<String>();
      LinkedHashSet<String> nameForms = new LinkedHashSet<String>();
      LinkedHashSet<String> ditContentRules =
           new LinkedHashSet<String>();
      LinkedHashSet<String> ditStructureRules =
           new LinkedHashSet<String>();
      LinkedHashSet<String> matchingRuleUses =
           new LinkedHashSet<String>();
      LinkedHashSet<String> ldapSyntaxes =
           new LinkedHashSet<String>();
      Set<String> attributeTypes = new LinkedHashSet<String>();
      Set<String> objectClasses = new LinkedHashSet<String>();
      Set<String> nameForms = new LinkedHashSet<String>();
      Set<String> ditContentRules = new LinkedHashSet<String>();
      Set<String> ditStructureRules = new LinkedHashSet<String>();
      Set<String> matchingRuleUses = new LinkedHashSet<String>();
      Set<String> ldapSyntaxes = new LinkedHashSet<String>();
      genConcatenatedSchema(attributeTypes, objectClasses, nameForms,
                            ditContentRules, ditStructureRules,
                            matchingRuleUses,ldapSyntaxes);
@@ -3547,13 +3563,13 @@
   *                       schema file elements.
   */
  public static void genConcatenatedSchema(
                          LinkedHashSet<String> attributeTypes,
                          LinkedHashSet<String> objectClasses,
                          LinkedHashSet<String> nameForms,
                          LinkedHashSet<String> ditContentRules,
                          LinkedHashSet<String> ditStructureRules,
                          LinkedHashSet<String> matchingRuleUses,
                          LinkedHashSet<String> ldapSyntaxes)
                          Set<String> attributeTypes,
                          Set<String> objectClasses,
                          Set<String> nameForms,
                          Set<String> ditContentRules,
                          Set<String> ditStructureRules,
                          Set<String> matchingRuleUses,
                          Set<String> ldapSyntaxes)
          throws IOException
  {
    // Get a sorted list of the files in the schema directory.
@@ -3672,13 +3688,13 @@
   *                       schema file elements.
   */
  public static void readConcatenatedSchema(String concatSchemaFile,
                          LinkedHashSet<String> attributeTypes,
                          LinkedHashSet<String> objectClasses,
                          LinkedHashSet<String> nameForms,
                          LinkedHashSet<String> ditContentRules,
                          LinkedHashSet<String> ditStructureRules,
                          LinkedHashSet<String> matchingRuleUses,
                          LinkedHashSet<String> ldapSyntaxes)
                          Set<String> attributeTypes,
                          Set<String> objectClasses,
                          Set<String> nameForms,
                          Set<String> ditContentRules,
                          Set<String> ditStructureRules,
                          Set<String> matchingRuleUses,
                          Set<String> ldapSyntaxes)
          throws IOException
  {
    BufferedReader reader =
@@ -3721,13 +3737,13 @@
   */
  private static void parseSchemaLine(String line,
                               LinkedHashSet<String> attributeTypes,
                               LinkedHashSet<String> objectClasses,
                               LinkedHashSet<String> nameForms,
                               LinkedHashSet<String> ditContentRules,
                               LinkedHashSet<String> ditStructureRules,
                               LinkedHashSet<String> matchingRuleUses,
                               LinkedHashSet<String> ldapSyntaxes)
                               Set<String> attributeTypes,
                               Set<String> objectClasses,
                               Set<String> nameForms,
                               Set<String> ditContentRules,
                               Set<String> ditStructureRules,
                               Set<String> matchingRuleUses,
                               Set<String> ldapSyntaxes)
  {
    String value;
    String lowerLine = toLowerCase(line);
@@ -3789,10 +3805,10 @@
   *                      identified differences should be written.
   */
  public static void compareConcatenatedSchema(
                          LinkedHashSet<String> oldElements,
                          LinkedHashSet<String> newElements,
                          Set<String> oldElements,
                          Set<String> newElements,
                          AttributeType elementType,
                          LinkedList<Modification> mods)
                          List<Modification> mods)
  {
    AttributeType attributeTypesType =
      DirectoryServer.getAttributeType(ATTR_ATTRIBUTE_TYPES_LC, true);