You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2012/11/10 15:37:38 UTC
svn commit: r1407825 [1/2] - in
/manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint:
CommonsHTTPSender.java SPSProxyHelper.java SharePointRepository.java
Author: kwright
Date: Sat Nov 10 14:37:37 2012
New Revision: 1407825
URL: http://svn.apache.org/viewvc?rev=1407825&view=rev
Log:
Convert SharePoint connector to httpcomponents 4.2.2
Modified:
manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/CommonsHTTPSender.java
manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java
manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java
Modified: manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/CommonsHTTPSender.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/CommonsHTTPSender.java?rev=1407825&r1=1407824&r2=1407825&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/CommonsHTTPSender.java (original)
+++ manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/CommonsHTTPSender.java Sat Nov 10 14:37:37 2012
@@ -33,26 +33,20 @@ import org.apache.axis.soap.SOAPConstant
import org.apache.axis.utils.JavaUtils;
import org.apache.axis.utils.Messages;
import org.apache.axis.utils.NetworkUtils;
-import org.apache.commons.httpclient.Cookie;
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.HttpVersion;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NTCredentials;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.RequestEntity;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.protocol.ProtocolFactory;
+
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.Header;
+import org.apache.http.params.CoreProtocolPNames;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.ProtocolVersion;
+import org.apache.http.util.EntityUtils;
+import org.apache.http.message.BasicHeader;
+
import org.apache.commons.logging.Log;
import javax.xml.soap.MimeHeader;
@@ -64,324 +58,158 @@ import java.io.InterruptedIOException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.Reader;
+import java.io.InputStreamReader;
+import java.io.Writer;
+import java.io.StringWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-/**
-* This class uses Jakarta Commons's HttpClient to call a SOAP server.
-*
-* @author Davanum Srinivas (dims@yahoo.com)
-* History: By Chandra Talluri
-* Modifications done for maintaining sessions. Cookies needed to be set on
-* HttpState not on MessageContext, since ttpMethodBase overwrites the cookies
-* from HttpState. Also we need to setCookiePolicy on HttpState to
-* CookiePolicy.COMPATIBILITY else it is defaulting to RFC2109Spec and adding
-* Version information to it and tomcat server not recognizing it
+
+/* Class to use httpcomponents to communicate with a SOAP server.
+* I've replaced the original rather complicated class with a much simpler one that
+* relies on having an HttpClient object passed into the invoke() method. Since
+* the object is already set up, not much needs to be done in here.
*/
+
public class CommonsHTTPSender extends BasicHandler {
/** Field log */
protected static Log log =
LogFactory.getLog(CommonsHTTPSender.class.getName());
- /** Connection pool, and initialization lock */
- protected static HttpConnectionManager connectionManager = null;
- protected static Object lockObject = new Object();
-
+ /** Properties */
protected CommonsHTTPClientProperties clientProperties;
- boolean httpChunkStream = true; //Use HTTP chunking or not.
public CommonsHTTPSender() {
- initialize();
- }
-
- protected void initialize() {
this.clientProperties = CommonsHTTPClientPropertiesFactory.create();
- synchronized (lockObject)
- {
- if (connectionManager == null)
- {
- MultiThreadedHttpConnectionManager cm = new MultiThreadedHttpConnectionManager();
- // I don't know where CommonsHTTPClientPropertiesFactory.create() gets its parameters, but it was too small
- // by default. Since we control
- // the pool sizes at a higher level, these should be pretty much wide open at this level
- //cm.getParams().setDefaultMaxConnectionsPerHost(clientProperties.getMaximumConnectionsPerHost());
- //cm.getParams().setMaxTotalConnections(clientProperties.getMaximumTotalConnections());
- cm.getParams().setDefaultMaxConnectionsPerHost(1000);
- cm.getParams().setMaxTotalConnections(1000);
- // If defined, set the default timeouts
- // Can be overridden by the MessageContext
- if(this.clientProperties.getDefaultConnectionTimeout()>0) {
- cm.getParams().setConnectionTimeout(this.clientProperties.getDefaultConnectionTimeout());
- }
- if(this.clientProperties.getDefaultSoTimeout()>0) {
- cm.getParams().setSoTimeout(this.clientProperties.getDefaultSoTimeout());
- }
- connectionManager = cm;
- }
- }
}
protected static class ExecuteMethodThread extends Thread
{
- protected HttpClient client;
- protected HostConfiguration hostConfiguration;
- protected HttpMethodBase executeMethod;
+ protected final HttpClient httpClient;
+ protected final String targetURL;
+ protected final MessageContext msgContext;
+
protected Throwable exception = null;
- protected int rval = 0;
+ protected int returnCode = 0;
- public ExecuteMethodThread(HttpClient client, HostConfiguration hostConfiguration, HttpMethodBase executeMethod)
+ public ExecuteMethodThread( HttpClient httpClient, String targetURL, MessageContext msgContext )
{
super();
setDaemon(true);
- this.client = client;
- this.hostConfiguration = hostConfiguration;
- this.executeMethod = executeMethod;
+ this.httpClient = httpClient;
+ this.targetURL = targetURL;
+ this.msgContext = msgContext;
}
public void run()
{
try
{
- // Call the execute method appropriately
- rval = client.executeMethod(hostConfiguration,executeMethod,null);
- }
- catch (Throwable e)
- {
- this.exception = e;
- }
- }
-
- public Throwable getException()
- {
- return exception;
- }
-
- public int getResponse()
- {
- return rval;
- }
- }
-
- /**
- * invoke creates a socket connection, sends the request SOAP message and then
- * reads the response SOAP message back from the SOAP server
- *
- * @param msgContext the messsage context
- *
- * @throws AxisFault
- */
- public void invoke(MessageContext msgContext) throws AxisFault {
- HttpMethodBase method = null;
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage("enter00",
- "CommonsHTTPSender::invoke"));
- }
- try {
- URL targetURL =
- new URL(msgContext.getStrProp(MessageContext.TRANS_URL));
-
- ProtocolFactory myFactory = (ProtocolFactory)msgContext.getProperty(SPSProxyHelper.PROTOCOL_FACTORY_PROPERTY);
- // Allow caller to override the connection manager that we use.
- HttpConnectionManager localConnectionManager = (HttpConnectionManager)msgContext.getProperty(SPSProxyHelper.CONNECTION_MANAGER_PROPERTY);
- if (localConnectionManager == null)
- localConnectionManager = connectionManager;
-
- // no need to retain these, as the cookies/credentials are
- // stored in the message context across multiple requests.
- // the underlying connection manager, however, is retained
- // so sockets get recycled when possible.
- HttpClient httpClient = new HttpClient(localConnectionManager);
- // the timeout value for allocation of connections from the pool
- httpClient.getParams().setConnectionManagerTimeout(this.clientProperties.getConnectionPoolTimeout());
- // Set our protocol factory, in case there's a redirect
- if (myFactory != null)
- httpClient.getParams().setParameter(org.apache.commons.httpclient.params.HttpClientParams.PROTOCOL_FACTORY,myFactory);
- // Allow circular redirections
- httpClient.getParams().setParameter(org.apache.commons.httpclient.params.HttpClientParams.ALLOW_CIRCULAR_REDIRECTS,new Boolean(true));
-
- HostConfiguration hostConfiguration =
- getHostConfiguration(httpClient, msgContext, targetURL, myFactory);
-
- boolean posting = true;
-
- // If we're SOAP 1.2, allow the web method to be set from the
- // MessageContext.
- if (msgContext.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS) {
- String webMethod = msgContext.getStrProp(SOAP12Constants.PROP_WEBMETHOD);
- if (webMethod != null) {
- posting = webMethod.equals(HTTPConstants.HEADER_POST);
- }
- }
-
- // Since the host configuration contains the host/port/protocol, we don't want to
- // have it overwritten. So, we need the relative url.
- String relativeTargetURL = targetURL.toString();
- int slashindex = relativeTargetURL.indexOf("/");
- if (slashindex != 0 && slashindex != -1)
- {
- slashindex = relativeTargetURL.indexOf("/",slashindex + 2);
- if (slashindex != -1)
- relativeTargetURL = relativeTargetURL.substring(slashindex);
- }
-
- if (posting) {
- method = new PostMethod(relativeTargetURL);
- } else {
- method = new GetMethod(relativeTargetURL);
- // Allow redirection
- method.setFollowRedirects(true);
- }
-
-
- // The variable 'releaseMethod' is null if we no longer have to release the connection into the pool
- // on exit from this section. Otherwise it remains set to the method, so that all exceptions cause
- // the release to occur.
- HttpMethodBase releaseMethod = method;
- try
- {
- // This stuff all needs to be inside the try above
- if (posting)
- {
- Message reqMessage = msgContext.getRequestMessage();
-
- // set false as default, addContetInfo can overwrite
- method.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE,
- false);
-
- addContextInfo(method, httpClient, msgContext, targetURL);
-
- MessageRequestEntity requestEntity = null;
- if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
- requestEntity = new GzipMessageRequestEntity(method, reqMessage, httpChunkStream);
- } else {
- requestEntity = new MessageRequestEntity(method, reqMessage, httpChunkStream);
+ boolean posting = true;
+ // If we're SOAP 1.2, allow the web method to be set from the
+ // MessageContext.
+ if (msgContext.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS) {
+ String webMethod = msgContext.getStrProp(SOAP12Constants.PROP_WEBMETHOD);
+ if (webMethod != null) {
+ posting = webMethod.equals(HTTPConstants.HEADER_POST);
}
- ((PostMethod)method).setRequestEntity(requestEntity);
- }
- else
- {
- addContextInfo(method, httpClient, msgContext, targetURL);
}
+ boolean http10 = false;
String httpVersion = msgContext.getStrProp(MessageContext.HTTP_TRANSPORT_VERSION);
if (httpVersion != null) {
if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_V10)) {
- method.getParams().setVersion(HttpVersion.HTTP_1_0);
+ http10 = true;
}
// assume 1.1
}
- // don't forget the cookies!
- // Cookies need to be set on HttpState, since HttpMethodBase
- // overwrites the cookies from HttpState
- if (msgContext.getMaintainSession()) {
- HttpState state = httpClient.getState();
- method.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
- String host = hostConfiguration.getHost();
- String path = targetURL.getPath();
- boolean secure = hostConfiguration.getProtocol().isSecure();
- fillHeaders(msgContext, state, HTTPConstants.HEADER_COOKIE, host, path, secure);
- fillHeaders(msgContext, state, HTTPConstants.HEADER_COOKIE2, host, path, secure);
- httpClient.setState(state);
- }
-
- int returnCode;
-
- ExecuteMethodThread t = new ExecuteMethodThread(httpClient,hostConfiguration,method);
- try
- {
- t.start();
- t.join();
- Throwable thr = t.getException();
- if (thr != null)
- {
- if (thr instanceof Exception)
- throw (Exception)thr;
- else
- throw (Error)thr;
- }
- returnCode = t.getResponse();
- }
- catch (InterruptedException e)
- {
- t.interrupt();
- // We need the caller to abandon any connections left around, so rethrow in a way that forces them to process the event properly.
- releaseMethod = null;
- throw e;
- }
+ HttpRequestBase method;
+ if (posting) {
+ HttpPost postMethod = new HttpPost(targetURL);
+
+ // set false as default, addContetInfo can overwrite
+ HttpProtocolParams.setUseExpectContinue(postMethod.getParams(),false);
- String contentType =
- getHeader(method, HTTPConstants.HEADER_CONTENT_TYPE);
- String contentLocation =
- getHeader(method, HTTPConstants.HEADER_CONTENT_LOCATION);
- String contentLength =
- getHeader(method, HTTPConstants.HEADER_CONTENT_LENGTH);
-
- if ((returnCode > 199) && (returnCode < 300)) {
-
- // SOAP return is OK - so fall through
- } else if (msgContext.getSOAPConstants() ==
- SOAPConstants.SOAP12_CONSTANTS) {
- // For now, if we're SOAP 1.2, fall through, since the range of
- // valid result codes is much greater
- } else if ((contentType != null) && !contentType.equals("text/html")
- && ((returnCode > 499) && (returnCode < 600))) {
+ Message reqMessage = msgContext.getRequestMessage();
+
+ boolean httpChunkStream = addContextInfo(postMethod, msgContext);
- // SOAP Fault should be in here - so fall through
+ HttpEntity requestEntity = null;
+ requestEntity = new MessageRequestEntity(reqMessage, httpChunkStream,
+ http10 || !httpChunkStream);
+ postMethod.setEntity(requestEntity);
+ method = postMethod;
} else {
- String statusMessage = method.getStatusText();
- AxisFault fault = new AxisFault("HTTP",
- "(" + returnCode + ")"
- + statusMessage, null,
- null);
-
- fault.setFaultDetailString(
- Messages.getMessage("return01",
- "" + returnCode,
- method.getResponseBodyAsString()));
- fault.addFaultDetail(Constants.QNAME_FAULTDETAIL_HTTPERRORCODE,
- Integer.toString(returnCode));
- throw fault;
+ method = new HttpGet(targetURL);
}
+
+ if (http10)
+ HttpProtocolParams.setVersion(method.getParams(),new ProtocolVersion("HTTP",1,0));
- // wrap the response body stream so that close() also releases
- // the connection back to the pool.
- InputStream releaseConnectionOnCloseStream =
- createConnectionReleasingInputStream(method);
- // If something goes wrong after this point and before this is safely
- // saved in the msg, we'll have a dangling stream, so we need a
- // try/catch to guarantee that it doesn't hang around.
- InputStream streamToClose = releaseConnectionOnCloseStream;
+ // Try block to insure that the connection gets cleaned up
try
{
+ // Begin the fetch
+ HttpResponse response = httpClient.execute(method);
+
+ returnCode = response.getStatusLine().getStatusCode();
+
+ String contentType =
+ getHeader(response, HTTPConstants.HEADER_CONTENT_TYPE);
+ String contentLocation =
+ getHeader(response, HTTPConstants.HEADER_CONTENT_LOCATION);
+ String contentLength =
+ getHeader(response, HTTPConstants.HEADER_CONTENT_LENGTH);
+
+ if ((returnCode > 199) && (returnCode < 300)) {
+
+ // SOAP return is OK - so fall through
+ } else if (msgContext.getSOAPConstants() ==
+ SOAPConstants.SOAP12_CONSTANTS) {
+ // For now, if we're SOAP 1.2, fall through, since the range of
+ // valid result codes is much greater
+ } else if ((contentType != null) && !contentType.equals("text/html")
+ && ((returnCode > 499) && (returnCode < 600))) {
+
+ // SOAP Fault should be in here - so fall through
+ } else {
+ String statusMessage = response.getStatusLine().toString();
+ AxisFault fault = new AxisFault("HTTP",
+ "(" + returnCode + ")"
+ + statusMessage, null,
+ null);
+
+ fault.setFaultDetailString(
+ Messages.getMessage("return01",
+ "" + returnCode,
+ getResponseBodyAsString(response)));
+ fault.addFaultDetail(Constants.QNAME_FAULTDETAIL_HTTPERRORCODE,
+ Integer.toString(returnCode));
+ throw fault;
+ }
+
+ InputStream releaseConnectionOnCloseStream = response.getEntity().getContent();
+
Header contentEncoding =
- method.getResponseHeader(HTTPConstants.HEADER_CONTENT_ENCODING);
+ response.getFirstHeader(HTTPConstants.HEADER_CONTENT_ENCODING);
if (contentEncoding != null) {
- if (contentEncoding.getValue().
- equalsIgnoreCase(HTTPConstants.COMPRESSION_GZIP)) {
- releaseConnectionOnCloseStream =
- new GZIPInputStream(releaseConnectionOnCloseStream);
- streamToClose = releaseConnectionOnCloseStream;
- } else {
- AxisFault fault = new AxisFault("HTTP",
- "unsupported content-encoding of '"
- + contentEncoding.getValue()
- + "' found", null, null);
- throw fault;
- }
-
+ AxisFault fault = new AxisFault("HTTP",
+ "unsupported content-encoding of '"
+ + contentEncoding.getValue()
+ + "' found", null, null);
+ throw fault;
}
+
Message outMsg = new Message(releaseConnectionOnCloseStream,
false, contentType, contentLocation);
+
// Transfer HTTP headers of HTTP message to MIME headers of SOAP message
- Header[] responseHeaders = method.getResponseHeaders();
+ Header[] responseHeaders = response.getAllHeaders();
MimeHeaders responseMimeHeaders = outMsg.getMimeHeaders();
for (int i = 0; i < responseHeaders.length; i++) {
Header responseHeader = responseHeaders[i];
@@ -389,340 +217,152 @@ public class CommonsHTTPSender extends B
responseHeader.getValue());
}
outMsg.setMessageType(Message.RESPONSE);
- // It's definitely not safe to not release the connection back to the pool until after the
- // successful execution of the following line (which, presumably, registers the
- // message in the msgcontext, where it will be closed if something goes wrong)
+
+ // Put the message in the message context.
msgContext.setResponseMessage(outMsg);
- releaseMethod = null;
- streamToClose = null;
- if (log.isDebugEnabled()) {
- if (null == contentLength) {
- log.debug("\n"
- + Messages.getMessage("no00", "Content-Length"));
- }
- log.debug("\n" + Messages.getMessage("xmlRecd00"));
- log.debug("-----------------------------------------------");
- log.debug(outMsg.getSOAPPartAsString());
- }
-
- // if we are maintaining session state,
- // handle cookies (if any)
- if (msgContext.getMaintainSession()) {
- Header[] headers = method.getResponseHeaders();
-
- for (int i = 0; i < headers.length; i++) {
- if (headers[i].getName().equalsIgnoreCase(HTTPConstants.HEADER_SET_COOKIE)) {
- handleCookie(HTTPConstants.HEADER_COOKIE, headers[i].getValue(), msgContext);
- } else if (headers[i].getName().equalsIgnoreCase(HTTPConstants.HEADER_SET_COOKIE2)) {
- handleCookie(HTTPConstants.HEADER_COOKIE2, headers[i].getValue(), msgContext);
- }
- }
- }
-
- // always release the connection back to the pool if
- // it was one way invocation
- if (msgContext.isPropertyTrue("axis.one.way")) {
- method.releaseConnection();
- releaseMethod = null;
- }
}
finally
{
- if (streamToClose != null)
- {
- streamToClose.close();
- releaseMethod = null;
- }
+ // Consumes and closes the stream, releasing the connection
+ method.abort();
}
}
- finally
+ catch (Throwable e)
{
- if (releaseMethod != null)
- releaseMethod.releaseConnection();
- }
- } catch (Exception e) {
- log.debug(e);
- throw AxisFault.makeFault(e);
- }
-
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage("exit00",
- "CommonsHTTPSender::invoke"));
- }
- }
-
- /**
- * little helper function for cookies. fills up the message context with
- * a string or an array of strings (if there are more than one Set-Cookie)
- *
- * @param cookieName
- * @param cookie
- * @param msgContext
- */
- public void handleCookie(String cookieName, String cookie,
- MessageContext msgContext) {
-
- cookie = cleanupCookie(cookie);
- int keyIndex = cookie.indexOf("=");
- String key = (keyIndex != -1) ? cookie.substring(0, keyIndex) : cookie;
-
- ArrayList cookies = new ArrayList();
- Object oldCookies = msgContext.getProperty(cookieName);
- boolean alreadyExist = false;
- if(oldCookies != null) {
- if(oldCookies instanceof String[]) {
- String[] oldCookiesArray = (String[])oldCookies;
- for(int i = 0; i < oldCookiesArray.length; i++) {
- String anOldCookie = oldCookiesArray[i];
- if (key != null && anOldCookie.indexOf(key) == 0) {
- // same cookie key
- anOldCookie = cookie; // update to new one
- alreadyExist = true;
- }
- cookies.add(anOldCookie);
- }
- } else {
- String oldCookie = (String)oldCookies;
- if (key != null && oldCookie.indexOf(key) == 0) {
- // same cookie key
- oldCookie = cookie; // update to new one
- alreadyExist = true;
- }
- cookies.add(oldCookie);
+ this.exception = e;
}
}
- if (!alreadyExist) {
- cookies.add(cookie);
- }
-
- if(cookies.size()==1) {
- msgContext.setProperty(cookieName, cookies.get(0));
- } else if (cookies.size() > 1) {
- msgContext.setProperty(cookieName, cookies.toArray(new String[cookies.size()]));
+ public Throwable getException()
+ {
+ return exception;
}
- }
- /**
- * Add cookies from message context
- *
- * @param msgContext
- * @param state
- * @param header
- * @param host
- * @param path
- * @param secure
- */
- private void fillHeaders(MessageContext msgContext, HttpState state, String header, String host, String path, boolean secure) {
- Object ck1 = msgContext.getProperty(header);
- if (ck1 != null) {
- if (ck1 instanceof String[]) {
- String [] cookies = (String[]) ck1;
- for (int i = 0; i < cookies.length; i++) {
- addCookie(state, cookies[i], host, path, secure);
- }
- } else {
- addCookie(state, (String) ck1, host, path, secure);
- }
+ public int getResponse()
+ {
+ return returnCode;
}
}
/**
- * add cookie to state
- * @param state
- * @param cookie
- */
- private void addCookie(HttpState state, String cookie,String host, String path, boolean secure) {
- int index = cookie.indexOf('=');
- state.addCookie(new Cookie(host, cookie.substring(0, index),
- cookie.substring(index + 1), path,
- null, secure));
- }
-
- /**
- * cleanup the cookie value.
+ * invoke creates a socket connection, sends the request SOAP message and then
+ * reads the response SOAP message back from the SOAP server
*
- * @param cookie initial cookie value
+ * @param msgContext the messsage context
*
- * @return a cleaned up cookie value.
+ * @throws AxisFault
*/
- private String cleanupCookie(String cookie) {
- cookie = cookie.trim();
- // chop after first ; a la Apache SOAP (see HTTPUtils.java there)
- int index = cookie.indexOf(';');
- if (index != -1) {
- cookie = cookie.substring(0, index);
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ if (log.isDebugEnabled())
+ {
+ log.debug(Messages.getMessage("enter00",
+ "CommonsHTTPSender::invoke"));
}
- return cookie;
- }
+
+ // Catch all exceptions and turn them into AxisFaults
+ try
+ {
+ // Get the URL
+ URL targetURL =
+ new URL(msgContext.getStrProp(MessageContext.TRANS_URL));
- protected HostConfiguration getHostConfiguration(HttpClient client,
- MessageContext context,
- URL targetURL,
- ProtocolFactory myFactory) {
-
-
- TransportClientProperties tcp =
- TransportClientPropertiesFactory.create(targetURL.getProtocol()); // http or https
- int port = targetURL.getPort();
- boolean hostInNonProxyList =
- isHostInNonProxyList(targetURL.getHost(), tcp.getNonProxyHosts());
-
- HostConfiguration config = new HostConfiguration();
-
- if (port == -1) {
- if(targetURL.getProtocol().equalsIgnoreCase("https")) {
- port = 443; // default port for https being 443
- } else {
- // it must be http
- port = 80; // default port for http being 80
+ // Get the HttpClient
+ HttpClient httpClient = (HttpClient)msgContext.getProperty(SPSProxyHelper.HTTPCLIENT_PROPERTY);
+
+ ExecuteMethodThread t = new ExecuteMethodThread(httpClient,targetURL.toString(),msgContext);
+ try
+ {
+ t.start();
+ t.join();
+ Throwable thr = t.getException();
+ if (thr != null)
+ {
+ if (thr instanceof RuntimeException)
+ throw (RuntimeException)thr;
+ else if (thr instanceof Exception)
+ throw (Exception)thr;
+ else
+ throw (Error)thr;
+ }
+ }
+ catch (InterruptedException e)
+ {
+ t.interrupt();
+ throw e;
}
- }
- if(hostInNonProxyList){
- if (myFactory != null)
- config.setHost(targetURL.getHost(), port, myFactory.getProtocol(targetURL.getProtocol()));
- else
- config.setHost(targetURL.getHost(), port, Protocol.getProtocol(targetURL.getProtocol()));
- } else {
- if (tcp.getProxyHost().length() == 0 ||
- tcp.getProxyPort().length() == 0) {
- if (myFactory != null)
- config.setHost(targetURL.getHost(), port, myFactory.getProtocol(targetURL.getProtocol()));
- else
- config.setHost(targetURL.getHost(), port, Protocol.getProtocol(targetURL.getProtocol()));
- } else {
- if (tcp.getProxyUser().length() != 0) {
- Credentials proxyCred =
- new UsernamePasswordCredentials(tcp.getProxyUser(),
- tcp.getProxyPassword());
- // if the username is in the form "user\domain"
- // then use NTCredentials instead.
- int domainIndex = tcp.getProxyUser().indexOf("\\");
- if (domainIndex > 0) {
- String domain = tcp.getProxyUser().substring(0, domainIndex);
- if (tcp.getProxyUser().length() > domainIndex + 1) {
- String user = tcp.getProxyUser().substring(domainIndex + 1);
- proxyCred = new NTCredentials(user,
- tcp.getProxyPassword(),
- tcp.getProxyHost(), domain);
- }
+ /*
+ if (log.isDebugEnabled()) {
+ if (null == contentLength) {
+ log.debug("\n"
+ + Messages.getMessage("no00", "Content-Length"));
}
- client.getState().setProxyCredentials(AuthScope.ANY, proxyCred);
+ log.debug("\n" + Messages.getMessage("xmlRecd00"));
+ log.debug("-----------------------------------------------");
+ log.debug(msgContext.getResponseMessage().getSOAPPartAsString());
}
- int proxyPort = new Integer(tcp.getProxyPort()).intValue();
- config.setProxy(tcp.getProxyHost(), proxyPort);
}
+ */
+
+ } catch (AxisFault af) {
+ log.debug(af);
+ throw af;
+ } catch (Exception e) {
+ log.debug(e);
+ throw AxisFault.makeFault(e);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage("exit00",
+ "CommonsHTTPSender::invoke"));
}
- return config;
}
/**
* Extracts info from message context.
*
- * @param method Post method
- * @param httpClient The client used for posting
+ * @param method Post or get method
* @param msgContext the message context
- * @param tmpURL the url to post to.
- *
- * @throws Exception
*/
- private void addContextInfo(HttpMethodBase method,
- HttpClient httpClient,
- MessageContext msgContext,
- URL tmpURL)
- throws Exception {
-
- // optionally set a timeout for the request
- if (msgContext.getTimeout() != 0) {
- /* ISSUE: these are not the same, but MessageContext has only one
- definition of timeout */
- // SO_TIMEOUT -- timeout for blocking reads
- httpClient.getHttpConnectionManager().getParams().setSoTimeout(msgContext.getTimeout());
- // timeout for initial connection
- // We don't set this because there's currently no good way to handle it in the SSL world
- //httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(msgContext.getTimeout());
- }
+ private static boolean addContextInfo(HttpPost method,
+ MessageContext msgContext)
+ throws AxisFault {
+
+ boolean httpChunkStream = false;
// Get SOAPAction, default to ""
String action = msgContext.useSOAPAction()
- ? msgContext.getSOAPActionURI()
- : "";
+ ? msgContext.getSOAPActionURI()
+ : "";
if (action == null) {
action = "";
}
Message msg = msgContext.getRequestMessage();
+
if (msg != null){
- method.setRequestHeader(new Header(HTTPConstants.HEADER_CONTENT_TYPE,
- msg.getContentType(msgContext.getSOAPConstants())));
- }
- method.setRequestHeader(new Header(HTTPConstants.HEADER_SOAP_ACTION,
- "\"" + action + "\""));
- method.setRequestHeader(new Header(HTTPConstants.HEADER_USER_AGENT, Messages.getMessage("axisUserAgent")));
- String userID = msgContext.getUsername();
- String passwd = msgContext.getPassword();
-
- // if UserID is not part of the context, but is in the URL, use
- // the one in the URL.
- if ((userID == null) && (tmpURL.getUserInfo() != null)) {
- String info = tmpURL.getUserInfo();
- int sep = info.indexOf(':');
-
- if ((sep >= 0) && (sep + 1 < info.length())) {
- userID = info.substring(0, sep);
- passwd = info.substring(sep + 1);
- } else {
- userID = info;
- }
- }
- if (userID != null && userID.length() > 0) {
- Credentials proxyCred =
- new UsernamePasswordCredentials(userID,
- passwd);
- // if the username is in the form "user\domain"
- // then use NTCredentials instead.
- int domainIndex = userID.indexOf("\\");
- if (domainIndex > 0) {
- String domain = userID.substring(0, domainIndex);
- if (userID.length() > domainIndex + 1) {
- String user = userID.substring(domainIndex + 1);
- proxyCred = new NTCredentials(user,
- passwd,
- NetworkUtils.getLocalHostname(), domain);
- }
- }
- httpClient.getState().setCredentials(AuthScope.ANY, proxyCred);
- }
- // add compression headers if needed
- if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
- method.addRequestHeader(HTTPConstants.HEADER_ACCEPT_ENCODING,
- HTTPConstants.COMPRESSION_GZIP);
- }
- if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
- method.addRequestHeader(HTTPConstants.HEADER_CONTENT_ENCODING,
- HTTPConstants.COMPRESSION_GZIP);
- }
-
- // Transfer MIME headers of SOAPMessage to HTTP headers.
- MimeHeaders mimeHeaders = msg.getMimeHeaders();
- if (mimeHeaders != null) {
- for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext(); ) {
- MimeHeader mimeHeader = (MimeHeader) i.next();
- //HEADER_CONTENT_TYPE and HEADER_SOAP_ACTION are already set.
- //Let's not duplicate them.
- String headerName = mimeHeader.getName();
- if (headerName.equals(HTTPConstants.HEADER_CONTENT_TYPE)
- || headerName.equals(HTTPConstants.HEADER_SOAP_ACTION)) {
- continue;
+ // First, transfer MIME headers of SOAPMessage to HTTP headers.
+ // Some of these might be overridden later.
+ MimeHeaders mimeHeaders = msg.getMimeHeaders();
+ if (mimeHeaders != null) {
+ for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext(); ) {
+ MimeHeader mimeHeader = (MimeHeader) i.next();
+ method.addHeader(mimeHeader.getName(),
+ mimeHeader.getValue());
}
- method.addRequestHeader(mimeHeader.getName(),
- mimeHeader.getValue());
}
+
+ method.setHeader(new BasicHeader(HTTPConstants.HEADER_CONTENT_TYPE,
+ msg.getContentType(msgContext.getSOAPConstants())));
}
+
+ method.setHeader(new BasicHeader(HTTPConstants.HEADER_SOAP_ACTION,
+ "\"" + action + "\""));
+ method.setHeader(new BasicHeader(HTTPConstants.HEADER_USER_AGENT, Messages.getMessage("axisUserAgent")));
+
// process user defined headers for information.
Hashtable userHeaderTable =
@@ -742,258 +382,107 @@ public class CommonsHTTPSender extends B
if (key.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT) &&
value.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT_100_Continue)) {
- method.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE,
- true);
+ HttpProtocolParams.setUseExpectContinue(method.getParams(),true);
} else if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
String val = me.getValue().toString();
if (null != val) {
httpChunkStream = JavaUtils.isTrue(val);
}
} else {
- method.addRequestHeader(key, value);
+ method.addHeader(key, value);
}
}
}
+
+ return httpChunkStream;
}
- /**
- * Check if the specified host is in the list of non proxy hosts.
- *
- * @param host host name
- * @param nonProxyHosts string containing the list of non proxy hosts
- *
- * @return true/false
- */
- protected boolean isHostInNonProxyList(String host, String nonProxyHosts) {
-
- if ((nonProxyHosts == null) || (host == null)) {
- return false;
- }
-
- /*
- * The http.nonProxyHosts system property is a list enclosed in
- * double quotes with items separated by a vertical bar.
- */
- StringTokenizer tokenizer = new StringTokenizer(nonProxyHosts, "|\"");
-
- while (tokenizer.hasMoreTokens()) {
- String pattern = tokenizer.nextToken();
-
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage("match00",
- new String[]{"HTTPSender",
- host,
- pattern}));
- }
- if (match(pattern, host, false)) {
- return true;
- }
- }
- return false;
+ private static String getHeader(HttpResponse response, String headerName) {
+ Header header = response.getFirstHeader(headerName);
+ return (header == null) ? null : header.getValue().trim();
}
- /**
- * Matches a string against a pattern. The pattern contains two special
- * characters:
- * '*' which means zero or more characters,
- *
- * @param pattern the (non-null) pattern to match against
- * @param str the (non-null) string that must be matched against the
- * pattern
- * @param isCaseSensitive
- *
- * @return <code>true</code> when the string matches against the pattern,
- * <code>false</code> otherwise.
- */
- protected static boolean match(String pattern, String str,
- boolean isCaseSensitive) {
-
- char[] patArr = pattern.toCharArray();
- char[] strArr = str.toCharArray();
- int patIdxStart = 0;
- int patIdxEnd = patArr.length - 1;
- int strIdxStart = 0;
- int strIdxEnd = strArr.length - 1;
- char ch;
- boolean containsStar = false;
-
- for (int i = 0; i < patArr.length; i++) {
- if (patArr[i] == '*') {
- containsStar = true;
- break;
- }
- }
- if (!containsStar) {
-
- // No '*'s, so we make a shortcut
- if (patIdxEnd != strIdxEnd) {
- return false; // Pattern and string do not have the same size
- }
- for (int i = 0; i <= patIdxEnd; i++) {
- ch = patArr[i];
- if (isCaseSensitive && (ch != strArr[i])) {
- return false; // Character mismatch
- }
- if (!isCaseSensitive
- && (Character.toUpperCase(ch)
- != Character.toUpperCase(strArr[i]))) {
- return false; // Character mismatch
- }
- }
- return true; // String matches against pattern
- }
- if (patIdxEnd == 0) {
- return true; // Pattern contains only '*', which matches anything
- }
-
- // Process characters before first star
- while ((ch = patArr[patIdxStart]) != '*'
- && (strIdxStart <= strIdxEnd)) {
- if (isCaseSensitive && (ch != strArr[strIdxStart])) {
- return false; // Character mismatch
- }
- if (!isCaseSensitive
- && (Character.toUpperCase(ch)
- != Character.toUpperCase(strArr[strIdxStart]))) {
- return false; // Character mismatch
- }
- patIdxStart++;
- strIdxStart++;
- }
- if (strIdxStart > strIdxEnd) {
-
- // All characters in the string are used. Check if only '*'s are
- // left in the pattern. If so, we succeeded. Otherwise failure.
- for (int i = patIdxStart; i <= patIdxEnd; i++) {
- if (patArr[i] != '*') {
- return false;
- }
- }
- return true;
- }
-
- // Process characters after last star
- while ((ch = patArr[patIdxEnd]) != '*' && (strIdxStart <= strIdxEnd)) {
- if (isCaseSensitive && (ch != strArr[strIdxEnd])) {
- return false; // Character mismatch
- }
- if (!isCaseSensitive
- && (Character.toUpperCase(ch)
- != Character.toUpperCase(strArr[strIdxEnd]))) {
- return false; // Character mismatch
- }
- patIdxEnd--;
- strIdxEnd--;
- }
- if (strIdxStart > strIdxEnd) {
-
- // All characters in the string are used. Check if only '*'s are
- // left in the pattern. If so, we succeeded. Otherwise failure.
- for (int i = patIdxStart; i <= patIdxEnd; i++) {
- if (patArr[i] != '*') {
- return false;
- }
- }
- return true;
- }
-
- // process pattern between stars. padIdxStart and patIdxEnd point
- // always to a '*'.
- while ((patIdxStart != patIdxEnd) && (strIdxStart <= strIdxEnd)) {
- int patIdxTmp = -1;
-
- for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {
- if (patArr[i] == '*') {
- patIdxTmp = i;
- break;
- }
- }
- if (patIdxTmp == patIdxStart + 1) {
-
- // Two stars next to each other, skip the first one.
- patIdxStart++;
- continue;
- }
-
- // Find the pattern between padIdxStart & padIdxTmp in str between
- // strIdxStart & strIdxEnd
- int patLength = (patIdxTmp - patIdxStart - 1);
- int strLength = (strIdxEnd - strIdxStart + 1);
- int foundIdx = -1;
-
- strLoop:
- for (int i = 0; i <= strLength - patLength; i++) {
- for (int j = 0; j < patLength; j++) {
- ch = patArr[patIdxStart + j + 1];
- if (isCaseSensitive
- && (ch != strArr[strIdxStart + i + j])) {
- continue strLoop;
- }
- if (!isCaseSensitive && (Character
- .toUpperCase(ch) != Character
- .toUpperCase(strArr[strIdxStart + i + j]))) {
- continue strLoop;
+ private static String getResponseBodyAsString(HttpResponse httpResponse)
+ throws IOException {
+ HttpEntity entity = httpResponse.getEntity();
+ if (entity != null)
+ {
+ InputStream is = entity.getContent();
+ try
+ {
+ String charSet = EntityUtils.getContentCharSet(entity);
+ if (charSet == null)
+ charSet = "utf-8";
+ char[] buffer = new char[65536];
+ Reader r = new InputStreamReader(is,charSet);
+ Writer w = new StringWriter();
+ try
+ {
+ while (true)
+ {
+ int amt = r.read(buffer);
+ if (amt == -1)
+ break;
+ w.write(buffer,0,amt);
}
}
- foundIdx = strIdxStart + i;
- break;
- }
- if (foundIdx == -1) {
- return false;
+ finally
+ {
+ w.flush();
+ }
+ return w.toString();
}
- patIdxStart = patIdxTmp;
- strIdxStart = foundIdx + patLength;
- }
-
- // All characters in the string are used. Check if only '*'s are left
- // in the pattern. If so, we succeeded. Otherwise failure.
- for (int i = patIdxStart; i <= patIdxEnd; i++) {
- if (patArr[i] != '*') {
- return false;
+ finally
+ {
+ is.close();
}
}
- return true;
- }
-
- private static String getHeader(HttpMethodBase method, String headerName) {
- Header header = method.getResponseHeader(headerName);
- return (header == null) ? null : header.getValue().trim();
- }
-
- private InputStream createConnectionReleasingInputStream(final HttpMethodBase method) throws IOException {
- return new FilterInputStream(method.getResponseBodyAsStream()) {
- public void close() throws IOException {
- try {
- super.close();
- } finally {
- method.releaseConnection();
- }
- }
- };
+ return "";
}
+
+ private static class MessageRequestEntity implements HttpEntity {
- private static class MessageRequestEntity implements RequestEntity {
-
- private HttpMethodBase method;
- private Message message;
- boolean httpChunkStream = true; //Use HTTP chunking or not.
+ private final Message message;
+ private final boolean httpChunkStream; //Use HTTP chunking or not.
+ private final boolean contentLengthNeeded;
- public MessageRequestEntity(HttpMethodBase method, Message message) {
+ public MessageRequestEntity(Message message, boolean httpChunkStream, boolean contentLengthNeeded) {
this.message = message;
- this.method = method;
- }
-
- public MessageRequestEntity(HttpMethodBase method, Message message, boolean httpChunkStream) {
- this.message = message;
- this.method = method;
this.httpChunkStream = httpChunkStream;
+ this.contentLengthNeeded = contentLengthNeeded;
}
+ @Override
+ public boolean isChunked() {
+ return httpChunkStream;
+ }
+
+ @Override
+ public void consumeContent()
+ throws IOException {
+ EntityUtils.consume(this);
+ }
+
+ @Override
public boolean isRepeatable() {
return true;
}
- public void writeRequest(OutputStream out) throws IOException {
+ @Override
+ public boolean isStreaming() {
+ return false;
+ }
+
+ @Override
+ public InputStream getContent()
+ throws IOException, IllegalStateException {
+ // MHL
+ return null;
+ }
+
+ @Override
+ public void writeTo(OutputStream out)
+ throws IOException {
try {
this.message.writeTo(out);
} catch (SOAPException e) {
@@ -1001,77 +490,28 @@ public class CommonsHTTPSender extends B
}
}
- protected boolean isContentLengthNeeded() {
- return this.method.getParams().getVersion() == HttpVersion.HTTP_1_0 || !httpChunkStream;
- }
-
+ @Override
public long getContentLength() {
- if (isContentLengthNeeded()) {
+ if (contentLengthNeeded) {
try {
return message.getContentLength();
} catch (Exception e) {
}
}
- return -1; /* -1 for chunked */
+ // Unknown (chunked) length
+ return -1L;
}
- public String getContentType() {
+ @Override
+ public Header getContentType() {
return null; // a separate header is added
}
- }
-
- private static class GzipMessageRequestEntity extends MessageRequestEntity {
-
- public GzipMessageRequestEntity(HttpMethodBase method, Message message) {
- super(method, message);
- }
-
- public GzipMessageRequestEntity(HttpMethodBase method, Message message, boolean httpChunkStream) {
- super(method, message, httpChunkStream);
- }
-
- public void writeRequest(OutputStream out) throws IOException {
- if (cachedStream != null) {
- cachedStream.writeTo(out);
- } else {
- GZIPOutputStream gzStream = new GZIPOutputStream(out);
- super.writeRequest(gzStream);
- gzStream.finish();
- }
- }
-
- public long getContentLength() {
- if(isContentLengthNeeded()) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- writeRequest(baos);
- cachedStream = baos;
- return baos.size();
- }
- catch (java.net.SocketTimeoutException e)
- {
- // fall through to doing chunked.
- }
- catch (org.apache.commons.httpclient.ConnectTimeoutException e)
- {
- // fall through to doing chunked.
- }
- catch (InterruptedIOException e)
- {
- // The thread was interrupted; preserve its interrupted status
- Thread.currentThread().interrupt();
- // fall through to doing chunked.
- }
- catch (IOException e)
- {
- // fall through to doing chunked.
- }
- }
- return -1; // do chunked
+ @Override
+ public Header getContentEncoding() {
+ return null;
}
-
- private ByteArrayOutputStream cachedStream;
}
+
}
Modified: manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java?rev=1407825&r1=1407824&r2=1407825&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java (original)
+++ manifoldcf/branches/CONNECTORS-120/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java Sat Nov 10 14:37:37 2012
@@ -37,9 +37,8 @@ import org.apache.manifoldcf.crawler.sys
import com.microsoft.schemas.sharepoint.dsp.*;
import com.microsoft.schemas.sharepoint.soap.*;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.protocol.ProtocolFactory;
-import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.http.client.HttpClient;
+
import org.apache.axis.EngineConfiguration;
import javax.xml.namespace.QName;
@@ -68,8 +67,7 @@ import org.w3c.dom.Document;
public class SPSProxyHelper {
- public static final String PROTOCOL_FACTORY_PROPERTY = "ManifoldCF_Protocol_Factory";
- public static final String CONNECTION_MANAGER_PROPERTY = "ManifoldCF_Connection_Manager";
+ public static final String HTTPCLIENT_PROPERTY = "ManifoldCF_HttpClient";
private String serverUrl;
private String serverLocation;
@@ -77,9 +75,8 @@ public class SPSProxyHelper {
private String baseUrl;
private String userName;
private String password;
- private ProtocolFactory myFactory;
private EngineConfiguration configuration;
- private HttpConnectionManager connectionManager;
+ private HttpClient httpClient;
/**
*
@@ -88,7 +85,7 @@ public class SPSProxyHelper {
* @param password
*/
public SPSProxyHelper( String serverUrl, String serverLocation, String decodedServerLocation, String userName, String password,
- ProtocolFactory myFactory, Class resourceClass, String configFileName, HttpConnectionManager connectionManager )
+ Class resourceClass, String configFileName, HttpClient httpClient )
{
this.serverUrl = serverUrl;
this.serverLocation = serverLocation;
@@ -99,9 +96,8 @@ public class SPSProxyHelper {
baseUrl = serverUrl + serverLocation;
this.userName = userName;
this.password = password;
- this.myFactory = myFactory;
this.configuration = new ResourceProvider(resourceClass,configFileName);
- this.connectionManager = connectionManager;
+ this.httpClient = httpClient;
}
/**
@@ -118,10 +114,10 @@ public class SPSProxyHelper {
try
{
if ( site.compareTo("/") == 0 ) site = ""; // root case
- UserGroupWS userService = new UserGroupWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ UserGroupWS userService = new UserGroupWS( baseUrl + site, userName, password, configuration, httpClient );
com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap userCall = userService.getUserGroupSoapHandler( );
- PermissionsWS aclService = new PermissionsWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ PermissionsWS aclService = new PermissionsWS( baseUrl + site, userName, password, configuration, httpClient );
com.microsoft.schemas.sharepoint.soap.directory.PermissionsSoap aclCall = aclService.getPermissionsSoapHandler( );
com.microsoft.schemas.sharepoint.soap.directory.GetPermissionCollectionResponseGetPermissionCollectionResult aclResult = aclCall.getPermissionCollection( guid, "List" );
@@ -318,10 +314,10 @@ public class SPSProxyHelper {
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("SharePoint: Getting document acls for site '"+site+"' file '"+file+"': Encoded relative path is '"+encodedRelativePath+"'");
- UserGroupWS userService = new UserGroupWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ UserGroupWS userService = new UserGroupWS( baseUrl + site, userName, password, configuration, httpClient );
com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap userCall = userService.getUserGroupSoapHandler( );
- MCPermissionsWS aclService = new MCPermissionsWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ MCPermissionsWS aclService = new MCPermissionsWS( baseUrl + site, userName, password, configuration, httpClient );
com.microsoft.sharepoint.webpartpages.PermissionsSoap aclCall = aclService.getPermissionsSoapHandler( );
com.microsoft.sharepoint.webpartpages.GetPermissionCollectionResponseGetPermissionCollectionResult aclResult = aclCall.getPermissionCollection( encodedRelativePath, "Item" );
@@ -516,7 +512,7 @@ public class SPSProxyHelper {
if ( site.equals("/") ) site = ""; // root case
if ( dspStsWorks )
{
- StsAdapterWS listService = new StsAdapterWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ StsAdapterWS listService = new StsAdapterWS( baseUrl + site, userName, password, configuration, httpClient );
StsAdapterSoapStub stub = (StsAdapterSoapStub)listService.getStsAdapterSoapHandler();
String[] vArray = new String[1];
@@ -609,7 +605,7 @@ public class SPSProxyHelper {
{
// New code
- MCPermissionsWS itemService = new MCPermissionsWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ MCPermissionsWS itemService = new MCPermissionsWS( baseUrl + site, userName, password, configuration, httpClient );
com.microsoft.sharepoint.webpartpages.PermissionsSoap itemCall = itemService.getPermissionsSoapHandler( );
int startingIndex = 0;
@@ -792,7 +788,7 @@ public class SPSProxyHelper {
parentSiteDecoded = "";
}
- ListsWS listsService = new ListsWS( baseUrl + parentSiteRequest, userName, password, myFactory, configuration, connectionManager );
+ ListsWS listsService = new ListsWS( baseUrl + parentSiteRequest, userName, password, configuration, httpClient );
ListsSoap listsCall = listsService.getListsSoapHandler( );
GetListCollectionResponseGetListCollectionResult listResp = listsCall.getListCollection();
@@ -981,7 +977,7 @@ public class SPSProxyHelper {
parentSiteDecoded = "";
}
- ListsWS listsService = new ListsWS( baseUrl + parentSiteRequest, userName, password, myFactory, configuration, connectionManager );
+ ListsWS listsService = new ListsWS( baseUrl + parentSiteRequest, userName, password, configuration, httpClient );
ListsSoap listsCall = listsService.getListsSoapHandler( );
GetListCollectionResponseGetListCollectionResult listResp = listsCall.getListCollection();
@@ -1166,7 +1162,7 @@ public class SPSProxyHelper {
try
{
if ( site.compareTo("/") == 0 ) site = ""; // root case
- VersionsWS versionsService = new VersionsWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ VersionsWS versionsService = new VersionsWS( baseUrl + site, userName, password, configuration, httpClient );
VersionsSoap versionsCall = versionsService.getVersionsSoapHandler( );
GetVersionsResponseGetVersionsResult versionsResp = versionsCall.getVersions( docPath );
@@ -1444,7 +1440,7 @@ public class SPSProxyHelper {
site = "";
// Attempt a listservice call
- ListsWS listService = new ListsWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ ListsWS listService = new ListsWS( baseUrl + site, userName, password, configuration, httpClient );
ListsSoap listCall = listService.getListsSoapHandler();
listCall.getListCollection();
@@ -1454,7 +1450,7 @@ public class SPSProxyHelper {
// The web service allows us to get acls for a site, so that's what we will attempt
// This fails:
- MCPermissionsWS aclService = new MCPermissionsWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ MCPermissionsWS aclService = new MCPermissionsWS( baseUrl + site, userName, password, configuration, httpClient );
com.microsoft.sharepoint.webpartpages.PermissionsSoap aclCall = aclService.getPermissionsSoapHandler( );
// This works:
@@ -1557,7 +1553,7 @@ public class SPSProxyHelper {
// The docLibrary must be a GUID, because we don't have title.
if ( site.compareTo( "/") == 0 ) site = "";
- ListsWS listService = new ListsWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ ListsWS listService = new ListsWS( baseUrl + site, userName, password, configuration, httpClient );
ListsSoap listCall = listService.getListsSoapHandler();
GetListResponseGetListResult listResponse = listCall.getList( listName );
@@ -1684,7 +1680,7 @@ public class SPSProxyHelper {
if ( dspStsWorks )
{
- StsAdapterWS listService = new StsAdapterWS( baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ StsAdapterWS listService = new StsAdapterWS( baseUrl + site, userName, password, configuration, httpClient );
StsAdapterSoapStub stub = (StsAdapterSoapStub)listService.getStsAdapterSoapHandler();
String[] vArray = new String[1];
@@ -1805,7 +1801,7 @@ public class SPSProxyHelper {
{
// SharePoint 2010: Get field values some other way
// Sharepoint 2010; use Lists service instead
- ListsWS lservice = new ListsWS(baseUrl + site, userName, password, myFactory, configuration, connectionManager );
+ ListsWS lservice = new ListsWS(baseUrl + site, userName, password, configuration, httpClient );
ListsSoapStub stub1 = (ListsSoapStub)lservice.getListsSoapHandler();
String sitePlusDocId = serverLocation + site + "/" + docId;
@@ -1951,7 +1947,7 @@ public class SPSProxyHelper {
ArrayList result = new ArrayList();
if ( parentSite.equals( "/") ) parentSite = "";
- WebsWS webService = new WebsWS( baseUrl + parentSite, userName, password, myFactory, configuration, connectionManager );
+ WebsWS webService = new WebsWS( baseUrl + parentSite, userName, password, configuration, httpClient );
WebsSoap webCall = webService.getWebsSoapHandler();
GetWebCollectionResponseGetWebCollectionResult webResp = webCall.getWebCollection();
@@ -2082,7 +2078,7 @@ public class SPSProxyHelper {
parentSiteDecoded = "";
}
- ListsWS listsService = new ListsWS( baseUrl + parentSiteRequest, userName, password, myFactory, configuration, connectionManager );
+ ListsWS listsService = new ListsWS( baseUrl + parentSiteRequest, userName, password, configuration, httpClient );
ListsSoap listsCall = listsService.getListsSoapHandler( );
GetListCollectionResponseGetListCollectionResult listResp = listsCall.getListCollection();
@@ -2226,7 +2222,7 @@ public class SPSProxyHelper {
parentSiteDecoded = "";
}
- ListsWS listsService = new ListsWS( baseUrl + parentSiteRequest, userName, password, myFactory, configuration, connectionManager );
+ ListsWS listsService = new ListsWS( baseUrl + parentSiteRequest, userName, password, configuration, httpClient );
ListsSoap listsCall = listsService.getListsSoapHandler( );
GetListCollectionResponseGetListCollectionResult listResp = listsCall.getListCollection();
@@ -2520,18 +2516,16 @@ public class SPSProxyHelper {
private java.net.URL endPoint;
private String userName;
private String password;
- private ProtocolFactory myFactory;
- private HttpConnectionManager connectionManager;
+ private HttpClient httpClient;
- public PermissionsWS ( String siteUrl, String userName, String password, ProtocolFactory myFactory, EngineConfiguration configuration, HttpConnectionManager connectionManager )
+ public PermissionsWS ( String siteUrl, String userName, String password, EngineConfiguration configuration, HttpClient httpClient )
throws java.net.MalformedURLException
{
super(configuration);
endPoint = new java.net.URL(siteUrl + "/_vti_bin/Permissions.asmx");
this.userName = userName;
this.password = password;
- this.myFactory = myFactory;
- this.connectionManager = connectionManager;
+ this.httpClient = httpClient;
}
public com.microsoft.schemas.sharepoint.soap.directory.PermissionsSoap getPermissionsSoapHandler( )
@@ -2541,10 +2535,7 @@ public class SPSProxyHelper {
_stub.setPortName(getPermissionsSoapWSDDServiceName());
_stub.setUsername( userName );
_stub.setPassword( password );
- if (myFactory != null)
- _stub._setProperty( PROTOCOL_FACTORY_PROPERTY, myFactory );
- if (connectionManager != null)
- _stub._setProperty( CONNECTION_MANAGER_PROPERTY, connectionManager );
+ _stub._setProperty( HTTPCLIENT_PROPERTY, httpClient);
return _stub;
}
}
@@ -2561,18 +2552,16 @@ public class SPSProxyHelper {
private java.net.URL endPoint;
private String userName;
private String password;
- private ProtocolFactory myFactory;
- private HttpConnectionManager connectionManager;
+ private HttpClient httpClient;
- public MCPermissionsWS ( String siteUrl, String userName, String password, ProtocolFactory myFactory, EngineConfiguration configuration, HttpConnectionManager connectionManager )
+ public MCPermissionsWS ( String siteUrl, String userName, String password, EngineConfiguration configuration, HttpClient httpClient )
throws java.net.MalformedURLException
{
super(configuration);
endPoint = new java.net.URL(siteUrl + "/_vti_bin/MCPermissions.asmx");
this.userName = userName;
this.password = password;
- this.myFactory = myFactory;
- this.connectionManager = connectionManager;
+ this.httpClient = httpClient;
}
public com.microsoft.sharepoint.webpartpages.PermissionsSoap getPermissionsSoapHandler( )
@@ -2582,10 +2571,7 @@ public class SPSProxyHelper {
_stub.setPortName(getPermissionsSoapWSDDServiceName());
_stub.setUsername( userName );
_stub.setPassword( password );
- if (myFactory != null)
- _stub._setProperty( PROTOCOL_FACTORY_PROPERTY, myFactory );
- if (connectionManager != null)
- _stub._setProperty( CONNECTION_MANAGER_PROPERTY, connectionManager );
+ _stub._setProperty( HTTPCLIENT_PROPERTY, httpClient );
return _stub;
}
}
@@ -2602,18 +2588,16 @@ public class SPSProxyHelper {
private java.net.URL endPoint;
private String userName;
private String password;
- private ProtocolFactory myFactory;
- private HttpConnectionManager connectionManager;
+ private HttpClient httpClient;
- public UserGroupWS ( String siteUrl, String userName, String password, ProtocolFactory myFactory, EngineConfiguration configuration, HttpConnectionManager connectionManager )
+ public UserGroupWS ( String siteUrl, String userName, String password, EngineConfiguration configuration, HttpClient httpClient )
throws java.net.MalformedURLException
{
super(configuration);
endPoint = new java.net.URL(siteUrl + "/_vti_bin/usergroup.asmx");
this.userName = userName;
this.password = password;
- this.myFactory = myFactory;
- this.connectionManager = connectionManager;
+ this.httpClient = httpClient;
}
public com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap getUserGroupSoapHandler( )
@@ -2623,10 +2607,7 @@ public class SPSProxyHelper {
_stub.setPortName(getUserGroupSoapWSDDServiceName());
_stub.setUsername( userName );
_stub.setPassword( password );
- if (myFactory != null)
- _stub._setProperty( PROTOCOL_FACTORY_PROPERTY, myFactory );
- if (connectionManager != null)
- _stub._setProperty( CONNECTION_MANAGER_PROPERTY, connectionManager );
+ _stub._setProperty( HTTPCLIENT_PROPERTY, httpClient );
return _stub;
}
}
@@ -2643,18 +2624,16 @@ public class SPSProxyHelper {
private java.net.URL endPoint;
private String userName;
private String password;
- private ProtocolFactory myFactory;
- private HttpConnectionManager connectionManager;
+ private HttpClient httpClient;
- public StsAdapterWS ( String siteUrl, String userName, String password, ProtocolFactory myFactory, EngineConfiguration configuration, HttpConnectionManager connectionManager )
+ public StsAdapterWS ( String siteUrl, String userName, String password, EngineConfiguration configuration, HttpClient httpClient )
throws java.net.MalformedURLException
{
super(configuration);
endPoint = new java.net.URL(siteUrl + "/_vti_bin/dspsts.asmx");
this.userName = userName;
this.password = password;
- this.myFactory = myFactory;
- this.connectionManager = connectionManager;
+ this.httpClient = httpClient;
}
public com.microsoft.schemas.sharepoint.dsp.StsAdapterSoap getStsAdapterSoapHandler( )
@@ -2664,10 +2643,7 @@ public class SPSProxyHelper {
_stub.setPortName(getStsAdapterSoapWSDDServiceName());
_stub.setUsername( userName );
_stub.setPassword( password );
- if (myFactory != null)
- _stub._setProperty( PROTOCOL_FACTORY_PROPERTY, myFactory );
- if (connectionManager != null)
- _stub._setProperty( CONNECTION_MANAGER_PROPERTY, connectionManager );
+ _stub._setProperty( HTTPCLIENT_PROPERTY, httpClient );
return _stub;
}
}
@@ -2684,18 +2660,16 @@ public class SPSProxyHelper {
private java.net.URL endPoint;
private String userName;
private String password;
- private ProtocolFactory myFactory;
- private HttpConnectionManager connectionManager;
+ private HttpClient httpClient;
- public ListsWS ( String siteUrl, String userName, String password, ProtocolFactory myFactory, EngineConfiguration configuration, HttpConnectionManager connectionManager )
+ public ListsWS ( String siteUrl, String userName, String password, EngineConfiguration configuration, HttpClient httpClient )
throws java.net.MalformedURLException
{
super(configuration);
endPoint = new java.net.URL(siteUrl + "/_vti_bin/lists.asmx");
this.userName = userName;
this.password = password;
- this.myFactory = myFactory;
- this.connectionManager = connectionManager;
+ this.httpClient = httpClient;
}
public com.microsoft.schemas.sharepoint.soap.ListsSoap getListsSoapHandler( )
@@ -2705,10 +2679,7 @@ public class SPSProxyHelper {
_stub.setPortName(getListsSoapWSDDServiceName());
_stub.setUsername( userName );
_stub.setPassword( password );
- if (myFactory != null)
- _stub._setProperty( PROTOCOL_FACTORY_PROPERTY, myFactory );
- if (connectionManager != null)
- _stub._setProperty( CONNECTION_MANAGER_PROPERTY, connectionManager );
+ _stub._setProperty( HTTPCLIENT_PROPERTY, httpClient );
return _stub;
}
}
@@ -2725,18 +2696,16 @@ public class SPSProxyHelper {
private java.net.URL endPoint;
private String userName;
private String password;
- private ProtocolFactory myFactory;
- private HttpConnectionManager connectionManager;
+ private HttpClient httpClient;
- public VersionsWS ( String siteUrl, String userName, String password, ProtocolFactory myFactory, EngineConfiguration configuration, HttpConnectionManager connectionManager )
+ public VersionsWS ( String siteUrl, String userName, String password, EngineConfiguration configuration, HttpClient httpClient )
throws java.net.MalformedURLException
{
super(configuration);
endPoint = new java.net.URL(siteUrl + "/_vti_bin/versions.asmx");
this.userName = userName;
this.password = password;
- this.myFactory = myFactory;
- this.connectionManager = connectionManager;
+ this.httpClient = httpClient;
}
public com.microsoft.schemas.sharepoint.soap.VersionsSoap getVersionsSoapHandler( )
@@ -2746,10 +2715,7 @@ public class SPSProxyHelper {
_stub.setPortName(getVersionsSoapWSDDServiceName());
_stub.setUsername( userName );
_stub.setPassword( password );
- if (myFactory != null)
- _stub._setProperty( PROTOCOL_FACTORY_PROPERTY, myFactory );
- if (connectionManager != null)
- _stub._setProperty( CONNECTION_MANAGER_PROPERTY, connectionManager );
+ _stub._setProperty( HTTPCLIENT_PROPERTY, httpClient );
return _stub;
}
}
@@ -2766,18 +2732,16 @@ public class SPSProxyHelper {
private java.net.URL endPoint;
private String userName;
private String password;
- private ProtocolFactory myFactory;
- private HttpConnectionManager connectionManager;
+ private HttpClient httpClient;
- public WebsWS ( String siteUrl, String userName, String password, ProtocolFactory myFactory, EngineConfiguration configuration, HttpConnectionManager connectionManager )
+ public WebsWS ( String siteUrl, String userName, String password, EngineConfiguration configuration, HttpClient httpClient )
throws java.net.MalformedURLException
{
super(configuration);
endPoint = new java.net.URL(siteUrl + "/_vti_bin/webs.asmx");
this.userName = userName;
this.password = password;
- this.myFactory = myFactory;
- this.connectionManager = connectionManager;
+ this.httpClient = httpClient;
}
public com.microsoft.schemas.sharepoint.soap.WebsSoap getWebsSoapHandler( )
@@ -2787,10 +2751,7 @@ public class SPSProxyHelper {
_stub.setPortName(getWebsSoapWSDDServiceName());
_stub.setUsername( userName );
_stub.setPassword( password );
- if (myFactory != null)
- _stub._setProperty( PROTOCOL_FACTORY_PROPERTY, myFactory );
- if (connectionManager != null)
- _stub._setProperty( CONNECTION_MANAGER_PROPERTY, connectionManager );
+ _stub._setProperty( HTTPCLIENT_PROPERTY, httpClient );
return _stub;
}
}