(CommandLine cli)
| 137 | } |
| 138 | |
| 139 | @Override |
| 140 | @SuppressWarnings({"rawtypes"}) |
| 141 | public void runImpl(CommandLine cli) throws Exception { |
| 142 | |
| 143 | String expressionArgument = cli.getArgs()[0]; |
| 144 | String execution = cli.getOptionValue(EXECUTION_OPTION, "remote"); |
| 145 | String arrayDelimiter = cli.getOptionValue(ARRAY_DELIMITER_OPTION, "|"); |
| 146 | String delimiter = cli.getOptionValue(DELIMITER_OPTION, " "); |
| 147 | boolean includeHeaders = cli.hasOption(HEADER_OPTION); |
| 148 | String[] outputHeaders = getOutputFields(cli); |
| 149 | |
| 150 | LineNumberReader bufferedReader = null; |
| 151 | String expr; |
| 152 | try { |
| 153 | Reader inputStream = |
| 154 | expressionArgument.toLowerCase(Locale.ROOT).endsWith(".expr") |
| 155 | ? new InputStreamReader( |
| 156 | new FileInputStream(expressionArgument), Charset.defaultCharset()) |
| 157 | : new StringReader(expressionArgument); |
| 158 | |
| 159 | bufferedReader = new LineNumberReader(inputStream); |
| 160 | expr = StreamTool.readExpression(bufferedReader, cli.getArgs()); |
| 161 | echoIfVerbose("Running Expression: " + expr); |
| 162 | } finally { |
| 163 | if (bufferedReader != null) { |
| 164 | bufferedReader.close(); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | // Validate inputs before opening any connection to Solr. |
| 169 | boolean local = execution.equalsIgnoreCase("local"); |
| 170 | if (!local) { |
| 171 | if (!cli.hasOption(COLLECTION_OPTION)) { |
| 172 | throw new IllegalStateException( |
| 173 | "You must provide --name COLLECTION with --execution remote parameter."); |
| 174 | } |
| 175 | if (expr.toLowerCase(Locale.ROOT).contains("stdin(")) { |
| 176 | throw new IllegalStateException( |
| 177 | "The stdin() expression is only usable with --execution local."); |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | // a stream needs a context |
| 182 | StreamContext streamContext = createStreamContext(cli); |
| 183 | // create the stream |
| 184 | PushBackStream pushBackStream = null; |
| 185 | try { |
| 186 | if (local) { |
| 187 | pushBackStream = doLocalMode(expr, streamContext.getStreamFactory()); |
| 188 | } else { |
| 189 | pushBackStream = doRemoteMode(expr, cli); |
| 190 | } |
| 191 | pushBackStream.setStreamContext(streamContext); |
| 192 | pushBackStream.open(); |
| 193 | |
| 194 | if (outputHeaders == null) { |
| 195 | |
| 196 | Tuple tuple = pushBackStream.read(); |
nothing calls this directly
no test coverage detected