| | |
| | | } |
| | | |
| | | /** Define the command-line arguments that may be used with this program. */ |
| | | private BooleanArgument append; |
| | | private BooleanArgument countRejects; |
| | | private BooleanArgument displayUsage; |
| | | private BooleanArgument isCompressed; |
| | | private BooleanArgument isEncrypted; |
| | | private BooleanArgument overwrite; |
| | | private BooleanArgument quietMode; |
| | | private BooleanArgument replaceExisting; |
| | | private BooleanArgument skipSchemaValidation; |
| | | private BooleanArgument clearBackend; |
| | | private IntegerArgument randomSeed; |
| | |
| | | INFO_LDIFIMPORT_DESCRIPTION_TEMPLATE_FILE.get()); |
| | | argParser.addArgument(templateFile); |
| | | |
| | | |
| | | append = |
| | | new BooleanArgument("append", 'a', "append", |
| | | INFO_LDIFIMPORT_DESCRIPTION_APPEND.get()); |
| | | argParser.addArgument(append); |
| | | |
| | | |
| | | replaceExisting = |
| | | new BooleanArgument( |
| | | "replaceexisting", 'r', "replaceExisting", |
| | | INFO_LDIFIMPORT_DESCRIPTION_REPLACE_EXISTING.get()); |
| | | argParser.addArgument(replaceExisting); |
| | | |
| | | |
| | | backendID = |
| | | new StringArgument("backendid", 'n', "backendID", false, false, true, |
| | | INFO_BACKENDNAME_PLACEHOLDER.get(), null, null, |
| | |
| | | addAttribute(attributes, ATTR_IMPORT_THREAD_COUNT, threadCount.getValue()); |
| | | |
| | | // Optional attributes |
| | | addAttribute2(attributes, ATTR_IMPORT_APPEND, append); |
| | | addAttribute2(attributes, ATTR_IMPORT_REPLACE_EXISTING, replaceExisting); |
| | | addAttribute2(attributes, ATTR_IMPORT_BACKEND_ID, backendID); |
| | | addAttribute(attributes, ATTR_IMPORT_INCLUDE_ATTRIBUTE, includeAttributeStrings.getValues()); |
| | | addAttribute(attributes, ATTR_IMPORT_EXCLUDE_ATTRIBUTE, excludeAttributeStrings.getValues()); |
| | |
| | | PrintStream err) { |
| | | |
| | | |
| | | // Perform the initial bootstrap of the Directory Server and process the |
| | | // configuration. |
| | | // Perform the initial bootstrap of the Directory Server and process the configuration. |
| | | DirectoryServer directoryServer = DirectoryServer.getInstance(); |
| | | if (initializeServer) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | // Make sure that if the "backendID" argument was provided, no include base |
| | | // was included, the |
| | | // "clearBackend" argument was also provided if there are more then one |
| | | // baseDNs for the backend being imported. |
| | | |
| | | if(backendID.isPresent() && !includeBranchStrings.isPresent() && |
| | | !append.isPresent() && |
| | | defaultIncludeBranches.size() > 1 && |
| | | !clearBackend.isPresent()) |
| | | { |
| | | StringBuilder builder = join(backend.getBaseDNs(), " / "); |
| | | printWrappedText(err, ERR_LDIFIMPORT_MISSING_CLEAR_BACKEND.get(builder, clearBackend.getLongIdentifier())); |
| | | return 1; |
| | | } |
| | | |
| | | for (String s : excludeBranchStrings.getValues()) |
| | | { |
| | | DN excludeBranch; |
| | |
| | | |
| | | |
| | | // Create the LDIF import configuration to use when reading the LDIF. |
| | | importConfig.setAppendToExistingData(append.isPresent()); |
| | | importConfig.setReplaceExistingEntries(replaceExisting.isPresent()); |
| | | importConfig.setCompressed(isCompressed.isPresent()); |
| | | importConfig.setClearBackend(clearBackend.isPresent()); |
| | | importConfig.setEncrypted(isEncrypted.isPresent()); |
| | |
| | | return false; |
| | | } |
| | | |
| | | private StringBuilder join(final DN[] baseDNs, final String separator) |
| | | { |
| | | final StringBuilder builder = new StringBuilder(); |
| | | builder.append(baseDNs[0]); |
| | | for (int i = 1; i < baseDNs.length; i++) |
| | | { |
| | | builder.append(separator); |
| | | builder.append(baseDNs[i]); |
| | | } |
| | | return builder; |
| | | } |
| | | |
| | | private Random newRandom() |
| | | { |
| | | if (randomSeed.isPresent()) |