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

16:46:32.518 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.commons.soap_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.internal.commons.soap;

import org.apache.commons.httpclient.HttpMethodBase;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;

public class SoapRequest
{
  private static ThreadLocal<SoapRequest> currentRequest = new ThreadLocal();
  private static final int METHOD_POLL_INTERVAL = 200;
  private volatile boolean done;
  private volatile HttpMethodBase method;
  private final IProgressMonitor monitor;
  
  public static SoapRequest getCurrentRequest()
  {
    return (SoapRequest)currentRequest.get();
  }
  
  public static void setCurrentRequest(SoapRequest request)
  {
    currentRequest.set(request);
  }
  
  public SoapRequest(IProgressMonitor monitor)
  {
    this.monitor = monitor;
  }
  
  public void cancel()
  {
    while (method == null)
    {
      if (done) {
        throw new OperationCanceledException();
      }
      try
      {
        Thread.sleep(200L);
      }
      catch (InterruptedException localInterruptedException)
      {
        throw new OperationCanceledException();
      }
    }
    method.abort();
  }
  
  public void done()
  {
    done = true;
  }
  
  public HttpMethodBase getMethod()
  {
    return method;
  }
  
  public IProgressMonitor getMonitor()
  {
    return monitor;
  }
  
  public void setMethod(HttpMethodBase method)
  {
    this.method = method;
  }
}

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

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;
import org.apache.axis.Message;
import org.apache.commons.httpclient.HttpMethodBase;

class CommonsHttpSender$GzipMessageRequestEntity
  extends CommonsHttpSender.MessageRequestEntity
{
  private ByteArrayOutputStream cachedStream;
  
  public CommonsHttpSender$GzipMessageRequestEntity(HttpMethodBase method, Message message)
  {
    super(method, message);
  }
  
  public CommonsHttpSender$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 (IOException localIOException) {}
    }
    return -1L;
  }
}

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

import java.io.ByteArrayOutputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPException;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.components.net.CommonsHTTPClientProperties;
import org.apache.axis.components.net.CommonsHTTPClientPropertiesFactory;
import org.apache.axis.components.net.TransportClientProperties;
import org.apache.axis.components.net.TransportClientPropertiesFactory;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.transport.http.HTTPConstants;
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.NTCredentials;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
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.HttpClientParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.protocol.Protocol;
import org.eclipse.mylyn.commons.net.WebUtil;

