shuber 2005/03/29 17:33:01 CEST
Modified files: (Branch: JAHIA-4-1-BRANCH)
metadata/jbproject/jahia Jahia Libs.library
src/java/org/jahia/params ParamBean.java
Log:
Updated implementation for new version of HttpClient that comes with Slide 2.
Revision Changes Path
No
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/.diff?r1=.-1&r2=No&f=h
No
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/.diff?r1=.-1&r2=No&f=h
1.149.2.9.2.5 +10 -16 jahia/src/java/org/jahia/params/ParamBean.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/src/java/org/jahia/params/ParamBean.java.diff?r1=1.149.2.9.2.4&r2=1.149.2.9.2.5&f=h
Index: ParamBean.java
===================================================================
RCS file:
/home/cvs/repository/jahia/src/java/org/jahia/params/Attic/ParamBean.java,v
retrieving revision 1.149.2.9.2.4
retrieving revision 1.149.2.9.2.5
diff -u -r1.149.2.9.2.4 -r1.149.2.9.2.5
--- ParamBean.java 24 Mar 2005 16:05:02 -0000 1.149.2.9.2.4
+++ ParamBean.java 29 Mar 2005 15:33:01 -0000 1.149.2.9.2.5
@@ -162,6 +162,7 @@
import java.net.Socket;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
+import org.apache.commons.httpclient.HostConfiguration;
/**
* This object contains most of the request context, including object such as
@@ -2703,6 +2704,7 @@
// let's check if we can resolve the site's server name address and
if
// it points to a Jahia installation. For this we connect to an URL
and
// try to retrieve a header specific to Jahia.
+ GetMethod method = null;
try {
Map contextVars = new HashMap();
@@ -2713,34 +2715,26 @@
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
+ // HostConfiguration hostConfiguration = new HostConfiguration();
+ //hostConfiguration.setHost(targetURL.getHost(),
targetURL.getPort(), targetURL.getProtocol());
+
client.setConnectionTimeout(settings().getSiteServerNameTestConnectTimeout());
- // we need to create our own socket in order to be able to set
- // the timeout. This won't be necessary once we upgrade to
- // HttpClient 2.0
- Socket socket = new Socket();
- SocketAddress endpoint = new
InetSocketAddress(targetURL.getHost(), targetURL.getPort());
- socket.connect(endpoint, 500);
- client.setSocket(socket);
-
- if (targetURL.getProtocol().equalsIgnoreCase("https")) {
- client.startSession(targetURL.getHost(),
targetURL.getPort(), true);
- } else {
- client.startSession(targetURL.getHost(),
targetURL.getPort(), false);
- }
// Create a method instance.
- GetMethod method = new GetMethod(targetURL.getPath());
+ method = new GetMethod(targetURL.toString());
// Execute the method.
client.executeMethod(method);
// Read the response body.
- Header javaVersionHeader = method.getHeader("jahia-version");
+ Header javaVersionHeader =
method.getResponseHeader("jahia-version");
if (javaVersionHeader != null) {
- serverNameValid = true;
+ serverNameValid = true;
}
} catch (Throwable t) {
serverNameValid = false;
+ } finally {
+ method.releaseConnection();
}
StringBuffer newSiteURL = new StringBuffer(getRequest().getScheme()
+ "://");