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

Matthew Swift
29.05.2016 cc3c0bcf6cec93bfc3e2044d4cb765e45ad1e0a9
Minor code cleanup
3 files modified
86 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java 40 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java 35 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java 11 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java
@@ -283,7 +283,7 @@
            rebuildIndexesNamed(INFO_UPGRADE_TASK_9013_DESCRIPTION.get(),
                "ds-sync-hist")));
    /** See OPENDJ-1284 */
    /* See OPENDJ-1284 */
    register("2.8.0", // userCertificate OID / cACertificate OID
        newAttributeTypes(INFO_UPGRADE_TASK_10133_1_SUMMARY.get(),
        "00-core.ldif", "2.5.4.36", "2.5.4.37"),
@@ -299,11 +299,11 @@
        "ds-cfg-enabled: true"));
    /** See OPENDJ-1295 */
    /* See OPENDJ-1295 */
    register("2.8.0",
        copySchemaFile("03-pwpolicyextension.ldif"));
    /** See OPENDJ-1490 and OPENDJ-1454 */
    /* See OPENDJ-1490 and OPENDJ-1454 */
    register("2.8.0",
        deleteConfigEntry(INFO_UPGRADE_TASK_10733_1_SUMMARY.get(),
        "dn: ds-cfg-backend-id=replicationChanges,cn=Backends,cn=config"),
@@ -316,14 +316,14 @@
            + "(version 3.0; acl \"Replication backend access\"; "
            + "deny (all) userdn=\"ldap:///anyone\";)"));
    /** See OPENDJ-1351 */
    /* See OPENDJ-1351 */
    register("2.8.0",
        modifyConfigEntry(INFO_UPGRADE_TASK_10820_SUMMARY.get(),
        "(objectClass=ds-cfg-root-dn)",
        "add: ds-cfg-default-root-privilege-name",
        "ds-cfg-default-root-privilege-name: changelog-read"));
    /** See OPENDJ-1580 */
    /* See OPENDJ-1580 */
    register("2.8.0",
        addConfigEntry(INFO_UPGRADE_TASK_10908_SUMMARY.get(),
            "dn: cn=PKCS5S2,cn=Password Storage Schemes,cn=config",
@@ -335,7 +335,7 @@
            "ds-cfg-java-class: org.opends.server.extensions.PKCS5S2PasswordStorageScheme",
            "ds-cfg-enabled: true"));
    /** See OPENDJ-1322 and OPENDJ-1067 */
    /* See OPENDJ-1322 and OPENDJ-1067 */
    register("2.8.0",
        rerunJavaPropertiesTool(INFO_UPGRADE_TASK_9206_SUMMARY.get()));