public class CommonsHttpSender
  extends BasicHandler
{
  protected HttpConnectionManager connectionManager;
  protected CommonsHTTPClientProperties clientProperties;
  boolean httpChunkStream = true;
  
  public CommonsHttpSender()
  {
    initialize();
  }
  
  protected void initialize()
  {
    clientProperties = CommonsHTTPClientPropertiesFactory.create();
    connectionManager = WebUtil.getConnectionManager();
  }
  
  public void invoke(MessageContext msgContext)
    throws AxisFault
  {
    HttpMethodBase method = null;
    try
    {
      URL targetURL = new URL(msgContext.getStrProp("transport.url"));
      
      HttpClient httpClient = new HttpClient(connectionManager);
      
      httpClient.getParams().setConnectionManagerTimeout(clientProperties.getConnectionPoolTimeout());
      
      HostConfiguration hostConfiguration = getHostConfiguration(httpClient, msgContext, targetURL);
      
      boolean posting = true;
      if (msgContext.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS)
      {
        String webMethod = msgContext.getStrProp("soap12.webmethod");
        if (webMethod != null) {
          posting = webMethod.equals("POST");
        }
      }
      if (posting)
      {
        Message reqMessage = msgContext.getRequestMessage();
        method = createPostMethod(targetURL);
        
        method.getParams().setBooleanParameter("http.protocol.expect-continue", false);
        
        addContextInfo(method, httpClient, msgContext, targetURL);
        
        MessageRequestEntity requestEntity = null;
        if (msgContext.isPropertyTrue("transport.http.gzipRequest")) {
          requestEntity = new GzipMessageRequestEntity(method, reqMessage, httpChunkStream);
        } else {
          requestEntity = new MessageRequestEntity(method, reqMessage, httpChunkStream);
        }
        ((PostMethod)method).setRequestEntity(requestEntity);
      }
      else
      {
        method = createGetMethod(targetURL);
        addContextInfo(method, httpClient, msgContext, targetURL);
      }
      String httpVersion = msgContext.getStrProp("axis.transport.version");
      if ((httpVersion != null) && 
        (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_V10))) {
        method.getParams().setVersion(HttpVersion.HTTP_1_0);
      }
      if (msgContext.getMaintainSession())
      {
        HttpState state = httpClient.getState();
        method.getParams().setCookiePolicy("compatibility");
        String host = hostConfiguration.getHost();
        String path = targetURL.getPath();
        secure = hostConfiguration.getProtocol().isSecure();
        fillHeaders(msgContext, state, "Cookie", host, path, secure);
        fillHeaders(msgContext, state, "Cookie2", host, path, secure);
        httpClient.setState(state);
      }
      int returnCode = httpClient.executeMethod(hostConfiguration, method, null);
      
      String contentType = getHeader(method, "Content-Type");
      String contentLocation = getHeader(method, "Content-Location");
      if ((returnCode <= 199) || (returnCode >= 300)) {
        if (msgContext.getSOAPConstants() != SOAPConstants.SOAP12_CONSTANTS) {
          if ((contentType == null) || (contentType.equals("text/html")) || 
            (returnCode <= 499) || (returnCode >= 600)) {
            try
            {
              throw AxisHttpFault.makeFault(method);
            }
            finally
            {
              method.releaseConnection();
            }
          }
        }
      }
      InputStream releaseConnectionOnCloseStream = createConnectionReleasingInputStream(method);
      
      Header contentEncoding = method.getResponseHeader("Content-Encoding");
      if (contentEncoding != null) {
        if (contentEncoding.getValue().equalsIgnoreCase("gzip"))
        {
          releaseConnectionOnCloseStream = new GZIPInputStream(releaseConnectionOnCloseStream);
        }
        else if ((!contentEncoding.getValue().equals("")) || (!msgContext.isPropertyTrue("org.eclipse.mylyn.commons.soap.allowEmptyContentEncoding")))
        {
          AxisFault fault = new AxisFault("HTTP", "unsupported content-encoding of '" + 
            contentEncoding.getValue() + "' found", null, null);
          throw fault;
        }
      }
      Message outMsg = new Message(releaseConnectionOnCloseStream, false, contentType, contentLocation);
      
      Header[] responseHeaders = method.getResponseHeaders();
      MimeHeaders responseMimeHeaders = outMsg.getMimeHeaders();
      Header[] arrayOfHeader1;
      int j = (arrayOfHeader1 = responseHeaders).length;
      for (int i = 0; i < j; i++)
      {
        Header responseHeader = arrayOfHeader1[i];
        responseMimeHeaders.addHeader(responseHeader.getName(), responseHeader.getValue());
      }
      outMsg.setMessageType("response");
      msgContext.setResponseMessage(outMsg);
      if (msgContext.getMaintainSession())
      {
        Header[] headers = method.getResponseHeaders();
        Header[] arrayOfHeader2;
        int k = (arrayOfHeader2 = headers).length;
        for (j = 0; j < k; j++)
        {
          Header header = arrayOfHeader2[j];
          if (header.getName().equalsIgnoreCase("Set-Cookie")) {
            handleCookie("Cookie", header.getValue(), msgContext);
          } else if (header.getName().equalsIgnoreCase("Set-Cookie2")) {
            handleCookie("Cookie2", header.getValue(), msgContext);
          }
        }
      }
      if (msgContext.isPropertyTrue("axis.one.way")) {
        method.releaseConnection();
      }
    }
    catch (Exception e)
    {
      throw AxisFault.makeFault(e);
    }
  }
  
  protected GetMethod createGetMethod(URL targetURL)
  {
    return new GetMethod(targetURL.toString());
  }
  
  protected PostMethod createPostMethod(URL targetURL)
  {
    return new PostMethod(targetURL.toString());
  }
  
  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;
    
    List<String> cookies = new ArrayList();
    Object oldCookies = msgContext.getProperty(cookieName);
    boolean alreadyExist = false;
    if (oldCookies != null) {
      if ((oldCookies instanceof String[]))
      {
        String[] oldCookiesArray = (String[])oldCookies;
        String[] arrayOfString1;
        int j = (arrayOfString1 = oldCookiesArray).length;
        for (int i = 0; i < j; i++)
        {
          String anOldCookie = arrayOfString1[i];
          if ((key != null) && (anOldCookie.indexOf(key) == 0))
          {
            anOldCookie = cookie;
            alreadyExist = true;
          }
          cookies.add(anOldCookie);
        }
      }
      else
      {
        String oldCookie = (String)oldCookies;
        if ((key != null) && (oldCookie.indexOf(key) == 0))
        {
          oldCookie = cookie;
          alreadyExist = true;
        }
        cookies.add(oldCookie);
      }
    }
    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()]));
    }
  }
  
  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;
        String[] arrayOfString1;
        int j = (arrayOfString1 = cookies).length;
        for (int i = 0; i < j; i++)
        {
          String cookie = arrayOfString1[i];
          addCookie(state, cookie, host, path, secure);
        }
      }
      else
      {
        addCookie(state, (String)ck1, host, path, secure);
      }
    }
  }
  
  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));
  }
  
  private String cleanupCookie(String cookie)
  {
    cookie = cookie.trim();
    
    int index = cookie.indexOf(';');
    if (index != -1) {
      cookie = cookie.substring(0, index);
    }
    return cookie;
  }
  
  protected HostConfiguration getHostConfiguration(HttpClient client, MessageContext context, URL targetURL)
  {
    TransportClientProperties tcp = TransportClientPropertiesFactory.create(targetURL.getProtocol());
    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;
      } else {
        port = 80;
      }
    }
    if (hostInNonProxyList)
    {
      config.setHost(targetURL.getHost(), port, targetURL.getProtocol());
    }
    else if ((tcp.getProxyHost().length() == 0) || (tcp.getProxyPort().length() == 0))
    {
      config.setHost(targetURL.getHost(), port, targetURL.getProtocol());
    }
    else
    {
      if (tcp.getProxyUser().length() != 0)
      {
        Credentials proxyCred = new UsernamePasswordCredentials(tcp.getProxyUser(), tcp.getProxyPassword());
        
        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);
          }
        }
        client.getState().setProxyCredentials(AuthScope.ANY, proxyCred);
      }
      int proxyPort = new Integer(tcp.getProxyPort()).intValue();
      config.setProxy(tcp.getProxyHost(), proxyPort);
    }
    return config;
  }
  
  protected void addContextInfo(HttpMethodBase method, HttpClient httpClient, MessageContext msgContext, URL tmpURL)
    throws Exception
  {
    String action = msgContext.useSOAPAction() ? msgContext.getSOAPActionURI() : "";
    if (action == null) {
      action = "";
    }
    Message msg = msgContext.getRequestMessage();
    if (msg != null) {
      method.setRequestHeader(new Header("Content-Type", 
        msg.getContentType(msgContext.getSOAPConstants())));
    }
    method.setRequestHeader(new Header("SOAPAction", "\"" + action + "\""));
    method.setRequestHeader(new Header("User-Agent", Messages.getMessage("axisUserAgent")));
    String userID = msgContext.getUsername();
    String passwd = msgContext.getPassword();
    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)
    {
      Credentials proxyCred = new UsernamePasswordCredentials(userID, passwd);
      
      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);
    }
    if (msgContext.isPropertyTrue("transport.http.acceptGzip")) {
      method.addRequestHeader("Accept-Encoding", "gzip");
    }
    if (msgContext.isPropertyTrue("transport.http.gzipRequest")) {
      method.addRequestHeader("Content-Encoding", "gzip");
    }
    MimeHeaders mimeHeaders = msg.getMimeHeaders();
    if (mimeHeaders != null) {
      for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext();)
      {
        MimeHeader mimeHeader = (MimeHeader)i.next();
        
        String headerName = mimeHeader.getName();
        if ((!headerName.equals("Content-Type")) && 
          (!headerName.equals("SOAPAction"))) {
          method.addRequestHeader(mimeHeader.getName(), mimeHeader.getValue());
        }
      }
    }
    Hashtable userHeaderTable = (Hashtable)msgContext.getProperty("HTTP-Request-Headers");
    if (userHeaderTable != null) {
      for (Iterator e = userHeaderTable.entrySet().iterator(); e.hasNext();)
      {
        Map.Entry me = (Map.Entry)e.next();
        Object keyObj = me.getKey();
        if (keyObj != null)
        {
          String key = keyObj.toString().trim();
          String value = me.getValue().toString().trim();
          if ((key.equalsIgnoreCase("Expect")) && 
            (value.equalsIgnoreCase("100-continue")))
          {
            method.getParams().setBooleanParameter("http.protocol.expect-continue", true);
          }
          else if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED))
          {
            String val = me.getValue().toString();
            if (val != null) {
              httpChunkStream = JavaUtils.isTrue(val);
            }
          }
          else if ("User-Agent".equalsIgnoreCase(key))
          {
            method.setRequestHeader(key, value);
          }
          else
          {
            method.addRequestHeader(key, value);
          }
        }
      }
    }
  }
  
  protected boolean isHostInNonProxyList(String host, String nonProxyHosts)
  {
    if ((nonProxyHosts == null) || (host == null)) {
      return false;
    }
    StringTokenizer tokenizer = new StringTokenizer(nonProxyHosts, "|\"");
    while (tokenizer.hasMoreTokens())
    {
      String pattern = tokenizer.nextToken();
      if (match(pattern, host, false)) {
        return true;
      }
    }
    return false;
  }
  
  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;
    
    boolean containsStar = false;
    char[] arrayOfChar1;
    int j = (arrayOfChar1 = patArr).length;
    for (int i = 0; i < j; i++)
    {
      char element = arrayOfChar1[i];
      if (element == '*')
      {
        containsStar = true;
        break;
      }
    }
    if (!containsStar)
    {
      if (patIdxEnd != strIdxEnd) {
        return false;
      }
      for (int i = 0; i <= patIdxEnd; i++)
      {
        char ch = patArr[i];
        if ((isCaseSensitive) && (ch != strArr[i])) {
          return false;
        }
        if ((!isCaseSensitive) && (Character.toUpperCase(ch) != Character.toUpperCase(strArr[i]))) {
          return false;
        }
      }
      return true;
    }
    if (patIdxEnd == 0) {
      return true;
    }
    char ch;
    while (((ch = patArr[patIdxStart]) != '*') && (strIdxStart <= strIdxEnd))
    {
      char ch;
      if ((isCaseSensitive) && (ch != strArr[strIdxStart])) {
        return false;
      }
      if ((!isCaseSensitive) && (Character.toUpperCase(ch) != Character.toUpperCase(strArr[strIdxStart]))) {
        return false;
      }
      patIdxStart++;
      strIdxStart++;
    }
    if (strIdxStart > strIdxEnd)
    {
      for (i = patIdxStart; i <= patIdxEnd; i++) {
        if (patArr[i] != '*') {
          return false;
        }
      }
      return true;
    }
    while (((ch = patArr[patIdxEnd]) != '*') && (strIdxStart <= strIdxEnd))
    {
      int i;
      if ((isCaseSensitive) && (ch != strArr[strIdxEnd])) {
        return false;
      }
      if ((!isCaseSensitive) && (Character.toUpperCase(ch) != Character.toUpperCase(strArr[strIdxEnd]))) {
        return false;
      }
      patIdxEnd--;
      strIdxEnd--;
    }
    if (strIdxStart > strIdxEnd)
    {
      for (i = patIdxStart; i <= patIdxEnd; i++) {
        if (patArr[i] != '*') {
          return false;
        }
      }
      return true;
    }
    while ((patIdxStart != patIdxEnd) && (strIdxStart <= strIdxEnd))
    {
      int i;
      int patIdxTmp = -1;
      for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {
        if (patArr[i] == '*')
        {
          patIdxTmp = i;
          break;
        }
      }
      if (patIdxTmp == patIdxStart + 1)
      {
        patIdxStart++;
      }
      else
      {
        int patLength = patIdxTmp - patIdxStart - 1;
        int strLength = strIdxEnd - strIdxStart + 1;
        int foundIdx = -1;
        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)])) {
              break;
            }
            if ((!isCaseSensitive) && 
              (Character.toUpperCase(ch) != Character.toUpperCase(strArr[(strIdxStart + i + j)]))) {
              break;
            }
          }
          foundIdx = strIdxStart + i;
          break;
        }
        if (foundIdx == -1) {
          return false;
        }
        patIdxStart = patIdxTmp;
        strIdxStart = foundIdx + patLength;
      }
    }
    for (int i = patIdxStart; i <= patIdxEnd; i++) {
      if (patArr[i] != '*') {
        return false;
      }
    }
    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
  {
    new FilterInputStream(method.getResponseBodyAsStream())
    {
      /* Error */
      public void close()
        throws IOException
      {
        // Byte code:
        //   0: aload_0
        //   1: invokespecial 35	java/io/FilterInputStream:close	()V
        //   4: goto +13 -> 17
        //   7: astore_1
        //   8: aload_0
        //   9: getfield 33	org/eclipse/mylyn/internal/provisional/commons/soap/CommonsHttpSender$1:val$method	Lorg/apache/commons/httpclient/HttpMethodBase;
        //   12: invokevirtual 37	org/apache/commons/httpclient/HttpMethodBase:releaseConnection	()V
        //   15: aload_1
        //   16: athrow
        //   17: aload_0
        //   18: getfield 33	org/eclipse/mylyn/internal/provisional/commons/soap/CommonsHttpSender$1:val$method	Lorg/apache/commons/httpclient/HttpMethodBase;
        //   21: invokevirtual 37	org/apache/commons/httpclient/HttpMethodBase:releaseConnection	()V
        //   24: return
        // Line number table:
        //   Java source line #769	-> byte code offset #0
        //   Java source line #770	-> byte code offset #7
        //   Java source line #771	-> byte code offset #8
        //   Java source line #772	-> byte code offset #15
        //   Java source line #771	-> byte code offset #17
        //   Java source line #773	-> byte code offset #24
        // Local variable table:
        //   start	length	slot	name	signature
        //   0	25	0	this	1
        //   7	9	1	localObject	Object
        // Exception table:
        //   from	to	target	type
        //   0	7	7	finally
      }
    };
  }
  
  private static class MessageRequestEntity
    implements RequestEntity
  {
    private final HttpMethodBase method;
    private final Message message;
    boolean httpChunkStream = true;
    
    public MessageRequestEntity(HttpMethodBase method, Message message)
    {
      this.message = message;
      this.method = method;
    }
    
    public MessageRequestEntity(HttpMethodBase method, Message message, boolean httpChunkStream)
    {
      this.message = message;
      this.method = method;
      this.httpChunkStream = httpChunkStream;
    }
    
    public boolean isRepeatable()
    {
      return true;
    }
    
    public void writeRequest(OutputStream out)
      throws IOException
    {
      try
      {
        message.writeTo(out);
      }
      catch (SOAPException e)
      {
        throw new IOException(e.getMessage());
      }
    }
    
    protected boolean isContentLengthNeeded()
    {
      return (method.getParams().getVersion() == HttpVersion.HTTP_1_0) || (!httpChunkStream);
    }
    
    public long getContentLength()
    {
      if (isContentLengthNeeded()) {
        try
        {
          return message.getContentLength();
        }
        catch (Exception localException) {}
      }
      return -1L;
    }
    
    public String getContentType()
    {
      return null;
    }
  }
  
  private static class GzipMessageRequestEntity
    extends CommonsHttpSender.MessageRequestEntity
  {
    private ByteArrayOutputStream cachedStream;
    
    public GzipMessageRequestEntity(HttpMethodBase method, Message message)
    {
      super(message);
    }
    
    public GzipMessageRequestEntity(HttpMethodBase method, Message message, boolean httpChunkStream)
    {
      super(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 (IOException localIOException) {}
      }
      return -1L;
    }
  }
}

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

