vgritsenko 01/06/20 19:35:44
Modified: src/org/apache/cocoon Tag: cocoon_20_branch Main.java
Log:
Added userAgent and accept command line parameters
Revision Changes Path
No revision
No revision
1.4.2.2 +35 -8 xml-cocoon2/src/org/apache/cocoon/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Main.java,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -r1.4.2.1 -r1.4.2.2
--- Main.java 2001/06/19 12:07:27 1.4.2.1
+++ Main.java 2001/06/21 02:35:42 1.4.2.2
@@ -48,7 +48,7 @@
* Command line entry point.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.4.2.1 $ $Date: 2001/06/19 12:07:27 $
+ * @version CVS $Revision: 1.4.2.2 $ $Date: 2001/06/21 02:35:42 $
*/
public class Main {
@@ -63,7 +63,12 @@
protected static final int DEST_DIR_OPT = 'd';
protected static final int WORK_DIR_OPT = 'w';
protected static final int XSP_OPT = 'x';
+ protected static final int AGENT_OPT = 'a';
+ protected static final int ACCEPT_OPT = 'p';
+ protected static final String DEFAULT_USER_AGENT = Constants.COMPLETE_NAME;
+ protected static final String DEFAULT_ACCEPT = "text/html, */*";
+
protected static final CLOptionDescriptor [] options = new CLOptionDescriptor
[] {
new CLOptionDescriptor("help",
CLOptionDescriptor.ARGUMENT_DISALLOWED,
@@ -96,7 +101,15 @@
new CLOptionDescriptor("xspOnly",
CLOptionDescriptor.ARGUMENT_DISALLOWED,
XSP_OPT,
- "generate java code for xsp files")
+ "generate java code for xsp files"),
+ new CLOptionDescriptor("userAgent",
+ CLOptionDescriptor.ARGUMENT_REQUIRED,
+ AGENT_OPT,
+ "use given string for user-agent header"),
+ new CLOptionDescriptor("accept",
+ CLOptionDescriptor.ARGUMENT_REQUIRED,
+ ACCEPT_OPT,
+ "use given string for accept header"),
};
@@ -110,6 +123,8 @@
String logUrl = null;
String logLevel = "DEBUG";
boolean xspOnly = false;
+ String userAgent = DEFAULT_USER_AGENT;
+ String accept = DEFAULT_ACCEPT;
List clOptions = parser.getArguments();
int size = clOptions.size();
@@ -153,6 +168,14 @@
case Main.XSP_OPT:
xspOnly = true;
break;
+
+ case Main.AGENT_OPT:
+ userAgent = option.getArgument();
+ break;
+
+ case Main.ACCEPT_OPT:
+ accept = option.getArgument();
+ break;
}
}
@@ -220,6 +243,8 @@
c.contextualize(appContext);
c.initialize();
Main main = new Main(c, context, dest);
+ main.userAgent = userAgent;
+ main.accept = accept;
main.warmup();
if(main.process(targets, xspOnly)==0)
main.recursivelyProcessXSP(context, context);
@@ -303,6 +328,8 @@
private HashMap empty;
private Map allProcessedLinks;
private Map allTranslatedLinks;
+ private String userAgent;
+ private String accept;
/**
* Creates the Main class
@@ -349,8 +376,8 @@
links.remove(url);
nCount++;
-System.err.println(" Memory: " +
(Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()));
-System.err.println(" Processed, Translated & Left: " + allProcessedLinks.size() +
", " + allTranslatedLinks.size() + ", " + links.size());
+ log.debug(" Memory used: " + (Runtime.getRuntime().totalMemory() -
Runtime.getRuntime().freeMemory()));
+ log.debug(" Processed, Translated & Left: " + allProcessedLinks.size()
+ ", " + allTranslatedLinks.size() + ", " + links.size());
}
return nCount;
}
@@ -400,8 +427,8 @@
// Get parameters, deperameterized URI and path from URI
final HashMap parameters = new HashMap();
- parameters.put("user-agent", Constants.COMPLETE_NAME);
- parameters.put("accept", "*");
+ parameters.put("user-agent", userAgent);
+ parameters.put("accept", accept);
final String deparameterizedURI = NetUtils.deparameterize(uri, parameters);
final String path = NetUtils.getPath(uri);
@@ -469,8 +496,8 @@
public String translateURI(String uri) throws Exception {
HashMap parameters = new HashMap();
- parameters.put("user-agent", Constants.COMPLETE_NAME);
- parameters.put("accept", "*");
+ parameters.put("user-agent", userAgent);
+ parameters.put("accept", accept);
String deparameterizedURI = NetUtils.deparameterize(uri, parameters);
String path = NetUtils.getPath(uri);
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]