| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.dsconfig; |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public MenuResult<Integer> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | try { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final MenuResult<Integer> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | try { |
| | |
| | | |
| | | Comparator<SubCommand> c = new Comparator<SubCommand>() { |
| | | |
| | | @Override |
| | | public int compare(SubCommand o1, SubCommand o2) { |
| | | return o1.getName().compareTo(o2.getName()); |
| | | } |
| | |
| | | Comparator<RelationDefinition<?, ?>> c = |
| | | new Comparator<RelationDefinition<?, ?>>() { |
| | | |
| | | @Override |
| | | public int compare(RelationDefinition<?, ?> rd1, |
| | | RelationDefinition<?, ?> rd2) { |
| | | String s1 = rd1.getUserFriendlyName().toString(); |
| | |
| | | } |
| | | |
| | | private void handleBatchFile(String[] args) { |
| | | BufferedReader reader = null; |
| | | try { |
| | | // Build a list of initial arguments, |
| | | // removing the batch file option + its value |
| | |
| | | initialArgs.remove(batchFileArgIndex); |
| | | } |
| | | String batchFilePath = batchFileArgument.getValue().trim(); |
| | | reader = |
| | | BufferedReader reader = |
| | | new BufferedReader(new FileReader(batchFilePath)); |
| | | String line; |
| | | String command = ""; |
| | |
| | | command = command.trim(); |
| | | // string between quotes support |
| | | command = replaceSpacesInQuotes(command); |
| | | String displayCommand = new String(command); |
| | | |
| | | // "\ " support |
| | | command = command.replace("\\ ", "##"); |
| | | displayCommand = displayCommand.replace("\\ ", " "); |
| | | |
| | | String[] fileArguments = command.split("\\s+"); |
| | | // reset command |
| | | command = ""; |
| | | for (int ii = 0; ii < fileArguments.length; ii++) { |
| | | fileArguments[ii] = fileArguments[ii].replace("##", " "); |
| | | System.out.println(fileArguments[ii]); |
| | | } |
| | | |
| | | printlnBatchProgress(displayCommand); |
| | | |
| | | // Append initial arguments to the file line |
| | | List<String> allArguments = new ArrayList<String>(); |
| | | Collections.addAll(allArguments, fileArguments); |
| | | allArguments.addAll(initialArgs); |
| | | String[] allArgsArray = allArguments.toArray(new String[]{}); |
| | | |
| | | // Build a single CLI string for display |
| | | StringBuffer cli = new StringBuffer(); |
| | | for (String arg : allArgsArray) { |
| | | cli.append(arg + " "); |
| | | } |
| | | |
| | | int exitCode = |
| | | main(allArgsArray, false, getOutputStream(), getErrorStream()); |
| | | if (exitCode != 0) { |
| | | reader.close(); |
| | | System.exit(filterExitCode(exitCode)); |
| | | } |
| | | printlnBatchProgress(""); |
| | | } |
| | | |
| | | reader.close(); |
| | | |
| | | } catch (IOException ex) { |