import java.io.IOException;
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.utils.Messages;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpMethodBase;

public class AxisHttpFault
  extends AxisFault
{
  private static final long serialVersionUID = -7568493217182396309L;
  private String location;
  private final int returnCode;
  
  public static AxisHttpFault makeFault(HttpMethodBase method)
    throws IOException
  {
    int returnCode = method.getStatusCode();
    String statusMessage = method.getStatusText();
    AxisHttpFault fault = new AxisHttpFault("HTTP", "(" + returnCode + ")" + statusMessage, returnCode);
    fault.extractDetails(method);
    fault.setFaultDetailString(Messages.getMessage("return01", returnCode, 
      method.getResponseBodyAsString()));
    fault.addFaultDetail(Constants.QNAME_FAULTDETAIL_HTTPERRORCODE, Integer.toString(returnCode));
    return fault;
  }
  
  public AxisHttpFault(String code, String faultString, int returnCode)
  {
    super(code, faultString, null, null);
    this.returnCode = returnCode;
  }
  
  private void extractDetails(HttpMethodBase method)
  {
    Header locationHeader = method.getResponseHeader("location");
    if (locationHeader != null) {
      location = locationHeader.getValue();
    }
  }
  
  public String getLocation()
  {
    return location;
  }
  
  public int getReturnCode()
  {
    return returnCode;
  }
}

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

