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

Gaetan Boismal
24.15.2016 3cdb7a881523ba1c3d148cc118c9889830f699cd
OPENDJ-2772 Improve sdk ldapmodify

Ensure that continueOnError argument works were provided LDIF is not
parseable.
Prevent printing "null" file in error message if the input is read from
stdin.
9 files modified
56 ■■■■■ changed files
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java 39 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties 3 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_de.properties 2 ●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_es.properties 2 ●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_fr.properties 2 ●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ja.properties 2 ●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ko.properties 2 ●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_zh_CN.properties 2 ●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_zh_TW.properties 2 ●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -20,7 +20,6 @@
import static com.forgerock.opendj.cli.CliMessages.INFO_FILE_PLACEHOLDER;
import static com.forgerock.opendj.cli.ToolVersionHandler.newSdkVersionHandler;
import static com.forgerock.opendj.ldap.tools.LDAPToolException.newToolException;
import static com.forgerock.opendj.ldap.tools.LDAPToolException.newToolParamException;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import static com.forgerock.opendj.ldap.tools.Utils.getConnection;
@@ -362,29 +361,37 @@
                                                         noop,
                                                         this)) {
            reader = createLDIFChangeRecordReader(filename, argParser.getTrailingArguments());
            final VisitorImpl visitor = new VisitorImpl(connection);
            try (final EntryWriter w = writer) {
                try {
                    while (reader.hasNext()) {
                        final ChangeRecord cr = reader.readChangeRecord();
                        final int result = cr.accept(visitor, null);
                        if (result != 0 && !continueOnError.isPresent()) {
                            return result;
                        }
                    }
                } catch (final IOException ioe) {
                    throw newToolParamException(
                            ioe, ERR_LDIF_FILE_READ_ERROR.get(filename.getValue(), ioe.getLocalizedMessage()));
                }
                return processModify(connection, reader, continueOnError.isPresent());
            } catch (final IOException e) {
                throw newToolException(e, ResultCode.UNDEFINED, ERR_LDAP_MODIFY_WRITTING_ENTRIES.get(e.getMessage()));
            }
        } finally {
            closeSilently(reader);
        }
    }
        return ResultCode.SUCCESS.intValue();
    private int processModify(final Connection connection,
                              final ChangeRecordReader reader,
                              final boolean continueOnError) {
        final VisitorImpl visitor = new VisitorImpl(connection);
        while (true) {
            try {
                if (!reader.hasNext()) {
                    return ResultCode.SUCCESS.intValue();
                }
                final ChangeRecord cr = reader.readChangeRecord();
                final int result = cr.accept(visitor, null);
                if (result != 0 && !continueOnError) {
                    return result;
                }
            } catch (final IOException ioe) {
                errPrintln(ERR_LDIF_FILE_READ_ERROR.get(ioe.getLocalizedMessage()));
                if (!continueOnError) {
                    return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            }
        }
    }
    private ChangeRecordReader createLDIFChangeRecordReader(final StringArgument fileNameArg,
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties
@@ -72,8 +72,7 @@
 attempting to open the LDIF file %s for reading:  %s
ERR_LDIF_FILE_CANNOT_OPEN_FOR_WRITE=An error occurred while \
 attempting to open the LDIF file %s for writing:  %s
ERR_LDIF_FILE_READ_ERROR=An error occurred while attempting to read \
 the contents of LDIF file %s:  %s
ERR_LDIF_FILE_READ_ERROR=An error occurred while attempting to read the contents of LDIF file(s):  %s
INFO_BIND_PASSWORD_EXPIRED=# Your password has expired
INFO_BIND_PASSWORD_EXPIRING=# Your password will expire in %s
INFO_BIND_ACCOUNT_LOCKED=# Your account has been locked
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_de.properties
@@ -60,7 +60,7 @@
ERR_PSEARCH_INVALID_RETURN_ECS=Der angegebene returnECs-Wert %s ist ung\u00fcltig.  Zul\u00e4ssige Werte sind 1, damit die Eintrags\u00e4nderungsbenachrichtigungssteuerung bei aktualisierten Eintr\u00e4gen eingeschlossen wird, oder 0, um die Steuerung von \u00fcbereinstimmenden Eintr\u00e4gen auszuschlie\u00dfen
ERR_LDAP_MATCHEDVALUES_INVALID_FILTER=Der angegebene Filter f\u00fcr \u00fcbereinstimmende Werte ist ung\u00fcltig: %s
ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ=Fehler beim Versuch, die LDIF-Datei %s zum Lesen zu \u00f6ffnen:  %s
ERR_LDIF_FILE_READ_ERROR=Fehler beim Versuch, den Inhalt der LDIF-Datei %s zu lesen: %s
ERR_LDIF_FILE_READ_ERROR=Fehler beim Versuch, den Inhalt der LDIF-Datei zu lesen: %s
ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF=Fehler beim Versuch, LDIF-Datei %s zum Schreiben zu \u00f6ffnen: %s
ERR_MAKELDIF_ERROR_WRITING_LDIF=Fehler beim Schreiben von Daten in LDIF-Datei %s: %s
INFO_MAKELDIF_PROCESSED_N_ENTRIES=%d Eintr\u00e4ge verarbeitet
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_es.properties
@@ -60,7 +60,7 @@
ERR_PSEARCH_INVALID_RETURN_ECS=El valor returnECs %s especificado no es v\u00e1lido.  Los valores permitidos son 1 para solicitar que el control de notificaci\u00f3n de cambios de entrada se incluya en entradas actualizadas o 0 para excluir el control de las entradas coincidentes
ERR_LDAP_MATCHEDVALUES_INVALID_FILTER=El filtro de valores coincidentes especificado no era v\u00e1lido:  %s
ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ=Se ha producido un error al tratar de abrir el archivo de LDIF %s para lectura: %s
ERR_LDIF_FILE_READ_ERROR=Se ha producido un error al tratar de leer los contenidos del archivo de LDIF %s: %s
ERR_LDIF_FILE_READ_ERROR=Se ha producido un error al tratar de leer los contenidos del archivo de LDIF: %s
ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF=Se ha producido un error al intentar abrir el archivo LDIF %s para escritura:  %s
ERR_MAKELDIF_ERROR_WRITING_LDIF=Se ha producido un error al escribir datos en el archivo LDIF %s:  %s
INFO_MAKELDIF_PROCESSED_N_ENTRIES=%d entradas procesadas
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_fr.properties
@@ -60,7 +60,7 @@
ERR_PSEARCH_INVALID_RETURN_ECS=La valeur returnECs indiqu\u00e9e %s est invalide.  Les valeurs autoris\u00e9es sont 1, pour demander l'inclusion du contr\u00f4le de notification de modification des entr\u00e9es dans les entr\u00e9es mises \u00e0 jour, ou 0, pour exclure le contr\u00f4le des entr\u00e9es correspondantes
ERR_LDAP_MATCHEDVALUES_INVALID_FILTER=Le filtre de valeurs avec correspondance fourni \u00e9tait invalide\u00a0:   %s
ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ=Une erreur s'est produite lors de la tentative d'ouverture du fichier LDIF %s pour la lecture\u00a0: %s
ERR_LDIF_FILE_READ_ERROR=Une erreur s'est produite lors de la tentative de lecture du contenu du fichier LDIF %s\u00a0: %s
ERR_LDIF_FILE_READ_ERROR=Une erreur s'est produite lors de la tentative de lecture du contenu LDIF \u00a0: %s
ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF=Une erreur s'est produite lors de la tentative d'ouverture du fichier LDIF %s pour \u00e9crire\u00a0:  %s
ERR_MAKELDIF_ERROR_WRITING_LDIF=Une erreur s'est produite lors de l'\u00e9criture des donn\u00e9es dans le fichier LDIF %s\u00a0:  %s
INFO_MAKELDIF_PROCESSED_N_ENTRIES=%d entr\u00e9es trait\u00e9es
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ja.properties
@@ -60,7 +60,7 @@
ERR_PSEARCH_INVALID_RETURN_ECS=\u6307\u5b9a\u3055\u308c\u305f returnECs \u5024 %s \u306f\u7121\u52b9\u3067\u3059\u3002  \u4f7f\u7528\u53ef\u80fd\u306a\u5024\u306f\u3001\u66f4\u65b0\u3055\u308c\u305f\u30a8\u30f3\u30c8\u30ea\u306b\u30a8\u30f3\u30c8\u30ea\u5909\u66f4\u901a\u77e5\u5236\u5fa1\u3092\u542b\u3081\u308b\u5834\u5408\u306f 1\u3001\u4e00\u81f4\u3059\u308b\u30a8\u30f3\u30c8\u30ea\u304b\u3089\u5236\u5fa1\u3092\u9664\u5916\u3059\u308b\u5834\u5408\u306f 0 \u3067\u3059
ERR_LDAP_MATCHEDVALUES_INVALID_FILTER=\u6307\u5b9a\u3055\u308c\u305f\u4e00\u81f4\u5024\u30d5\u30a3\u30eb\u30bf\u306f\u7121\u52b9\u3067\u3057\u305f:  %s
ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ=LDIF \u30d5\u30a1\u30a4\u30eb %s \u3092\u8aad\u307f\u53d6\u308a\u7528\u306b\u958b\u3044\u3066\u3044\u308b\u3068\u304d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f:  %s
ERR_LDIF_FILE_READ_ERROR=LDIF \u30d5\u30a1\u30a4\u30eb %s \u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u8aad\u307f\u53d6\u308a\u4e2d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f:  %s
ERR_LDIF_FILE_READ_ERROR=LDIF \u30d5\u30a1\u30a4\u30eb \u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u8aad\u307f\u53d6\u308a\u4e2d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f:  %s
ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF=LDIF \u30d5\u30a1\u30a4\u30eb %s \u3092\u66f8\u304d\u8fbc\u307f\u7528\u306b\u958b\u3044\u3066\u3044\u308b\u3068\u304d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f:  %s
ERR_MAKELDIF_ERROR_WRITING_LDIF=\u30c7\u30fc\u30bf\u3092 LDIF \u30d5\u30a1\u30a4\u30eb %s \u306b\u66f8\u304d\u8fbc\u307f\u4e2d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f:  %s
INFO_MAKELDIF_PROCESSED_N_ENTRIES=%d \u30a8\u30f3\u30c8\u30ea\u304c\u51e6\u7406\u3055\u308c\u307e\u3057\u305f
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ko.properties
@@ -59,7 +59,7 @@
ERR_PSEARCH_INVALID_RETURN_ECS=\uc81c\uacf5\ub41c returnECs \uac12 %s\uc774(\uac00) \uc798\ubabb\ub418\uc5c8\uc2b5\ub2c8\ub2e4.  \ud5c8\uc6a9\ub418\ub294 \uac12\uc740 \uc5c5\ub370\uc774\ud2b8\ub41c \ud56d\ubaa9\uc5d0 \ud56d\ubaa9 \ubcc0\uacbd \uc54c\ub9bc \uc81c\uc5b4\ub97c \ud3ec\ud568\ud558\ub3c4\ub85d \uc694\uccad\ud558\ub294 \uacbd\uc6b0 1\uc774\uace0, \uc77c\uce58 \ud56d\ubaa9\uc5d0\uc11c \uc81c\uc5b4\ub97c \uc81c\uc678\ud558\ub294 \uacbd\uc6b0 0\uc785\ub2c8\ub2e4.
ERR_LDAP_MATCHEDVALUES_INVALID_FILTER=\uc81c\uacf5\ub41c \uc77c\uce58 \uac12 \ud544\ud130\uac00 \uc798\ubabb\ub418\uc5c8\uc2b5\ub2c8\ub2e4: %s
ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ=\uc77d\uae30 \uc704\ud574 LDIF \ud30c\uc77c %s\uc744(\ub97c) \uc5ec\ub294 \ub3d9\uc548 \uc624\ub958\uac00 \ubc1c\uc0dd\ud588\uc2b5\ub2c8\ub2e4: %s
ERR_LDIF_FILE_READ_ERROR=LDIF \ud30c\uc77c %s\uc758 \ub0b4\uc6a9\uc744 \uc77d\ub294 \ub3d9\uc548 \uc624\ub958\uac00 \ubc1c\uc0dd\ud588\uc2b5\ub2c8\ub2e4: %s
ERR_LDIF_FILE_READ_ERROR=LDIF \ud30c\uc77c \uc758 \ub0b4\uc6a9\uc744 \uc77d\ub294 \ub3d9\uc548 \uc624\ub958\uac00 \ubc1c\uc0dd\ud588\uc2b5\ub2c8\ub2e4: %s
ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF=\uc4f0\uae30 \uc704\ud574 LDIF \ud30c\uc77c %s\uc744(\ub97c) \uc5ec\ub294 \ub3d9\uc548 \uc624\ub958\uac00 \ubc1c\uc0dd\ud588\uc2b5\ub2c8\ub2e4: %s
ERR_MAKELDIF_ERROR_WRITING_LDIF=LDIF \ud30c\uc77c %s\uc5d0 \ub370\uc774\ud130\ub97c \uc4f0\ub294 \ub3d9\uc548 \uc624\ub958\uac00 \ubc1c\uc0dd\ud588\uc2b5\ub2c8\ub2e4: %s
INFO_MAKELDIF_PROCESSED_N_ENTRIES=%d\uac1c \ud56d\ubaa9\uc744 \ucc98\ub9ac\ud588\uc2b5\ub2c8\ub2e4.
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_zh_CN.properties
@@ -60,7 +60,7 @@
ERR_PSEARCH_INVALID_RETURN_ECS=\u63d0\u4f9b\u7684 returnECs \u503c %s \u65e0\u6548\u3002\u5141\u8bb8\u7684\u503c\u4e3a 1\uff08\u8bf7\u6c42\u5728\u66f4\u65b0\u7684\u6761\u76ee\u4e2d\u5305\u542b\u6761\u76ee\u66f4\u6539\u901a\u77e5\u63a7\u5236\uff09\u6216 0\uff08\u4ece\u5339\u914d\u6761\u76ee\u4e2d\u6392\u9664\u8be5\u63a7\u5236\uff09
ERR_LDAP_MATCHEDVALUES_INVALID_FILTER=\u63d0\u4f9b\u7684\u5339\u914d\u503c\u8fc7\u6ee4\u5668\u65e0\u6548: %s
ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ=\u5728\u5c1d\u8bd5\u6253\u5f00 LDIF \u6587\u4ef6 %s \u4ee5\u8fdb\u884c\u8bfb\u53d6\u65f6\u51fa\u73b0\u9519\u8bef: %s
ERR_LDIF_FILE_READ_ERROR=\u5728\u5c1d\u8bd5\u8bfb\u53d6 LDIF \u6587\u4ef6 %s \u7684\u5185\u5bb9\u65f6\u51fa\u73b0\u9519\u8bef: %s
ERR_LDIF_FILE_READ_ERROR=\u5728\u5c1d\u8bd5\u8bfb\u53d6 LDIF \u6587\u4ef6 \u7684\u5185\u5bb9\u65f6\u51fa\u73b0\u9519\u8bef: %s
ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF=\u5728\u5c1d\u8bd5\u6253\u5f00 LDIF \u6587\u4ef6 %s \u4ee5\u5199\u5165\u6570\u636e\u65f6\u51fa\u73b0\u9519\u8bef: %s
ERR_MAKELDIF_ERROR_WRITING_LDIF=\u5728\u5c06\u6570\u636e\u5199\u5165 LDIF \u6587\u4ef6 %s \u65f6\u51fa\u73b0\u9519\u8bef: %s
INFO_MAKELDIF_PROCESSED_N_ENTRIES=\u5df2\u5904\u7406 %d \u4e2a\u6761\u76ee
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_zh_TW.properties
@@ -59,7 +59,7 @@
ERR_PSEARCH_INVALID_RETURN_ECS=\u63d0\u4f9b\u7684 returnECs \u503c %s \u7121\u6548\u3002\u5141\u8a31\u7684\u503c\u70ba 1 \u6216 0\uff0c\u524d\u8005\u6703\u8acb\u6c42\u5728\u66f4\u65b0\u7684\u9805\u76ee\u4e2d\u7d0d\u5165\u9805\u76ee\u8b8a\u66f4\u901a\u77e5\u63a7\u5236\uff0c\u5f8c\u8005\u5247\u6703\u5f9e\u76f8\u7b26\u9805\u76ee\u4e2d\u6392\u9664\u8a72\u63a7\u5236
ERR_LDAP_MATCHEDVALUES_INVALID_FILTER=\u63d0\u4f9b\u7684\u76f8\u7b26\u503c\u7be9\u9078\u5668\u7121\u6548: %s
ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ=\u5617\u8a66\u958b\u555f LDIF \u6a94\u6848 %s \u9032\u884c\u8b80\u53d6\u6642\u767c\u751f\u932f\u8aa4: %s
ERR_LDIF_FILE_READ_ERROR=\u5617\u8a66\u8b80\u53d6 LDIF \u6a94\u6848 %s \u7684\u5167\u5bb9\u6642\u767c\u751f\u932f\u8aa4: %s
ERR_LDIF_FILE_READ_ERROR=\u5617\u8a66\u8b80\u53d6 LDIF \u6a94\u6848 \u7684\u5167\u5bb9\u6642\u767c\u751f\u932f\u8aa4: %s
ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF=\u5617\u8a66\u958b\u555f LDIF \u6a94\u6848 %s \u9032\u884c\u5beb\u5165\u6642\u767c\u751f\u932f\u8aa4: %s
ERR_MAKELDIF_ERROR_WRITING_LDIF=\u5c07\u8cc7\u6599\u5beb\u5165\u81f3 LDIF \u6a94\u6848 %s \u6642\u767c\u751f\u932f\u8aa4: %s
INFO_MAKELDIF_PROCESSED_N_ENTRIES=\u5df2\u8655\u7406 %d \u500b\u9805\u76ee