@@ -373,7 +373,7 @@
             "add:ds-cfg-override-severity",
             "ds-cfg-override-severity: SYNC=INFO,ERROR,WARNING,NOTICE"));
    /** See OPENDJ-1545 */
    /* See OPENDJ-1545 */
    register("2.8.0",
        deleteConfigEntry(INFO_UPGRADE_TASK_11237_1_SUMMARY.get(),
            "dn: cn=Network Groups,cn=config"),
@@ -388,23 +388,23 @@
        deleteConfigEntry(INFO_UPGRADE_TASK_11339_SUMMARY.get(),
            "dn: cn=Extensions,cn=config"));
    /** See OPENDJ-1701 */
    /* See OPENDJ-1701 */
    register("2.8.0",
        deleteConfigEntry(INFO_UPGRADE_TASK_11476_SUMMARY.get(),
            "dn: cn=File System,cn=Entry Caches,cn=config"));
    /** See OPENDJ-1869 */
    /* See OPENDJ-1869 */
    register("2.8.0",
        modifyConfigEntry(INFO_UPGRADE_TASK_12226_SUMMARY.get(),
            "(objectclass=ds-cfg-root-config)",
            "delete: ds-cfg-entry-cache-preload"));
    /** See OPENDJ-2054 */
    /* See OPENDJ-2054 */
    register("2.8.0",
        deleteFile(new File(binDirectory, "dsframework")),
        deleteFile(new File(batDirectory, "dsframework.bat")));
    /** If the upgraded version is a non OEM one, migrates local-db backends to JE Backend, see OPENDJ-2364 **/
    /* If the upgraded version is a non OEM one, migrates local-db backends to JE Backend, see OPENDJ-2364 **/
    register("3.0.0",
        conditionalUpgradeTasks(
          new UpgradeCondition() {
@@ -456,7 +456,7 @@
        )
    );
    /** If the upgraded version is OEM, migrates local-db backends to PDB, see OPENDJ-2364 **/
    /* If the upgraded version is OEM, migrates local-db backends to PDB, see OPENDJ-2364 **/
    register("3.0.0",
      conditionalUpgradeTasks(
        new UpgradeCondition() {
@@ -500,12 +500,12 @@
      )
    );
    /** Remove dbtest tool (replaced by backendstat in 3.0.0) - see OPENDJ-1791 **/
    /* Remove dbtest tool (replaced by backendstat in 3.0.0) - see OPENDJ-1791 **/
    register("3.0.0",
            deleteFile(new File(binDirectory, "dbtest")),
            deleteFile(new File(batDirectory, "dbtest.bat")));
    /**
    /*
     * Rebuild all indexes when upgrading to 3.0.0.
     *
     * 1) matching rules have changed in 2.8.0 and again in 3.0.0- see OPENDJ-1637
@@ -514,11 +514,11 @@
    register("3.0.0",
            rebuildAllIndexes(INFO_UPGRADE_TASK_11260_SUMMARY.get()));
    /** See OPENDJ-1742 */
    /* See OPENDJ-1742 */
    register("3.0.0",
        clearReplicationDbDirectory());
    /** See OPENDJ-2435 */
    /* See OPENDJ-2435 */
    register("3.5.0",
        addConfigEntry(INFO_UPGRADE_TASK_BCRYPT_SCHEME_SUMMARY.get(),
            "dn: cn=Bcrypt,cn=Password Storage Schemes,cn=config",
@@ -530,7 +530,7 @@
            "ds-cfg-java-class: org.opends.server.extensions.BcryptPasswordStorageScheme",
            "ds-cfg-enabled: true"));
    /** See OPENDJ-2683 */
    /* See OPENDJ-2683 */
    register("3.5.0",
        deleteConfigEntry(INFO_UPGRADE_TASK_REMOVE_MATCHING_RULES.get(),
        "cn=Auth Password Exact Equality Matching Rule,cn=Matching Rules,cn=config",
@@ -577,7 +577,7 @@
        "cn=UUID Ordering Matching Rule,cn=Matching Rules,cn=config",
        "cn=Word Equality Matching Rule,cn=Matching Rules,cn=config"));
    /** see OPENDJ-2730 */
    /* see OPENDJ-2730 */
    register("3.5.0", removeOldJarFiles());
    register("3.5.0",
@@ -739,7 +739,7 @@
        addConfigFile("rest2ldap")
    );
    /** All upgrades will refresh the server configuration schema and generate a new upgrade folder. */
    /* All upgrades will refresh the server configuration schema and generate a new upgrade folder. */
    registerLast(
        performOEMMigrationIfNeeded(),
        copySchemaFile("02-config.ldif"),
@@ -1063,7 +1063,7 @@
      throw new ClientException(ReturnCode.SUCCESS, message);
    }
    // The upgrade only supports version >= 2.4.5.
    // Exclude upgrade from very old versions.
    if (context.getFromVersion().compareTo(UPGRADE_SUPPORTS_VERSION_FROM) < 0)
    {
      final LocalizableMessage message =
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -78,7 +78,7 @@
import com.sleepycat.je.TransactionConfig;
/** Factory methods for create new upgrade tasks. */
public final class UpgradeTasks
final class UpgradeTasks
{
  /** Logger for the upgrade. */
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
@@ -108,7 +108,7 @@
   * @return A new upgrade task which applies an LDIF record to all
   *         configuration entries matching the provided filter.
   */
  public static UpgradeTask addConfigEntry(final LocalizableMessage summary,
  static UpgradeTask addConfigEntry(final LocalizableMessage summary,
      final String... ldif)
  {
    return updateConfigEntry(summary, null, ChangeOperationType.ADD, ldif);
@@ -123,7 +123,7 @@
   * @return A new upgrade task which applies an LDIF record to all
   *         configuration entries matching the provided filter.
   */
  public static UpgradeTask addConfigEntry(final String... ldif)
  static UpgradeTask addConfigEntry(final String... ldif)
  {
    return new AbstractUpgradeTask()
    {
@@ -160,7 +160,7 @@
   *         config / schema folder. If the file already exists, it's
   *         overwritten.
   */
  public static UpgradeTask copySchemaFile(final String fileName)
  static UpgradeTask copySchemaFile(final String fileName)
  {
    return new AbstractUpgradeTask()
    {
@@ -210,7 +210,7 @@
   * @return A task which copy the the file placed in parameter within the
   *         config folder. If the file already exists, it's overwritten.
   */
  public static UpgradeTask addConfigFile(final String fileName)
  static UpgradeTask addConfigFile(final String fileName)
  {
    return new AbstractUpgradeTask()
    {
@@ -256,7 +256,7 @@
   * @return A new upgrade task which applies an LDIF record to all configuration entries matching
   *         the provided filter.
   */
  public static UpgradeTask deleteConfigEntry(final LocalizableMessage summary, final String... dnsInLDIF)
  static UpgradeTask deleteConfigEntry(final LocalizableMessage summary, final String... dnsInLDIF)
  {
    return updateConfigEntry(summary, null, ChangeOperationType.DELETE, dnsInLDIF);
  }
@@ -274,7 +274,7 @@
   * @return A new upgrade task which applies an LDIF record to all
   *         configuration entries matching the provided filter.
   */
  public static UpgradeTask modifyConfigEntry(final LocalizableMessage summary,
  static UpgradeTask modifyConfigEntry(final LocalizableMessage summary,
      final String filter, final String... ldif)
  {
    return updateConfigEntry(summary, filter, ChangeOperationType.MODIFY, ldif);
@@ -307,7 +307,7 @@
   *         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,
  static UpgradeTask newAttributeTypes(final LocalizableMessage summary,
      final String fileName, final String... attributeOids)
  {
    return new AbstractUpgradeTask()
@@ -410,7 +410,7 @@
   *          The summary of the task.
   * @return An upgrade task which runs dsjavaproperties.
   */
  public static UpgradeTask rerunJavaPropertiesTool(final LocalizableMessage summary)
  static UpgradeTask rerunJavaPropertiesTool(final LocalizableMessage summary)
  {
    return new AbstractUpgradeTask()
    {
@@ -455,7 +455,7 @@
   * @return An upgrade task which will only be invoked if the current version
   *         is more recent than the provided version.
   */
  public static UpgradeTask regressionInVersion(final String versionString, final UpgradeTask... tasks)
  static UpgradeTask regressionInVersion(final String versionString, final UpgradeTask... tasks)
  {
    final BuildVersion version = BuildVersion.valueOf(versionString);
    return conditionalUpgradeTasks(new UpgradeCondition()
@@ -596,7 +596,7 @@
   *          The summary of this upgrade task.
   * @return An Upgrade task which rebuild all the indexes.
   */
  public static UpgradeTask rebuildAllIndexes(final LocalizableMessage summary)
  static UpgradeTask rebuildAllIndexes(final LocalizableMessage summary)
  {
    return new AbstractUpgradeTask()
    {
@@ -650,7 +650,7 @@
   *          The indexes to rebuild.
   * @return The rebuild index task.
   */
  public static UpgradeTask rebuildIndexesNamed(final LocalizableMessage summary, final String... indexNames)
  static UpgradeTask rebuildIndexesNamed(final LocalizableMessage summary, final String... indexNames)
  {
    return new AbstractUpgradeTask()
    {
@@ -702,7 +702,7 @@
   *
   * @return The post upgrade rebuild indexes task.
   */
  public static UpgradeTask postUpgradeRebuildIndexes()
  static UpgradeTask postUpgradeRebuildIndexes()
  {
    return new AbstractUpgradeTask()
    {
@@ -795,7 +795,7 @@
   *         new schema.ldif.rev which is needed after schema customization for
   *         starting correctly the server.
   */
  public static UpgradeTask updateConfigUpgradeFolder()
  static UpgradeTask updateConfigUpgradeFolder()
  {
    return new AbstractUpgradeTask()
    {
@@ -891,7 +891,7 @@
   *          The file to be removed.
   * @return An upgrade task which removes the specified file from the file-system.
   */
  public static UpgradeTask deleteFile(final File file)
  static UpgradeTask deleteFile(final File file)
  {
    return new AbstractUpgradeTask()
    {
@@ -926,7 +926,7 @@
   *
   * @return An upgrade task which is responsible for preparing local-db backend JE databases.
   */
  public static UpgradeTask migrateLocalDBBackendsToJEBackends() {
  static UpgradeTask migrateLocalDBBackendsToJEBackends() {
    return new AbstractUpgradeTask() {
      /** Properties of JE backends to be migrated. */
      class Backend {
@@ -1435,8 +1435,9 @@
   * but not in the concatenated schema then append its definition to the concatenated schema,
   * omitting the trailing spaces.
   *
   * See OPENDJ-3081
   *
   * @return The relevant upgrade task
   * @see OPENDJ-3081
   */
  static UpgradeTask restoreCsvDelimiterAttributeTypeInConcatenatedSchemaFile()
  {
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -119,7 +119,7 @@
    final String path = getInstallPath(classPaths);
    if (path == null)
    {
      return installPath;
      return null;
    }
    /*
@@ -332,9 +332,8 @@
      final Filter filter, final ChangeOperationType changeType,
      final String... ldifLines) throws IOException
  {
    final File original = configFile;
    final File copyConfig =
        File.createTempFile("copyConfig", ".tmp", original.getParentFile());
        File.createTempFile("copyConfig", ".tmp", configFile.getParentFile());
    int changeCount = 0;
    final Schema schema = getUpgradeSchema();
@@ -416,7 +415,7 @@
      if (changeType == ADD && !entryAlreadyExist)
      {
        writer.writeEntry(Requests.newAddRequest(ldifLines));
        logger.debug(LocalizableMessage.raw("Entry successfully added %s in %s", ldifDN, original.getAbsolutePath()));
        logger.debug(LocalizableMessage.raw("Entry successfully added %s in %s", ldifDN, configFile.getAbsolutePath()));
        changeCount++;
      }
    }
@@ -437,7 +436,7 @@
    catch (IOException e)
    {
      logger.error(LocalizableMessage.raw(e.getMessage()));
      deleteRecursively(original);
      deleteRecursively(configFile);
      throw e;
    }
  }
@@ -531,7 +530,7 @@
    return changeCount;
  }
  private static Entry readFirstEntryFromTemplate(final File destination) throws DecodeException, IOException
  private static Entry readFirstEntryFromTemplate(final File destination) throws IOException
  {
    try (LDIFEntryReader r = new LDIFEntryReader(new FileInputStream(destination)))
    {