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

neil_a_wilson
15.22.2007 07205c4180040250b4504aa1ed719056d29bcc84
Update the Directory Server schema processing code so that it will detect the
case in which there is more than one entry in a schema configuration file (or
if there is garbage after the first entry) and log it as a warning message.

OpenDS Issue Number: 1795
2 files modified
57 ■■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/core/SchemaConfigManager.java 27 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/messages/ConfigMessages.java 30 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/core/SchemaConfigManager.java
@@ -865,6 +865,7 @@
      if (entry == null)
      {
        // The file was empty -- skip it.
        reader.close();
        return new LinkedList<Modification>();
      }
    }
@@ -891,6 +892,32 @@
      }
    }
    // If there are any more entries in the file, then print a warning message.
    try
    {
      Entry e = reader.readEntry(false);
      if (e != null)
      {
        int    msgID   = MSGID_CONFIG_SCHEMA_MULTIPLE_ENTRIES_IN_FILE;
        String message = getMessage(msgID, schemaFile, schemaDirPath);
        logError(ErrorLogCategory.SCHEMA, ErrorLogSeverity.SEVERE_WARNING,
                 message, msgID);
      }
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      int    msgID   = MSGID_CONFIG_SCHEMA_UNPARSEABLE_EXTRA_DATA_IN_FILE;
      String message = getMessage(msgID, schemaFile, schemaDirPath,
                                  getExceptionMessage(e));
      logError(ErrorLogCategory.SCHEMA, ErrorLogSeverity.SEVERE_WARNING,
               message, msgID);
    }
    try
    {
      reader.close();
opendj-sdk/opends/src/server/org/opends/server/messages/ConfigMessages.java
@@ -6673,6 +6673,27 @@
  /**
   * The message ID for the message that will be used if a schema configuration
   * file is found to have multiple entries.  This takes two arguments, which
   * are the name of the schema file and the path to the schema directory.
   */
  public static final int MSGID_CONFIG_SCHEMA_MULTIPLE_ENTRIES_IN_FILE =
       CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_WARNING | 662;
  /**
   * The message ID for the message that will be used if a schema configuration
   * file is found to have unparseable data after the first entry.  This takes
   * three arguments, which are the name of the schema file, the path to the
   * schema directory, and a message explaining the problem that occurred.
   */
  public static final int MSGID_CONFIG_SCHEMA_UNPARSEABLE_EXTRA_DATA_IN_FILE =
       CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_WARNING | 663;
  /**
   * Associates a set of generic messages with the message IDs defined in this
@@ -7975,6 +7996,15 @@
                    "Schema configuration file %s in directory %s cannot be " +
                    "parsed because an unexpected error occurred while " +
                    "trying to read its contents as an LDIF entry:  %s");
    registerMessage(MSGID_CONFIG_SCHEMA_MULTIPLE_ENTRIES_IN_FILE,
                    "Schema configuration file %s in directory %s contains " +
                    "more than one entry.  Only the first entry will be " +
                    "examined, and the additional entries will be ignored");
    registerMessage(MSGID_CONFIG_SCHEMA_UNPARSEABLE_EXTRA_DATA_IN_FILE,
                    "Schema configuration file %s in directory %s contains " +
                    "additional data after the schema entry that cannot be " +
                    "parsed by the LDIF reader:  %s.  The first entry will " +
                    "be processed, but the remaining data will be ignored");
    registerMessage(MSGID_CONFIG_SCHEMA_CANNOT_PARSE_ATTR_TYPE,
                    "Unable to parse an attribute type definition from " +
                    "schema configuration file %s:  %s");