ktlili 2005/06/27 12:20:17 CEST
Modified files:
war/src/java/com/jahia/clipping/Bean UrlBean.java
war/src/java/com/jahia/clipping/web/http/impl
HttpProcessor.java
Log:
- fix httpClient bug: support string query
Revision Changes Path
1.10 +1 -11
webclip_builder/war/src/java/com/jahia/clipping/Bean/UrlBean.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/Bean/UrlBean.java.diff?r1=1.9&r2=1.10&f=h
1.8 +20 -23
webclip_builder/war/src/java/com/jahia/clipping/web/http/impl/HttpProcessor.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/http/impl/HttpProcessor.java.diff?r1=1.7&r2=1.8&f=h
Index: UrlBean.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/Bean/UrlBean.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- UrlBean.java 27 Jun 2005 08:51:00 -0000 1.9
+++ UrlBean.java 27 Jun 2005 10:20:16 -0000 1.10
@@ -28,15 +28,6 @@
/**
* Constructor for the UrlBean object
- */
- public UrlBean() {
-
- }
-
-
-
- /**
- * Constructor for the UrlBean object
*
[EMAIL PROTECTED] cBean Description of Parameter
[EMAIL PROTECTED] baseURL Description of Parameter
@@ -230,8 +221,7 @@
for (int j = 0; j < this.getQueryParamBeanList().size(); j++) {
QueryParamBean qBean = (QueryParamBean)
getQueryParamBeanList().get(j);
String name = qBean.getName();
- String[] value = {
- qBean.getDefaultValue()};
+ String[] value = {qBean.getDefaultValue()};
queryParams.put(name, value);
}
return queryParams;
Index: HttpProcessor.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/http/impl/HttpProcessor.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HttpProcessor.java 24 Jun 2005 13:37:41 -0000 1.7
+++ HttpProcessor.java 27 Jun 2005 10:20:17 -0000 1.8
@@ -35,7 +35,6 @@
// redirection
private GetMethod redirect = null;
-
//state
private HttpState stateBeforeExecution;
private HttpState stateAfterExecution;
@@ -100,13 +99,13 @@
logger.debug("[ Method is " + httpMethod + "]");
if (httpMethod.equalsIgnoreCase("GET")) {
GetMethod method = new GetMethod();
- method.addRequestHeader("User-Agent","Mozilla/5.0
(Macintosh; U; PPC MacOS X; en)");
+ method.addRequestHeader("User-Agent", "Mozilla/5.0
(Macintosh; U; PPC MacOS X; en)");
setObjectMethod(method);
}
else if (httpMethod.equalsIgnoreCase("POST")) {
PostMethod method = new PostMethod();
- method.addRequestHeader("User-Agent","Mozilla/5.0
(Macintosh; U; PPC MacOS X; en)");
+ method.addRequestHeader("User-Agent", "Mozilla/5.0
(Macintosh; U; PPC MacOS X; en)");
setObjectMethod(method);
((PostMethod)
getObjectMethod()).addParameters(getParamAndValue());
}
@@ -138,7 +137,6 @@
-
/**
* Sets the UrlBean attribute of the HttpProcessor object
*
@@ -248,8 +246,6 @@
-
-
/**
* Gets the UrlBean attribute of the HttpProcessor object
*
@@ -265,7 +261,7 @@
*
[EMAIL PROTECTED] The Client value
*/
- public HttpClient getDefaultClient() {
+ public HttpClient getHttpClient() {
if (defaultClient == null) {
defaultClient = getNewHttpClient();
@@ -399,7 +395,7 @@
[EMAIL PROTECTED] WebClippingException Description of Exception
*/
public void execute() throws WebClippingException {
- execute(getDefaultClient());
+ execute(getHttpClient());
}
@@ -418,7 +414,7 @@
*/
private void setParamAndValueFromUrlBean() {
setParamAndValue(getNameValuePairFromURLBean());
- HttpMethod method = this.getObjectMethod();
+ HttpMethod method = getObjectMethod();
if (method instanceof GetMethod) {
// set the query string
method.setQueryString(getParamAndValue());
@@ -436,7 +432,8 @@
*/
private void setRequestedFileFromUrlBean() {
HttpMethod method = getObjectMethod();
- String path = getUrlBean().getURL().getPath();
+ String path = getUrlBean().getUrlValue();
+ method.setQueryString(getUrlBean().getURL().getQuery());
method.setPath(path);
}
@@ -447,7 +444,7 @@
* object
*/
private void setHostConfigurationFromUrlBean() {
- HostConfiguration hostConfig =
getDefaultClient().getHostConfiguration();
+ HostConfiguration hostConfig =
getHttpClient().getHostConfiguration();
String host = getUrlBean().getURL().getHost();
hostConfig.setHost(host);
}
@@ -458,7 +455,7 @@
*/
private void setClientSate() {
if (getStateBeforeExecution() != null) {
- getDefaultClient().setState(getStateBeforeExecution());
+ getHttpClient().setState(getStateBeforeExecution());
}
}
@@ -502,8 +499,8 @@
//build array
NameValuePair[] paramAndValue = new
NameValuePair[queryParamBeanList.size()];
- logger.debug("[ Url: "+getUrlBean().getUrlValue()+" ]");
- logger.debug("[ queryParamBeanList.size():
"+queryParamBeanList.size()+" ]");
+ logger.debug("[ Url: " + getUrlBean().getUrlValue() + " ]");
+ logger.debug("[ queryParamBeanList.size(): " +
queryParamBeanList.size() + " ]");
for (int i = 0; i < queryParamBeanList.size(); i++) {
QueryParamBean qBean = (QueryParamBean)
queryParamBeanList.get(i);
String name = qBean.getName();
@@ -527,7 +524,7 @@
initClient();
//HttpState
- HttpState s = getDefaultClient().getState();
+ HttpState s = getHttpClient().getState();
Cookie[] cookiess = s.getCookies();
@@ -536,7 +533,7 @@
Cookie c = cookiess[i];
logger.debug("[ Found cookie before execution: " +
c.getName() + " ]");
}
- logger.debug("[ HttpClient: Finish Enumerate cookies before
execution ]");
+ logger.debug("[ HttpClient: Finish Enumerate cookies before
execution ]");
// Init
String html = null;
@@ -577,7 +574,7 @@
// Get the reponse
html =
redirect.getResponseBodyAsString();
- logger.debug("[ Redirect: " +
redirect.getStatusLine().toString() +" ]");
+ logger.debug("[ Redirect: " +
redirect.getStatusLine().toString() + " ]");
// set redirectedUrl
getUrlBean().setRedirectUrl(URLUtilities.getURL(newuri));
@@ -593,11 +590,11 @@
else {
html = method.getResponseBodyAsString();
- Header[] tab = method.getResponseHeaders();
- for(int i=0; i<tab.length;i++){
- Header h = tab[i];
- logger.debug("[header found:
"+h.getName()+","+h.getValue()+"]");
- }
+ Header[] tab = method.getResponseHeaders();
+ for (int i = 0; i < tab.length; i++) {
+ Header h = tab[i];
+ logger.debug("[header found: " +
h.getName() + "," + h.getValue() + "]");
+ }
}
// set html
@@ -631,7 +628,7 @@
}
//HttpState
- HttpState state = getDefaultClient().getState();
+ HttpState state = getHttpClient().getState();
Cookie[] cookies = state.getCookies();
logger.debug("[ Begin Enumerate cookies after execution
]");
for (int i = 0; i < cookies.length; i++) {