greenrd 00/12/22 03:52:59
Modified: . changes.xml
src/org/apache/cocoon Cocoon.java EngineWrapper.java
Log:
user agent support in command line
Revision Changes Path
1.167 +7 -1 xml-cocoon/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/changes.xml,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -r1.166 -r1.167
--- changes.xml 2000/12/13 13:30:26 1.166
+++ changes.xml 2000/12/22 11:52:51 1.167
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.166 2000/12/13 13:30:26 greenrd Exp $
+ $Id: changes.xml,v 1.167 2000/12/22 11:52:51 greenrd Exp $
-->
<changes title="History of Changes">
@@ -18,6 +18,12 @@
</devs>
<release version="@version@" date="@date@">
+ <action dev="RDG" type="add" due-to="Ovidiu Predescu" due-to-email="[EMAIL
PROTECTED]">
+ Added user-agent option (-A) to command-line mode.
+ </action>
+ <action dev="RDG" type="fix" due-to="Ovidiu Predescu" due-to-email="[EMAIL
PROTECTED]">
+ Fixed command-line mode.
+ </action>
<action dev="RDG" type="add">
Added multi-encoding support to esql. Even tables using multiple
encodings can be
read from! However, this will only work if your JDBC driver
1.20 +41 -16 xml-cocoon/src/org/apache/cocoon/Cocoon.java
Index: Cocoon.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Cocoon.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Cocoon.java 2000/12/13 03:38:39 1.19
+++ Cocoon.java 2000/12/22 11:52:57 1.20
@@ -1,4 +1,4 @@
-/*-- $Id: Cocoon.java,v 1.19 2000/12/13 03:38:39 greenrd Exp $ --
+/*-- $Id: Cocoon.java,v 1.20 2000/12/22 11:52:57 greenrd Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -64,7 +64,7 @@
* separate different knowledge contexts in different processing layers.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version $Revision: 1.19 $ $Date: 2000/12/13 03:38:39 $
+ * @version $Revision: 1.20 $ $Date: 2000/12/22 11:52:57 $
*/
public class Cocoon extends HttpServlet implements Defaults {
@@ -266,31 +266,56 @@
public static void main(String[] argument) throws Exception {
String properties = null;
+ String userAgent = null;
String xml = null;
- String xsl = null;
String out = null;
- int i = 0;
+ PrintWriter writer = null;
+ Configurations confs = null;
- if ((argument.length < 2) || (argument.length > 4)) {
+ if (argument.length == 0)
+ usage();
+
+ for (int i = 0; i < argument.length; i++) {
+ if (argument[i].equals("-p")) {
+ if (i + 1 < argument.length)
+ properties = argument[++i];
+ else
+ usage();
+ }
+ else if (argument[i].equals("-A")) {
+ if (i + 1 < argument.length)
+ userAgent = argument[++i];
+ else
+ usage();
+ }
+ else if (xml == null)
+ xml = argument[i];
+ else if (out == null)
+ out = argument[i];
+ else
usage();
}
- if (argument[i].charAt(0) == '-') {
- properties = getProperties(argument[++i]);
- i++;
- }
-
- xml = argument[i++];
- out = argument[i];
-
- EngineWrapper engine = new EngineWrapper(new
Configurations(properties));
- engine.handle(new PrintWriter(new FileWriter(out), true), new
File(xml));
+ if (xml == null)
+ usage();
+
+ confs = new Configurations(properties);
+ if (userAgent != null)
+ confs.put("user-agent", userAgent);
+
+ EngineWrapper engine = new EngineWrapper(confs);
+ if (out == null)
+ writer = new PrintWriter(System.out);
+ else
+ writer = new PrintWriter(new FileWriter(out), true);
+ engine.handle(writer, new File(xml));
}
private static void usage() {
- System.err.println("Usage: java org.apache.cocoon.Cocoon [-p
properties] Input Output");
+ System.err.println("Usage:\n java org.apache.cocoon.Cocoon [-p
properties] [-A user-agent] Input Output");
System.err.println("\nOptions:");
System.err.println(" -p : indicates the property file");
+ System.err.println(" -A : indicates the user agent");
System.err.println("\nNote: if the property file is not specified,
Cocoon looks for a file named");
System.err.println("\"cocoon.properties\" in the current working
directory, in the user directory");
System.err.println("and in the \"/usr/local/etc/\" directory before
giving up.");
1.12 +8 -5 xml-cocoon/src/org/apache/cocoon/EngineWrapper.java
Index: EngineWrapper.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/EngineWrapper.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- EngineWrapper.java 2000/05/25 14:06:34 1.11
+++ EngineWrapper.java 2000/12/22 11:52:58 1.12
@@ -1,4 +1,4 @@
-/*-- $Id: EngineWrapper.java,v 1.11 2000/05/25 14:06:34 stefano Exp $ --
+/*-- $Id: EngineWrapper.java,v 1.12 2000/12/22 11:52:58 greenrd Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -70,15 +70,17 @@
* But I have more important stuff to do right now.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version $Revision: 1.11 $ $Date: 2000/05/25 14:06:34 $
+ * @version $Revision: 1.12 $ $Date: 2000/12/22 11:52:58 $
*/
public class EngineWrapper {
private Engine engine;
+ private String userAgent;
protected EngineWrapper(Configurations confs) throws Exception {
this.engine = Engine.getInstance(confs, new Object());
+ this.userAgent = (String)confs.get("user-agent");
}
public void handle(PrintWriter out, File pathToDocument) throws
Exception {
@@ -122,11 +124,12 @@
public String getPathInfo() { return ""; }
public String getParameter(String name) {
- if ((document != null) && (name.equalsIgnoreCase("producer"))) {
+ if ((document != null) && (name.equalsIgnoreCase("producer")))
return "org.apache.cocoon.producer.ProducerFromRequest";
- } else {
+ else if (name.equalsIgnoreCase("user-agent"))
+ return userAgent;
+ else
return null;
- }
}
public BufferedReader getReader () throws IOException {