svn commit: r1853818 - in /cocoon/branches/BRANCH_2_1_X: ./ lib/ lib/core/ src/blocks/proxy/java/org/apache/cocoon/generation/
[email protected] Mon, 18 Feb 2019 19:06:49 -0000
| Newsgroups | gmane.text.xml.cocoon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: anathaniel
Date: Mon Feb 18 19:06:49 2019
New Revision: 1853818
URL: http://svn.apache.org/viewvc?rev=1853818&view=rev
Log:
Update to commons-httpclient-3.1
Added:
cocoon/branches/BRANCH_2_1_X/lib/core/commons-httpclient-3.1.jar (with props)
Removed:
cocoon/branches/BRANCH_2_1_X/lib/core/commons-httpclient-2.0.2.jar
Modified:
cocoon/branches/BRANCH_2_1_X/lib/jars.xml
cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/HttpProxyGenerator.java
cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/WebServiceProxyGenerator.java
cocoon/branches/BRANCH_2_1_X/status.xml
Added: cocoon/branches/BRANCH_2_1_X/lib/core/commons-httpclient-3.1.jar
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/lib/core/commons-httpclient-3.1.jar?rev=1853818&view=auto
==============================================================================
Binary file - no diff available.
Propchange: cocoon/branches/BRANCH_2_1_X/lib/core/commons-httpclient-3.1.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: cocoon/branches/BRANCH_2_1_X/lib/jars.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/lib/jars.xml?rev=1853818&r1=1853817&r2=1853818&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/lib/jars.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/lib/jars.xml Mon Feb 18 19:06:49 2019
@@ -429,7 +429,7 @@
HTTP standards and recommendations.
</description>
<used-by>SOAP logicsheet, WebServiceProxyGenerator, HttpProxyGenerator</used-by>
- <lib>core/commons-httpclient-2.0.2.jar</lib>
+ <lib>core/commons-httpclient-3.1.jar</lib>
<homepage>http://jakarta.apache.org/commons/httpclient/</homepage>
</file>
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/HttpProxyGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/HttpProxyGenerator.java?rev=1853818&r1=1853817&r2=1853818&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/HttpProxyGenerator.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/HttpProxyGenerator.java Mon Feb 18 19:06:49 2019
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.apache.avalon.framework.configuration.Configurable;
@@ -65,9 +66,9 @@ public class HttpProxyGenerator extends
/** The base HTTP URL for requests. */
private HttpURL url = null;
/** The list of request parameters for the request */
- private ArrayList reqParams = null;
+ private List<NameValuePair> reqParams = null;
/** The list of query parameters for the request */
- private ArrayList qryParams = null;
+ private List<NameValuePair> qryParams = null;
/** Wether we want a debug output or not */
private boolean debug = false;
@@ -142,9 +143,10 @@ public class HttpProxyGenerator extends
* (one for the body, one for the query string, otherwise it's going
* to be the same one, as all parameters are passed on the query string
*/
- ArrayList req = new ArrayList();
- ArrayList qry = req;
- if (this.method instanceof PostMethod) qry = new ArrayList();
+ List<NameValuePair> req = new ArrayList<NameValuePair>();
+ List<NameValuePair> qry = req;
+ if (this.method instanceof PostMethod)
+ qry = new ArrayList<NameValuePair>();
req.addAll(this.reqParams);
qry.addAll(this.qryParams);
@@ -152,9 +154,8 @@ public class HttpProxyGenerator extends
* Parameter handling: complete or override the configured parameters with
* those specified in the pipeline.
*/
- String names[] = parameters.getNames();
- for (int x = 0; x < names.length; x++) {
- String name = names[x];
+ String[] names = parameters.getNames();
+ for (String name : names) {
String value = parameters.getParameter(name, null);
if (value == null) continue;
@@ -191,8 +192,8 @@ public class HttpProxyGenerator extends
/* And now process the query string (from the parameters above) */
if (qry.size() > 0) {
String qs = this.method.getQueryString();
- NameValuePair nvpa[] = new NameValuePair[qry.size()];
- this.method.setQueryString((NameValuePair []) qry.toArray(nvpa));
+ NameValuePair[] nvpa = new NameValuePair[qry.size()];
+ this.method.setQueryString(qry.toArray(nvpa));
if (qs != null) {
this.method.setQueryString(qs + "&" + this.method.getQueryString());
}
@@ -201,8 +202,8 @@ public class HttpProxyGenerator extends
/* Finally process the body parameters */
if ((this.method instanceof PostMethod) && (req.size() > 0)) {
PostMethod post = (PostMethod) this.method;
- NameValuePair nvpa[] = new NameValuePair[req.size()];
- post.setRequestBody((NameValuePair []) req.toArray(nvpa));
+ NameValuePair[] nvpa = new NameValuePair[req.size()];
+ post.setRequestBody(req.toArray(nvpa));
}
/* Check the debugging flag */
@@ -292,7 +293,8 @@ public class HttpProxyGenerator extends
super.xmlConsumer.startElement("", "request", "request", attributes);
if (this.method instanceof PostMethod) {
- String body = ((PostMethod) this.method).getRequestBodyAsString();
+ byte[] bodyBytes = this.method.getResponseBody();
+ String body = new String(bodyBytes, "utf-8");
attributes.clear();
attributes.addAttribute("", "name", "name", "CDATA", "Content-Type");
@@ -315,7 +317,6 @@ public class HttpProxyGenerator extends
super.xmlConsumer.endElement("", "request", "request");
super.xmlConsumer.endDocument();
- return;
}
/**
@@ -326,14 +327,13 @@ public class HttpProxyGenerator extends
* @return A <code>List</code> of <code>NameValuePair</code> elements.
* @throws ConfigurationException If a parameter doesn't specify a name.
*/
- private ArrayList getParams(Configuration configurations[])
+ private List<NameValuePair> getParams(Configuration[] configurations)
throws ConfigurationException {
- ArrayList list = new ArrayList();
+ List<NameValuePair> list = new ArrayList<NameValuePair>();
if (configurations.length < 1) return (list);
- for (int x = 0; x < configurations.length; x++) {
- Configuration configuration = configurations[x];
+ for (Configuration configuration : configurations) {
String name = configuration.getAttribute("name", null);
if (name == null) {
throw new ConfigurationException("No name specified for parameter at "
@@ -343,14 +343,14 @@ public class HttpProxyGenerator extends
String value = configuration.getAttribute("value", null);
if (value != null) list.add(new NameValuePair(name, value));
- Configuration subconfigurations[] = configuration.getChildren("value");
- for (int y = 0; y < subconfigurations.length; y++) {
- value = subconfigurations[y].getValue(null);
+ Configuration[] subconfigurations = configuration.getChildren("value");
+ for (Configuration subconfiguration : subconfigurations) {
+ value = subconfiguration.getValue(null);
if (value != null) list.add(new NameValuePair(name, value));
}
}
- return (list);
+ return list;
}
/**
@@ -362,10 +362,10 @@ public class HttpProxyGenerator extends
* @param value The new parameter value.
* @return The same <code>List</code> of <code>NameValuePair</code> elements.
*/
- private ArrayList overrideParams(ArrayList list, String name, String value) {
- Iterator iterator = list.iterator();
+ private List<NameValuePair> overrideParams(List<NameValuePair> list, String name, String value) {
+ Iterator<NameValuePair> iterator = list.iterator();
while (iterator.hasNext()) {
- NameValuePair param = (NameValuePair) iterator.next();
+ NameValuePair param = iterator.next();
if (param.getName().equals(name)) {
iterator.remove();
break;
@@ -375,4 +375,3 @@ public class HttpProxyGenerator extends
return (list);
}
}
-
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/WebServiceProxyGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/WebServiceProxyGenerator.java?rev=1853818&r1=1853817&r2=1853818&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/WebServiceProxyGenerator.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/WebServiceProxyGenerator.java Mon Feb 18 19:06:49 2019
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,6 +44,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -138,7 +139,7 @@ public class WebServiceProxyGenerator ex
/**
* Forwards the request and returns the response.
- *
+ *
* The rest is probably out of date:
* Will use a UrlGetMethod to benefit the cacheing mechanism
* and intermediate proxy servers.
@@ -148,7 +149,7 @@ public class WebServiceProxyGenerator ex
* @return byte[] XML response
*/
public byte[] fetch() throws ProcessingException {
- HttpMethod method = null;
+ final HttpMethod method;
// check which method (GET or POST) to use.
if (this.configuredHttpMethod.equalsIgnoreCase(METHOD_POST)) {
@@ -167,13 +168,13 @@ public class WebServiceProxyGenerator ex
// copy request parameters and merge with URL parameters
Request request = ObjectModelHelper.getRequest(objectModel);
- ArrayList paramList = new ArrayList();
- Enumeration enumeration = request.getParameterNames();
+ List<NameValuePair> paramList = new ArrayList<NameValuePair>();
+ Enumeration<String> enumeration = (Enumeration<String>) request.getParameterNames();
while (enumeration.hasMoreElements()) {
- String pname = (String)enumeration.nextElement();
+ String pname = enumeration.nextElement();
String[] paramsForName = request.getParameterValues(pname);
- for (int i = 0; i < paramsForName.length; i++) {
- NameValuePair pair = new NameValuePair(pname, paramsForName[i]);
+ for (String value : paramsForName) {
+ NameValuePair pair = new NameValuePair(pname, value);
paramList.add(pair);
}
}
@@ -189,17 +190,17 @@ public class WebServiceProxyGenerator ex
String submitQryString = method.getQueryString();
// set final web service query string
-
+
// sometimes the querystring is null here...
if (null == urlQryString) {
method.setQueryString(submitQryString);
} else {
- method.setQueryString(urlQryString + "&" + submitQryString);
+ method.setQueryString(urlQryString + "&" + submitQryString);
}
-
+
} // if there are submit parameters
- byte[] response = null;
+ final byte[] response;
try {
int httpStatus = httpClient.executeMethod(method);
if (httpStatus < 400) {
@@ -209,6 +210,7 @@ public class WebServiceProxyGenerator ex
} else {
throw new ProcessingException("The remote returned error " + httpStatus + " when attempting to access remote URL:" + method.getURI());
}
+ response = method.getResponseBody();
} catch (URIException e) {
throw new ProcessingException("There is a problem with the URI: " + this.source, e);
} catch (IOException e) {
@@ -222,7 +224,6 @@ public class WebServiceProxyGenerator ex
* connection regardless of whether the server returned an error or not.
* {@link http://jakarta.apache.org/commons/httpclient/tutorial.html}
*/
- response = method.getResponseBody();
method.releaseConnection();
}
@@ -230,11 +231,9 @@ public class WebServiceProxyGenerator ex
} // fetch
/**
- * Create one per client session.
+ * Create one per client session.
*/
protected HttpClient getHttpClient() throws ProcessingException {
- URI uri = null;
- String host = null;
Request request = ObjectModelHelper.getRequest(objectModel);
Session session = request.getSession(true);
HttpClient httpClient = null;
@@ -242,15 +241,16 @@ public class WebServiceProxyGenerator ex
httpClient = (HttpClient)session.getAttribute(HTTP_CLIENT);
}
if (httpClient == null) {
+ final URI uri;
+ final String host;
httpClient = new HttpClient();
HostConfiguration config = httpClient.getHostConfiguration();
if (config == null) {
config = new HostConfiguration();
}
-
-
+
/* TODO: fixme!
- * When the specified source sent to the wsproxy is not "http"
+ * When the specified source sent to the wsproxy is not "http"
* (e.g. "cocoon:/"), the HttpClient throws an exception. Does the source
* here need to be resolved before being set in the HostConfiguration?
*/
@@ -282,7 +282,7 @@ public class WebServiceProxyGenerator ex
// computer.example.com? it seems to be a very common
// idiom for the nonProxyHosts, in that case then we want
// to change "^" to "^.*"
- RE re = null;
+ final RE re;
try {
re = new RE("^" + nonProxiableHost + "$");
}
@@ -310,6 +310,4 @@ public class WebServiceProxyGenerator ex
}
return httpClient;
}
-
-
-} // class
+}
Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=1853818&r1=1853817&r2=1853818&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Mon Feb 18 19:06:49 2019
@@ -185,6 +185,9 @@
<changes>
<release version="2.1.13" date="TBD">
<action dev="AN" type="update">
+ Update to commons-httpclient-3.1
+ </action>
+ <action dev="AN" type="update">
XSP: Remove alternative Javac because there is no common API for Java 5 to 8.
</action>
<action dev="AN" type="update">