|
From: <dgl...@us...> - 2003-08-14 01:38:56
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv23737/modules/core/src/com/babeldoc/core/pipeline/stage
Modified Files:
ExternalApplicationPipelineStage.java
Log Message:
Added pipeInResponse attribute to return the output of the command in the ExternalApplicationResponse attribute
Index: ExternalApplicationPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/ExternalApplicationPipelineStage.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ExternalApplicationPipelineStage.java 27 Jun 2003 02:19:59 -0000 1.4
--- ExternalApplicationPipelineStage.java 14 Aug 2003 01:33:23 -0000 1.5
***************
*** 71,75 ****
--- 71,77 ----
import com.babeldoc.core.pipeline.*;
+ import java.io.BufferedReader;
import java.io.IOException;
+ import java.io.InputStreamReader;
import java.io.OutputStream;
***************
*** 105,108 ****
--- 107,111 ----
public static final String APPLICATION = "application";
public static final String PIPE_OUT_DOCUMENT = "pipeOutDocument";
+ public static final String PIPE_IN_RESPONSE = "pipeInResponse";
/**
***************
*** 128,131 ****
--- 131,137 ----
IConfigOptionType.BOOLEAN, null, false,
"core.pipeline.stage.externalapplication.opt.pipeout"));
+ options.add(new ConfigOption(PIPE_IN_RESPONSE,
+ IConfigOptionType.BOOLEAN, null, false,
+ "core.pipeline.stage.externalapplication.opt.pipein"));
return options;
***************
*** 148,153 ****
public PipelineStageResult[] process() throws PipelineException {
String application = getOptions(APPLICATION);
! boolean pipeOut = (getOptions(PIPE_OUT_DOCUMENT) != null) &&
! getOptions(PIPE_OUT_DOCUMENT).equals(Boolean.valueOf(true));
try {
--- 154,159 ----
public PipelineStageResult[] process() throws PipelineException {
String application = getOptions(APPLICATION);
! boolean pipeOut = Boolean.valueOf(getOptions(PIPE_OUT_DOCUMENT)).booleanValue();
! boolean pipeIn = Boolean.valueOf(getOptions(PIPE_IN_RESPONSE )).booleanValue();
try {
***************
*** 160,163 ****
--- 166,181 ----
os.write(doc.getBytes());
os.close();
+ }
+
+ if (pipeIn) {
+ StringBuffer response = new StringBuffer();
+ String line;
+ BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ while ((line = in.readLine()) != null) {
+ System.out.println(line);
+ response.append(line);
+ response.append("\n");
+ }
+ this.getDocument().put("ExternalApplicationResponse", new String(response));
}
} catch (IOException e) {
|