import java.io.FilterInputStream;
import java.io.InputStream;
import org.apache.commons.httpclient.HttpMethodBase;

class CommonsHttpSender$1
  extends FilterInputStream
{
  CommonsHttpSender$1(CommonsHttpSender paramCommonsHttpSender, InputStream $anonymous0, HttpMethodBase paramHttpMethodBase)
  {
    super($anonymous0);
  }
  
  /* Error */
  public void close()
    throws java.io.IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 35	java/io/FilterInputStream:close	()V
    //   4: goto +13 -> 17
    //   7: astore_1
    //   8: aload_0
    //   9: getfield 33	org/eclipse/mylyn/internal/provisional/commons/soap/CommonsHttpSender$1:val$method	Lorg/apache/commons/httpclient/HttpMethodBase;
    //   12: invokevirtual 37	org/apache/commons/httpclient/HttpMethodBase:releaseConnection	()V
    //   15: aload_1
    //   16: athrow
    //   17: aload_0
    //   18: getfield 33	org/eclipse/mylyn/internal/provisional/commons/soap/CommonsHttpSender$1:val$method	Lorg/apache/commons/httpclient/HttpMethodBase;
    //   21: invokevirtual 37	org/apache/commons/httpclient/HttpMethodBase:releaseConnection	()V
    //   24: return
    // Line number table:
    //   Java source line #769	-> byte code offset #0
    //   Java source line #770	-> byte code offset #7
    //   Java source line #771	-> byte code offset #8
    //   Java source line #772	-> byte code offset #15
    //   Java source line #771	-> byte code offset #17
    //   Java source line #773	-> byte code offset #24
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	25	0	this	1
    //   7	9	1	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	7	7	finally
  }
}

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

