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

jvergara
16.06.2008 a8dead15304de869444d966cf128e8c55f3eb065
Fix for issue 2817 (Command backup should detect dupplicated backupID and exit on error rather than trying to process).

Check whether the user provided several times the same backend ID.

Appart from that and to be consistent with the other CLIs display the usage when there is an incompatibility with the provided arguments.
2 files modified
43 ■■■■■ changed files
opendj-sdk/opends/src/messages/messages/tools.properties 3 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java 40 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/messages/messages/tools.properties
@@ -2220,4 +2220,5 @@
 specified in the properties file %s
INFO_DESCRIPTION_TEST_IF_OFFLINE_1496=When this is set test if the command \
 must be run in offline or online mode, returning the appropriate error code
SEVERE_ERR_BACKUPDB_REPEATED_BACKEND_ID_1497=The backend ID '%s' has been \
 specified several times
opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java
@@ -327,6 +327,7 @@
                backUpAll.getLongIdentifier(),
                backendID.getLongIdentifier());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(argParser.getUsage());
        return 1;
      }
    }
@@ -336,8 +337,44 @@
              backUpAll.getLongIdentifier(),
              backendID.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(argParser.getUsage());
      return 1;
    }
    else
    {
      // Check that the backendID has not been expressed twice.
      HashSet<String> backendIDLowerCase = new HashSet<String>();
      HashSet<String> repeatedBackendIds = new HashSet<String>();
      StringBuilder repeatedBackends = new StringBuilder();
      for (String id : backendID.getValues())
      {
        String lId = id.toLowerCase();
        if (backendIDLowerCase.contains(lId))
        {
          if (!repeatedBackendIds.contains(lId))
          {
            repeatedBackendIds.add(lId);
            if (repeatedBackends.length() > 0)
            {
              repeatedBackends.append(", ");
            }
            repeatedBackends.append(id);
          }
        }
        else
        {
          backendIDLowerCase.add(lId);
        }
      }
      if (repeatedBackends.length() > 0)
      {
        Message message = ERR_BACKUPDB_REPEATED_BACKEND_ID.get(
            repeatedBackends.toString());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(argParser.getUsage());
        return 1;
      }
    }
    // If the incremental base ID was specified, then make sure it is an
    // incremental backup.
@@ -350,6 +387,7 @@
                        incrementalBaseID.getLongIdentifier(),
                        incremental.getLongIdentifier());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(argParser.getUsage());
        return 1;
      }
    }
@@ -364,6 +402,7 @@
                      encrypt.getLongIdentifier(),
                      signHash.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -375,6 +414,7 @@
              signHash.getLongIdentifier(),
              hash.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(argParser.getUsage());
      return 1;
    }