opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MakeLDIF.java
@@ -20,6 +20,7 @@ import static com.forgerock.opendj.cli.ToolVersionHandler.newSdkVersionHandler; import static com.forgerock.opendj.ldap.tools.ToolsMessages.*; import static com.forgerock.opendj.cli.Utils.filterExitCode; import static com.forgerock.opendj.ldap.tools.ToolsMessages.INFO_MAKELDIF_WRAP_COLUMN_PLACEHOLDER; import static org.forgerock.util.Utils.closeSilently; import java.io.BufferedWriter; @@ -80,6 +81,7 @@ StringArgument ldifFile; StringArgument resourcePath; StringArgument constants; IntegerArgument wrapColumn; try { resourcePath = StringArgument.builder(OPTION_LONG_RESOURCE_PATH) @@ -114,6 +116,15 @@ .description(INFO_MAKELDIF_DESCRIPTION_HELP.get()) .buildAndAddToParser(argParser); wrapColumn = IntegerArgument.builder("wrapColumn") .shortIdentifier('w') .description(INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN.get()) .lowerBound(0) .defaultValue(0) .valuePlaceholder(INFO_MAKELDIF_WRAP_COLUMN_PLACEHOLDER.get()) .buildAndAddToParser(argParser); argParser.setUsageArgument(showUsage, getOutputStream()); } catch (ArgumentException ae) { errPrintln(ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); @@ -132,12 +143,12 @@ return 0; } final String templatePath = argParser.getTrailingArguments().get(0); return run(templatePath, resourcePath, ldifFile, randomSeed, constants); return run(templatePath, resourcePath, ldifFile, randomSeed, constants, wrapColumn); } /** Run Make LDIF with provided arguments. */ private int run(final String templatePath, final StringArgument resourcePath, final StringArgument ldifFile, final IntegerArgument randomSeedArg, final StringArgument constants) { private int run(final String templatePath, final StringArgument resourcePath, final StringArgument ldifFile, final IntegerArgument randomSeedArg, final StringArgument constants, final IntegerArgument wrapColumn) { LDIFEntryWriter writer = null; try (EntryGenerator generator = createGenerator(templatePath, resourcePath, randomSeedArg, constants)) { if (generator == null) { @@ -150,15 +161,14 @@ } } if (ldifFile.isPresent()) { try { writer = new LDIFEntryWriter(new BufferedWriter(new FileWriter(new File(ldifFile.getValue())))); } catch (IOException e) { writer = createLdifWriter(ldifFile, wrapColumn); } catch (final IOException e) { errPrintln(ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF.get(ldifFile.getValue(), e.getMessage())); return EXIT_CODE_FAILURE; } } else { writer = new LDIFEntryWriter(getOutputStream()); } catch (final ArgumentException e) { errPrintln(ERR_ERROR_PARSING_ARGS.get(e.getMessageObject())); return EXIT_CODE_FAILURE; } if (!generateEntries(generator, writer, ldifFile)) { @@ -173,6 +183,17 @@ } } private LDIFEntryWriter createLdifWriter(final StringArgument ldifFile, final IntegerArgument wrapColumn) throws IOException, ArgumentException { final LDIFEntryWriter writer; if (ldifFile.isPresent()) { writer = new LDIFEntryWriter(new BufferedWriter(new FileWriter(ldifFile.getValue()))); } else { writer = new LDIFEntryWriter(getOutputStream()); } return writer.setWrapColumn(wrapColumn.getIntValue()); } static EntryGenerator createGenerator(final String templatePath, final StringArgument resourcePath, final IntegerArgument randomSeedArg, final StringArgument constants, final boolean generateBranches, final ConsoleApplication app) { opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties
@@ -323,6 +323,9 @@ processing : %s ERR_CONSTANT_ARG_CANNOT_DECODE=Unable to parse a constant argument \ expecting name=value but got %s INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN=Maximum length of an output line \ (0 for no wrapping) INFO_MAKELDIF_WRAP_COLUMN_PLACEHOLDER={wrapColumn} # # AddRate Tool # opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ca_ES.properties
New file @@ -0,0 +1,20 @@ # # The contents of this file are subject to the terms of the Common Development and # Distribution License (the License). You may not use this file except in compliance with the # License. # # You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the # specific language governing permission and limitations under the License. # # When distributing Covered Software, include this CDDL Header Notice in each file and include # the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL # Header, with the fields enclosed by brackets [] replaced by your own identifying # information: "Portions Copyright [year] [name of copyright owner]". # # Copyright 2016 ForgeRock AS. # # # MakeLDIF tool # INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN=Columna in la qual s'envoltaran les l\u00ednies incorrectes (0 per no envoltar) opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_de.properties
@@ -11,4 +11,9 @@ # information: "Portions Copyright [year] [name of copyright owner]". # # Copyright 2009 Sun Microsystems, Inc. # Portions Copyright 2016 ForgeRock AS. # # MakeLDIF tool # INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN=Spalte, in der lange Zeile umgebrochen werden sollen (0 f\u00fcr keinen Zeilenumbruch) opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_es.properties
@@ -11,4 +11,9 @@ # information: "Portions Copyright [year] [name of copyright owner]". # # Copyright 2009 Sun Microsystems, Inc. # Portions Copyright 2016 ForgeRock AS. # # MakeLDIF tool # INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN=Columna en la que ajustar l\u00edneas largas (0 para ning\u00fan ajuste) opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_fr.properties
@@ -11,4 +11,9 @@ # information: "Portions Copyright [year] [name of copyright owner]". # # Copyright 2009 Sun Microsystems, Inc. # Portions Copyright 2016 ForgeRock AS. # # MakeLDIF tool # INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN=Taille maximum d'une ligne dans le fichier de sortie (0 = pas de limite) opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ja.properties
@@ -11,4 +11,9 @@ # information: "Portions Copyright [year] [name of copyright owner]". # # Copyright 2009 Sun Microsystems, Inc. # Portions Copyright 2016 ForgeRock AS. # # MakeLDIF tool # INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN=\u9577\u3044\u884c\u3092\u6298\u308a\u8fd4\u3059\u6841 (0 \u306f\u6298\u308a\u8fd4\u3057\u306a\u3057) opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ko.properties
@@ -11,4 +11,9 @@ # information: "Portions Copyright [year] [name of copyright owner]". # # Copyright 2009 Sun Microsystems, Inc. # Portions Copyright 2016 ForgeRock AS. # # MakeLDIF tool # INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN=\uae34 \ud589\uc744 \ub798\ud551\ud560 \uc5f4(0 = \ub798\ud551 \uc548 \ud568) opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_pl.properties
New file @@ -0,0 +1,20 @@ # # The contents of this file are subject to the terms of the Common Development and # Distribution License (the License). You may not use this file except in compliance with the # License. # # You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the # specific language governing permission and limitations under the License. # # When distributing Covered Software, include this CDDL Header Notice in each file and include # the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL # Header, with the fields enclosed by brackets [] replaced by your own identifying # information: "Portions Copyright [year] [name of copyright owner]". # # Copyright 2016 ForgeRock AS. # # # MakeLDIF tool # INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN=Kolumna na kt\u00f3rej zawijane b\u0119d\u0105 d\u0142ugie linie (0 aby wy\u0142\u0105czy\u0107 zawijanie) opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_zh_CN.properties
@@ -11,4 +11,9 @@ # information: "Portions Copyright [year] [name of copyright owner]". # # Copyright 2009 Sun Microsystems, Inc. # Portions Copyright 2016 ForgeRock AS. # # MakeLDIF tool # INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN=\u5bf9\u8f83\u957f\u7684\u884c\u8fdb\u884c\u6362\u884c\u7684\u5217\uff080 \u8868\u793a\u4e0d\u6362\u884c\uff09 opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_zh_TW.properties
@@ -11,4 +11,9 @@ # information: "Portions Copyright [year] [name of copyright owner]". # # Copyright 2009 Sun Microsystems, Inc. # Portions Copyright 2016 ForgeRock AS. # # MakeLDIF tool # INFO_MAKELDIF_DESCRIPTION_WRAP_COLUMN=\u8981\u5c0d\u9577\u53e5\u63db\u884c\u7684\u6b04 (0 \u8868\u793a\u4e0d\u63db\u884c) opendj-sdk/opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/MakeLDIFITCase.java
@@ -134,6 +134,16 @@ } /** See OPENDJ-2505 and OPENDJ-2754 */ @Test public void testMakeLDIFSupportsLineFoldingAndLineWrapping() throws Exception { final Path tempOutputFile = Paths.get(TEST_RESOURCE_PATH, TEMP_OUTPUT_FILE); run(args("-o", tempOutputFile.toString(), "-w", "80", VALID_TEMPLATE_FILE_PATH), SUCCESS, INFO_MAKELDIF_PROCESSING_COMPLETE.get(2)); assertFilesAreEquals(TEMP_OUTPUT_FILE, "expected_output_80_column.ldif"); Files.delete(tempOutputFile); } private void assertFilesAreEquals(final String outputFile, final String expectedOutputFileName) throws IOException { assertThat(Files.readAllBytes(Paths.get(TEST_RESOURCE_PATH, outputFile))).isEqualTo( Files.readAllBytes(Paths.get(TEST_RESOURCE_PATH, expectedOutputFileName))); } opendj-sdk/opendj-ldap-toolkit/src/test/resources/expected_output_80_column.ldif
New file @@ -0,0 +1,14 @@ dn: dc=example,dc=com dc: example dn: coretokenid=tokenId,dc=example,dc=com coretokenid: tokenId objectClass: top objectClass: frCoreToken coretokenstring08: /myrealm coretokenstring07: Bearer coretokenobject: {"redirectURI":["http://fake.com"],"acr":[],"clientID":["client OIDC"],"lineFoldingTest":["This line should have been correctly folded"],"token Name":["refresh_token"],"authModules":["LDAP"],"realm":["/myrealm"],"id":["fake id"],"userName":["johndoe"],"tokenType":["Bearer"]}