import java.net.URL;
import org.apache.axis.MessageContext;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethodBase;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.WebUtil;
import org.eclipse.mylyn.internal.commons.soap.SoapRequest;

public class SoapHttpSender
  extends CommonsHttpSender
{
  private static final long serialVersionUID = -5876804777334482128L;
  public static final String LOCATION = "org.eclipse.mylyn.commons.soap.location";
  public static final String USER_AGENT = "org.eclipse.mylyn.commons.soap.userAgent";
  public static final String ALLOW_EMPTY_CONTENT_ENCODING = "org.eclipse.mylyn.commons.soap.allowEmptyContentEncoding";
  
  protected HostConfiguration getHostConfiguration(HttpClient client, MessageContext context, URL url)
  {
    AbstractWebLocation location = (AbstractWebLocation)context.getProperty("org.eclipse.mylyn.commons.soap.location");
    if (location == null) {
      throw new RuntimeException("Required property SoapHttpSender.LOCATION not set");
    }
    SoapRequest request = SoapRequest.getCurrentRequest();
    WebUtil.configureHttpClient(client, (String)context.getProperty("org.eclipse.mylyn.commons.soap.userAgent"));
    return WebUtil.createHostConfiguration(client, location, request != null ? request.getMonitor() : null);
  }
  
  protected void addContextInfo(HttpMethodBase method, HttpClient httpClient, MessageContext msgContext, URL tmpURL)
    throws Exception
  {
    super.addContextInfo(method, httpClient, msgContext, tmpURL);
    
    SoapRequest request = SoapRequest.getCurrentRequest();
    if (request != null) {
      request.setMethod(method);
    }
  }
}

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

