org.eclipse.mylyn.commons.xmlrpc_3.7.1.v20120425-0100

16:46:36.078 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.commons.xmlrpc_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.internal.commons.xmlrpc;

import java.io.BufferedOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
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.HttpException;
import org.apache.commons.httpclient.HttpVersion;
import org.apache.commons.httpclient.auth.AuthState;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientException;
import org.apache.xmlrpc.client.XmlRpcHttpClientConfig;
import org.apache.xmlrpc.client.XmlRpcHttpTransport;
import org.apache.xmlrpc.client.XmlRpcStreamTransport.ReqWriter;
import org.apache.xmlrpc.client.XmlRpcTransport;
import org.apache.xmlrpc.client.XmlRpcTransportFactory;
import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
import org.apache.xmlrpc.util.HttpUtil;
import org.apache.xmlrpc.util.XmlRpcIOException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.SslCertificateException;
import org.eclipse.mylyn.commons.net.WebUtil;
import org.xml.sax.SAXException;

class HttpClientTransportFactory
  implements XmlRpcTransportFactory
{
  private final XmlRpcClient xmlRpcClient;
  private AbstractWebLocation location;
  private final HttpClient httpClient;
  private HttpMethodInterceptor interceptor;
  
  static class HttpClientTransport
    extends XmlRpcHttpTransport
  {
    private final HttpClient httpClient;
    private final AbstractWebLocation location;
    private PostMethod method;
    private int contentLength = -1;
    private XmlRpcHttpClientConfig config;
    private IProgressMonitor monitor;
    private HostConfiguration hostConfiguration;
    private final HttpMethodInterceptor interceptor;
    
    public HttpClientTransport(XmlRpcClient client, HttpClient httpClient, AbstractWebLocation location, HttpMethodInterceptor interceptor)
    {
      super("");
      this.httpClient = httpClient;
      this.location = location;
      this.interceptor = interceptor;
    }
    
    protected void close()
      throws XmlRpcClientException
    {
      method.releaseConnection();
    }
    
    public int getContentLength()
    {
      return contentLength;
    }
    
    protected InputStream getInputStream()
      throws XmlRpcException
    {
      int responseCode = method.getStatusCode();
      if (responseCode != 200)
      {
        XmlRpcHttpException e = new XmlRpcHttpException(responseCode);
        if (responseCode == 401) {
          e.setAuthScheme(method.getHostAuthState().getAuthScheme());
        }
        throw e;
      }
      try
      {
        return method.getResponseBodyAsStream();
      }
      catch (HttpException e)
      {
        throw new XmlRpcClientException("Error in HTTP transport: " + e.getMessage(), e);
      }
      catch (IOException e)
      {
        throw new XmlRpcClientException("I/O error in server communication: " + e.getMessage(), e);
      }
    }
    
    protected String getUserAgent()
    {
      return WebUtil.getUserAgent("");
    }
    
    protected void initHttpHeaders(XmlRpcRequest request)
      throws XmlRpcClientException
    {
      config = ((XmlRpcHttpClientConfig)request.getConfig());
      if ((request instanceof XmlRpcClientRequest))
      {
        XmlRpcClientRequest clientRequest = (XmlRpcClientRequest)request;
        monitor = clientRequest.getProgressMonitor();
      }
      else
      {
        monitor = null;
      }
      String url = config.getServerURL().toString();
      hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
      method = new PostMethod(WebUtil.getRequestPath(url));
      
      super.initHttpHeaders(request);
      if (config.getConnectionTimeout() != 0) {
        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(config.getConnectionTimeout());
      }
      if (config.getReplyTimeout() != 0) {
        httpClient.getHttpConnectionManager().getParams().setSoTimeout(config.getConnectionTimeout());
      }
      method.getParams().setVersion(HttpVersion.HTTP_1_1);
      if (interceptor != null) {
        interceptor.processRequest(method);
      }
    }
    
    protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig config)
    {
      Header header = method.getResponseHeader("Content-Encoding");
      return (header != null) && (HttpUtil.isUsingGzipEncoding(header.getValue()));
    }
    
    protected void setContentLength(int contentLength)
    {
      this.contentLength = contentLength;
    }
    
    protected void setCredentials(XmlRpcHttpClientConfig config)
      throws XmlRpcClientException
    {}
    
    protected void setRequestHeader(String header, String value)
    {
      method.setRequestHeader(new Header(header, value));
    }
    
    protected void writeRequest(final XmlRpcStreamTransport.ReqWriter writer)
      throws XmlRpcException
    {
      method.setRequestEntity(new RequestEntity()
      {
        public long getContentLength()
        {
          return getContentLength();
        }
        
        public String getContentType()
        {
          return "text/xml";
        }
        
        public boolean isRepeatable()
        {
          return getContentLength() != -1L;
        }
        
        public void writeRequest(OutputStream pOut)
          throws IOException
        {
          try
          {
            OutputStream ostream;
            OutputStream ostream;
            if (isUsingByteArrayOutput(config)) {
              ostream = new FilterOutputStream(pOut)
              {
                public void close()
                  throws IOException
                {
                  flush();
                }
              };
            } else {
              ostream = new BufferedOutputStream(pOut)
              {
                public void close()
                  throws IOException
                {
                  flush();
                }
              };
            }
            writer.write(ostream);
          }
          catch (XmlRpcException e)
          {
            throw new XmlRpcIOException(e);
          }
          catch (SAXException e)
          {
            throw new XmlRpcIOException(e);
          }
        }
      });
      try
      {
        WebUtil.execute(httpClient, hostConfiguration, method, monitor);
        if (interceptor != null) {
          interceptor.processResponse(method);
        }
      }
      catch (XmlRpcIOException e)
      {
        Throwable t = e.getLinkedException();
        if ((t instanceof XmlRpcException)) {
          throw ((XmlRpcException)t);
        }
        throw new XmlRpcException("Unexpected exception: " + t.getMessage(), t);
      }
      catch (SslCertificateException e)
      {
        throw new XmlRpcSslCertificateException(e);
      }
      catch (IOException e)
      {
        throw new XmlRpcException("I/O error while communicating with HTTP server: " + e.getMessage(), e);
      }
    }
  }
  
  public HttpClientTransportFactory(XmlRpcClient xmlRpcClient, HttpClient httpClient)
  {
    this.xmlRpcClient = xmlRpcClient;
    this.httpClient = httpClient;
  }
  
  public AbstractWebLocation getLocation()
  {
    return location;
  }
  
  public XmlRpcTransport getTransport()
  {
    return new HttpClientTransport(xmlRpcClient, httpClient, location, interceptor);
  }
  
  public void setLocation(AbstractWebLocation location)
  {
    this.location = location;
  }
  
  public HttpMethodInterceptor getInterceptor()
  {
    return interceptor;
  }
  
  public void setInterceptor(HttpMethodInterceptor interceptor)
  {
    this.interceptor = interceptor;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.HttpClientTransportFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;

class HttpClientTransportFactory$HttpClientTransport$1$2
  extends BufferedOutputStream
{
  HttpClientTransportFactory$HttpClientTransport$1$2(HttpClientTransportFactory.HttpClientTransport.1 param1, OutputStream $anonymous0)
  {
    super($anonymous0);
  }
  
  public void close()
    throws IOException
  {
    flush();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.HttpClientTransportFactory.HttpClientTransport.1.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import java.util.ArrayList;
import java.util.List;

public class MulticallResult
{
  private final Object[] response;
  
  public MulticallResult(Object[] response)
  {
    this.response = response;
  }
  
  public List<Object> getItems()
  {
    return getItems(Object.class);
  }
  
  public <T> List<T> getItems(Class<T> itemClass)
  {
    List<T> items = new ArrayList(response.length);
    Object[] arrayOfObject;
    int j = (arrayOfObject = response).length;
    for (int i = 0; i < j; i++)
    {
      Object element = arrayOfObject[i];
      items.add(itemClass.cast(getMultiCallResult(element)));
    }
    return items;
  }
  
  private Object getMultiCallResult(Object item)
  {
    return ((Object[])item)[0];
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.MulticallResult
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;

public class Multicall
{
  List<Map<String, Object>> calls = new ArrayList();
  
  public Multicall add(String methodName, Object... parameters)
    throws XmlRpcException
  {
    Map<String, Object> table = new HashMap();
    table.put("methodName", methodName);
    table.put("params", parameters);
    calls.add(table);
    return this;
  }
  
  public Map<String, Object>[] getCalls()
  {
    return (Map[])calls.toArray(new Map[0]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.Multicall
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import org.apache.xmlrpc.XmlRpcException;

public class XmlRpcLoginException
  extends XmlRpcException
{
  private static final long serialVersionUID = -6128773690643367414L;
  private boolean ntlmAuthRequested;
  
  public XmlRpcLoginException(String message)
  {
    super(message);
  }
  
  public XmlRpcLoginException()
  {
    super(null);
  }
  
  public boolean isNtlmAuthRequested()
  {
    return ntlmAuthRequested;
  }
  
  void setNtlmAuthRequested(boolean ntlmAuthRequested)
  {
    this.ntlmAuthRequested = ntlmAuthRequested;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.XmlRpcLoginException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.TimeZone;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.auth.AuthScheme;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.auth.AuthState;
import org.apache.commons.httpclient.auth.DigestScheme;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.serializer.CharSetXmlWriterFactory;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.commons.net.WebUtil;
import org.eclipse.osgi.util.NLS;

public class CommonXmlRpcClient
{
  static final boolean DEBUG_AUTH = Boolean.valueOf(Platform.getDebugOption("org.eclipse.mylyn.commons.xmlrpc/debug/authentication")).booleanValue();
  static final boolean DEBUG_XMLRPC = Boolean.valueOf(Platform.getDebugOption("org.eclipse.mylyn.commons.xmlrpc/debug/xmlrpc")).booleanValue();
  private static final String DEFAULT_CHARSET = "UTF-8";
  private static final String DEFAULT_TIME_ZONE = TimeZone.getDefault().getID();
  private static final String DEFAULT_USER_AGENT = "Apache XML-RPC/3.0";
  private static final String DEFAULT_CONTENT_TYPE = "text/xml";
  private final AuthScope authScope;
  private XmlRpcClientConfigImpl config;
  volatile DigestScheme digestScheme;
  private HttpClientTransportFactory factory;
  final HttpClient httpClient;
  private final AbstractWebLocation location;
  private XmlRpcClient xmlrpc;
  private volatile boolean contentTypeCheckingEnabled;
  
  private static HttpClient createHttpClient(String userAgent)
  {
    HttpClient httpClient = new HttpClient();
    httpClient.setHttpConnectionManager(WebUtil.getConnectionManager());
    httpClient.getParams().setCookiePolicy("rfc2109");
    WebUtil.configureHttpClient(httpClient, userAgent);
    return httpClient;
  }
  
  public CommonXmlRpcClient(AbstractWebLocation location)
  {
    this(location, createHttpClient("Apache XML-RPC/3.0"));
  }
  
  public CommonXmlRpcClient(AbstractWebLocation location, HttpClient client)
  {
    this.location = location;
    httpClient = createHttpClient("Apache XML-RPC/3.0");
    authScope = new AuthScope(WebUtil.getHost(location.getUrl()), WebUtil.getPort(location.getUrl()), null, 
      AuthScope.ANY_SCHEME);
  }
  
  public <T> T call(final IProgressMonitor monitor, final String method, final Object... parameters)
    throws XmlRpcException
  {
    
    
      (T)new XmlRpcOperation(this)
      {
        public T execute()
          throws XmlRpcException
        {
          return (T)call(monitor, method, parameters);
        }
      }.execute();
  }
  
  public MulticallResult call(final IProgressMonitor monitor, final Multicall call)
    throws XmlRpcException
  {
    
    
      new XmlRpcOperation(this)
      {
        public MulticallResult execute()
          throws XmlRpcException
        {
          return call(monitor, call);
        }
      }.execute();
  }
  
  protected void createXmlRpcClient()
  {
    config = new XmlRpcClientConfigImpl();
    config.setEncoding("UTF-8");
    config.setTimeZone(TimeZone.getTimeZone(DEFAULT_TIME_ZONE));
    config.setContentLengthOptional(false);
    config.setConnectionTimeout(WebUtil.getConnectionTimeout());
    config.setReplyTimeout(WebUtil.getSocketTimeout());
    
    xmlrpc = new XmlRpcClient();
    xmlrpc.setConfig(config);
    
    xmlrpc.setXmlWriterFactory(new CharSetXmlWriterFactory());
    
    factory = new HttpClientTransportFactory(xmlrpc, httpClient);
    factory.setLocation(location);
    factory.setInterceptor(new HttpMethodInterceptor()
    {
      public void processRequest(HttpMethod method)
      {
        DigestScheme scheme = digestScheme;
        if (scheme != null)
        {
          if (CommonXmlRpcClient.DEBUG_AUTH) {
            System.err.println(location.getUrl() + ": Digest scheme is present");
          }
          Credentials creds = httpClient.getState().getCredentials(authScope);
          if (creds != null)
          {
            if (CommonXmlRpcClient.DEBUG_AUTH) {
              System.err.println(location.getUrl() + ": Setting digest scheme for request");
            }
            method.getHostAuthState().setAuthScheme(digestScheme);
            method.getHostAuthState().setAuthRequested(true);
          }
        }
      }
      
      public void processResponse(HttpMethod method)
        throws XmlRpcException
      {
        if (isContentTypeCheckingEnabled())
        {
          Header contentTypeHeader = method.getResponseHeader("Content-Type");
          if ((contentTypeHeader == null) || (!"text/xml".equals(contentTypeHeader.getValue()))) {
            throw new XmlRpcIllegalContentTypeException(
              NLS.bind(
              "The server returned an unexpected content type: ''{0}''", contentTypeHeader.getValue()), contentTypeHeader.getValue());
          }
        }
        AuthScheme authScheme = method.getHostAuthState().getAuthScheme();
        if ((authScheme instanceof DigestScheme))
        {
          digestScheme = ((DigestScheme)authScheme);
          if (CommonXmlRpcClient.DEBUG_AUTH) {
            System.err.println(location.getUrl() + ": Received digest scheme");
          }
        }
      }
    });
    xmlrpc.setTransportFactory(factory);
    try
    {
      config.setServerURL(new URL(location.getUrl()));
    }
    catch (MalformedURLException e)
    {
      throw new RuntimeException(e);
    }
  }
  
  public synchronized XmlRpcClient getClient()
  {
    if (xmlrpc == null) {
      createXmlRpcClient();
    }
    return xmlrpc;
  }
  
  public HttpClient getHttpClient()
  {
    return httpClient;
  }
  
  public AbstractWebLocation getLocation()
  {
    return location;
  }
  
  AuthenticationCredentials updateCredentials()
  {
    AuthenticationCredentials credentials = location.getCredentials(AuthenticationType.REPOSITORY);
    if (credentials != null)
    {
      Credentials httpCredentials = WebUtil.getHttpClientCredentials(credentials, 
        WebUtil.getHost(location.getUrl()));
      httpClient.getState().setCredentials(authScope, httpCredentials);
      
      httpClient.getState().setCredentials(authScope, httpCredentials);
    }
    else
    {
      httpClient.getState().clearCredentials();
    }
    return credentials;
  }
  
  public boolean isContentTypeCheckingEnabled()
  {
    return contentTypeCheckingEnabled;
  }
  
  public void setContentTypeCheckingEnabled(boolean contentTypeCheckingEnabled)
  {
    this.contentTypeCheckingEnabled = contentTypeCheckingEnabled;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.CommonXmlRpcClient
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import org.apache.xmlrpc.XmlRpcException;

public class XmlRpcIllegalContentTypeException
  extends XmlRpcException
{
  private static final long serialVersionUID = -1844484692848370951L;
  private final String contentType;
  
  public XmlRpcIllegalContentTypeException(String message, String contentType)
  {
    super(message);
    this.contentType = contentType;
  }
  
  public String getContentType()
  {
    return contentType;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.XmlRpcIllegalContentTypeException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import java.net.URL;
import org.apache.xmlrpc.XmlRpcRequestConfig;
import org.apache.xmlrpc.client.XmlRpcClientRequestImpl;
import org.eclipse.core.runtime.IProgressMonitor;

class XmlRpcClientRequest
  extends XmlRpcClientRequestImpl
{
  private final IProgressMonitor progressMonitor;
  private final URL url;
  
  public XmlRpcClientRequest(XmlRpcRequestConfig config, URL url, String methodName, Object[] params, IProgressMonitor monitor)
  {
    super(config, methodName, params);
    this.url = url;
    progressMonitor = monitor;
  }
  
  public IProgressMonitor getProgressMonitor()
  {
    return progressMonitor;
  }
  
  public URL getUrl()
  {
    return url;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.XmlRpcClientRequest
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import org.apache.xmlrpc.XmlRpcException;
import org.eclipse.mylyn.commons.net.SslCertificateException;

public class XmlRpcSslCertificateException
  extends XmlRpcException
{
  private static final long serialVersionUID = 6981133252991248441L;
  
  public XmlRpcSslCertificateException(String message)
  {
    super(message);
  }
  
  public XmlRpcSslCertificateException()
  {
    super(null);
  }
  
  public XmlRpcSslCertificateException(SslCertificateException e)
  {
    super(null);
    initCause(e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.XmlRpcSslCertificateException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import org.apache.commons.httpclient.auth.AuthScheme;
import org.apache.xmlrpc.XmlRpcException;

public class XmlRpcHttpException
  extends XmlRpcException
{
  private static final long serialVersionUID = 9032521978140685830L;
  private AuthScheme authScheme;
  
  public XmlRpcHttpException(int responseCode)
  {
    super(responseCode, "HTTP Error " + responseCode);
  }
  
  public AuthScheme getAuthScheme()
  {
    return authScheme;
  }
  
  public void setAuthScheme(AuthScheme authScheme)
  {
    this.authScheme = authScheme;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.XmlRpcHttpException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import org.apache.xmlrpc.XmlRpcException;

public class XmlRpcNoSuchMethodException
  extends XmlRpcException
{
  private static final long serialVersionUID = 9075003728286406705L;
  
  public XmlRpcNoSuchMethodException(XmlRpcException e)
  {
    super("No such method", e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.XmlRpcNoSuchMethodException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import org.apache.commons.httpclient.HttpMethod;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClientException;

abstract interface HttpMethodInterceptor
{
  public abstract void processRequest(HttpMethod paramHttpMethod)
    throws XmlRpcClientException;
  
  public abstract void processResponse(HttpMethod paramHttpMethod)
    throws XmlRpcException;
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.HttpMethodInterceptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import org.apache.xmlrpc.XmlRpcException;
import org.eclipse.core.runtime.IProgressMonitor;

class CommonXmlRpcClient$1
  extends XmlRpcOperation<T>
{
  CommonXmlRpcClient$1(CommonXmlRpcClient paramCommonXmlRpcClient1, CommonXmlRpcClient $anonymous0, IProgressMonitor paramIProgressMonitor, String paramString, Object[] paramArrayOfObject)
  {
    super($anonymous0);
  }
  
  public T execute()
    throws XmlRpcException
  {
    return (T)call(val$monitor, val$method, val$parameters);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.CommonXmlRpcClient.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.httpclient.auth.AuthScheme;
import org.apache.commons.httpclient.auth.NTLMScheme;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.mylyn.commons.core.CoreUtil;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.commons.net.Policy;
import org.eclipse.mylyn.commons.net.UnsupportedRequestException;

public abstract class XmlRpcOperation<T>
{
  private static final Pattern RPC_METHOD_NOT_FOUND_PATTERN = Pattern.compile("No such handler: ");
  protected static final int XML_FAULT_GENERAL_ERROR = 1;
  protected static final int XML_FAULT_PERMISSION_DENIED = 403;
  private final CommonXmlRpcClient client;
  
  public XmlRpcOperation(CommonXmlRpcClient client)
  {
    this.client = client;
  }
  
  protected Object call(IProgressMonitor monitor, String method, Object... parameters)
    throws XmlRpcException
  {
    monitor = Policy.monitorFor(monitor);
    XmlRpcException lastException = null;
    for (int attempt = 0; attempt < 3; attempt++) {
      try
      {
        return executeCall(monitor, method, parameters);
      }
      catch (XmlRpcLoginException e)
      {
        try
        {
          client.getLocation().requestCredentials(AuthenticationType.REPOSITORY, null, monitor);
        }
        catch (UnsupportedRequestException localUnsupportedRequestException1)
        {
          throw e;
        }
        lastException = e;
      }
      catch (XmlRpcPermissionDeniedException e)
      {
        try
        {
          client.getLocation().requestCredentials(AuthenticationType.REPOSITORY, null, monitor);
        }
        catch (UnsupportedRequestException localUnsupportedRequestException2)
        {
          throw e;
        }
        lastException = e;
      }
      catch (XmlRpcProxyAuthenticationException e)
      {
        try
        {
          client.getLocation().requestCredentials(AuthenticationType.PROXY, null, monitor);
        }
        catch (UnsupportedRequestException localUnsupportedRequestException3)
        {
          throw e;
        }
        lastException = e;
      }
      catch (XmlRpcSslCertificateException e)
      {
        try
        {
          client.getLocation().requestCredentials(AuthenticationType.CERTIFICATE, null, monitor);
        }
        catch (UnsupportedRequestException localUnsupportedRequestException4)
        {
          throw e;
        }
        lastException = e;
      }
    }
    if (lastException != null) {
      throw lastException;
    }
    throw new IllegalStateException();
  }
  
  private void checkForException(Object result)
    throws NumberFormatException, XmlRpcException
  {
    if ((result instanceof Map))
    {
      Map<?, ?> exceptionData = (Map)result;
      if ((exceptionData.containsKey("faultCode")) && (exceptionData.containsKey("faultString"))) {
        throw new XmlRpcException(Integer.parseInt(exceptionData.get("faultCode").toString()), 
          (String)exceptionData.get("faultString"));
      }
      if (exceptionData.containsKey("title"))
      {
        String message = (String)exceptionData.get("title");
        String detail = (String)exceptionData.get("_message");
        if (detail != null) {
          message = message + ": " + detail;
        }
        throw new XmlRpcException(1, message);
      }
    }
  }
  
  protected boolean credentialsValid(AuthenticationCredentials credentials)
  {
    return credentials != null;
  }
  
  public abstract T execute()
    throws XmlRpcException;
  
  protected Object executeCall(IProgressMonitor monitor, String method, Object... parameters)
    throws XmlRpcException
  {
    try
    {
      if (CommonXmlRpcClient.DEBUG_XMLRPC) {
        System.err.println("Calling " + client.getLocation().getUrl() + ": " + method + " " + CoreUtil.toString(parameters));
      }
      AuthenticationCredentials credentials = client.updateCredentials();
      XmlRpcClientRequest request = new XmlRpcClientRequest(client.getClient().getClientConfig(), 
        getXmlRpcUrl(credentials), method, parameters, monitor);
      return client.getClient().execute(request);
    }
    catch (XmlRpcHttpException e)
    {
      handleAuthenticationException(code, e.getAuthScheme());
      
      throw e;
    }
    catch (XmlRpcIllegalContentTypeException e)
    {
      throw e;
    }
    catch (XmlRpcException e)
    {
      if (("XML_RPC privileges are required to perform this operation".equals(e.getMessage())) || 
        (code == 403))
      {
        handleAuthenticationException(403, null);
        
        throw new XmlRpcRemoteException(e);
      }
      if (isNoSuchMethodException(e)) {
        throw new XmlRpcNoSuchMethodException(e);
      }
      throw new XmlRpcRemoteException(e);
    }
    catch (OperationCanceledException e)
    {
      throw e;
    }
    catch (Exception e)
    {
      throw new XmlRpcException("Unexpected exception", e);
    }
  }
  
  protected final CommonXmlRpcClient getClient()
  {
    return client;
  }
  
  protected Object getMultiCallResult(Object item)
  {
    return ((Object[])item)[0];
  }
  
  protected URL getXmlRpcUrl(AuthenticationCredentials credentials)
  {
    try
    {
      return new URL(client.getLocation().getUrl());
    }
    catch (MalformedURLException e)
    {
      throw new RuntimeException("Encoding of URL failed", e);
    }
  }
  
  protected boolean handleAuthenticationException(int code, AuthScheme authScheme)
    throws XmlRpcException
  {
    if (code == 401)
    {
      if (CommonXmlRpcClient.DEBUG_AUTH) {
        System.err.println(client.getLocation().getUrl() + ": Unauthorized (" + code + ")");
      }
      client.digestScheme = null;
      XmlRpcLoginException exception = new XmlRpcLoginException();
      exception.setNtlmAuthRequested(authScheme instanceof NTLMScheme);
      throw exception;
    }
    if (code == 403)
    {
      if (CommonXmlRpcClient.DEBUG_AUTH) {
        System.err.println(client.getLocation().getUrl() + ": Forbidden (" + code + ")");
      }
      client.digestScheme = null;
      throw new XmlRpcPermissionDeniedException();
    }
    if (code == 407)
    {
      if (CommonXmlRpcClient.DEBUG_AUTH) {
        System.err.println(client.getLocation().getUrl() + ": Proxy authentication required (" + code + ")");
      }
      throw new XmlRpcProxyAuthenticationException();
    }
    return false;
  }
  
  protected boolean isNoSuchMethodException(XmlRpcException e)
  {
    if (RPC_METHOD_NOT_FOUND_PATTERN.matcher(e.getMessage()).find()) {
      return true;
    }
    return false;
  }
  
  protected MulticallResult call(IProgressMonitor monitor, Multicall call)
    throws XmlRpcException
  {
    Object[] response = (Object[])call(monitor, "system.multicall", new Object[] { call.getCalls() });
    Object[] arrayOfObject1;
    int j = (arrayOfObject1 = response).length;
    for (int i = 0; i < j; i++)
    {
      Object item = arrayOfObject1[i];
      checkForException(item);
    }
    return new MulticallResult(response);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.XmlRpcOperation
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import java.io.BufferedOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
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.HttpException;
import org.apache.commons.httpclient.HttpVersion;
import org.apache.commons.httpclient.auth.AuthState;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientException;
import org.apache.xmlrpc.client.XmlRpcHttpClientConfig;
import org.apache.xmlrpc.client.XmlRpcHttpTransport;
import org.apache.xmlrpc.client.XmlRpcStreamTransport.ReqWriter;
import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
import org.apache.xmlrpc.util.HttpUtil;
import org.apache.xmlrpc.util.XmlRpcIOException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.SslCertificateException;
import org.eclipse.mylyn.commons.net.WebUtil;
import org.xml.sax.SAXException;

class HttpClientTransportFactory$HttpClientTransport
  extends XmlRpcHttpTransport
{
  private final HttpClient httpClient;
  private final AbstractWebLocation location;
  private PostMethod method;
  private int contentLength = -1;
  private XmlRpcHttpClientConfig config;
  private IProgressMonitor monitor;
  private HostConfiguration hostConfiguration;
  private final HttpMethodInterceptor interceptor;
  
  public HttpClientTransportFactory$HttpClientTransport(XmlRpcClient client, HttpClient httpClient, AbstractWebLocation location, HttpMethodInterceptor interceptor)
  {
    super(client, "");
    this.httpClient = httpClient;
    this.location = location;
    this.interceptor = interceptor;
  }
  
  protected void close()
    throws XmlRpcClientException
  {
    method.releaseConnection();
  }
  
  public int getContentLength()
  {
    return contentLength;
  }
  
  protected InputStream getInputStream()
    throws XmlRpcException
  {
    int responseCode = method.getStatusCode();
    if (responseCode != 200)
    {
      XmlRpcHttpException e = new XmlRpcHttpException(responseCode);
      if (responseCode == 401) {
        e.setAuthScheme(method.getHostAuthState().getAuthScheme());
      }
      throw e;
    }
    try
    {
      return method.getResponseBodyAsStream();
    }
    catch (HttpException e)
    {
      throw new XmlRpcClientException("Error in HTTP transport: " + e.getMessage(), e);
    }
    catch (IOException e)
    {
      throw new XmlRpcClientException("I/O error in server communication: " + e.getMessage(), e);
    }
  }
  
  protected String getUserAgent()
  {
    return WebUtil.getUserAgent("");
  }
  
  protected void initHttpHeaders(XmlRpcRequest request)
    throws XmlRpcClientException
  {
    config = ((XmlRpcHttpClientConfig)request.getConfig());
    if ((request instanceof XmlRpcClientRequest))
    {
      XmlRpcClientRequest clientRequest = (XmlRpcClientRequest)request;
      monitor = clientRequest.getProgressMonitor();
    }
    else
    {
      monitor = null;
    }
    String url = config.getServerURL().toString();
    hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
    method = new PostMethod(WebUtil.getRequestPath(url));
    
    super.initHttpHeaders(request);
    if (config.getConnectionTimeout() != 0) {
      httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(config.getConnectionTimeout());
    }
    if (config.getReplyTimeout() != 0) {
      httpClient.getHttpConnectionManager().getParams().setSoTimeout(config.getConnectionTimeout());
    }
    method.getParams().setVersion(HttpVersion.HTTP_1_1);
    if (interceptor != null) {
      interceptor.processRequest(method);
    }
  }
  
  protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig config)
  {
    Header header = method.getResponseHeader("Content-Encoding");
    return (header != null) && (HttpUtil.isUsingGzipEncoding(header.getValue()));
  }
  
  protected void setContentLength(int contentLength)
  {
    this.contentLength = contentLength;
  }
  
  protected void setCredentials(XmlRpcHttpClientConfig config)
    throws XmlRpcClientException
  {}
  
  protected void setRequestHeader(String header, String value)
  {
    method.setRequestHeader(new Header(header, value));
  }
  
  protected void writeRequest(final XmlRpcStreamTransport.ReqWriter writer)
    throws XmlRpcException
  {
    method.setRequestEntity(new RequestEntity()
    {
      public long getContentLength()
      {
        return getContentLength();
      }
      
      public String getContentType()
      {
        return "text/xml";
      }
      
      public boolean isRepeatable()
      {
        return getContentLength() != -1L;
      }
      
      public void writeRequest(OutputStream pOut)
        throws IOException
      {
        try
        {
          OutputStream ostream;
          OutputStream ostream;
          if (isUsingByteArrayOutput(config)) {
            ostream = new FilterOutputStream(pOut)
            {
              public void close()
                throws IOException
              {
                flush();
              }
            };
          } else {
            ostream = new BufferedOutputStream(pOut)
            {
              public void close()
                throws IOException
              {
                flush();
              }
            };
          }
          writer.write(ostream);
        }
        catch (XmlRpcException e)
        {
          throw new XmlRpcIOException(e);
        }
        catch (SAXException e)
        {
          throw new XmlRpcIOException(e);
        }
      }
    });
    try
    {
      WebUtil.execute(httpClient, hostConfiguration, method, monitor);
      if (interceptor != null) {
        interceptor.processResponse(method);
      }
    }
    catch (XmlRpcIOException e)
    {
      Throwable t = e.getLinkedException();
      if ((t instanceof XmlRpcException)) {
        throw ((XmlRpcException)t);
      }
      throw new XmlRpcException("Unexpected exception: " + t.getMessage(), t);
    }
    catch (SslCertificateException e)
    {
      throw new XmlRpcSslCertificateException(e);
    }
    catch (IOException e)
    {
      throw new XmlRpcException("I/O error while communicating with HTTP server: " + e.getMessage(), e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.HttpClientTransportFactory.HttpClientTransport
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import org.apache.xmlrpc.XmlRpcException;
import org.eclipse.core.runtime.IProgressMonitor;

class CommonXmlRpcClient$2
  extends XmlRpcOperation<MulticallResult>
{
  CommonXmlRpcClient$2(CommonXmlRpcClient paramCommonXmlRpcClient1, CommonXmlRpcClient $anonymous0, IProgressMonitor paramIProgressMonitor, Multicall paramMulticall)
  {
    super($anonymous0);
  }
  
  public MulticallResult execute()
    throws XmlRpcException
  {
    return call(val$monitor, val$call);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.CommonXmlRpcClient.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.xmlrpc;

import org.apache.xmlrpc.XmlRpcException;

public class XmlRpcPermissionDeniedException
  extends XmlRpcException
{
  private static final long serialVersionUID = -6128773690643367414L;
  
  public XmlRpcPermissionDeniedException()
  {
    super(null);
  }
  
  public XmlRpcPermissionDeniedException(String message)
  {
    super(message);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.xmlrpc.
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd