From f6beccdd93ff6c7fee022805c8390ca51bd03511 Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Mon, 29 Feb 2016 13:32:08 +0000
Subject: [PATCH] OPENDJ-2716 update the changelog schema in-place instead of overwriting entire file
---
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java | 5 ++
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java | 42 +++++++++++----------
opendj-server-legacy/src/messages/org/opends/messages/tool.properties | 2 +
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java | 20 +++++-----
4 files changed, 38 insertions(+), 31 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java
index 7a332cf..ab7beba 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java
@@ -80,7 +80,10 @@
// @formatter:off
/** See OPENDJ-2716 */
register("2.5.0",
- copySchemaFile("03-changelog.ldif"));
+ newAttributeTypes(INFO_UPGRADE_TASK_2716_1_SUMMARY.get(),
+ "03-changelog.ldif", "1.3.6.1.4.1.36733.2.1.1.6"), // includedAttributes
+ newObjectClasses(INFO_UPGRADE_TASK_2716_2_SUMMARY.get(),
+ "03-changelog.ldif", "2.16.840.1.113730.3.2.1")); // changeLogEntry
register("2.5.0",
modifyConfigEntry(INFO_UPGRADE_TASK_6869_SUMMARY.get(),
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
index e78e571..03b6fbf 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -229,14 +229,16 @@
}
/**
- * This task adds a new attribute type (must exists in the original file) to
- * the specified file placed in parameter. The destination must be a file
- * contained in the config/schema folder. E.g : This example adds a new
- * attribute type named 'etag' in the 00.core.ldif. The 'etag' attribute
- * already exists in the 00-core.ldif template schema file.
+ * This task adds or updates an attribute type (must exist in the original file)
+ * to the file specified in {@code fileName}. The destination must be a file
+ * contained in the config/schema folder. The attribute type is updated if an
+ * attribute with the same OID exists.
+ *
+ * e.g : This example adds a new attribute type named 'etag' in the 00-core.ldif.
+ * The 'etag' attribute already exists in the 00-core.ldif template schema file.
*
* <pre>
- * register("2.5.0.7192",
+ * register("2.5.0",
* newAttributeTypes(LocalizableMessage.raw("New attribute etag"),
* false, "00-core.ldif",
* "1.3.6.1.4.1.36733.2.1.1.59"));
@@ -245,13 +247,13 @@
* @param summary
* The summary of the task.
* @param fileName
- * The file where to add the new attribute types. This file must be
+ * The file where to add the new definitions. This file must be
* contained in the configuration/schema folder.
* @param attributeOids
- * The OIDs of the new attributes to add to.
- * @return An upgrade task which adds new attribute types, defined previously
- * in the configuration template files, reads the definition
- * and adds it onto the specified file in parameter.
+ * The OIDs of the attributes to add or update.
+ * @return An upgrade task which adds or updates attribute types, defined
+ * previously in the configuration template files, reads the
+ * definition and adds it onto the file specified in {@code fileName}
*/
public static UpgradeTask newAttributeTypes(final LocalizableMessage summary,
final String fileName, final String... attributeOids)
@@ -296,21 +298,21 @@
}
/**
- * This task adds a new object class (must exists in the original file) to the
- * specified file placed in parameter. The destination must be a file
- * contained in the config/schema folder.
+ * This task adds or updates an object class (must exist in the original file)
+ * to the file specified in {@code fileName}. The destination must be a file
+ * contained in the config/schema folder. The object class will be updated if
+ * a definition with the same OID exists, and added otherwise.
*
* @param summary
* The summary of the task.
* @param fileName
- * The file where to add the new object classes. This file must be
+ * The file where to add the new definitions. This file must be
* contained in the configuration/schema folder.
* @param objectClassesOids
- * The OIDs of the new object classes to add to.
- * @return An upgrade task which adds new object classes, defined previously
- * in the configuration template files,
- * reads the definition and adds it onto the specified file in
- * parameter.
+ * The OIDs of the object classes to add or update.
+ * @return An upgrade task which adds or updates object classes, defined
+ * previously in the configuration template files, reads the
+ * definition and adds it onto the file specified in {@code fileName}
*/
public static UpgradeTask newObjectClasses(final LocalizableMessage summary,
final String fileName, final String... objectClassesOids)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java
index 6699965..54f7c78 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -506,22 +506,22 @@
}
/**
- * This task adds new attributes / object classes to the specified destination
- * file. The new attributes and object classes must be originally defined in
- * the template file.
+ * This task adds or updates attributes / object classes in the specified
+ * destination file. The new attributes and object classes must be originally
+ * defined in the template file. The definitions will replace previous definitions
+ * if they have the same normalized value (i.e. OID), and add new definitions if
+ * they don't previously exist.
*
* @param templateFile
- * The file in which the new attribute/object definition can be read.
+ * The file in which the attribute/object definition can be read.
* @param destination
- * The file where we want to add the new definitions.
+ * The file where we want to update the definitions.
* @param attributes
- * Those attributes needed to be inserted into the new destination
- * file.
+ * Those attributes needed to be stored in the new destination file.
* @param objectClasses
- * Those object classes needed to be inserted into the new
- * destination file.
+ * Those object classes needed to be stored in the new destination file.
* @return An integer which represents each time an attribute / object class
- * is inserted successfully to the destination file.
+ * is updated successfully in the destination file.
* @throws IOException
* If an unexpected IO error occurred while reading the entry.
* @throws IllegalStateException
diff --git a/opendj-server-legacy/src/messages/org/opends/messages/tool.properties b/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
index e4fd49a..58bb0b6 100644
--- a/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
+++ b/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
@@ -2621,6 +2621,8 @@
INFO_UPGRADE_TASK_RENAME_JE_DB_DIR_WARNING_20023=You must reimport all your data into the PDB \
backends in order to have a fully functional server
INFO_UPGRADE_TASK_REMOVE_MATCHING_RULES_2683=Removing configuration for matching rules
+INFO_UPGRADE_TASK_2716_1_SUMMARY_20024=Adding 'includedAttributes' attribute type to changelog schema
+INFO_UPGRADE_TASK_2716_2_SUMMARY_20025=Updating 'changeLogEntry' object class in changelog schema
INFO_LDAP_CONN_PROMPT_SECURITY_LDAP=LDAP
INFO_LDAP_CONN_PROMPT_SECURITY_USE_SSL=LDAP with SSL
--
Gitblit v1.10.0