import java.rmi.RemoteException;
import java.util.concurrent.Callable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.commons.net.Policy;
import org.eclipse.mylyn.commons.net.UnsupportedRequestException;
import org.eclipse.mylyn.commons.net.WebRequest;
import org.eclipse.mylyn.commons.net.WebUtil;
import org.eclipse.mylyn.internal.commons.soap.SoapRequest;

public abstract class AbstractSoapClient
{
  protected <T> T call(IProgressMonitor monitor, Callable<T> runnable)
    throws Exception
  {
    try
    {
      return (T)callOnce(monitor, runnable);
    }
    catch (Exception e)
    {
      if ((isAuthenticationException(e)) && (doLogin(monitor))) {
        return (T)callOnce(monitor, runnable);
      }
      throw e;
    }
    catch (Exception e)
    {
      while (isAuthenticationException(e)) {
        try
        {
          getLocation().requestCredentials(AuthenticationType.REPOSITORY, null, monitor);
        }
        catch (UnsupportedRequestException localUnsupportedRequestException)
        {
          throw e;
        }
      }
      throw e;
    }
  }
  
  protected <T> T callOnce(IProgressMonitor monitor, final Callable<T> runnable)
    throws Exception
  {
    try
    {
      monitor = Policy.monitorFor(monitor);
      
      final SoapRequest request = new SoapRequest(monitor);
      (T)WebUtil.execute(monitor, new WebRequest()
      {
        public void abort()
        {
          request.cancel();
        }
        
        public T call()
          throws Exception
        {
          try
          {
            SoapRequest.setCurrentRequest(request);
            return (T)runnable.call();
          }
          finally
          {
            request.done();
          }
        }
      });
    }
    catch (RemoteException e)
    {
      throw e;
    }
    catch (Exception e)
    {
      throw e;
    }
    catch (Error e)
    {
      throw e;
    }
    catch (Throwable e)
    {
      throw new RuntimeException(e);
    }
  }
  
