Author: midon
Date: Wed Nov 26 17:24:00 2008
New Revision: 721060
URL: http://svn.apache.org/viewvc?rev=721060&view=rev
Log:
ODE-409: user properties are now applied to the HTTP method
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java?rev=721060&r1=721059&r2=721060&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java
(original)
+++
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java
Wed Nov 26 17:24:00 2008
@@ -63,6 +63,9 @@
public static final String PROP_HTTP_PROXY_DOMAIN = PROP_HTTP_PROXY_PREFIX
+ "domain";
public static final String PROP_HTTP_PROXY_USER = PROP_HTTP_PROXY_PREFIX +
"user";
public static final String PROP_HTTP_PROXY_PASSWORD =
PROP_HTTP_PROXY_PREFIX + "password";
+ /**
+ * @deprecated use
org.apache.commons.httpclient.params.HttpMethodParams#HTTP_CONTENT_CHARSET
(="http.protocol.content-charset")
+ */
public static final String PROP_HTTP_PROTOCOL_ENCODING =
"http.protocol.encoding";
// Httpclient specific
@@ -124,7 +127,11 @@
if (log.isDebugEnabled()) log.debug("Translating Properties for
Axis2");
if (properties.isEmpty()) return options;
- /*first add all property pairs so that new properties (with string
value)
+ // First set any default values to make sure they can be overwriten
+ // set the default encoding for HttpClient (HttpClient uses
ISO-8859-1 by default)
+
options.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
+
+ /*then add all property pairs so that new properties (with string
value)
are automatically handled (i.e no translation needed) */
for (Map.Entry<String, String> e : properties.entrySet()) {
options.setProperty(e.getKey(), e.getValue());
@@ -148,8 +155,12 @@
}
}
if (properties.containsKey(PROP_HTTP_PROTOCOL_ENCODING)) {
+ if(log.isWarnEnabled())log.warn("Deprecated property:
http.protocol.encoding. Use http.protocol.content-charset");
options.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
properties.get(PROP_HTTP_PROTOCOL_ENCODING));
}
+ if (properties.containsKey(HttpMethodParams.HTTP_CONTENT_CHARSET))
{
+
options.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
properties.get(HttpMethodParams.HTTP_CONTENT_CHARSET));
+ }
if (properties.containsKey(PROP_HTTP_PROTOCOL_VERSION)) {
options.setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION,
properties.get(PROP_HTTP_PROTOCOL_VERSION));
}
@@ -200,7 +211,11 @@
log.debug("Translating Properties for HttpClient. Properties
size=" + properties.size());
if (properties.isEmpty()) return p;
- /*first add all property pairs so that new properties (with string
value)
+ // First set any default values to make sure they can be overwriten
+ // set the default encoding for HttpClient (HttpClient uses
ISO-8859-1 by default)
+ p.setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
+
+ /*then all property pairs so that new properties (with string
value)
are automatically handled (i.e no translation needed) */
for (Map.Entry<String, String> e : properties.entrySet()) {
p.setParameter(e.getKey(), e.getValue());
@@ -228,16 +243,23 @@
}
}
- // set the default encoding for HttpClient (HttpClient uses
ISO-8859-1 by default)
- p.setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
if (properties.containsKey(PROP_HTTP_PROTOCOL_ENCODING)) {
+ if(log.isWarnEnabled())log.warn("Deprecated property:
http.protocol.encoding. Use http.protocol.content-charset");
p.setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,
properties.get(PROP_HTTP_PROTOCOL_ENCODING));
}
+ // the next one is redundant because
HttpMethodParams.HTTP_CONTENT_CHARSET accepts a string and we use the same
property name
+ // so the property has already been added.
+ if (properties.containsKey(HttpMethodParams.HTTP_CONTENT_CHARSET))
{
+ p.setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,
properties.get(HttpMethodParams.HTTP_CONTENT_CHARSET));
+ }
+
if (properties.containsKey(PROP_HTTP_PROTOCOL_VERSION)) {
try {
p.setParameter(HttpMethodParams.PROTOCOL_VERSION,
HttpVersion.parse(properties.get(PROP_HTTP_PROTOCOL_VERSION)));
} catch (ProtocolException e) {
if (log.isWarnEnabled())
+
+
log.warn("Mal-formatted Property: [" +
PROP_HTTP_PROTOCOL_VERSION + "]", e);
}
}
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java?rev=721060&r1=721059&r2=721060&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
(original)
+++
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
Wed Nov 26 17:24:00 2008
@@ -30,6 +30,7 @@
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HostParams;
import org.apache.commons.httpclient.params.HttpParams;
+import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -170,6 +171,7 @@
} else if ("DELETE".equalsIgnoreCase(verb)) {
method = new DeleteMethod();
}
+ method.getParams().setDefaults(params);
if (useUrlEncoded) {
queryPath = encodedParams;
}
@@ -185,7 +187,7 @@
} else if ("PUT".equalsIgnoreCase(verb)) {
method = new PutMethod();
}
-
+ method.getParams().setDefaults(params);
// some body-building...
final String contentCharset =
method.getParams().getContentCharset();
if (log.isDebugEnabled()) log.debug("Content-Type [" + contentType
+ "] Charset [" + contentCharset + "]");