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

Jean-Noël Rouvignac
26.59.2016 8c2fb347d05648fa8e6ee41abc86cc658b8a3f70
OPENDJ-2797 When adding matching rule use, also set their schema file

SchemBackend.java, Schema.java:
Compute and add the schema file of matching rule use when they are added

DirectoryServer.java, DirectoryConfig.java:
Remove unused methods related to matching rule use
4 files modified
93 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java 10 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java 35 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java 16 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java 32 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -2441,15 +2441,15 @@
    // Otherwise, we're replacing an existing matching rule use.
    if (existingMRU == null)
    {
      schema.registerMatchingRuleUse(matchingRuleUse, false);
      addNewSchemaElement(modifiedSchemaFiles, new ServerSchemaElement(matchingRuleUse));
      String schemaFile = addNewSchemaElement(modifiedSchemaFiles, new ServerSchemaElement(matchingRuleUse));
      schema.registerMatchingRuleUse(matchingRuleUse, schemaFile, false);
    }
    else
    {
      schema.deregisterMatchingRuleUse(existingMRU);
      schema.registerMatchingRuleUse(matchingRuleUse, false);
      replaceExistingSchemaElement(modifiedSchemaFiles, new ServerSchemaElement(matchingRuleUse),
          new ServerSchemaElement(existingMRU));
      String schemaFile = replaceExistingSchemaElement(
          modifiedSchemaFiles, new ServerSchemaElement(matchingRuleUse), new ServerSchemaElement(existingMRU));
      schema.registerMatchingRuleUse(matchingRuleUse, schemaFile, false);
    }
  }
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -2707,41 +2707,6 @@
  }
  /**
   * Registers the provided matching rule use with the Directory Server.
   *
   * @param  matchingRuleUse    The matching rule use to register with the
   *                            server.
   * @param  overwriteExisting  Indicates whether to overwrite an existing
   *                            mapping if there are any conflicts (i.e.,
   *                            another matching rule use with the same matching
   *                            rule).
   *
   * @throws  DirectoryException  If a conflict is encountered and the
   *                              <CODE>overwriteExisting</CODE> flag is set to
   *                              <CODE>false</CODE>
   */
  public static void registerMatchingRuleUse(MatchingRuleUse matchingRuleUse,
                                             boolean overwriteExisting)
         throws DirectoryException
  {
    directoryServer.schema.registerMatchingRuleUse(matchingRuleUse,
                                                   overwriteExisting);
  }
  /**
   * Deregisters the provided matching rule use with the Directory Server.
   *
   * @param  matchingRuleUse  The matching rule use to deregister with the
   *                          server.
   * @throws DirectoryException
   *            If the resulting schema contains warning.
   */
  public static void deregisterMatchingRuleUse(MatchingRuleUse matchingRuleUse) throws DirectoryException
  {
    directoryServer.schema.deregisterMatchingRuleUse(matchingRuleUse);
  }
  /**
   * Retrieves the DIT content rule associated with the specified objectclass.
   *
   * @param  objectClass  The objectclass for which to retrieve the associated
opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
@@ -349,22 +349,6 @@
  }
  /**
   * Retrieves the matching rule use associated with the provided
   * matching rule.
   *
   * @param  matchingRule  The matching rule for which to retrieve the
   *                       matching rule use.
   *
   * @return  The matching rule use for the provided matching rule, or
   *          <CODE>null</CODE> if none is defined.
   */
  public static MatchingRuleUse
       getMatchingRuleUse(MatchingRule matchingRule)
  {
    return DirectoryServer.getMatchingRuleUse(matchingRule);
  }
  /**
   * Retrieves the DIT content rule associated with the specified
   * objectclass.
   *
opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java
@@ -1211,24 +1211,21 @@
    return schemaNG.getMatchingRuleUse(matchingRule);
  }
  /**
   * Registers the provided matching rule use definition with this
   * schema.
   * Registers the provided matching rule use definition with this schema.
   *
   * @param  matchingRuleUse    The matching rule use definition to
   *                            register.
   * @param  overwriteExisting  Indicates whether to overwrite an
   *                            existing mapping if there are any
   *                            conflicts (i.e., another matching rule
   *                            use with the same matching rule).
   *
   * @throws  DirectoryException  If a conflict is encountered and the
   *                              <CODE>overwriteExisting</CODE> flag
   *                              is set to <CODE>false</CODE>
   * @param matchingRuleUse
   *          The matching rule use definition to register.
   * @param schemaFile
   *          The schema file where this definition belongs, maybe {@code null}
   * @param overwriteExisting
   *          Indicates whether to overwrite an existing mapping if there are any conflicts (i.e.,
   *          another matching rule use with the same matching rule).
   * @throws DirectoryException
   *           If a conflict is encountered and the {@code overwriteExisting} flag is set to
   *           {@code false}
   */
  public void registerMatchingRuleUse(MatchingRuleUse matchingRuleUse, boolean overwriteExisting)
  public void registerMatchingRuleUse(MatchingRuleUse matchingRuleUse, String schemaFile, boolean overwriteExisting)
         throws DirectoryException
  {
    exclusiveLock.lock();
@@ -1236,6 +1233,11 @@
    {
      SchemaBuilder builder = new SchemaBuilder(schemaNG);
      Builder mruBuilder = builder.buildMatchingRuleUse(matchingRuleUse);
      if (schemaFile != null)
      {
        mruBuilder.removeExtraProperty(SCHEMA_PROPERTY_FILENAME)
                  .extraProperties(SCHEMA_PROPERTY_FILENAME, schemaFile);
      }
      if (overwriteExisting)
      {
        mruBuilder.addToSchemaOverwrite();