  protected abstract AbstractWebLocation getLocation();
  
  protected abstract boolean isAuthenticationException(Exception paramException);
  
  protected abstract boolean doLogin(IProgressMonitor paramIProgressMonitor);
}

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

import java.util.concurrent.Callable;
import org.eclipse.mylyn.commons.net.WebRequest;
import org.eclipse.mylyn.internal.commons.soap.SoapRequest;

class AbstractSoapClient$1
  extends WebRequest<T>
{
  AbstractSoapClient$1(AbstractSoapClient paramAbstractSoapClient, SoapRequest paramSoapRequest, Callable paramCallable) {}
  
  public void abort()
  {
    val$request.cancel();
  }
  
  public T call()
    throws Exception
  {
    try
    {
      SoapRequest.setCurrentRequest(val$request);
      return (T)val$runnable.call();
    }
    finally
    {
      val$request.done();
    }
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import javax.xml.soap.SOAPException;
import org.apache.axis.Message;
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.HttpVersion;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.params.HttpMethodParams;

class CommonsHttpSender$MessageRequestEntity
  implements RequestEntity
{
  private final HttpMethodBase method;
  private final Message message;
  boolean httpChunkStream = true;
  
  public CommonsHttpSender$MessageRequestEntity(HttpMethodBase method, Message message)
  {
    this.message = message;
    this.method = method;
  }
  
  public CommonsHttpSender$MessageRequestEntity(HttpMethodBase method, Message message, boolean httpChunkStream)
  {
    this.message = message;
    this.method = method;
    this.httpChunkStream = httpChunkStream;
  }
  
  public boolean isRepeatable()
  {
    return true;
  }
  
  public void writeRequest(OutputStream out)
    throws IOException
  {
    try
    {
      message.writeTo(out);
    }
    catch (SOAPException e)
    {
      throw new IOException(e.getMessage());
    }
  }
  
  protected boolean isContentLengthNeeded()
  {
    return (method.getParams().getVersion() == HttpVersion.HTTP_1_0) || (!httpChunkStream);
  }
  
  public long getContentLength()
  {
    if (isContentLengthNeeded()) {
      try
      {
        return message.getContentLength();
      }
      catch (Exception localException) {}
    }
    return -1L;
  }
  
  public String getContentType()
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.provisional.commons.soap.CommonsHttpSender.MessageRequestEntity
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
1

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